Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
82af39c5
Commit
82af39c5
authored
Apr 09, 2021
by
niklas.baumgarten
Browse files
using verbose as quick hack to get rid of useless logging
parent
9d74096d
Changes
1
Hide whitespace changes
Inline
Side-by-side
mlmc/src/pdesolver/PDESolver.hpp
View file @
82af39c5
...
...
@@ -25,183 +25,189 @@
class
PDESolver
{
protected:
int
verbose
=
1
;
int
verbose
=
1
;
int
plotting
=
0
;
int
plotting
=
0
;
Meshes
&
meshes
;
Meshes
&
meshes
;
std
::
string
quantity
;
std
::
string
quantity
;
std
::
string
costMeasure
;
std
::
string
costMeasure
;
virtual
void
run
(
SampleSolution
&
solution
)
=
0
;
virtual
void
run
(
SampleSolution
&
solution
)
=
0
;
virtual
void
computeQ
(
SampleSolution
&
solution
)
=
0
;
virtual
void
computeQ
(
SampleSolution
&
solution
)
=
0
;
virtual
void
computeCost
(
SampleSolution
&
solution
)
=
0
;
virtual
void
computeCost
(
SampleSolution
&
solution
)
=
0
;
virtual
void
plotSolution
(
SampleSolution
&
solution
)
=
0
;
virtual
void
plotSolution
(
SampleSolution
&
solution
)
=
0
;
public:
PDESolver
(
Meshes
&
meshes
,
const
std
::
string
&
quantity
,
const
std
::
string
&
costMeasure
)
:
meshes
(
meshes
),
quantity
(
quantity
),
costMeasure
(
costMeasure
)
{
config
.
get
(
"PDESolverVerbose"
,
verbose
);
config
.
get
(
"PDESolverPlotting"
,
plotting
);
}
virtual
~
PDESolver
()
{};
virtual
void
PrintInfo
()
const
{
mout
.
PrintInfo
(
Name
(),
verbose
,
PrintInfoEntry
(
"Quantity"
,
quantity
),
PrintInfoEntry
(
"Cost measure"
,
costMeasure
));
}
void
Run
(
SampleSolution
&
solution
)
{
mout
.
StartBlock
(
"PDE Solver"
);
vout
(
2
)
<<
solution
.
IdString
()
<<
endl
;
run
(
solution
);
computeQ
(
solution
);
computeCost
(
solution
);
plotSolution
(
solution
);
vout
(
2
)
<<
"Q="
<<
solution
.
Q
<<
" cost="
<<
solution
.
Cost
<<
endl
;
mout
.
EndBlock
(
verbose
<=
1
);
}
virtual
IAssemble
*
GetAssemble
()
const
=
0
;
virtual
IDiscretization
*
GetDisc
()
const
=
0
;
virtual
IStochasticProblem
*
GetProblem
()
const
=
0
;
virtual
void
DrawSample
(
const
SampleID
&
id
)
=
0
;
virtual
std
::
string
Name
()
const
=
0
;
PDESolver
(
Meshes
&
meshes
,
const
std
::
string
&
quantity
,
const
std
::
string
&
costMeasure
)
:
meshes
(
meshes
),
quantity
(
quantity
),
costMeasure
(
costMeasure
)
{
config
.
get
(
"PDESolverVerbose"
,
verbose
);
config
.
get
(
"PDESolverPlotting"
,
plotting
);
}
virtual
~
PDESolver
()
{};
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
;
run
(
solution
);
computeQ
(
solution
);
computeCost
(
solution
);
plotSolution
(
solution
);
vout
(
2
)
<<
"Q="
<<
solution
.
Q
<<
" cost="
<<
solution
.
Cost
<<
endl
;
mout
.
EndBlock
(
verbose
<=
1
);
}
virtual
IAssemble
*
GetAssemble
()
const
=
0
;
virtual
IDiscretization
*
GetDisc
()
const
=
0
;
virtual
IStochasticProblem
*
GetProblem
()
const
=
0
;
virtual
void
DrawSample
(
const
SampleID
&
id
)
=
0
;
virtual
std
::
string
Name
()
const
=
0
;
};
class
DummyPDESolver
:
public
PDESolver
{
private:
IStochasticDummyAssemble
*
assemble
;
IStochasticDummyAssemble
*
assemble
;
protected:
void
run
(
SampleSolution
&
solution
)
override
;;
void
run
(
SampleSolution
&
solution
)
override
;;
void
computeQ
(
SampleSolution
&
solution
)
override
;;
void
computeQ
(
SampleSolution
&
solution
)
override
;;
void
computeCost
(
SampleSolution
&
solution
)
override
;;
void
computeCost
(
SampleSolution
&
solution
)
override
;;
void
plotSolution
(
SampleSolution
&
solution
)
override
;;
void
plotSolution
(
SampleSolution
&
solution
)
override
;;
public:
DummyPDESolver
(
IStochasticDummyAssemble
*
assemble
,
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
assemble
(
assemble
)
{
PrintInfo
();
// assemble->PrintInfo();
DummyPDESolver
(
IStochasticDummyAssemble
*
assemble
,
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
assemble
(
assemble
)
{
if
(
verbose
>
0
)
{
PrintInfo
();
assemble
->
PrintInfo
();
}
}
IAssemble
*
GetAssemble
()
const
override
{
return
assemble
;
}
IAssemble
*
GetAssemble
()
const
override
{
return
assemble
;
}
IDiscretization
*
GetDisc
()
const
override
{
return
assemble
->
GetDisc
();
}
IDiscretization
*
GetDisc
()
const
override
{
return
assemble
->
GetDisc
();
}
IStochasticProblem
*
GetProblem
()
const
override
{
return
assemble
->
GetProblem
();
}
IStochasticProblem
*
GetProblem
()
const
override
{
return
assemble
->
GetProblem
();
}
void
DrawSample
(
const
SampleID
&
id
)
override
{
assemble
->
DrawSample
(
id
);
}
void
DrawSample
(
const
SampleID
&
id
)
override
{
assemble
->
DrawSample
(
id
);
}
std
::
string
Name
()
const
override
{
return
"DummyPDESolver"
;
}
std
::
string
Name
()
const
override
{
return
"DummyPDESolver"
;
}
};
class
EllipticPDESolver
:
public
PDESolver
{
private:
Newton
*
newton
;
Newton
*
newton
;
IStochasticEllipticAssemble
*
assemble
;
IStochasticEllipticAssemble
*
assemble
;
protected:
void
run
(
SampleSolution
&
solution
)
override
;
void
run
(
SampleSolution
&
solution
)
override
;
void
computeQ
(
SampleSolution
&
solution
)
override
;
void
computeQ
(
SampleSolution
&
solution
)
override
;
void
computeCost
(
SampleSolution
&
solution
)
override
;
void
computeCost
(
SampleSolution
&
solution
)
override
;
void
plotSolution
(
SampleSolution
&
solution
)
override
;
void
plotSolution
(
SampleSolution
&
solution
)
override
;
public:
EllipticPDESolver
(
IStochasticEllipticAssemble
*
assemble
,
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
newton
(
new
Newton
()),
assemble
(
assemble
)
{
PrintInfo
();
newton
->
PrintInfo
();
assemble
->
PrintInfo
();
EllipticPDESolver
(
IStochasticEllipticAssemble
*
assemble
,
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
newton
(
new
Newton
()),
assemble
(
assemble
)
{
if
(
verbose
>
0
)
{
PrintInfo
();
newton
->
PrintInfo
();
assemble
->
PrintInfo
();
}
}
~
EllipticPDESolver
()
{
delete
assemble
;
delete
newton
;
}
~
EllipticPDESolver
()
{
delete
assemble
;
delete
newton
;
}
IAssemble
*
GetAssemble
()
const
override
{
return
assemble
;
}
IAssemble
*
GetAssemble
()
const
override
{
return
assemble
;
}
IDiscretization
*
GetDisc
()
const
override
{
return
assemble
->
GetDisc
();
}
IDiscretization
*
GetDisc
()
const
override
{
return
assemble
->
GetDisc
();
}
IStochasticProblem
*
GetProblem
()
const
override
{
return
assemble
->
GetProblem
();
}
IStochasticProblem
*
GetProblem
()
const
override
{
return
assemble
->
GetProblem
();
}
void
DrawSample
(
const
SampleID
&
id
)
override
{
assemble
->
DrawSample
(
id
);
}
void
DrawSample
(
const
SampleID
&
id
)
override
{
assemble
->
DrawSample
(
id
);
}
std
::
string
Name
()
const
override
{
return
"EllipticPDESolver"
;
}
std
::
string
Name
()
const
override
{
return
"EllipticPDESolver"
;
}
};
class
TransportPDESolver
:
public
PDESolver
{
private:
TimeIntegrator
*
timeInt
;
TimeIntegrator
*
timeInt
;
IStochasticLinearTransportAssemble
*
assemble
;
IStochasticLinearTransportAssemble
*
assemble
;
protected:
void
run
(
SampleSolution
&
solution
)
override
;
void
run
(
SampleSolution
&
solution
)
override
;
void
computeQ
(
SampleSolution
&
solution
)
override
;
void
computeQ
(
SampleSolution
&
solution
)
override
;
void
computeCost
(
SampleSolution
&
solution
)
override
;
void
computeCost
(
SampleSolution
&
solution
)
override
;
void
plotSolution
(
SampleSolution
&
solution
)
override
;
void
plotSolution
(
SampleSolution
&
solution
)
override
;
public:
TransportPDESolver
(
IStochasticLinearTransportAssemble
*
assemble
,
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
assemble
(
assemble
),
timeInt
(
TimeIntegratorCreator
(
IMPLICIT_MIDPOINT
).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
Create
())
{
PrintInfo
();
}
~
TransportPDESolver
()
{
delete
assemble
;
delete
timeInt
;
}
IAssemble
*
GetAssemble
()
const
override
{
return
nullptr
;
TransportPDESolver
(
IStochasticLinearTransportAssemble
*
assemble
,
Meshes
&
meshes
,
const
std
::
string
&
quantity
=
"L2"
,
const
std
::
string
&
costMeasure
=
"size"
)
:
PDESolver
(
meshes
,
quantity
,
costMeasure
),
assemble
(
assemble
),
timeInt
(
TimeIntegratorCreator
(
IMPLICIT_MIDPOINT
).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
WithLinearSolver
(
new
GMRES
(
GetPC
(
"PointBlockJacobi_dG"
))).
Create
())
{
if
(
verbose
)
PrintInfo
();
}
~
TransportPDESolver
()
{
delete
assemble
;
delete
timeInt
;
}
IAssemble
*
GetAssemble
()
const
override
{
return
nullptr
;
// return assemble;
}
}
IDiscretization
*
GetDisc
()
const
override
{
return
assemble
->
GetDisc
();
}
IDiscretization
*
GetDisc
()
const
override
{
return
assemble
->
GetDisc
();
}
IStochasticProblem
*
GetProblem
()
const
override
{
return
assemble
->
GetProblem
();
}
IStochasticProblem
*
GetProblem
()
const
override
{
return
assemble
->
GetProblem
();
}
void
DrawSample
(
const
SampleID
&
id
)
override
{
assemble
->
DrawSample
(
id
);
}
void
DrawSample
(
const
SampleID
&
id
)
override
{
assemble
->
DrawSample
(
id
);
}
std
::
string
Name
()
const
override
{
return
"TransportPDESolver"
;
}
std
::
string
Name
()
const
override
{
return
"TransportPDESolver"
;
}
};
#endif //PDESOLVER_HPP
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment