Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dorie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
dorie
dorie
Commits
47e5d483
Commit
47e5d483
authored
Aug 23, 2018
by
Santiago Ospina De Los Ríos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed functions and added const keywords where needed
parent
8917df20
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
53 deletions
+72
-53
dune/dorie/interface/simulation_base.hh
dune/dorie/interface/simulation_base.hh
+60
-46
dune/dorie/test/simulation_base.cc
dune/dorie/test/simulation_base.cc
+12
-7
No files found.
dune/dorie/interface/simulation_base.hh
View file @
47e5d483
#ifndef DUNE_DORIE_
BASE_SIMULATION
_HH
#define DUNE_DORIE_
BASE_SIMULATION
_HH
#ifndef DUNE_DORIE_
SIMULATION_BASE
_HH
#define DUNE_DORIE_
SIMULATION_BASE
_HH
#include "util.hh"
...
...
@@ -17,43 +17,52 @@ class SimulationBase
public:
/**
* @brief Constructs the
object
.
* @brief Constructs the
SimulationBase
.
*
* @param[in] output
_
policy The output policy
* @param[in] adapt
_
policy The adapt policy
* @param[in] outputpolicy The output policy
* @param[in] adaptpolicy The adapt policy
*/
SimulationBase
(
OutputPolicy
output
_policy
,
AdaptivityPolicy
adapt_
policy
)
:
_output
_policy
(
output_
policy
)
,
_adapt
_policy
(
adapt_
policy
)
SimulationBase
(
OutputPolicy
output
policy
,
AdaptivityPolicy
adapt
policy
)
:
_output
policy
(
output
policy
)
,
_adapt
policy
(
adapt
policy
)
{}
/**
* @brief Constructs the object.
* @brief Constructs the SimulationBase.
*
* @param[in] outputpolicy The output policy
*/
SimulationBase
(
OutputPolicy
outputpolicy
)
:
SimulationBase
(
outputpolicy
,
AdaptivityPolicy
::
None
)
{}
/**
* @brief Constructs the SimulationBase.
*/
SimulationBase
()
:
SimulationBase
(
OutputPolicy
::
None
,
AdaptivityPolicy
::
None
)
:
SimulationBase
(
OutputPolicy
::
None
,
AdaptivityPolicy
::
None
)
{}
/**
* @brief Sets the output policy.
*
* @param[in] output
_
policy The output policy,
* @param[in] outputpolicy The output policy,
*/
void
set
Policy
(
OutputPolicy
output_policy
)
{
_output_policy
=
output_
policy
;}
void
set
_policy
(
OutputPolicy
outputpolicy
)
{
_outputpolicy
=
output
policy
;}
/**
* @brief Sets the adaptivity policy.
*
* @param[in] adapt
_
policy The adaptivity policy.
* @param[in] adaptpolicy The adaptivity policy.
*/
void
set
Policy
(
AdaptivityPolicy
adapt_policy
)
{
_adapt_policy
=
adapt_
policy
;}
void
set
_policy
(
AdaptivityPolicy
adaptpolicy
)
{
_adaptpolicy
=
adapt
policy
;}
/**
* @brief Returns the current output policy.
*
* @return The current output policy.
*/
OutputPolicy
output
Policy
()
{
return
_output_
policy
;}
OutputPolicy
output
_policy
()
const
{
return
_output
policy
;}
/**
...
...
@@ -61,122 +70,127 @@ public:
*
* @return The current adaptivity policy.
*/
AdaptivityPolicy
adaptivity
Policy
()
{
return
_adapt_
policy
;}
AdaptivityPolicy
adaptivity
_policy
()
const
{
return
_adapt
policy
;}
/**
* @brief Writes the data.
*/
void
virtual
write
Data
()
void
virtual
write
_data
()
const
{
if
(
_output
_
policy
!=
OutputPolicy
::
None
)
if
(
_outputpolicy
!=
OutputPolicy
::
None
)
DUNE_THROW
(
Dune
::
IOError
,
"Simulation can't write data!"
);
}
/**
* @brief Mark the grid in order to improve the current model.
*/
virtual
void
mark
G
rid
()
virtual
void
mark
_g
rid
()
{
DUNE_THROW
(
Dune
::
NotImplemented
,
"Simulation can't mark the grid for adaptivity!"
);
DUNE_THROW
(
Dune
::
NotImplemented
,
"Simulation can't mark the grid for adaptivity!"
);
}
/**
* @brief Operations before adaptation of the grid
*/
virtual
void
pre
AdaptG
rid
()
{};
virtual
void
pre
_adapt_g
rid
()
{};
/**
* @brief Adapt the grid together it every dependency of the
* grid (e.g. solution vector and grid function spaces).
*/
virtual
void
adapt
G
rid
()
virtual
void
adapt
_g
rid
()
{
if
(
_adapt
_
policy
!=
AdaptivityPolicy
::
None
)
if
(
_adaptpolicy
!=
AdaptivityPolicy
::
None
)
DUNE_THROW
(
Dune
::
NotImplemented
,
"Simulation can't be adapted!"
);
else
DUNE_THROW
(
Dune
::
InvalidStateException
,
"Simulation uses adaptivity policy None. Method adapt() must not be called!"
);
"Simulation uses adaptivity policy None.
Method adapt() must not be called!"
);
}
/**
* @brief Operations after adaptation of the grid
*/
virtual
void
post
AdaptG
rid
()
{};
virtual
void
post
_adapt_g
rid
()
{};
/**
* @brief Method that provides the begin time of the model.
*
* @return Begin time of the model.
*/
virtual
double
begin
Time
()
=
0
;
virtual
double
begin
_time
()
const
=
0
;
/**
* @brief Method that provides the end time of the model.
*
* @return End time of the model.
*/
virtual
double
end
Time
()
=
0
;
virtual
double
end
_time
()
const
=
0
;
/**
* @brief Method that provides the current time of the model.
*
* @return Current time of the model.
*/
virtual
double
current
Time
()
=
0
;
virtual
double
current
_time
()
const
=
0
;
/**
* @brief Suggest a time step to the model.
*
* @param[in] suggestion for the internal time step of the model.
*/
virtual
void
suggest
T
imestep
(
double
dt
)
=
0
;
virtual
void
suggest
_t
imestep
(
double
dt
)
=
0
;
/**
* @brief Operations before step of the simulation.
*/
virtual
void
pre
S
tep
()
{};
virtual
void
pre
_s
tep
()
{};
/**
* @brief Performs one steps in direction to end
T
ime(). The time-step
* @brief Performs one steps in direction to end
_t
ime(). The time-step
* should never result on a bigger step than the one suggested
* in suggest
T
imestep().
* in suggest
_t
imestep().
*/
virtual
void
step
()
=
0
;
/**
* @brief Operations after step of the simulation.
*/
virtual
void
post
S
tep
()
{};
virtual
void
post
_s
tep
()
{};
/**
* @brief Runs the model performing steps until currentTime() equals endTime()
* @brief Runs the model performing steps until current_time() equals
* end_time()
*/
virtual
void
run
()
{
if
(
output
P
olicy
()
!=
OutputPolicy
::
None
)
write
D
ata
();
while
(
Dune
::
FloatCmp
::
lt
(
currentTime
(),
endT
ime
())
)
if
(
output
_p
olicy
()
!=
OutputPolicy
::
None
)
write
_d
ata
();
while
(
Dune
::
FloatCmp
::
lt
(
current_time
(),
end_t
ime
())
)
{
pre_step
();
step
();
post_step
();
if
(
adaptivity
P
olicy
()
!=
AdaptivityPolicy
::
None
)
if
(
Dune
::
FloatCmp
::
lt
(
currentTime
(),
endT
ime
())
)
if
(
adaptivity
_p
olicy
()
!=
AdaptivityPolicy
::
None
)
if
(
Dune
::
FloatCmp
::
lt
(
current_time
(),
end_t
ime
())
)
{
mark
G
rid
();
pre
AdaptG
rid
();
adapt
G
rid
();
post
AdaptG
rid
();
mark
_g
rid
();
pre
_adapt_g
rid
();
adapt
_g
rid
();
post
_adapt_g
rid
();
}
}
}
private:
OutputPolicy
_output
_
policy
;
AdaptivityPolicy
_adapt
_
policy
;
OutputPolicy
_outputpolicy
;
AdaptivityPolicy
_adaptpolicy
;
};
}
// namespace Dorie
}
// namespace Dune
#endif // DUNE_DORIE_BASE_SIMULATION_HH
\ No newline at end of file
#endif // DUNE_DORIE_SIMULATION_BASE_HH
\ No newline at end of file
dune/dorie/test/simulation_base.cc
View file @
47e5d483
...
...
@@ -2,7 +2,7 @@
#include "config.h"
#endif
#include <dune/dorie/interface/
base_simulation
.hh>
#include <dune/dorie/interface/
simulation_base
.hh>
#include <dune/common/parallel/mpihelper.hh>
...
...
@@ -10,16 +10,21 @@ class DummyModel : public Dune::Dorie::SimulationBase
{
public:
DummyModel
()
:
Dune
::
Dorie
::
SimulationBase
()
:
Dune
::
Dorie
::
SimulationBase
(
Dune
::
Dorie
::
OutputPolicy
::
EndOfStep
)
,
_dt
(
.1
)
,
_current_time
(
begin
T
ime
())
,
_current_time
(
begin
_t
ime
())
{}
double
begin
Time
()
override
{
return
0.
;}
double
end
Time
()
override
{
return
1.
;}
double
current
Time
()
override
{
return
_current_time
;}
void
suggest
Timestep
(
double
dt
)
override
{
}
double
begin
_time
()
const
override
{
return
0.
;}
double
end
_time
()
const
override
{
return
1.
;}
double
current
_time
()
const
override
{
return
_current_time
;}
void
suggest
_timestep
(
double
dt
)
override
{
_dt
=
std
::
min
(
dt
,
_dt
);
}
void
step
()
override
{
_current_time
+=
_dt
;}
void
write_data
()
const
override
{
std
::
cout
<<
"current time: "
<<
_current_time
<<
std
::
endl
;
}
private:
double
_dt
;
...
...
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