Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
81ac3c27
Commit
81ac3c27
authored
Feb 04, 2019
by
Praetorius, Simon
Browse files
Remove dependency on ProblemStatBase from ProblemInstatBase
parent
d68cbeaf
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/amdis/ProblemInstat.hpp
View file @
81ac3c27
...
...
@@ -28,23 +28,21 @@ namespace AMDiS
using
SystemVector
=
typename
ProblemType
::
SystemVector
;
public:
/// Constructs a ProblemInstat with prob as its stationary problem.
/// Constructs a ProblemInstat with prob as its stationary problem
, stored as reference
.
ProblemInstat
(
std
::
string
const
&
name
,
ProblemType
&
prob
)
:
ProblemInstatBase
(
name
,
nullptr
)
,
problemStat_
(
prob
)
:
ProblemInstatBase
(
name
)
,
problemStat_
(
&
prob
)
{}
/// Constructor. Stores a reference to prob and initialProb.
ProblemInstat
(
std
::
string
const
&
name
,
ProblemType
&
prob
,
ProblemStatBase
&
initialProb
)
:
ProblemInstatBase
(
name
,
&
initialProb
)
,
problemStat_
(
prob
)
:
ProblemInstatBase
(
name
,
initialProb
)
,
problemStat_
(
&
prob
)
{}
/// Initialisation of the problem.
virtual
void
initialize
(
Flag
initFlag
=
INIT_NOTHING
);
/// Used in \ref initialize().
virtual
void
createUhOld
();
/// Implementation of \ref ProblemTimeInterface::initTimestep().
virtual
void
initTimestep
(
AdaptInfo
&
adaptInfo
)
override
;
...
...
@@ -52,8 +50,8 @@ namespace AMDiS
virtual
void
closeTimestep
(
AdaptInfo
&
adaptInfo
)
override
;
/// Returns \ref problemStat.
ProblemType
&
problemStat
()
{
return
problemStat_
;
}
ProblemType
const
&
problemStat
()
const
{
return
problemStat_
;
}
ProblemType
&
problemStat
()
{
return
*
problemStat_
;
}
ProblemType
const
&
problemStat
()
const
{
return
*
problemStat_
;
}
/// Returns \ref oldSolution.
SystemVector
const
&
oldSolutionVector
()
const
...
...
@@ -83,8 +81,12 @@ namespace AMDiS
virtual
void
transferInitialSolution
(
AdaptInfo
&
adaptInfo
)
override
;
protected:
/// Space problem solved in each timestep.
ProblemType
&
problemStat_
;
/// Used in \ref initialize() to create the \ref oldSolution_.
void
createUhOld
();
protected:
/// Space problem solved in each timestep. (non-owning pointer)
ProblemType
*
problemStat_
;
/// Solution of the last timestep.
std
::
unique_ptr
<
SystemVector
>
oldSolution_
;
...
...
@@ -96,6 +98,10 @@ namespace AMDiS
template
<
class
Traits
>
ProblemInstat
(
std
::
string
const
&
name
,
ProblemStat
<
Traits
>&
prob
)
->
ProblemInstat
<
Traits
>
;
template
<
class
Traits
>
ProblemInstat
(
std
::
string
const
&
name
,
ProblemStat
<
Traits
>&
prob
,
ProblemStatBase
&
initialProb
)
->
ProblemInstat
<
Traits
>
;
#endif
// Generator for ProblemInstat with given ProblemStat
...
...
@@ -105,6 +111,13 @@ namespace AMDiS
return
{
name
,
prob
};
}
// Generator for ProblemInstat with given ProblemStat and initialization problem
template
<
class
Traits
>
ProblemInstat
<
Traits
>
makeProblemInstat
(
std
::
string
const
&
name
,
ProblemStat
<
Traits
>&
prob
,
ProblemStatBase
&
initialProb
)
{
return
{
name
,
prob
,
initialProb
};
}
}
// end namespace AMDiS
#include
"ProblemInstat.inc.hpp"
src/amdis/ProblemInstat.inc.hpp
View file @
81ac3c27
...
...
@@ -16,7 +16,7 @@ void ProblemInstat<Traits>::transferInitialSolution(AdaptInfo& adaptInfo)
test_exit
(
adaptInfo
.
time
()
==
adaptInfo
.
startTime
(),
"after initial solution: time != start time"
);
problemStat_
.
writeFiles
(
adaptInfo
,
true
);
problemStat_
->
writeFiles
(
adaptInfo
,
true
);
}
...
...
@@ -24,7 +24,7 @@ template <class Traits>
void
ProblemInstat
<
Traits
>::
closeTimestep
(
AdaptInfo
&
adaptInfo
)
{
bool
force
=
(
adaptInfo
.
time
()
>=
adaptInfo
.
endTime
());
problemStat_
.
writeFiles
(
adaptInfo
,
force
);
problemStat_
->
writeFiles
(
adaptInfo
,
force
);
}
...
...
@@ -45,7 +45,7 @@ void ProblemInstat<Traits>::createUhOld()
if
(
oldSolution_
)
warning
(
"oldSolution already created
\n
"
);
else
// create oldSolution
oldSolution_
.
reset
(
new
SystemVector
(
problemStat_
.
globalBasis
()));
oldSolution_
.
reset
(
new
SystemVector
(
problemStat_
->
globalBasis
()));
}
...
...
@@ -53,7 +53,7 @@ template <class Traits>
void
ProblemInstat
<
Traits
>::
initTimestep
(
AdaptInfo
&
)
{
if
(
oldSolution_
)
*
oldSolution_
=
problemStat_
.
solutionVector
();
*
oldSolution_
=
problemStat_
->
solutionVector
();
}
}
// end namespace AMDiS
src/amdis/ProblemInstatBase.cpp
View file @
81ac3c27
...
...
@@ -2,6 +2,7 @@
#include
"AdaptInfo.hpp"
#include
"AdaptStationary.hpp"
#include
"ProblemStatBase.hpp"
#include
"StandardProblemIteration.hpp"
namespace
AMDiS
{
...
...
@@ -16,10 +17,11 @@ void ProblemInstatBase::setTime(AdaptInfo& adaptInfo)
void
ProblemInstatBase
::
solveInitialProblem
(
AdaptInfo
&
adaptInfo
)
{
StandardProblemIteration
iteration
(
*
initialProblem_
);
AdaptStationary
initialAdapt
(
name_
+
"->initial->adapt"
,
iteration
,
adaptInfo
);
initialAdapt
.
adapt
();
if
(
initialProblem_
)
{
StandardProblemIteration
iteration
(
*
initialProblem_
);
AdaptStationary
initialAdapt
(
name_
+
"->initial->adapt"
,
iteration
,
adaptInfo
);
initialAdapt
.
adapt
();
}
}
}
// end namespace AMDiS
src/amdis/ProblemInstatBase.hpp
View file @
81ac3c27
#pragma once
#include
"ProblemStatBase.hpp"
#include
<string>
#include
"ProblemTimeInterface.hpp"
namespace
AMDiS
{
// forward declarations
class
AdaptInfo
;
class
ProblemStatBase
;
/**
* \ingroup Problem
...
...
@@ -16,14 +18,18 @@ namespace AMDiS
*/
class
ProblemInstatBase
:
public
ProblemTimeInterface
,
public
ProblemStatBase
// NOTE: Why is this derived from ProblemStatBase
{
public:
/// Constructor.
ProblemInstatBase
(
std
::
string
const
&
name
)
:
name_
(
name
)
{}
/// Constructor. Stores a pointer to the provided initialProblem.
ProblemInstatBase
(
std
::
string
const
&
name
,
ProblemStatBase
*
initialProb
)
ProblemStatBase
&
initialProb
lem
)
:
name_
(
name
)
,
initialProblem_
(
initialProb
?
initialProb
:
this
)
,
initialProblem_
(
&
initialProb
lem
)
{}
/// Destructor.
...
...
@@ -32,78 +38,50 @@ namespace AMDiS
/// Implementation of \ref ProblemTimeInterface::setTime().
virtual
void
setTime
(
AdaptInfo
&
adaptInfo
)
override
;
void
solve
(
AdaptInfo
&
)
{
/* do nothing */
}
/// Implementation of \ref ProblemStatBase::solve().
virtual
void
solve
(
AdaptInfo
&
adaptInfo
,
bool
,
bool
)
override
{
solve
(
adaptInfo
);
}
/// Implementation of \ref ProblemStatBase::estimate().
virtual
void
estimate
(
AdaptInfo
&
)
override
{
/* do nothing */
}
/// Implementation of \ref ProblemStatBase::buildAfterAdapt().
virtual
void
buildAfterAdapt
(
AdaptInfo
&
,
Flag
,
bool
,
bool
)
override
{
/* do nothing */
}
/// Implementation of \ref ProblemStatBase::markElements().
virtual
Flag
markElements
(
AdaptInfo
&
)
override
{
return
0
;
}
/// Implementation of \ref ProblemStatBase::refineMesh().
virtual
Flag
adaptGrid
(
AdaptInfo
&
)
override
{
return
0
;
}
/// Implementation of \ref ProblemTimeInterface::closeTimestep().
virtual
void
closeTimestep
(
AdaptInfo
&
)
override
{
/* do nothing */
}
/// Implementation of \ref ProblemTimeInterface::solveInitialProblem().
virtual
void
solveInitialProblem
(
AdaptInfo
&
adaptInfo
)
override
;
///
Implementation of \ref ProblemStatBase::
name
().
virtual
std
::
string
const
&
name
()
const
override
///
Return the name of the instationary problem \ref
name
_
virtual
std
::
string
const
&
name
()
const
{
return
name_
;
}
/// Implementation of \ref ProblemTimeInterface::solveInitialProblem().
virtual
void
solveInitialProblem
(
AdaptInfo
&
adaptInfo
)
override
;
/// Return reference to current simulation time \ref time_ set in \ref setTime
/// from `
a
daptInfo
->getT
ime()`.
/// from `
A
daptInfo
::t
ime()`.
double
const
&
time
()
const
{
return
time_
;
}
/// Return reference to current simulation timestep \ref tau_ set in \ref setTime
/// from `
a
daptInfo
->getT
imestep()`.
/// from `
A
daptInfo
::t
imestep()`.
double
const
&
tau
()
const
&
{
return
tau_
;
}
/// Return reference to current simulation 1.0/timestep \ref invTau_ set in
/// \ref setTime from `1.0 /
a
daptInfo
->getT
imestep()`.
/// \ref setTime from `1.0 /
A
daptInfo
::t
imestep()`.
double
const
&
invTau
()
const
{
return
invTau_
;
}
protected:
/// Name of the problem.
/// Name of the
instationary
problem.
std
::
string
name_
;
ProblemStatBase
*
initialProblem_
;
/// An initialization problem solved in \ref solveInitialProblem(). non-owning pointer.
ProblemStatBase
*
initialProblem_
=
nullptr
;
/// T
ime
/// T
he current time, set from adaptInfo.time()
double
time_
=
0.0
;
/// Timestep
/// Timestep
, set from adaptInfo.timestep()
double
tau_
=
1.0
;
/// 1 / timestep
/// 1 / timestep
, calculated after timestep is set
double
invTau_
=
1.0
;
};
...
...
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