HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Base class for simulation and declarations for C functions. More...
Go to the source code of this file.
Data Structures | |
class | Simulation |
Base class for a simulation. More... | |
Functions | |
int | ReadInputs (void *, int, int) |
int | WriteInputs (void *, int, int) |
int | Initialize (void *, int) |
int | Initialize_GPU (void *, int) |
int | InitialSolution (void *, int) |
int | InitializeBoundaries (void *, int) |
int | InitializeImmersedBoundaries (void *, int) |
int | InitializePhysics (void *, int) |
int | InitializePhysicsData (void *, int, int, int *) |
int | InitializeSolvers (void *, int) |
int | Cleanup (void *, int) |
void | SimWriteErrors (void *, int, int, double, double) |
int | SolvePETSc (void *, int, int, int) |
Integrate in time with PETSc. More... | |
int | Solve (void *, int, int, int) |
Base class for simulation and declarations for C functions.
Definition in file simulation.h.
int ReadInputs | ( | void * | s, |
int | nsims, | ||
int | rank | ||
) |
Read the input parameters
Read the simulation inputs from the file solver.inp. Rank 0 reads in the inputs and broadcasts them to all the processors.
The format of solver.inp is as follows:
begin <keyword> <value> <keyword> <value> <keyword> <value> ... <keyword> <value> end
where the list of keywords and their type are:
Keyword name | Type | Variable | Default value |
---|---|---|---|
ndims | int | HyPar::ndims | 1 |
nvars | int | HyPar::nvars | 1 |
size | int[ndims] | HyPar::dim_global | must be specified |
iproc | int[ndims] | MPIVariables::iproc | must be specified (see notes below) |
ghost | int | HyPar::ghosts | 1 |
n_iter | int | HyPar::n_iter | 0 |
restart_iter | int | HyPar::restart_iter | 0 |
time_scheme | char[] | HyPar::time_scheme | euler |
time_scheme_type | char[] | HyPar::time_scheme_type | none |
hyp_space_scheme | char[] | HyPar::spatial_scheme_hyp | 1 |
hyp_flux_split | char[] | HyPar::SplitHyperbolicFlux | no |
hyp_interp_type | char[] | HyPar::interp_type | characteristic |
par_space_type | char[] | HyPar::spatial_type_par | nonconservative-1stage |
par_space_scheme | char[] | HyPar::spatial_scheme_par | 2 |
dt | double | HyPar::dt | 0.0 |
conservation_check | char[] | HyPar::ConservationCheck | no |
screen_op_iter | int | HyPar::screen_op_iter | 1 |
file_op_iter | int | HyPar::file_op_iter | 1000 |
op_file_format | char[] | HyPar::op_file_format | text |
ip_file_type | char[] | HyPar::ip_file_type | ascii |
input_mode | char[] | HyPar::input_mode | serial |
output_mode | char[] | HyPar::output_mode | serial |
op_overwrite | char[] | HyPar::op_overwrite | no |
plot_solution | char[] | HyPar::plot_solution | no |
model | char[] | HyPar::model | must be specified |
immersed_body | char[] | HyPar::ib_filename | "none" |
size_exact | int[ndims] | HyPar::dim_global_ex | HyPar::dim_global |
use_gpu | char[] | HyPar::use_gpu | no |
gpu_device_no | int | HyPar::gpu_device_no | -1 |
Notes:
if "input_mode" or "output_mode" are set to "parallel" or "mpi-io", the number of I/O ranks must be specified right after as an integer. For example:
begin ... input_mode parallel 4 ... end
This means that 4 MPI ranks will participate in file I/O (assuming total MPI ranks is more than 4) (see ReadArrayParallel(), WriteArrayParallel(), ReadArrayMPI_IO() ).
s | Array of simulation objects of type SimulationObject of size nsims |
nsims | Number of simulation objects |
rank | MPI rank of this process |
Definition at line 93 of file ReadInputs.c.
int WriteInputs | ( | void * | s, |
int | nsims, | ||
int | rank | ||
) |
Write the input parameters
Write the simulation inputs read from the file solver.inp.
s | Array of simulation objects of type SimulationObject of size nsims |
nsims | Number of simulation objects |
rank | MPI rank of this process |
Definition at line 15 of file WriteInputs.c.
int Initialize | ( | void * | s, |
int | nsims | ||
) |
Initialize the solver
Initialization function called at the beginning of a simulation. This function does the following:
s | Array of simulation objects of type SimulationObject |
nsims | Number of simulation objects |
Definition at line 26 of file Initialize.c.
int Initialize_GPU | ( | void * | , |
int | |||
) |
Initialize the solver
int InitialSolution | ( | void * | s, |
int | nsims | ||
) |
Read the initial solution
Read in initial solution from file, and compute grid spacing and volume integral of the initial solution
s | Array of simulation objects of type SimulationObject |
nsims | Number of simulation objects |
Definition at line 25 of file InitialSolution.c.
int InitializeBoundaries | ( | void * | s, |
int | nsims | ||
) |
Initialize the boundary conditions
This function initializes the variables and functions related to implementing the boundary conditions.
Note that boundary conditions are implemented as boundary objects of the type DomainBoundary.
s | Array of simulation objects of type SimulationObject |
nsims | number of simulation objects |
Definition at line 36 of file InitializeBoundaries.c.
int InitializeImmersedBoundaries | ( | void * | s, |
int | nsims | ||
) |
Initialize the immersed boundary conditions
Initialize the immersed boundaries, if present.
s | Array of simulation objects of type SimulationObject |
nsims | Number of simulation objects |
Definition at line 22 of file InitializeImmersedBoundaries.c.
int InitializePhysics | ( | void * | s, |
int | nsims | ||
) |
Initialize the physics
Initialize the physical model for a simulation: Depending on the physical model specified, this function calls the initialization function for that physical model. The latter is responsible for setting all the physics-specific functions that are required by the model.
s | Array of simulation objects of type SimulationObject |
nsims | number of simulation objects |
Definition at line 38 of file InitializePhysics.c.
int InitializePhysicsData | ( | void * | s, |
int | idx, | ||
int | nsims, | ||
int * | dim_data | ||
) |
Initialize the physics data
For each simulation object, call the physics-specific function to read in any physics data that is not a part of the solution vector.
s | Simulation object of type SimulationObject |
idx | Index of this simulation object |
nsims | Total number of simuations |
dim_data | Dimenions of physics-specific data |
Definition at line 12 of file InitializePhysicsData.c.
int InitializeSolvers | ( | void * | s, |
int | nsims | ||
) |
Initialize the solvers
This function initializes all solvers-specific function pointers depending on user input. The specific functions used for spatial discretization, time integration, and solution output are set here.
s | Array of simulation objects of type SimulationObject |
nsims | number of simulation objects |
Definition at line 52 of file InitializeSolvers.c.
int Cleanup | ( | void * | s, |
int | nsims | ||
) |
Clean up: deallocate all arrays and objects
Cleans up and frees the memory after the completion of the simulation.
s | Array of simulation objects of type SimulationObject |
nsims | number of simulation objects |
Definition at line 39 of file Cleanup.c.
void SimWriteErrors | ( | void * | s, |
int | nsims, | ||
int | rank, | ||
double | solver_runtime, | ||
double | main_runtime | ||
) |
Write errors for each simulation
Writes out the errors and other data for each simulation.
s | Array of simulations of type SimulationObject |
nsims | Number of simulations |
rank | MPI rank of this process |
solver_runtime | Measured runtime of solver |
main_runtime | Measured total runtime |
Definition at line 18 of file SimulationWriteErrors.c.
int SolvePETSc | ( | void * | s, |
int | nsims, | ||
int | rank, | ||
int | nproc | ||
) |
Integrate in time with PETSc.
Solve the PDE using PETSc TS
This function integrates the semi-discrete ODE (obtained from discretizing the PDE in space) using the time-integration module of PETSc (https://petsc.org/release/docs/manualpages/TS/index.html). The time-integration context is set up using the parameters specified in the input file. However, they can also be specified using PETSc's command line inputs.
See PETSc's documentation and examples for more details on how to use its TS module. All functions and data types whose names start with Vec, Mat, PC, KSP, SNES, and TS are PETSc functions - refer to the PETSc documentation (usually googling with the function name shows the man page for that function on PETSc's website).
s | Array of simulation objects of type SimulationObject |
nsims | number of simulation objects |
rank | MPI rank of this process |
nproc | Number of MPI processes |
Definition at line 50 of file SolvePETSc.cpp.
int Solve | ( | void * | s, |
int | nsims, | ||
int | rank, | ||
int | nproc | ||
) |
Solve the PDE - time-integration
This function integrates the semi-discrete ODE (obtained from discretizing the PDE in space) using natively implemented time integration methods. It initializes the time integration object, iterates the simulation for the required number of time steps, and calculates the errors. After the specified number of iterations, it writes out some information to the screen and the solution to a file.
s | Array of simulation objects of type SimulationObject |
nsims | number of simulation objects |
rank | MPI rank of this process |
nproc | Number of MPI processes |
Definition at line 37 of file Solve.cpp.