Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-gdt
Commits
4ce37350
Commit
4ce37350
authored
9 years ago
by
Tobias Leibner
Browse files
Options
Downloads
Patches
Plain Diff
[discretization.default] cleanup
parent
f0308b50
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/gdt/discretizations/default.hh
+24
-64
24 additions, 64 deletions
dune/gdt/discretizations/default.hh
with
24 additions
and
64 deletions
dune/gdt/discretizations/default.hh
+
24
−
64
View file @
4ce37350
...
...
@@ -58,10 +58,10 @@ public:
typedef
ProblemImp
ProblemType
;
typedef
FVSpaceImp
FVSpaceType
;
typedef
typename
FVSpaceType
::
RangeFieldType
RangeFieldType
;
typedef
typename
Dune
::
Stuff
::
LA
::
CommonDenseVector
<
RangeFieldType
>
Stationary
VectorType
;
typedef
DiscreteFunction
<
FVSpaceType
,
Stationary
VectorType
>
DiscreteFunctionType
;
typedef
std
::
vector
<
std
::
pair
<
double
,
StationaryVectorType
>>
Vector
Type
;
};
// class Stationary
ContainerBased
DefaultTraits
typedef
typename
Dune
::
Stuff
::
LA
::
CommonDenseVector
<
RangeFieldType
>
VectorType
;
typedef
DiscreteFunction
<
FVSpaceType
,
VectorType
>
DiscreteFunctionType
;
typedef
std
::
vector
<
std
::
pair
<
double
,
DiscreteFunctionType
>>
DiscreteSolution
Type
;
};
// class
Non
StationaryDefaultTraits
}
// namespace internal
...
...
@@ -210,18 +210,16 @@ class NonStationaryDefault
public:
using
typename
BaseType
::
ProblemType
;
using
typename
BaseType
::
FVSpaceType
;
using
typename
BaseType
::
DiscreteSolutionType
;
using
typename
BaseType
::
VectorType
;
using
typename
BaseType
::
StationaryVectorType
;
using
typename
BaseType
::
DiscreteFunctionType
;
NonStationaryDefault
(
const
ProblemType
&
prblm
,
const
FVSpaceType
fvspace
)
NonStationaryDefault
(
const
ProblemType
&
prblm
,
const
std
::
shared_ptr
<
const
FVSpaceType
>
fv
_
space
_ptr
)
:
problem_
(
prblm
)
,
fv_space_
(
fvspace
)
,
fv_space_
(
fv
_
space
_ptr
)
{
}
NonStationaryDefault
(
ThisType
&&
/*source*/
)
=
default
;
/// \name Required by NonStationaryDiscretizationInterface.
/// \{
...
...
@@ -232,12 +230,12 @@ public:
const
FVSpaceType
&
fv_space
()
const
{
return
fv_space_
;
return
*
fv_space_
;
}
using
BaseType
::
solve
;
void
solve
(
Vector
Type
&
solution
,
const
bool
is_linear
)
const
void
solve
(
DiscreteSolution
Type
&
solution
,
const
bool
is_linear
)
const
{
try
{
DSC_CONFIG
.
set
(
"threading.partition_factor"
,
1
,
true
);
...
...
@@ -247,19 +245,19 @@ public:
// get analytical flux, initial and boundary values
typedef
typename
ProblemType
::
FluxType
AnalyticalFluxType
;
typedef
typename
ProblemType
::
SourceType
Source
Type
;
typedef
typename
ProblemType
::
FunctionType
Function
Type
;
typedef
typename
ProblemType
::
RHSType
RHS
Type
;
typedef
typename
ProblemType
::
InitialValueType
InitialValue
Type
;
typedef
typename
ProblemType
::
BoundaryValueType
BoundaryValueType
;
typedef
typename
Function
Type
::
DomainFieldType
DomainFieldType
;
typedef
typename
Problem
Type
::
DomainFieldType
DomainFieldType
;
typedef
typename
ProblemType
::
RangeFieldType
RangeFieldType
;
const
std
::
shared_ptr
<
const
AnalyticalFluxType
>
analytical_flux
=
problem_
.
flux
();
const
std
::
shared_ptr
<
const
Function
Type
>
initial_values
=
problem_
.
initial_values
();
const
std
::
shared_ptr
<
const
InitialValue
Type
>
initial_values
=
problem_
.
initial_values
();
const
std
::
shared_ptr
<
const
BoundaryValueType
>
boundary_values
=
problem_
.
boundary_values
();
const
std
::
shared_ptr
<
const
SourceType
>
source
=
problem_
.
source
();
const
std
::
shared_ptr
<
const
RHSType
>
rhs
=
problem_
.
rhs
();
// allocate a discrete function for the concentration and another one to temporary store the update in each step
typedef
DiscreteFunction
<
FVSpaceType
,
Dune
::
Stuff
::
LA
::
CommonDenseVector
<
RangeFieldType
>>
FVFunctionType
;
FVFunctionType
u
(
fv_space_
,
"solution"
);
FVFunctionType
u
(
*
fv_space_
,
"solution"
);
// project initial values
project
(
*
initial_values
,
u
);
...
...
@@ -268,75 +266,37 @@ public:
const
double
CFL
=
problem_
.
CFL
();
// calculate dx and choose t_end and initial dt
Dune
::
Stuff
::
Grid
::
Dimensions
<
typename
FVSpaceType
::
GridViewType
>
dimensions
(
fv_space_
.
grid_view
());
Dune
::
Stuff
::
Grid
::
Dimensions
<
typename
FVSpaceType
::
GridViewType
>
dimensions
(
fv_space_
->
grid_view
());
double
dx
=
dimensions
.
entity_width
.
max
();
if
(
dimDomain
==
2
)
dx
/=
std
::
sqrt
(
2
);
double
dt
=
CFL
*
dx
;
// create butcher_array
// forward euler
Dune
::
DynamicMatrix
<
RangeFieldType
>
A
(
DSC
::
fromString
<
Dune
::
DynamicMatrix
<
RangeFieldType
>>
(
"[0]"
));
Dune
::
DynamicVector
<
RangeFieldType
>
b
(
DSC
::
fromString
<
Dune
::
DynamicVector
<
RangeFieldType
>>
(
"[1]"
));
Dune
::
DynamicVector
<
RangeFieldType
>
c
(
DSC
::
fromString
<
Dune
::
DynamicVector
<
RangeFieldType
>>
(
"[0]"
));
// generic second order, x = 1 (see https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods)
// Dune::DynamicMatrix< RangeFieldType > A(DSC::fromString< Dune::DynamicMatrix< RangeFieldType > >("[0
// 0; 1 0]"));
// Dune::DynamicVector< RangeFieldType > b(DSC::fromString< Dune::DynamicVector< RangeFieldType >
// >("[0.5 0.5]"));
// Dune::DynamicVector< RangeFieldType > c(DSC::fromString< Dune::DynamicVector< RangeFieldType > >("[0
// 1]"));
// optimal third order SSP
// Dune::DynamicMatrix< RangeFieldType > A(DSC::fromString< Dune::DynamicMatrix< RangeFieldType > >("[0
// 0 0; 1 0 0; 0.25 0.25 0]"));
// Dune::DynamicVector< RangeFieldType > b(DSC::fromString< Dune::DynamicVector< RangeFieldType >
// >("[1.0/6.0 1.0/6.0 2.0/3.0]"));
// Dune::DynamicVector< RangeFieldType > c(DSC::fromString< Dune::DynamicVector< RangeFieldType > >("[0 1
// 0.5]"));
// classic fourth order RK
// Dune::DynamicMatrix< RangeFieldType > A(DSC::fromString< Dune::DynamicMatrix< RangeFieldType > >("[0 0 0 0;
// 0.5 0 0 0; 0 0.5 0 0; 0 0 1 0]"));
// Dune::DynamicVector< RangeFieldType > b(DSC::fromString< Dune::DynamicVector< RangeFieldType > >("[" +
// DSC::toString(1.0/6.0) + " " + DSC::toString(1.0/3.0) + " " + DSC::toString(1.0/3.0) + " " +
// DSC::toString(1.0/6.0) + "]"));
// define operator types
typedef
typename
Dune
::
Stuff
::
Functions
::
Constant
<
typename
FVSpaceType
::
EntityType
,
DomainFieldType
,
dimDomain
,
RangeFieldType
,
dimRange
,
1
>
ConstantFunctionType
;
typedef
typename
Dune
::
GDT
::
Operators
::
AdvectionGodunov
<
AnalyticalFluxType
,
ConstantFunctionType
,
BoundaryValueType
,
FVSpaceType
/*, Dune::GDT::Operators::SlopeLimiters::mc*/
>
OperatorType
;
typedef
typename
Dune
::
GDT
::
Operators
::
AdvectionSource
<
SourceType
,
FVSpaceType
>
SourceOperatorType
;
typedef
typename
Dune
::
GDT
::
TimeStepper
::
RungeKutta
<
OperatorType
,
SourceOperatorType
,
FVFunctionType
,
double
>
typedef
typename
Dune
::
GDT
::
Operators
::
AdvectionGodunov
<
AnalyticalFluxType
,
BoundaryValueType
>
OperatorType
;
typedef
typename
Dune
::
GDT
::
Operators
::
AdvectionRHS
<
RHSType
>
RHSOperatorType
;
typedef
typename
Dune
::
GDT
::
TimeStepper
::
RungeKutta
<
OperatorType
,
RHSOperatorType
,
FVFunctionType
,
double
>
TimeStepperType
;
// create source operator, is independent of dt
Source
OperatorType
source
_operator
(
*
source
,
fv_space_
);
RHS
OperatorType
rhs
_operator
(
*
rhs
);
// create advection operator
const
ConstantFunctionType
dx_function
(
dx
);
OperatorType
advection_operator
(
*
analytical_flux
,
dx_function
,
dt
,
*
boundary_values
,
fv_space_
,
is_linear
/*, true, true*/
);
OperatorType
advection_operator
(
*
analytical_flux
,
*
boundary_values
,
is_linear
/*, true, true*/
);
// create timestepper
TimeStepperType
timestepper
(
advection_operator
,
source
_operator
,
u
,
dx
,
A
,
b
,
c
);
TimeStepperType
timestepper
(
advection_operator
,
rhs
_operator
,
u
,
dx
);
// now do the time steps
std
::
vector
<
std
::
pair
<
double
,
DiscreteFunctionType
>>
solution_as_discrete_function
;
const
double
saveInterval
=
t_end
/
1000
>
dt
?
t_end
/
1000
:
dt
;
timestepper
.
solve
(
t_end
,
dt
,
saveInterval
,
solution_as_discrete_function
);
solution
.
clear
();
const
size_t
num_time_steps
=
solution_as_discrete_function
.
size
();
for
(
size_t
ii
=
0
;
ii
<
num_time_steps
;
++
ii
)
{
StationaryVectorType
stationary_vector
(
solution_as_discrete_function
[
ii
].
second
.
vector
());
solution
.
emplace_back
(
std
::
make_pair
(
solution_as_discrete_function
[
ii
].
first
,
stationary_vector
));
}
timestepper
.
solve
(
t_end
,
dt
,
saveInterval
,
solution
);
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cerr
<<
"Dune reported: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
@@ -348,7 +308,7 @@ public:
private
:
const
ProblemType
&
problem_
;
const
FVSpaceType
fv_space_
;
const
std
::
shared_ptr
<
const
FVSpaceType
>
fv_space_
;
};
// class NonStationaryDefault
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment