Template Class Task
Defined in File Task.hpp
Class Documentation
-
template<typename CombiDataType = double>
class Task Abstract class for a task that is worked on by a process group (consisting of ProcessGroupWorkers)
In the combination technique, this will correspond to the current solution of the PDE for a component grid of a certain level, along with the operators to advance further in time.
The task’s domain is assumed to be the unit hypercube ((0,1)^d or [0,1)^d [0,1]^d , depending on the boundary conditions)
If the Task uses MPI, it MUST NEVER use MPI_COMM_WORLD, even in calls to linked or included functions. It should instead use the local communicator of the process group: lcomm or theMPISystem()->getLocalComm() .
Public Functions
-
inline virtual ~Task()
-
inline const LevelVector &getLevelVector() const
get the level vector of the task
-
inline size_t getID() const
get the unique ID of the task
-
inline void setID(size_t id)
explicitly set a new ID for the task;
useful if process groups read their task assignment from file instead of receiving it from the manager
make sure ID is continuous and unique!
-
virtual void run(CommunicatorType lcomm) = 0
run the task
For PDE solvers, this will typically advance the solution to the next timestep
- Parameters:
lcomm – local communicator of the process group
-
inline virtual void changeDir(CommunicatorType lcomm)
change the current working directory
useful for tasks that write output files
- Parameters:
lcomm – local communicator of the process group
-
virtual void init(CommunicatorType lcomm, const std::vector<IndexVector> &decomposition = std::vector<IndexVector>()) = 0
initialize the task
- Parameters:
lcomm – local communicator of the process group
decomposition – optional decomposition of the task’s domain
-
inline bool isFinished() const
flag to indicate that the task has finished
useful for concurrent setups, needs setFinished() to be called at the end of run()
-
inline void setFinished(bool finished)
set the finished flag
-
inline virtual void getFullGrid(FullGrid<CombiDataType> &fg, RankType lroot, CommunicatorType lcomm, int n = 0)
gathers the entire full grid on a single process
should only be done for small grids!
- Parameters:
fg – the full grid to gather to
lroot – rank of the root process
lcomm – local communicator of the process group
n – index of the distributed full grid to gather
-
virtual DistributedFullGridRef<CombiDataType> getDistributedFullGrid(size_t n = 0) = 0
get the DistributedFullGrid of the task
This is where the high-dimensional data is stored. There may be multiple DistributedFullGrid s, to allow for advanced setups with multple fields (e.g. different species in a plasma simulation, concentration and electric field, etc.)
- Parameters:
n – index of the distributed full grid to get
-
inline virtual ConstDistributedFullGridRef<CombiDataType> getDistributedFullGrid(size_t n) const
-
template<typename Visitor>
inline decltype(auto) visitDistributedFullGrid(Visitor &&visitor, size_t n = 0) visit the DistributedFullGrid with a visitor (convenience wrapper)
-
template<typename Visitor>
inline decltype(auto) visitDistributedFullGrid(Visitor &&visitor, size_t n = 0) const
-
virtual void setZero() = 0
set all DistributedFullGrid values to zero
-
inline virtual real getCurrentTimestep() const
get the current time step of the task
useful if there is adaptive timestepping in the solver
-
inline virtual real getCurrentTime() const
get the current time in the task
useful if there is adaptive timestepping in the solver
-
inline virtual CombiDataType analyticalSolution(const std::vector<real> &coords, int n = 0) const
get the analytical solution of the task
only applicable where an analytical solution exists, then it can be used for diagnostics such as error integrals
- Parameters:
coords – coordinates in the task’s domain
-
inline virtual std::vector<IndexVector> getDecomposition()
get the decomposition of task’s DistributedFullGrid points to the (Cartesian) process grid
- Returns:
vector of index vectors, each containing the lower bounds of the points in one dimension
-
inline virtual bool isInitialized()
-
inline virtual void doDiagnostics()
do task-specific postprocessing
useful for tasks that need to do additional work after the main task has been completed
-
inline virtual void receiveDiagnostics()
receive diagnostics from the task
useful for tasks that need to send additional data to the manager
-
inline const std::vector<BoundaryType> &getBoundary() const
get the task’s boundary flags
Public Static Functions
-
static inline void receive(Task **t, RankType source, CommunicatorType comm)
receive a task from another rank
-
static inline void send(const Task *const t, RankType dest, CommunicatorType comm)
send a task to another rank
-
static inline void broadcast(Task **t, RankType root, CommunicatorType comm)
broadcast a task to all ranks (typically within the same process group)
Protected Functions
-
inline Task(DimType dim, const LevelVector &l, const std::vector<BoundaryType> &boundary, real coeff, LoadModel *loadModel, FaultCriterion *faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})))
Task constructor.
- Parameters:
dim – dimensionality of the task’s domain
l – levelvector of the task
boundary – boundary conditions of the task
coeff – combination coefficient of the task
loadModel – load model for the task, required for dynamic load balancing
faultCrit – fault criterion for the task, required for fault simulation
-
inline Task(const LevelVector &l, const std::vector<BoundaryType> &boundary, real coeff, LoadModel *loadModel, FaultCriterion *faultCrit = (new StaticFaults({0, IndexVector(0), IndexVector(0)})))
Task constructor.
- Parameters:
l – levelvector of the task
boundary – boundary conditions of the task
coeff – combination coefficient of the task
loadModel – load model for the task, required for dynamic load balancing
faultCrit – fault criterion for the task, required for fault simulation
Protected Attributes
-
FaultCriterion *faultCriterion_
-
LevelVector l_
-
std::vector<BoundaryType> boundary_
-
size_t id_
-
bool isFinished_
Protected Static Attributes
-
static size_t count = 0
Friends
- friend class boost::serialization::access
-
inline virtual ~Task()