Skip to content
GitLab
Menu
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
cc03c3e4
Commit
cc03c3e4
authored
May 23, 2018
by
Müller, Felix
Committed by
Praetorius, Simon
May 23, 2018
Browse files
Added Key type, changed iterator loops to range-based for loops
parent
1bf4708f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/amdis/AdaptInfo.cpp
View file @
cc03c3e4
...
...
@@ -46,19 +46,19 @@ namespace AMDiS
void
AdaptInfo
::
printTimeErrorLowInfo
()
const
{
for
(
auto
it
=
scalContent
s
.
begin
();
it
!=
scalContents
.
end
();
it
++
)
for
(
auto
const
&
scalContent
:
scalContents
)
{
auto
i
=
it
->
first
;
auto
i
=
scalContent
.
first
;
std
::
cout
<<
" Time error estimate ["
<<
i
<<
"] = "
<<
getTimeEstCombined
(
i
)
<<
"
\n
"
<<
" Time error estimate sum ["
<<
i
<<
"] = "
<<
it
->
second
.
est_t_sum
<<
"
\n
"
<<
scalContent
.
second
.
est_t_sum
<<
"
\n
"
<<
" Time error estimate max ["
<<
i
<<
"] = "
<<
it
->
second
.
est_t_max
<<
"
\n
"
<<
scalContent
.
second
.
est_t_max
<<
"
\n
"
<<
" Time error low bound ["
<<
i
<<
"] = "
<<
it
->
second
.
timeErrLow
<<
"
\n
"
<<
scalContent
.
second
.
timeErrLow
<<
"
\n
"
<<
" Time error high bound ["
<<
i
<<
"] = "
<<
it
->
second
.
timeTolerance
<<
"
\n
"
;
<<
scalContent
.
second
.
timeTolerance
<<
"
\n
"
;
}
}
...
...
src/amdis/AdaptInfo.hpp
View file @
cc03c3e4
...
...
@@ -27,6 +27,9 @@ namespace AMDiS
*/
class
AdaptInfo
{
public:
using
Key
=
std
::
string
;
protected:
/** \brief
* Stores adapt infos for a scalar problem or for one component of a
...
...
@@ -85,8 +88,8 @@ namespace AMDiS
/// Returns whether space tolerance is reached.
virtual
bool
spaceToleranceReached
()
const
{
for
(
auto
it
=
scalContent
s
.
begin
();
it
!=
scalContents
.
end
();
it
++
)
{
if
(
!
(
it
->
second
.
est_sum
<
it
->
second
.
spaceTolerance
))
for
(
auto
const
&
scalContent
:
scalContents
)
{
if
(
!
(
scalContent
.
second
.
est_sum
<
scalContent
.
second
.
spaceTolerance
))
return
false
;
}
...
...
@@ -94,7 +97,7 @@ namespace AMDiS
}
/// Returns whether space tolerance of component associated with key is reached.
virtual
bool
spaceToleranceReached
(
std
::
string
key
)
const
virtual
bool
spaceToleranceReached
(
Key
key
)
const
{
if
(
!
(
getScalContent
(
key
).
est_sum
<
getScalContent
(
key
).
spaceTolerance
))
return
false
;
...
...
@@ -111,15 +114,15 @@ namespace AMDiS
/// Returns whether time tolerance is reached.
virtual
bool
timeToleranceReached
()
const
{
for
(
auto
it
=
scalContent
s
.
begin
();
it
!=
scalContents
.
end
();
it
++
)
if
(
!
(
getTimeEstCombined
(
it
->
first
)
<
it
->
second
.
timeTolerance
))
for
(
auto
const
&
scalContent
:
scalContents
)
if
(
!
(
getTimeEstCombined
(
scalContent
.
first
)
<
scalContent
.
second
.
timeTolerance
))
return
false
;
return
true
;
}
/// Returns whether time tolerance of component associated with key is reached.
virtual
bool
timeToleranceReached
(
std
::
string
key
)
const
virtual
bool
timeToleranceReached
(
Key
key
)
const
{
if
(
!
(
getTimeEstCombined
(
key
)
<
getScalContent
(
key
).
timeTolerance
))
return
false
;
...
...
@@ -136,8 +139,8 @@ namespace AMDiS
/// Returns whether time error is under its lower bound.
virtual
bool
timeErrorLow
()
const
{
for
(
auto
it
=
scalContent
s
.
begin
();
it
!=
scalContents
.
end
();
it
++
)
if
(
!
(
getTimeEstCombined
(
it
->
first
)
<
it
->
second
.
timeErrLow
))
for
(
auto
const
&
scalContent
:
scalContents
)
if
(
!
(
getTimeEstCombined
(
scalContent
.
first
)
<
scalContent
.
second
.
timeErrLow
))
return
false
;
return
true
;
...
...
@@ -145,7 +148,7 @@ namespace AMDiS
/// Returns the time estimation as a combination
/// of maximal and integral time error
double
getTimeEstCombined
(
std
::
string
key
)
const
double
getTimeEstCombined
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_max
*
getScalContent
(
key
).
fac_max
+
...
...
@@ -282,7 +285,7 @@ namespace AMDiS
}
/// Sets \ref est_sum.
void
setEstSum
(
double
e
,
std
::
string
key
)
void
setEstSum
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_sum
=
e
;
}
...
...
@@ -294,7 +297,7 @@ namespace AMDiS
}
/// Sets \ref est_max.
void
setEstMax
(
double
e
,
std
::
string
key
)
void
setEstMax
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_max
=
e
;
}
...
...
@@ -306,7 +309,7 @@ namespace AMDiS
}
/// Sets \ref est_max.
void
setTimeEstMax
(
double
e
,
std
::
string
key
)
void
setTimeEstMax
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_t_max
=
e
;
}
...
...
@@ -318,7 +321,7 @@ namespace AMDiS
}
/// Sets \ref est_t_sum.
void
setTimeEstSum
(
double
e
,
std
::
string
key
)
void
setTimeEstSum
(
double
e
,
Key
key
)
{
getScalContent
(
key
).
est_t_sum
=
e
;
}
...
...
@@ -330,11 +333,8 @@ namespace AMDiS
}
/// Returns \ref est_sum.
double
getEstSum
(
std
::
string
key
)
const
double
getEstSum
(
Key
key
)
const
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
);
test_exit_dbg
(
scalContents
.
count
(
key
)
==
1
,
"Wrong key for adaptInfo!
\n
"
);
return
getScalContent
(
key
).
est_sum
;
}
...
...
@@ -345,7 +345,7 @@ namespace AMDiS
}
/// Returns \ref est_t_sum.
double
getEstTSum
(
std
::
string
key
)
const
double
getEstTSum
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_sum
;
}
...
...
@@ -357,11 +357,8 @@ namespace AMDiS
}
/// Returns \ref est_max.
double
getEstMax
(
std
::
string
key
)
const
double
getEstMax
(
Key
key
)
const
{
AMDIS_FUNCNAME_DBG
(
"AdaptInfo::getEstSum()"
);
test_exit_dbg
(
scalContents
.
count
(
key
)
==
1
,
"Wrong key for adaptInfo!
\n
"
);
return
getScalContent
(
key
).
est_max
;
}
...
...
@@ -372,7 +369,7 @@ namespace AMDiS
}
/// Returns \ref est_max.
double
getTimeEstMax
(
std
::
string
key
)
const
double
getTimeEstMax
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_max
;
}
...
...
@@ -384,7 +381,7 @@ namespace AMDiS
}
/// Returns \ref est_t_sum.
double
getTimeEstSum
(
std
::
string
key
)
const
double
getTimeEstSum
(
Key
key
)
const
{
return
getScalContent
(
key
).
est_t_sum
;
}
...
...
@@ -407,7 +404,7 @@ namespace AMDiS
}
/// Returns \ref spaceTolerance.
double
getSpaceTolerance
(
std
::
string
key
)
const
double
getSpaceTolerance
(
Key
key
)
const
{
return
getScalContent
(
key
).
spaceTolerance
;
}
...
...
@@ -419,7 +416,7 @@ namespace AMDiS
}
/// Sets \ref spaceTolerance.
void
setSpaceTolerance
(
std
::
string
key
,
double
tol
)
void
setSpaceTolerance
(
Key
key
,
double
tol
)
{
getScalContent
(
key
).
spaceTolerance
=
tol
;
}
...
...
@@ -431,7 +428,7 @@ namespace AMDiS
}
/// Returns \ref timeTolerance.
double
getTimeTolerance
(
std
::
string
key
)
const
double
getTimeTolerance
(
Key
key
)
const
{
return
getScalContent
(
key
).
timeTolerance
;
}
...
...
@@ -443,7 +440,7 @@ namespace AMDiS
}
/// Returns \ref timeRelativeTolerance.
double
getTimeRelativeTolerance
(
std
::
string
key
)
const
double
getTimeRelativeTolerance
(
Key
key
)
const
{
return
getScalContent
(
key
).
timeRelativeTolerance
;
}
...
...
@@ -573,7 +570,7 @@ namespace AMDiS
}
/// Returns \ref timeErrLow.
double
getTimeErrLow
(
std
::
string
key
)
const
double
getTimeErrLow
(
Key
key
)
const
{
return
getScalContent
(
key
).
timeErrLow
;
}
...
...
@@ -585,7 +582,7 @@ namespace AMDiS
}
/// Returns whether coarsening is allowed or not.
bool
isCoarseningAllowed
(
std
::
string
key
)
const
bool
isCoarseningAllowed
(
Key
key
)
const
{
return
(
getScalContent
(
key
).
coarsenAllowed
==
1
);
}
...
...
@@ -597,7 +594,7 @@ namespace AMDiS
}
/// Returns whether coarsening is allowed or not.
bool
isRefinementAllowed
(
std
::
string
key
)
const
bool
isRefinementAllowed
(
Key
key
)
const
{
return
(
getScalContent
(
key
).
refinementAllowed
==
1
);
}
...
...
@@ -609,7 +606,7 @@ namespace AMDiS
}
///
void
allowRefinement
(
bool
allow
,
std
::
string
key
)
void
allowRefinement
(
bool
allow
,
Key
key
)
{
getScalContent
(
key
).
refinementAllowed
=
allow
;
}
...
...
@@ -621,7 +618,7 @@ namespace AMDiS
}
///
void
allowCoarsening
(
bool
allow
,
std
::
string
key
)
void
allowCoarsening
(
bool
allow
,
Key
key
)
{
getScalContent
(
key
).
coarsenAllowed
=
allow
;
}
...
...
@@ -715,7 +712,7 @@ namespace AMDiS
}
private:
ScalContent
&
getScalContent
(
std
::
string
key
)
const
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
;
...
...
@@ -793,7 +790,7 @@ namespace AMDiS
double
globalTimeTolerance
=
1.0
;
/// Scalar adapt infos
mutable
std
::
map
<
std
::
string
,
ScalContent
>
scalContents
;
mutable
std
::
map
<
Key
,
ScalContent
>
scalContents
;
/// Is true, if the adaptive procedure was deserialized from a file. TODO: remove deserialization
bool
deserialized
=
false
;
...
...
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