HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
single_simulation.h
Go to the documentation of this file.
1 
6 #ifndef _SINGLE_SIM_H_
7 #define _SINGLE_SIM_H_
8 
9 #include <stdio.h>
10 #include <vector>
11 #include <simulation.h>
12 
13 #define _NSIMS_ 1
14 
27 {
28  public:
29 
32  {
33  m_is_defined = false;
34  m_sim = nullptr;
35  m_nproc = -1;
36  m_rank = -1;
37  }
38 
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  }
49 
51  int define(int, int);
52 
54  inline int ReadInputs()
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  }
64 
66  inline int Initialize()
67  {
68  int retval = ::Initialize( (void*) m_sim,
69  _NSIMS_ );
70  return retval;
71  }
72 
74  inline int InitialSolution()
75  {
76  int retval = ::InitialSolution( (void*) m_sim,
77  _NSIMS_ );
78  return retval;
79  }
80 
82  inline int InitializeBoundaries()
83  {
84  int retval = ::InitializeBoundaries( (void*) m_sim,
85  _NSIMS_ );
86  return retval;
87  }
88 
91  {
92  int retval = ::InitializeImmersedBoundaries( (void*) m_sim,
93  _NSIMS_ );
94  return retval;
95  }
96 
98  inline int InitializePhysics()
99  {
100  int retval = ::InitializePhysics( (void*) m_sim,
101  _NSIMS_ );
102  return retval;
103  }
104 
107  {
108  int retval = ::InitializePhysicsData( (void*) m_sim,
109  0, _NSIMS_, NULL );
110  return retval;
111  }
112 
114  inline int InitializeSolvers()
115  {
116  int retval = ::InitializeSolvers( (void*) m_sim,
117  _NSIMS_ );
118  return retval;
119  }
120 
122  inline int Solve()
123  {
124  int retval = ::Solve( (void*) m_sim,
125  _NSIMS_,
126  m_rank,
127  m_nproc );
128  return retval;
129  }
130 
132  inline void WriteErrors(double a_wt_solver,
133  double a_wt_total )
134  {
135  ::SimWriteErrors( (void*) m_sim,
136  _NSIMS_,
137  m_rank,
138  a_wt_solver,
139  a_wt_total );
140  return;
141  }
142 
144  inline bool isDefined() const { return m_is_defined; }
145 
146 #ifndef serial
147 
148  inline int mpiCommDup()
149  {
150  MPI_Comm_dup(MPI_COMM_WORLD, &(m_sim->mpi.world));
151  return 0;
152  }
153 #endif
154 
155 #ifdef with_petsc
156 
157  inline void usePetscTS(PetscBool a_flag)
158  {
159  m_sim->solver.use_petscTS = a_flag;
160  }
161 
163  inline int SolvePETSc()
164  {
165  int retval = ::SolvePETSc( (void*) m_sim,
166  _NSIMS_,
167  m_rank,
168  m_nproc );
169  return retval;
170  }
171 #endif
172 
173  protected:
174 
176  int m_rank,
177  m_nproc;
179  SimulationObject* m_sim; /*< Simulation object */
180 
181  private:
182 
183 };
184 
185 #endif
SimulationObject * m_sim
int Cleanup(void *, int)
Definition: Cleanup.c:39
void usePetscTS(PetscBool a_flag)
Base class for simulation and declarations for C functions.
Class describing a single simulation.
int WriteInputs(void *, int, int)
Definition: WriteInputs.c:15
bool isDefined() const
#define _NSIMS_
MPI_Comm world
void WriteErrors(double a_wt_solver, double a_wt_total)
int use_petscTS
Definition: hypar.h:395
Structure defining a simulation.
void SimWriteErrors(void *, int, int, double, double)
int InitializeImmersedBoundaries()
Base class for a simulation.
Definition: simulation.h:46