HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SingleSimulation Class Reference

Class describing a single simulation. More...

#include <single_simulation.h>

Inheritance diagram for SingleSimulation:
Simulation

Public Member Functions

 SingleSimulation ()
 
 ~SingleSimulation ()
 
int define (int, int)
 
int ReadInputs ()
 
int Initialize ()
 
int InitialSolution ()
 
int InitializeBoundaries ()
 
int InitializeImmersedBoundaries ()
 
int InitializePhysics ()
 
int InitializePhysicsData ()
 
int InitializeSolvers ()
 
int Solve ()
 
void WriteErrors (double a_wt_solver, double a_wt_total)
 
bool isDefined () const
 
int mpiCommDup ()
 
void usePetscTS (PetscBool a_flag)
 
int SolvePETSc ()
 
- Public Member Functions inherited from Simulation
 Simulation ()
 
virtual ~Simulation ()
 
virtual int InitializationWrapup ()
 

Protected Attributes

bool m_is_defined
 
int m_rank
 
int m_nproc
 
SimulationObjectm_sim
 

Detailed Description

Class describing a single simulation.

Class describing a single simulation This class contains all data and functions needed to run a single simulation.

This class contains all data and functions needed to run a single simulation.

Definition at line 26 of file single_simulation.h.

Constructor & Destructor Documentation

SingleSimulation ( )
inline

Constructor

Definition at line 31 of file single_simulation.h.

32  {
33  m_is_defined = false;
34  m_sim = nullptr;
35  m_nproc = -1;
36  m_rank = -1;
37  }
SimulationObject * m_sim
~SingleSimulation ( )
inline

Destructor

Definition at line 40 of file single_simulation.h.

41  {
42  int err = Cleanup((void*) m_sim, _NSIMS_);
43  if (err) {
44  printf( "Error: CleanUp() returned with status %d on process %d.\n",
45  err, m_rank );
46  }
47  delete m_sim;
48  }
SimulationObject * m_sim
int Cleanup(void *, int)
Definition: Cleanup.c:39
#define _NSIMS_

Member Function Documentation

int define ( int  a_rank,
int  a_nproc 
)
virtual

Define this object

Define the single simulation object

Parameters
a_rankMPI rank of this process
a_nprocTotal number of MPI ranks

Implements Simulation.

Definition at line 10 of file SingleSimulationDefine.cpp.

13 {
14  if (m_is_defined) {
15  fprintf(stderr,"Error: object already defined on rank %d.\n", a_rank);
16  return 1;
17  }
18 
19  m_rank = a_rank;
20  m_nproc = a_nproc;
21 
22  m_sim = new SimulationObject;
23  m_sim->solver.my_idx = 0;
24  m_sim->solver.nsims = 1;
25  m_sim->mpi.rank = m_rank;
27 
28  if (!m_rank) {
29  printf("Allocated simulation object(s).\n");
30  }
31 
32  m_is_defined = true;
33  return 0;
34 }
SimulationObject * m_sim
int nsims
Definition: hypar.h:64
Structure defining a simulation.
int my_idx
Definition: hypar.h:61
int ReadInputs ( )
inlinevirtual

Read solver inputs

Implements Simulation.

Definition at line 54 of file single_simulation.h.

55  {
56  int retval = ::ReadInputs( (void*) m_sim,
57  _NSIMS_,
58  m_rank );
59  ::WriteInputs( (void*) m_sim,
60  _NSIMS_,
61  m_rank );
62  return retval;
63  }
SimulationObject * m_sim
int WriteInputs(void *, int, int)
Definition: WriteInputs.c:15
#define _NSIMS_
int Initialize ( )
inlinevirtual

Initialize the simulations

Implements Simulation.

Definition at line 66 of file single_simulation.h.

67  {
68  int retval = ::Initialize( (void*) m_sim,
69  _NSIMS_ );
70  return retval;
71  }
SimulationObject * m_sim
#define _NSIMS_
int InitialSolution ( )
inlinevirtual

Read initial solution for each simulation

Implements Simulation.

Definition at line 74 of file single_simulation.h.

75  {
76  int retval = ::InitialSolution( (void*) m_sim,
77  _NSIMS_ );
78  return retval;
79  }
SimulationObject * m_sim
#define _NSIMS_
int InitializeBoundaries ( )
inlinevirtual

Initialize the boundary conditions of the simulations

Implements Simulation.

Definition at line 82 of file single_simulation.h.

83  {
84  int retval = ::InitializeBoundaries( (void*) m_sim,
85  _NSIMS_ );
86  return retval;
87  }
SimulationObject * m_sim
#define _NSIMS_
int InitializeImmersedBoundaries ( )
inlinevirtual

Initialize the immersed boundary conditions of the simulations

Implements Simulation.

Definition at line 90 of file single_simulation.h.

91  {
92  int retval = ::InitializeImmersedBoundaries( (void*) m_sim,
93  _NSIMS_ );
94  return retval;
95  }
SimulationObject * m_sim
#define _NSIMS_
int InitializeImmersedBoundaries()
int InitializePhysics ( )
inlinevirtual

Initialize the physics of the simulations

Implements Simulation.

Definition at line 98 of file single_simulation.h.

99  {
100  int retval = ::InitializePhysics( (void*) m_sim,
101  _NSIMS_ );
102  return retval;
103  }
SimulationObject * m_sim
#define _NSIMS_
int InitializePhysicsData ( )
inlinevirtual

Initialize the physics data of the simulations

Implements Simulation.

Definition at line 106 of file single_simulation.h.

107  {
108  int retval = ::InitializePhysicsData( (void*) m_sim,
109  0, _NSIMS_, NULL );
110  return retval;
111  }
SimulationObject * m_sim
#define _NSIMS_
int InitializeSolvers ( )
inlinevirtual

Initialize the numerical solvers of the simulations

Implements Simulation.

Definition at line 114 of file single_simulation.h.

115  {
116  int retval = ::InitializeSolvers( (void*) m_sim,
117  _NSIMS_ );
118  return retval;
119  }
SimulationObject * m_sim
#define _NSIMS_
int Solve ( )
inlinevirtual

Run the simulation using native time integrators

Implements Simulation.

Definition at line 122 of file single_simulation.h.

123  {
124  int retval = ::Solve( (void*) m_sim,
125  _NSIMS_,
126  m_rank,
127  m_nproc );
128  return retval;
129  }
SimulationObject * m_sim
#define _NSIMS_
void WriteErrors ( double  a_wt_solver,
double  a_wt_total 
)
inlinevirtual

Write simulation errors and wall times to file

Implements Simulation.

Definition at line 132 of file single_simulation.h.

134  {
135  ::SimWriteErrors( (void*) m_sim,
136  _NSIMS_,
137  m_rank,
138  a_wt_solver,
139  a_wt_total );
140  return;
141  }
SimulationObject * m_sim
#define _NSIMS_
void SimWriteErrors(void *, int, int, double, double)
bool isDefined ( ) const
inlinevirtual

Return whether object is defined or not

Implements Simulation.

Definition at line 144 of file single_simulation.h.

144 { return m_is_defined; }
int mpiCommDup ( )
inlinevirtual

Create duplicate MPI communicators

Implements Simulation.

Definition at line 148 of file single_simulation.h.

149  {
150  MPI_Comm_dup(MPI_COMM_WORLD, &(m_sim->mpi.world));
151  return 0;
152  }
SimulationObject * m_sim
MPI_Comm world
void usePetscTS ( PetscBool  a_flag)
inlinevirtual

Set flag whether to use PETSc time integration

Implements Simulation.

Definition at line 157 of file single_simulation.h.

158  {
159  m_sim->solver.use_petscTS = a_flag;
160  }
SimulationObject * m_sim
int use_petscTS
Definition: hypar.h:395
int SolvePETSc ( )
inlinevirtual

Run the simulation using PETSc time integrators

Implements Simulation.

Definition at line 163 of file single_simulation.h.

164  {
165  int retval = ::SolvePETSc( (void*) m_sim,
166  _NSIMS_,
167  m_rank,
168  m_nproc );
169  return retval;
170  }
SimulationObject * m_sim
#define _NSIMS_

Field Documentation

bool m_is_defined
protected

Boolean to show if this object is defined

Definition at line 175 of file single_simulation.h.

int m_rank
protected

MPI rank of this process

Definition at line 176 of file single_simulation.h.

int m_nproc
protected

Total number of MPI ranks

Definition at line 176 of file single_simulation.h.

SimulationObject* m_sim
protected

Definition at line 179 of file single_simulation.h.


The documentation for this class was generated from the following files: