Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
amdis
amdis-core
Commits
074f8e52
Commit
074f8e52
authored
6 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Plain Diff
resolved merge conflict
parents
9a807d6d
64766b4e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/amdis/AdaptInfo.cpp
+8
-23
8 additions, 23 deletions
src/amdis/AdaptInfo.cpp
src/amdis/AdaptInfo.hpp
+189
-87
189 additions, 87 deletions
src/amdis/AdaptInfo.hpp
test/AdaptInfoTest.cpp
+38
-0
38 additions, 0 deletions
test/AdaptInfoTest.cpp
test/CMakeLists.txt
+3
-0
3 additions, 0 deletions
test/CMakeLists.txt
with
238 additions
and
110 deletions
src/amdis/AdaptInfo.cpp
+
8
−
23
View file @
074f8e52
#include
"AdaptInfo.hpp"
#include
"AdaptInfo.hpp"
// std c++ headers
// std c++ headers
#include
<string>
#include
<iostream>
#include
<iostream>
#include
<string>
#include
<amdis/Initfile.hpp>
#include
<amdis/Initfile.hpp>
...
@@ -16,8 +16,6 @@ namespace AMDiS
...
@@ -16,8 +16,6 @@ namespace AMDiS
Parameters
::
get
(
prefix
+
"->time relative tolerance"
,
timeRelativeTolerance
);
Parameters
::
get
(
prefix
+
"->time relative tolerance"
,
timeRelativeTolerance
);
Parameters
::
get
(
prefix
+
"->coarsen allowed"
,
coarsenAllowed
);
Parameters
::
get
(
prefix
+
"->coarsen allowed"
,
coarsenAllowed
);
Parameters
::
get
(
prefix
+
"->refinement allowed"
,
refinementAllowed
);
Parameters
::
get
(
prefix
+
"->refinement allowed"
,
refinementAllowed
);
Parameters
::
get
(
prefix
+
"->refine bisections"
,
refineBisections
);
Parameters
::
get
(
prefix
+
"->coarsen bisections"
,
coarseBisections
);
Parameters
::
get
(
prefix
+
"->sum factor"
,
fac_sum
);
Parameters
::
get
(
prefix
+
"->sum factor"
,
fac_sum
);
Parameters
::
get
(
prefix
+
"->max factor"
,
fac_max
);
Parameters
::
get
(
prefix
+
"->max factor"
,
fac_max
);
...
@@ -27,7 +25,7 @@ namespace AMDiS
...
@@ -27,7 +25,7 @@ namespace AMDiS
}
}
AdaptInfo
::
AdaptInfo
(
std
::
string
name
,
int
size
)
AdaptInfo
::
AdaptInfo
(
std
::
string
name
)
:
name
(
name
)
:
name
(
name
)
{
{
// init();
// init();
...
@@ -43,37 +41,24 @@ namespace AMDiS
...
@@ -43,37 +41,24 @@ namespace AMDiS
Parameters
::
get
(
name
+
"->max timestep"
,
maxTimestep
);
Parameters
::
get
(
name
+
"->max timestep"
,
maxTimestep
);
Parameters
::
get
(
name
+
"->number of timesteps"
,
nTimesteps
);
Parameters
::
get
(
name
+
"->number of timesteps"
,
nTimesteps
);
Parameters
::
get
(
name
+
"->time tolerance"
,
globalTimeTolerance
);
Parameters
::
get
(
name
+
"->time tolerance"
,
globalTimeTolerance
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
scalContents
.
emplace_back
(
new
ScalContent
(
name
+
"["
+
std
::
to_string
(
i
)
+
"]"
));
}
void
AdaptInfo
::
setScalContents
(
int
newSize
)
{
int
oldSize
=
int
(
scalContents
.
size
());
if
(
newSize
>
oldSize
)
{
for
(
int
i
=
oldSize
;
i
<
newSize
;
++
i
)
scalContents
.
emplace_back
(
new
ScalContent
(
name
+
"["
+
std
::
to_string
(
i
)
+
"]"
));
}
}
}
void
AdaptInfo
::
printTimeErrorLowInfo
()
const
void
AdaptInfo
::
printTimeErrorLowInfo
()
const
{
{
for
(
std
::
size_t
i
=
0
;
i
<
scalContents
.
size
();
i
++
)
for
(
auto
const
&
scalContent
:
scalContents
)
{
{
auto
i
=
scalContent
.
first
;
std
::
cout
<<
" Time error estimate ["
<<
i
<<
"] = "
std
::
cout
<<
" Time error estimate ["
<<
i
<<
"] = "
<<
getTimeEstCombined
(
i
)
<<
"
\n
"
<<
getTimeEstCombined
(
i
)
<<
"
\n
"
<<
" Time error estimate sum ["
<<
i
<<
"] = "
<<
" Time error estimate sum ["
<<
i
<<
"] = "
<<
scalContent
s
[
i
]
->
est_t_sum
<<
"
\n
"
<<
scalContent
.
second
.
est_t_sum
<<
"
\n
"
<<
" Time error estimate max ["
<<
i
<<
"] = "
<<
" Time error estimate max ["
<<
i
<<
"] = "
<<
scalContent
s
[
i
]
->
est_t_max
<<
"
\n
"
<<
scalContent
.
second
.
est_t_max
<<
"
\n
"
<<
" Time error low bound ["
<<
i
<<
"] = "
<<
" Time error low bound ["
<<
i
<<
"] = "
<<
scalContent
s
[
i
]
->
timeErrLow
<<
"
\n
"
<<
scalContent
.
second
.
timeErrLow
<<
"
\n
"
<<
" Time error high bound ["
<<
i
<<
"] = "
<<
" Time error high bound ["
<<
i
<<
"] = "
<<
scalContent
s
[
i
]
->
timeTolerance
<<
"
\n
"
;
<<
scalContent
.
second
.
timeTolerance
<<
"
\n
"
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/amdis/AdaptInfo.hpp
+
189
−
87
View file @
074f8e52
...
@@ -4,12 +4,15 @@
...
@@ -4,12 +4,15 @@
#include
<algorithm>
#include
<algorithm>
#include
<cmath>
#include
<cmath>
#include
<limits>
#include
<limits>
#include
<map>
#include
<string>
#include
<string>
#include
<
vector
>
#include
<
utility
>
// AMDiS includes
// AMDiS includes
#include
<amdis/Output.hpp>
#include
<amdis/Output.hpp>
#include
<amdis/common/ConceptsBase.hpp>
#include
<amdis/common/Math.hpp>
#include
<amdis/common/Math.hpp>
#include
<amdis/utility/TreePath.hpp>
namespace
AMDiS
namespace
AMDiS
{
{
...
@@ -18,11 +21,13 @@ namespace AMDiS
...
@@ -18,11 +21,13 @@ namespace AMDiS
* \ingroup Adaption
* \ingroup Adaption
*
*
* \brief
* \brief
* Holds adapt parameters and infos about the problem. Base class
* Holds adapt parameters and infos about the problem.
* for AdaptInfoScal and AdaptInfoVec.
*/
*/
class
AdaptInfo
class
AdaptInfo
{
{
public:
using
Key
=
std
::
string
;
protected:
protected:
/** \brief
/** \brief
* Stores adapt infos for a scalar problem or for one component of a
* Stores adapt infos for a scalar problem or for one component of a
...
@@ -66,25 +71,11 @@ namespace AMDiS
...
@@ -66,25 +71,11 @@ namespace AMDiS
/// true if refinement is allowed, false otherwise.
/// true if refinement is allowed, false otherwise.
int
refinementAllowed
=
1
;
int
refinementAllowed
=
1
;
/** \brief
* parameter to tell the marking strategy how many bisections should be
* performed when an element is marked for refinement; usually the value is
* 1 or DIM
*/
int
refineBisections
=
1
;
/** \brief
* parameter to tell the marking strategy how many bisections should
* be undone when an element is marked for coarsening; usually the value is
* 1 or DIM
*/
int
coarseBisections
=
1
;
};
};
public
:
public
:
/// Constructor.
/// Constructor.
explicit
AdaptInfo
(
std
::
string
name
,
int
size
=
1
);
explicit
AdaptInfo
(
std
::
string
name
);
/// Destructor.
/// Destructor.
virtual
~
AdaptInfo
()
{}
virtual
~
AdaptInfo
()
{}
...
@@ -95,61 +86,78 @@ namespace AMDiS
...
@@ -95,61 +86,78 @@ namespace AMDiS
/// Returns whether space tolerance is reached.
/// Returns whether space tolerance is reached.
virtual
bool
spaceToleranceReached
()
const
virtual
bool
spaceToleranceReached
()
const
{
{
for
(
std
::
size_t
i
=
0
;
i
<
scalContents
.
size
();
i
++
)
for
(
auto
const
&
scalContent
:
scalContents
)
{
{
if
(
!
(
scalContent
.
second
.
est_sum
<
scalContent
.
second
.
spaceTolerance
))
if
(
!
(
scalContents
[
i
]
->
est_sum
<
scalContents
[
i
]
->
spaceTolerance
))
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
/// Returns whether space tolerance of component
i
is reached.
/// Returns whether space tolerance of component
associated with key
is reached.
virtual
bool
spaceToleranceReached
(
int
i
)
const
virtual
bool
spaceToleranceReached
(
Key
key
)
const
{
{
if
(
!
(
s
calContent
s
[
i
]
->
est_sum
<
s
calContent
s
[
i
]
->
spaceTolerance
))
if
(
!
(
getS
calContent
(
key
).
est_sum
<
getS
calContent
(
key
).
spaceTolerance
))
return
false
;
return
false
;
else
else
return
true
;
return
true
;
}
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
bool
spaceToleranceReached
(
const
TP
&
tp
)
const
{
return
spaceToleranceReached
(
to_string
(
tp
));
}
/// Returns whether time tolerance is reached.
/// Returns whether time tolerance is reached.
virtual
bool
timeToleranceReached
()
const
virtual
bool
timeToleranceReached
()
const
{
{
for
(
std
::
size_t
i
=
0
;
i
<
scalContents
.
size
();
i
++
)
for
(
auto
const
&
scalContent
:
scalContents
)
if
(
!
(
getTimeEstCombined
(
i
)
<
scalContent
s
[
i
]
->
timeTolerance
))
if
(
!
(
getTimeEstCombined
(
scalContent
.
first
)
<
scalContent
.
second
.
timeTolerance
))
return
false
;
return
false
;
return
true
;
return
true
;
}
}
/// Returns whether time tolerance of component
i
is reached.
/// Returns whether time tolerance of component
associated with key
is reached.
virtual
bool
timeToleranceReached
(
int
i
)
const
virtual
bool
timeToleranceReached
(
Key
key
)
const
{
{
if
(
!
(
getTimeEstCombined
(
i
)
<
s
calContent
s
[
i
]
->
timeTolerance
))
if
(
!
(
getTimeEstCombined
(
key
)
<
getS
calContent
(
key
).
timeTolerance
))
return
false
;
return
false
;
else
else
return
true
;
return
true
;
}
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
bool
timeToleranceReached
(
const
TP
&
tp
)
const
{
return
timeToleranceReached
(
to_string
(
tp
));
}
/// Returns whether time error is under its lower bound.
/// Returns whether time error is under its lower bound.
virtual
bool
timeErrorLow
()
const
virtual
bool
timeErrorLow
()
const
{
{
for
(
std
::
size_t
i
=
0
;
i
<
scalContents
.
size
();
i
++
)
for
(
auto
const
&
scalContent
:
scalContents
)
if
(
!
(
getTimeEstCombined
(
i
)
<
scalContent
s
[
i
]
->
timeErrLow
))
if
(
!
(
getTimeEstCombined
(
scalContent
.
first
)
<
scalContent
.
second
.
timeErrLow
))
return
false
;
return
false
;
return
true
;
return
true
;
}
}
/// Returns the time estimation as a combination
/// Returns the time estimation as a combination
/// of maximal and integral time error
/// of maximal and integral time error
double
getTimeEstCombined
(
std
::
size_t
i
)
const
double
getTimeEstCombined
(
Key
key
)
const
{
{
return
return
s
calContent
s
[
i
]
->
est_t_max
*
s
calContent
s
[
i
]
->
fac_max
+
getS
calContent
(
key
).
est_t_max
*
getS
calContent
(
key
).
fac_max
+
s
calContent
s
[
i
]
->
est_t_sum
*
s
calContent
s
[
i
]
->
fac_sum
;
getS
calContent
(
key
).
est_t_sum
*
getS
calContent
(
key
).
fac_sum
;
}
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getTimeEstCombined
(
const
TP
&
tp
)
const
{
return
getTimeEstCombined
(
to_string
(
tp
));
}
/// Print debug information about time error and its bound.
/// Print debug information about time error and its bound.
void
printTimeErrorLowInfo
()
const
;
void
printTimeErrorLowInfo
()
const
;
...
@@ -275,63 +283,111 @@ namespace AMDiS
...
@@ -275,63 +283,111 @@ namespace AMDiS
}
}
/// Sets \ref est_sum.
/// Sets \ref est_sum.
void
setEstSum
(
double
e
,
int
index
)
void
setEstSum
(
double
e
,
Key
key
)
{
{
scalContents
[
index
]
->
est_sum
=
e
;
getScalContent
(
key
).
est_sum
=
e
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
setEstSum
(
double
e
,
const
TP
&
tp
)
{
setEstSum
(
e
,
to_string
(
tp
));
}
}
/// Sets \ref est_max.
/// Sets \ref est_max.
void
setEstMax
(
double
e
,
int
index
)
void
setEstMax
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_max
=
e
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
setEstMax
(
double
e
,
const
TP
&
tp
)
{
{
s
calContents
[
index
]
->
est_max
=
e
;
s
etEstMax
(
e
,
to_string
(
tp
))
;
}
}
/// Sets \ref est_max.
/// Sets \ref est_max.
void
setTimeEstMax
(
double
e
,
int
index
)
void
setTimeEstMax
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_t_max
=
e
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
setTimeEstMax
(
double
e
,
const
TP
&
tp
)
{
{
s
calContents
[
index
]
->
est_t_max
=
e
;
s
etTimeEstMax
(
e
,
to_string
(
tp
))
;
}
}
/// Sets \ref est_t_sum.
/// Sets \ref est_t_sum.
void
setTimeEstSum
(
double
e
,
int
index
)
void
setTimeEstSum
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_t_sum
=
e
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
setTimeEstSum
(
double
e
,
const
TP
&
tp
)
{
{
s
calContents
[
index
]
->
est_t_sum
=
e
;
s
etTimeEstSum
(
e
,
to_string
(
tp
))
;
}
}
/// Returns \ref est_sum.
/// Returns \ref est_sum.
double
getEstSum
(
int
index
)
const
double
getEstSum
(
Key
key
)
const
{
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
)
;
return
getScalContent
(
key
).
est_sum
;
test_exit_dbg
(
size_t
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
}
return
scalContents
[
index
]
->
est_sum
;
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getEstSum
(
const
TP
&
tp
)
{
return
getEstSum
(
to_string
(
tp
));
}
}
/// Returns \ref est_t_sum.
/// Returns \ref est_t_sum.
double
getEstTSum
(
int
index
)
const
double
getEstTSum
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_sum
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getEstTSum
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
est_t_sum
;
return
getEstTSum
(
to_string
(
tp
))
;
}
}
/// Returns \ref est_max.
/// Returns \ref est_max.
double
getEstMax
(
int
index
)
const
double
getEstMax
(
Key
key
)
const
{
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
)
;
return
getScalContent
(
key
).
est_max
;
test_exit_dbg
(
size_t
(
index
)
<
scalContents
.
size
(),
"Wrong index for adaptInfo!
\n
"
);
}
return
scalContents
[
index
]
->
est_max
;
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getEstMax
(
const
TP
&
tp
)
{
return
getEstMax
(
to_string
(
tp
));
}
}
/// Returns \ref est_max.
/// Returns \ref est_max.
double
getTimeEstMax
(
int
index
)
const
double
getTimeEstMax
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_max
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getTimeEstmax
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
est_t_max
;
return
getTimeEstMax
(
to_string
(
tp
))
;
}
}
/// Returns \ref est_t_sum.
/// Returns \ref est_t_sum.
double
getTimeEstSum
(
int
index
)
const
double
getTimeEstSum
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_sum
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getTimeEstSum
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
est_t_sum
;
return
getTimeEstSum
(
to_string
(
tp
))
;
}
}
/// Returns \ref est_t the estimated overall time error
/// Returns \ref est_t the estimated overall time error
...
@@ -346,27 +402,51 @@ namespace AMDiS
...
@@ -346,27 +402,51 @@ namespace AMDiS
}
}
/// Returns \ref spaceTolerance.
/// Returns \ref spaceTolerance.
double
getSpaceTolerance
(
int
index
)
const
double
getSpaceTolerance
(
Key
key
)
const
{
return
getScalContent
(
key
).
spaceTolerance
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getSpaceTolerance
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
spaceTolerance
;
return
getSpaceTolerance
(
to_string
(
tp
))
;
}
}
/// Sets \ref spaceTolerance.
/// Sets \ref spaceTolerance.
void
setSpaceTolerance
(
int
index
,
double
tol
)
void
setSpaceTolerance
(
Key
key
,
double
tol
)
{
{
scalContents
[
index
]
->
spaceTolerance
=
tol
;
getScalContent
(
key
).
spaceTolerance
=
tol
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
setSpaceTolerance
(
const
TP
&
tp
,
double
tol
)
{
return
setSpaceTolerance
(
to_string
(
tp
),
tol
);
}
}
/// Returns \ref timeTolerance.
/// Returns \ref timeTolerance.
double
getTimeTolerance
(
int
index
)
const
double
getTimeTolerance
(
Key
key
)
const
{
return
getScalContent
(
key
).
timeTolerance
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getTimeTolerance
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
timeTolerance
;
return
getTimeTolerance
(
to_string
(
tp
))
;
}
}
/// Returns \ref timeRelativeTolerance.
/// Returns \ref timeRelativeTolerance.
double
getTimeRelativeTolerance
(
int
index
)
const
double
getTimeRelativeTolerance
(
Key
key
)
const
{
return
getScalContent
(
key
).
timeRelativeTolerance
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getTimeRelativeTolerance
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
t
imeRelativeTolerance
;
return
getT
imeRelativeTolerance
(
to_string
(
tp
))
;
}
}
/// Sets \ref time
/// Sets \ref time
...
@@ -488,45 +568,63 @@ namespace AMDiS
...
@@ -488,45 +568,63 @@ namespace AMDiS
}
}
/// Returns \ref timeErrLow.
/// Returns \ref timeErrLow.
double
getTimeErrLow
(
int
index
)
const
double
getTimeErrLow
(
Key
key
)
const
{
return
getScalContent
(
key
).
timeErrLow
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
double
getTimeErrLow
(
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
timeErrLow
;
return
getTimeErrLow
(
to_string
(
tp
))
;
}
}
/// Returns whether coarsening is allowed or not.
/// Returns whether coarsening is allowed or not.
bool
isCoarseningAllowed
(
int
index
)
const
bool
isCoarseningAllowed
(
Key
key
)
const
{
{
return
(
scalContents
[
index
]
->
coarsenAllowed
==
1
);
return
(
getScalContent
(
key
).
coarsenAllowed
==
1
);
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
bool
isCoarseningAllowed
(
const
TP
&
tp
)
{
return
isCoarseningAllowed
(
to_string
(
tp
));
}
}
/// Returns whether coarsening is allowed or not.
/// Returns whether coarsening is allowed or not.
bool
isRefinementAllowed
(
int
index
)
const
bool
isRefinementAllowed
(
Key
key
)
const
{
{
return
(
s
calContent
s
[
index
]
->
refinementAllowed
==
1
);
return
(
getS
calContent
(
key
).
refinementAllowed
==
1
);
}
}
///
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
allowRefinement
(
bool
allow
,
int
index
)
bool
isRefinementAllowed
(
const
TP
&
tp
)
{
{
scalContents
[
index
]
->
r
efinementAllowed
=
allow
;
return
isR
efinementAllowed
(
to_string
(
tp
))
;
}
}
///
///
void
allow
Coarsening
(
bool
allow
,
int
index
)
void
allow
Refinement
(
bool
allow
,
Key
key
)
{
{
s
calContent
s
[
index
]
->
coars
enAllowed
=
allow
;
getS
calContent
(
key
).
refinem
en
t
Allowed
=
allow
;
}
}
/// Returns \ref refineBisections
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
int
getRefineBisections
(
int
index
)
const
void
allowRefinement
(
bool
allow
,
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
refineBisections
;
return
allowRefinement
(
allow
,
to_string
(
tp
))
;
}
}
/// Returns \ref coarseBisections
///
int
getCoarseBisections
(
int
index
)
const
void
allowCoarsening
(
bool
allow
,
Key
key
)
{
getScalContent
(
key
).
coarsenAllowed
=
allow
;
}
template
<
class
TP
,
REQUIRES
(
Concepts
::
PreTreePath
<
TP
>
)
>
void
allowCoarsening
(
bool
allow
,
const
TP
&
tp
)
{
{
return
scalContents
[
index
]
->
coarseBisections
;
return
allowCoarsening
(
allow
,
to_string
(
tp
))
;
}
}
int
getSize
()
const
int
getSize
()
const
...
@@ -596,9 +694,6 @@ namespace AMDiS
...
@@ -596,9 +694,6 @@ namespace AMDiS
rosenbrockMode
=
b
;
rosenbrockMode
=
b
;
}
}
/// Creates new scalContents with the given size.
void
setScalContents
(
int
newSize
);
/** \brief
/** \brief
* Resets timestep, current time and time boundaries without
* Resets timestep, current time and time boundaries without
* any check. Is used by the parareal algorithm.
* any check. Is used by the parareal algorithm.
...
@@ -614,6 +709,13 @@ namespace AMDiS
...
@@ -614,6 +709,13 @@ namespace AMDiS
timestepNumber
=
0
;
timestepNumber
=
0
;
}
}
private
:
ScalContent
&
getScalContent
(
Key
key
)
const
{
auto
result
=
scalContents
.
emplace
(
std
::
piecewise_construct
,
std
::
forward_as_tuple
(
key
),
std
::
forward_as_tuple
(
name
+
"["
+
key
+
"]"
)
);
return
result
.
first
->
second
;
}
protected
:
protected
:
/// Name.
/// Name.
std
::
string
name
;
std
::
string
name
;
...
@@ -648,7 +750,7 @@ namespace AMDiS
...
@@ -648,7 +750,7 @@ namespace AMDiS
/// Final time
/// Final time
double
endTime
=
1.0
;
double
endTime
=
1.0
;
///Time step size to be used
///
Time step size to be used
double
timestep
=
0.0
;
double
timestep
=
0.0
;
/// Last processed time step size of finished iteration
/// Last processed time step size of finished iteration
...
@@ -685,8 +787,8 @@ namespace AMDiS
...
@@ -685,8 +787,8 @@ namespace AMDiS
/// tolerance for the overall time error
/// tolerance for the overall time error
double
globalTimeTolerance
=
1.0
;
double
globalTimeTolerance
=
1.0
;
/// Scalar adapt infos
.
/// Scalar adapt infos
std
::
vector
<
std
::
unique_ptr
<
ScalContent
>
>
scalContents
;
mutable
std
::
map
<
Key
,
ScalContent
>
scalContents
;
/// Is true, if the adaptive procedure was deserialized from a file. TODO: remove deserialization
/// Is true, if the adaptive procedure was deserialized from a file. TODO: remove deserialization
bool
deserialized
=
false
;
bool
deserialized
=
false
;
...
...
This diff is collapsed.
Click to expand it.
test/AdaptInfoTest.cpp
0 → 100644
+
38
−
0
View file @
074f8e52
#include
<amdis/AdaptInfo.cpp>
#include
<amdis/AMDiS.hpp>
#include
<amdis/common/Literals.hpp>
#include
<amdis/utility/TreePath.hpp>
#include
"Tests.hpp"
using
namespace
AMDiS
;
int
main
()
{
AdaptInfo
adaptInfo
(
"adapt"
);
auto
root_tp
=
treepath
();
auto
tp
=
treepath
(
0
_c
);
std
::
string
str
=
"0"
;
adaptInfo
.
setEstSum
(
0.1
,
tp
);
AMDIS_TEST_EQ
(
adaptInfo
.
getEstSum
(
tp
),
0.1
);
adaptInfo
.
setEstSum
(
0.2
,
root_tp
);
AMDIS_TEST_EQ
(
adaptInfo
.
getEstSum
(
root_tp
),
0.2
);
AMDIS_TEST_EQ
(
adaptInfo
.
getSize
(),
2
);
adaptInfo
.
setEstSum
(
0.3
,
"0"
);
AMDIS_TEST_EQ
(
adaptInfo
.
getEstSum
(
tp
),
0.3
);
adaptInfo
.
setEstSum
(
0.4
,
0
_c
);
AMDIS_TEST_EQ
(
adaptInfo
.
getEstSum
(
tp
),
0.4
);
adaptInfo
.
setEstSum
(
0.5
,
str
);
AMDIS_TEST_EQ
(
adaptInfo
.
getEstSum
(
tp
),
0.5
);
return
report_errors
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/CMakeLists.txt
+
3
−
0
View file @
074f8e52
dune_add_test
(
SOURCES AdaptInfoTest.cpp
LINK_LIBRARIES amdis
)
dune_add_test
(
SOURCES ClonablePtrTest.cpp
dune_add_test
(
SOURCES ClonablePtrTest.cpp
LINK_LIBRARIES amdis
)
LINK_LIBRARIES amdis
)
...
...
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