Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
d7f16f2b
Commit
d7f16f2b
authored
Jul 13, 2021
by
niklas.baumgarten
Browse files
refactored PDESolver
parent
cdfd7ab1
Pipeline
#158348
canceled with stages
in 3 minutes and 54 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
mluq/src/pdesolvers/EllipticPDESolver.cpp
View file @
d7f16f2b
...
...
@@ -33,20 +33,20 @@ void EllipticPDESolver::plotSolution(SampleSolution &solution) {
IDiscretization
*
pressureDisc
;
if
(
typeid
(
*
assemble
).
name
()
==
typeid
(
HybridEllipticAssemble
).
name
())
pressureDisc
=
new
LagrangeDiscretization
(
m
eshes
,
0
,
1
);
pressureDisc
=
new
LagrangeDiscretization
(
GetDisc
()
->
GetM
eshes
()
,
0
,
1
);
else
pressureDisc
=
new
LagrangeDiscretization
(
m
eshes
,
1
,
1
);
pressureDisc
=
new
LagrangeDiscretization
(
GetDisc
()
->
GetM
eshes
()
,
1
,
1
);
SampleSolution
pressure
(
pressureDisc
,
solution
.
Id
(),
"Pressure"
);
assemble
->
SetPressure
(
solution
.
U
,
pressure
.
U
);
mpp
::
plot
(
pressure
.
IdString
())
<<
pressure
.
U
<<
mpp
::
endp
;
LagrangeDiscretization
fluxDisc
(
m
eshes
,
0
,
SpaceDimension
);
LagrangeDiscretization
fluxDisc
(
GetDisc
()
->
GetM
eshes
()
,
0
,
SpaceDimension
);
SampleSolution
flux
(
&
fluxDisc
,
solution
.
Id
(),
"Flux"
);
assemble
->
SetFlux
(
solution
.
U
,
flux
.
U
);
mpp
::
plot
(
flux
.
IdString
())
<<
flux
.
U
<<
mpp
::
endp
;
LagrangeDiscretization
kappaDisc
(
m
eshes
,
0
,
1
);
LagrangeDiscretization
kappaDisc
(
GetDisc
()
->
GetM
eshes
()
,
0
,
1
);
SampleSolution
kappa
(
&
kappaDisc
,
solution
.
Id
(),
"Kappa"
);
assemble
->
GetProblem
()
->
Permeability
(
kappa
.
U
);
mpp
::
plot
(
kappa
.
IdString
())
<<
kappa
.
U
<<
mpp
::
endp
;
...
...
mluq/src/pdesolvers/EllipticPDESolver.hpp
View file @
d7f16f2b
#ifndef ELLIPTICPDESOLVER_HPP
#define ELLIPTICPDESOLVER_HPP
#include "LagrangeEllipticAssemble.hpp"
#include "MixedEllipticAssemble.hpp"
#include "HybridEllipticAssemble.hpp"
...
...
@@ -12,7 +11,11 @@
class
EllipticPDESolver
:
public
PDESolver
{
private:
Newton
*
newton
;
std
::
unique_ptr
<
Newton
>
newton
;
std
::
string
quantity
=
"L2"
;
std
::
string
costMeasure
=
"size"
;
IStochasticEllipticAssemble
*
assemble
;
...
...
@@ -26,21 +29,21 @@ protected:
void
plotSolution
(
SampleSolution
&
solution
)
override
;
public:
EllipticPDESolver
(
IStochasticEllipticAssemble
*
assemble
,
const
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
newton
(
new
Newton
()),
assemble
(
assemble
)
{
EllipticPDESolver
(
IStochasticEllipticAssemble
*
assemble
,
const
string
&
quantity
,
const
string
&
costMeasure
)
:
PDESolver
(),
assemble
(
assemble
),
quantity
(
quantity
),
costMeasure
(
costMeasure
),
newton
(
std
::
make_unique
<
Newton
>
())
{
if
(
verbose
>
0
)
{
PrintInfo
();
mout
.
PrintInfo
(
"EllipticPDESolver"
,
verbose
,
PrintInfoEntry
(
"Quantity"
,
quantity
),
PrintInfoEntry
(
"Cost measure"
,
costMeasure
));
newton
->
PrintInfo
();
assemble
->
PrintInfo
();
}
}
~
EllipticPDESolver
()
{
~
EllipticPDESolver
()
override
{
delete
assemble
;
delete
newton
;
}
IAssemble
*
GetAssemble
()
const
override
{
return
assemble
;
}
...
...
mluq/src/pdesolvers/PDESolver.hpp
View file @
d7f16f2b
...
...
@@ -18,12 +18,6 @@ protected:
int
plotting
=
0
;
const
Meshes
&
meshes
;
std
::
string
quantity
;
std
::
string
costMeasure
;
virtual
void
run
(
SampleSolution
&
solution
)
=
0
;
virtual
void
computeQ
(
SampleSolution
&
solution
)
=
0
;
...
...
@@ -37,23 +31,13 @@ protected:
}
public:
PDESolver
(
const
Meshes
&
meshes
,
const
std
::
string
&
quantity
,
const
std
::
string
&
costMeasure
)
:
meshes
(
meshes
),
quantity
(
quantity
),
costMeasure
(
costMeasure
)
{
PDESolver
()
{
config
.
get
(
"PDESolverVerbose"
,
verbose
);
config
.
get
(
"PDESolverPlotting"
,
plotting
);
}
virtual
~
PDESolver
()
=
default
;
virtual
void
PrintInfo
()
const
{
if
(
verbose
>
0
)
mout
.
PrintInfo
(
Name
(),
verbose
,
PrintInfoEntry
(
"Quantity"
,
quantity
),
PrintInfoEntry
(
"Cost measure"
,
costMeasure
));
}
void
Run
(
SampleSolution
&
solution
)
{
mout
.
StartBlock
(
"PDE Solver"
);
vout
(
2
)
<<
solution
.
IdString
()
<<
endl
;
...
...
@@ -95,9 +79,8 @@ protected:
void
plotSolution
(
SampleSolution
&
solution
)
override
{}
public:
// Todo remove costMeasure and quantity
DummyPDESolver
(
IStochasticDummyAssemble
*
assemble
,
const
Meshes
&
meshes
)
:
PDESolver
(
meshes
,
""
,
""
),
assemble
(
assemble
)
{}
explicit
DummyPDESolver
(
IStochasticDummyAssemble
*
assemble
)
:
PDESolver
(),
assemble
(
assemble
)
{}
IAssemble
*
GetAssemble
()
const
override
{
return
assemble
;
}
...
...
mluq/src/pdesolvers/PDESolverCreator.cpp
View file @
d7f16f2b
...
...
@@ -6,42 +6,42 @@
PDESolver
*
PDESolverCreator
::
Create
(
const
Meshes
&
meshes
)
{
if
(
_model
==
"LagrangeElliptic"
)
return
new
EllipticPDESolver
(
new
LagrangeEllipticAssemble
(
new
LagrangeDiscretization
(
meshes
,
_degree
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
),
meshes
,
_quantity
,
_costMeasure
new
LagrangeEllipticAssemble
(
new
LagrangeDiscretization
(
meshes
,
_degree
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
)
,
_quantity
,
_costMeasure
);
if
(
_model
==
"MixedElliptic"
)
return
new
EllipticPDESolver
(
new
MixedEllipticAssemble
(
new
RTLagrangeDiscretization
(
meshes
,
0
,
0
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
),
meshes
,
_quantity
,
_costMeasure
new
MixedEllipticAssemble
(
new
RTLagrangeDiscretization
(
meshes
,
0
,
0
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
)
,
_quantity
,
_costMeasure
);
if
(
_model
==
"HybridElliptic"
)
return
new
EllipticPDESolver
(
new
HybridEllipticAssemble
(
new
HybridRTLagrangeDiscretization
(
meshes
,
0
,
0
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
),
meshes
,
_quantity
,
_costMeasure
new
HybridEllipticAssemble
(
new
HybridRTLagrangeDiscretization
(
meshes
,
0
,
0
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
)
,
_quantity
,
_costMeasure
);
if
(
_model
==
"DGElliptic"
)
return
new
EllipticPDESolver
(
new
DGEllipticAssemble
(
new
DGDiscretization
(
meshes
,
_degree
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
),
meshes
,
_quantity
,
_costMeasure
new
DGEllipticAssemble
(
new
DGDiscretization
(
meshes
,
_degree
),
CreateStochasticEllipticProblem
(
_problem
,
meshes
)
)
,
_quantity
,
_costMeasure
);
if
(
_model
==
"DGTransport"
)
return
new
TransportPDESolver
(
new
DGLinearTransportAssemble
(
new
DGDiscretization
(
meshes
,
_degree
),
CreateStochasticTransportProblem
(
_problem
,
meshes
)
),
meshes
,
_quantity
,
_costMeasure
new
DGLinearTransportAssemble
(
new
DGDiscretization
(
meshes
,
_degree
),
CreateStochasticTransportProblem
(
_problem
,
meshes
)
)
,
_quantity
,
_costMeasure
);
if
(
_model
==
"PGTransport"
)
...
...
@@ -65,11 +65,10 @@ PDESolver *PDESolverCreator::Create(const Meshes &meshes) {
if
(
_model
==
"DummyPDESolver"
)
return
new
DummyPDESolver
(
new
IStochasticDummyAssemble
(
new
LagrangeDiscretization
(
meshes
,
_degree
),
CreateStochasticDummyProblem
(
_problem
,
meshes
)
),
meshes
);
new
IStochasticDummyAssemble
(
new
LagrangeDiscretization
(
meshes
,
_degree
),
CreateStochasticDummyProblem
(
_problem
,
meshes
)
));
Exit
(
_model
+
" not found"
)
}
...
...
mluq/src/pdesolvers/TransportPDESolver.cpp
View file @
d7f16f2b
...
...
@@ -20,6 +20,9 @@ void TransportPDESolver::computeQ(SampleSolution &solution) {
}
void
TransportPDESolver
::
computeCost
(
SampleSolution
&
solution
)
{
if
(
costMeasure
==
"size"
)
solution
.
C
=
solution
.
U
.
size
();
// else if (costMeasure == "time") solution.Cost = solution.U.size(); // Todo
else
Exit
(
"Cost measure not implemented"
)
}
void
TransportPDESolver
::
plotSolution
(
SampleSolution
&
solution
)
{
...
...
mluq/src/pdesolvers/TransportPDESolver.hpp
View file @
d7f16f2b
...
...
@@ -8,7 +8,11 @@
class
TransportPDESolver
:
public
PDESolver
{
private:
TimeIntegrator
*
timeInt
;
std
::
string
quantity
=
"L2"
;
std
::
string
costMeasure
=
"size"
;
std
::
unique_ptr
<
TimeIntegrator
>
timeInt
;
IStochasticLinearTransportAssemble
*
assemble
;
...
...
@@ -23,23 +27,22 @@ protected:
public:
TransportPDESolver
(
IStochasticLinearTransportAssemble
*
assemble
,
const
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
assemble
(
assemble
),
const
string
&
quantity
,
const
string
&
costMeasure
)
:
PDESolver
(),
assemble
(
assemble
),
quantity
(
quantity
),
costMeasure
(
costMeasure
),
timeInt
(
TimeIntegratorCreator
(
IMPLICIT_MIDPOINT
).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
Create
())
{
Create
Unique
())
{
if
(
verbose
)
PrintInfo
();
mout
.
PrintInfo
(
"TransportPDESolver"
,
verbose
,
PrintInfoEntry
(
"Quantity"
,
quantity
),
PrintInfoEntry
(
"Cost measure"
,
costMeasure
));
}
~
TransportPDESolver
()
{
~
TransportPDESolver
()
override
{
delete
assemble
;
delete
timeInt
;
}
IAssemble
*
GetAssemble
()
const
override
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment