diff --git a/.gitignore b/.gitignore index 397c8226..40f4e9a7 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ __pycache__ *.tmp doc/README .venv/ +test-driver diff --git a/Examples/2D/NavierStokes2D/RisingThermalBubble_libROM_DMD_Train/aux/CompareSolutions.cpp b/Examples/2D/NavierStokes2D/RisingThermalBubble_libROM_DMD_Train/aux/CompareSolutions.cpp index 3fbc31f8..e46141eb 100644 --- a/Examples/2D/NavierStokes2D/RisingThermalBubble_libROM_DMD_Train/aux/CompareSolutions.cpp +++ b/Examples/2D/NavierStokes2D/RisingThermalBubble_libROM_DMD_Train/aux/CompareSolutions.cpp @@ -152,7 +152,7 @@ double ArraySumSquarenD(int nvars, return(sum); } -void fillGhostCells( const int* const a_dim, +void FillGhostCells( const int* const a_dim, const int a_ngpt, double* const a_u, const int a_nvars, @@ -654,7 +654,7 @@ int InterpolateGlobalnDVar( const int* const a_dim_dst, u_to = (double*) calloc (size, sizeof(double)); } - fillGhostCells( dim_from, + FillGhostCells( dim_from, ghosts, u_from, a_nvars, diff --git a/Extras/CompareSolutions.c b/Extras/CompareSolutions.c index 1b971587..c2342b94 100644 --- a/Extras/CompareSolutions.c +++ b/Extras/CompareSolutions.c @@ -150,7 +150,7 @@ double ArraySumSquarenD(int nvars, return(sum); } -void fillGhostCells( const int* const a_dim, +void FillGhostCells( const int* const a_dim, const int a_ngpt, double* const a_u, const int a_nvars, @@ -652,7 +652,7 @@ int InterpolateGlobalnDVar( const int* const a_dim_dst, u_to = (double*) calloc (size, sizeof(double)); } - fillGhostCells( dim_from, + FillGhostCells( dim_from, ghosts, u_from, a_nvars, diff --git a/doc/templates/TemplateModelAdvection.c b/doc/templates/TemplateModelAdvection.c index d5c21ab8..1c22c527 100644 --- a/doc/templates/TemplateModelAdvection.c +++ b/doc/templates/TemplateModelAdvection.c @@ -29,12 +29,12 @@ int TemplateModelAdvection( ) { HyPar *solver = (HyPar*) s; - TemplateModel *physics = (TemplateModel*) solver->physics; + TemplateModel *physics = (TemplateModel*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; /* * Array indexing in HyPar: diff --git a/doc/templates/TemplateModelComputeCFL.c b/doc/templates/TemplateModelComputeCFL.c index f4840c31..c225505d 100644 --- a/doc/templates/TemplateModelComputeCFL.c +++ b/doc/templates/TemplateModelComputeCFL.c @@ -35,13 +35,13 @@ double TemplateModelComputeCFL( ) { HyPar *solver = (HyPar*) s; - TemplateModel *physics = (TemplateModel*) solver->physics; + TemplateModel *physics = (TemplateModel*) solver->m_physics; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *u = solver->u; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *u = solver->m_u; double max_cfl = 0.0; int index[ndims]; @@ -65,7 +65,7 @@ double TemplateModelComputeCFL( /* Get inverse grid spacing in this direction */ double dxinv; - _GetCoordinate_(dir,index[dir],dim,ghosts,solver->dxinv,dxinv); + _GetCoordinate_(dir,index[dir],dim,ghosts,solver->m_dxinv,dxinv); /* [REPLACE] Calculate wave speed (eigenvalue) */ diff --git a/doc/templates/TemplateModelInitialize.c b/doc/templates/TemplateModelInitialize.c index 98930008..12aa4f1c 100644 --- a/doc/templates/TemplateModelInitialize.c +++ b/doc/templates/TemplateModelInitialize.c @@ -37,7 +37,7 @@ int TemplateModelInitialize(void *s, /*!< Solver object of type #HyPar */ { HyPar *solver = (HyPar*) s; MPIVariables *mpi = (MPIVariables*) m; - TemplateModel *physics = (TemplateModel*) solver->physics; + TemplateModel *physics = (TemplateModel*) solver->m_physics; int ferr, i; static int count = 0; @@ -128,7 +128,7 @@ int TemplateModelInitialize(void *s, /*!< Solver object of type #HyPar */ } /* Check for incompatible solver options */ - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { if (!mpi->rank) { fprintf(stderr,"Error in TemplateModelInitialize: "); fprintf(stderr,"This physical model does not have flux splitting defined.\n"); @@ -148,11 +148,11 @@ int TemplateModelInitialize(void *s, /*!< Solver object of type #HyPar */ /* [REPLACE] Allocate model-specific arrays if needed */ /* Example: allocate field array based on grid size int size = 1; - for (i=0; indims; i++) { - size *= (solver->dim_local[i] + 2*solver->ghosts); + for (i=0; im_ndims; i++) { + size *= (solver->m_dim_local[i] + 2*solver->m_ghosts); } physics->field_size = size; - physics->field_array = (double*) calloc(size*solver->nvars, sizeof(double)); + physics->field_array = (double*) calloc(size*solver->m_nvars, sizeof(double)); */ /* Register required function pointers with solver */ diff --git a/doc/templates/TemplateModelUpwind.c b/doc/templates/TemplateModelUpwind.c index 7939dfed..bfbbcba5 100644 --- a/doc/templates/TemplateModelUpwind.c +++ b/doc/templates/TemplateModelUpwind.c @@ -36,12 +36,12 @@ int TemplateModelUpwind( ) { HyPar *solver = (HyPar*) s; - TemplateModel *physics = (TemplateModel*) solver->physics; + TemplateModel *physics = (TemplateModel*) solver->m_physics; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; /* * Interface array indexing: diff --git a/include/bandedmatrix.h b/include/bandedmatrix.h index f4912845..131a168d 100644 --- a/include/bandedmatrix.h +++ b/include/bandedmatrix.h @@ -16,12 +16,12 @@ * This structure contains all the variables for defining a banded block matrix. */ typedef struct banded_matrix { - int nbands; /*!< number of block bands */ - int nrows_local; /*!< number of block rows (local) */ - int BlockSize; /*!< block size */ - int *ncol; /*!< global column numbers for each block */ - int *nrow; /*!< global row numbers for each block */ - double *data; /*!< array containing the matrix elements */ + int m_nbands; /*!< number of block bands */ + int m_nrows_local; /*!< number of block rows (local) */ + int m_BlockSize; /*!< block size */ + int *m_ncol; /*!< global column numbers for each block */ + int *m_nrow; /*!< global row numbers for each block */ + double *m_data; /*!< array containing the matrix elements */ } BandedMatrix; int BandedMatrixDestroy (void*); /*!< Destroy a banded block matrix object */ diff --git a/include/boundaryconditions.h b/include/boundaryconditions.h index 14d18d38..7bf2a8a9 100644 --- a/include/boundaryconditions.h +++ b/include/boundaryconditions.h @@ -68,48 +68,48 @@ typedef struct domain_boundaries { /*! Type of boundary (#_PERIODIC_, #_EXTRAPOLATE_, #_DIRICHLET_, etc) */ - char bctype [_MAX_STRING_SIZE_]; + char m_bctype [_MAX_STRING_SIZE_]; /*! Dimension along which this BC applies (For an \a n -dimensional problem, dimensions are indexed \a 0 to \a n-1 ) */ - int dim; + int m_dim; /*! Face on which this BC applies (1 -> left/min, or -1 -> right/max) */ - int face; + int m_face; /*! Spatial extent of this boundary condition: \a xmin is an array of size \a n for a \a n -dimensional problem containing the starting spatial coordinates of the zone where this boundary applies */ - double *xmin; + double *m_xmin; /*! Spatial extent of this boundary condition: \a xmax is an array of size \a n for a \a n -dimensional problem containing the ending spatial coordinates of the zone where this boundary applies */ - double *xmax; + double *m_xmax; - int on_this_proc; /*!< Flag indicating if this BC is applicable on this process (not an input) */ - int *is, *ie; /*!< Index range on which to apply this BC on this process (not an input) */ + int m_on_this_proc; /*!< Flag indicating if this BC is applicable on this process (not an input) */ + int *m_is, *m_ie; /*!< Index range on which to apply this BC on this process (not an input) */ /*! Pointer to the specific boundary condition function for the solution vector U */ int (*BCFunctionU) (void*,void*,int,int,int*,int,double*,double); - double *DirichletValue; /*!< Specified value for steady Dirichlet BC */ - double *SpongeValue; /*!< Specified value for steady Sponge BC */ + double *m_DirichletValue; /*!< Specified value for steady Dirichlet BC */ + double *m_SpongeValue; /*!< Specified value for steady Sponge BC */ - int *UnsteadyDirichletSize; /*!< Size of array to hold unsteady Dirichlet data */ - double *UnsteadyDirichletData; /*!< Array to hold unsteady Dirichlet data */ + int *m_UnsteadyDirichletSize; /*!< Size of array to hold unsteady Dirichlet data */ + double *m_UnsteadyDirichletData; /*!< Array to hold unsteady Dirichlet data */ /*! Filename to read in unsteady Dirichlet data from */ - char UnsteadyDirichletFilename[_MAX_STRING_SIZE_]; + char m_UnsteadyDirichletFilename[_MAX_STRING_SIZE_]; /* variables specific to Navier-Stokes/Euler equations BCs */ - double gamma, /*!< Ratio of specific heats (specific to Euler/Navier-Stokes) */ - FlowDensity, /*!< Boundary flow density (specific to Euler/Navier-Stokes) */ - *FlowVelocity, /*!< Boundary flow velocity (specific to Euler/Navier-Stokes) */ - FlowPressure; /*!< Boundary flow pressure (specific to Euler/Navier-Stokes) */ + double m_gamma, /*!< Ratio of specific heats (specific to Euler/Navier-Stokes) */ + m_FlowDensity, /*!< Boundary flow density (specific to Euler/Navier-Stokes) */ + *m_FlowVelocity, /*!< Boundary flow velocity (specific to Euler/Navier-Stokes) */ + m_FlowPressure; /*!< Boundary flow pressure (specific to Euler/Navier-Stokes) */ /* variables specific to the thermal slip-wall boundary condition */ - int *UnsteadyTemperatureSize; /*!< Size of array to hold unsteady temperature data for BCThermalSlipWallU() and BCThermalNoslipWallU() */ - double *UnsteadyTimeLevels; /*!< Array to hold the time levels for unsteady temperature data for BCThermalSlipWallU() and BCThermalNoslipWallU() */ - double *UnsteadyTemperatureData; /*!< Array to hold unsteady temperature data for BCThermalSlipWallU() and BCThermalNoslipWallU() */ + int *m_UnsteadyTemperatureSize; /*!< Size of array to hold unsteady temperature data for BCThermalSlipWallU() and BCThermalNoslipWallU() */ + double *m_UnsteadyTimeLevels; /*!< Array to hold the time levels for unsteady temperature data for BCThermalSlipWallU() and BCThermalNoslipWallU() */ + double *m_UnsteadyTemperatureData; /*!< Array to hold unsteady temperature data for BCThermalSlipWallU() and BCThermalNoslipWallU() */ /*! Filename to read in unsteady temperature data from for the BCThermalSlipWallU() and BCThermalNoslipWallU() boundary condition */ - char UnsteadyTemperatureFilename[_MAX_STRING_SIZE_]; + char m_UnsteadyTemperatureFilename[_MAX_STRING_SIZE_]; #if defined(HAVE_CUDA) - int gpu_npoints_bounds; - int gpu_npoints_local_wghosts; - int *gpu_bounds, *gpu_is, *gpu_ie; - double *gpu_FlowVelocity; + int m_gpu_npoints_bounds; + int m_gpu_npoints_local_wghosts; + int *m_gpu_bounds, *m_gpu_is, *m_gpu_ie; + double *m_gpu_FlowVelocity; #endif } DomainBoundary; diff --git a/include/ensemble_simulations.h b/include/ensemble_simulations.h index 53a289b6..ec4765ad 100644 --- a/include/ensemble_simulations.h +++ b/include/ensemble_simulations.h @@ -116,7 +116,7 @@ class EnsembleSimulation : public Simulation if (retval) { fprintf(stderr, "Error in EnsembleSimulations::InitializePhysicsData()\n"); fprintf(stderr, " InitializePhysicsData returned with error code %d on rank %d.\n", - retval, m_sims[ns].mpi.rank); + retval, m_sims[ns].mpi.m_rank); return retval; } } @@ -161,7 +161,7 @@ class EnsembleSimulation : public Simulation inline int mpiCommDup() { for (int n = 0; n < m_nsims; n++) { - MPI_Comm_dup(MPI_COMM_WORLD, &(m_sims[n].mpi.world)); + MPI_Comm_dup(MPI_COMM_WORLD, &(m_sims[n].mpi.m_world)); } return 0; } @@ -172,7 +172,7 @@ class EnsembleSimulation : public Simulation inline void usePetscTS(PetscBool a_flag) { for (int n = 0; n < m_nsims; n++) { - m_sims[n].solver.use_petscTS = a_flag; + m_sims[n].solver.m_use_petsc_ts = a_flag; } } diff --git a/include/hypar.h b/include/hypar.h index 34e0ba0f..8c12e39a 100644 --- a/include/hypar.h +++ b/include/hypar.h @@ -23,189 +23,189 @@ typedef struct main_parameters { /*! Number of spatial/coordinate dimensions (input - \b solver.inp ) */ - int ndims; + int m_ndims; /*! Number of variables or DoFs at a grid point (input - \b solver.inp ) */ - int nvars; + int m_nvars; - /*! Global dimensions: array of size #HyPar::ndims containing the global grid size + /*! Global dimensions: array of size #HyPar::m_ndims containing the global grid size * in each spatial/coordinate dimension (input - \b solver.inp )*/ - int *dim_global; + int *m_dim_global; - /*! Local dimensions: array of size #HyPar::ndims containing the local grid size + /*! Local dimensions: array of size #HyPar::m_ndims containing the local grid size * in each spatial/coordinate dimension (computed, based on the number of processors) */ - int *dim_local; + int *m_dim_local; - /*! Global number of grid points (product of all the elements of dim_global) */ - int npoints_global; + /*! Global number of grid points (product of all the elements of m_dim_global) */ + int m_npoints_global; - int npoints_local, /*!< Local number of grid points (product of all the elements of dim_local) */ - npoints_local_wghosts; /*!< Local number of grid points with ghost points - (product of the [elements of dim_local + 2*#HyPar::ghosts]) */ + int m_npoints_local, /*!< Local number of grid points (product of all the elements of m_dim_local) */ + m_npoints_local_wghosts; /*!< Local number of grid points with ghost points + (product of the [elements of m_dim_local + 2*#HyPar::m_ghosts]) */ - int ndof_nodes; /*!< Total number of degrees of freedom considering cell corners (no ghosts)*/ - int ndof_cells_wghosts; /*!< Total number of degrees of freedom considering cell centered (with ghosts)*/ - int size_x; /*!< the size of #HyPar::x array */ + int m_ndof_nodes; /*!< Total number of degrees of freedom considering cell corners (no ghosts)*/ + int m_ndof_cells_wghosts; /*!< Total number of degrees of freedom considering cell centered (with ghosts)*/ + int m_size_x; /*!< the size of #HyPar::m_x array */ /*! Number of ghost points at the boundary - it's the same along all dimensions * (input - \b solver.inp ) */ - int ghosts; + int m_ghosts; /*! Number of time steps (input - \b solver.inp ) */ - int n_iter; + int m_n_iter; /*! If restart run, time step iteration at which to restart. 0 -> not a restart run (input - \b solver.inp ) */ - int restart_iter; + int m_restart_iter; /*! for multi-domain simulations, index of this solver object */ - int my_idx; + int m_my_idx; /*! for multi-domain simulations, total number of solver objects */ - int nsims; + int m_nsims; /*! time step size (input - \b solver.inp ) */ - double dt; + double m_dt; /*! Global dimensions of exact solution, if available: if an exact/reference solution is available to compute errors, - this array of size #HyPar::ndims contains its global grid + this array of size #HyPar::m_ndims contains its global grid size in each spatial/coordinate dimension. By default, it is - the same as #HyPar::dim_global, unless specified otherwise in + the same as #HyPar::m_dim_global, unless specified otherwise in \b solver.inp */ - int *dim_global_ex; + int *m_dim_global_ex; /*! choice of time integration class (eg RK) (input - \b solver.inp ) */ - char time_scheme [_MAX_STRING_SIZE_]; + char m_time_scheme [_MAX_STRING_SIZE_]; /*! specific time-integration scheme in that class (eg. rk44, ssprk3) (input - \b solver.inp ) */ - char time_scheme_type [_MAX_STRING_SIZE_]; + char m_time_scheme_type [_MAX_STRING_SIZE_]; /*! choice of spatial discretization scheme for the hyperbolic terms (eg: weno5, crweno5, muscl3) (input - \b solver.inp ) */ - char spatial_scheme_hyp [_MAX_STRING_SIZE_]; + char m_spatial_scheme_hyp [_MAX_STRING_SIZE_]; /*! type of reconstruction for spatial discretization of hyperbolic term * (characteristic or component-wise) (input - \b solver.inp ) */ - char interp_type [_MAX_STRING_SIZE_]; + char m_interp_type [_MAX_STRING_SIZE_]; /*! split the hyperbolic flux into two terms - for implicit-explicit time-integration or * for any other purpose (input - \b solver.inp ) */ - char SplitHyperbolicFlux [_MAX_STRING_SIZE_]; + char m_split_hyperbolic_flux [_MAX_STRING_SIZE_]; /*! type of spatial discretization for the parabolic term * conservative-1stage, nonconservative-1stage, or nonconservative-2stage (input - \b solver.inp )*/ - char spatial_type_par [_MAX_STRING_SIZE_]; + char m_spatial_type_par [_MAX_STRING_SIZE_]; /*! choice of spatial discretization scheme for the parabolic term (input - \b solver.inp ) */ - char spatial_scheme_par [_MAX_STRING_SIZE_]; + char m_spatial_scheme_par [_MAX_STRING_SIZE_]; - /*! a #HyPar::ndims-dimensional integer array used to reference grid points */ - int *index; + /*! a #HyPar::m_ndims-dimensional integer array used to reference grid points */ + int *m_index; /*! the coordinate vector: one 1D array containing the spatial coordinates along each dimension * of the grid points, one dimension after the other. * Use #_GetCoordinate_ to access the spatial coordinate at a specific grid point */ - double *x; + double *m_x; - /*! array containing (1.0/dx): layout same as that of x */ - double *dxinv; + /*! array containing (1.0/dx): layout same as that of m_x */ + double *m_dxinv; - /*! Solution vector: the #HyPar::ndims-dimensional solution vector with nvars components at each + /*! Solution vector: the #HyPar::m_ndims-dimensional solution vector with m_nvars components at each * grid point is stored as a 1D array. **Includes ghost points** * Use #_ArrayIndex1D_ to calculate the index in the 1D array - * corresponding to a #HyPar::ndims-dimensional index (i_0, i_1, i_2, ..., i_{ndims-1}) */ - double *u; + * corresponding to a #HyPar::m_ndims-dimensional index (i_0, i_1, i_2, ..., i_{m_ndims-1}) */ + double *m_u; - /*! Array to hold the discretized hyperbolic term: Same layout as u */ - double *hyp; + /*! Array to hold the discretized hyperbolic term: Same layout as m_u */ + double *m_hyp; - /*! Array to hold the discretized parabolic term: Same layout as u */ - double *par; + /*! Array to hold the discretized parabolic term: Same layout as m_u */ + double *m_par; - /*! Array to hold the source term: Same layout as u */ - double *source; + /*! Array to hold the source term: Same layout as m_u */ + double *m_source; - /*! Array to hold the cell-centered hyperbolic flux: Same layout as u */ - double *fluxC; + /*! Array to hold the cell-centered hyperbolic flux: Same layout as m_u */ + double *m_flux_c; - /*! Array to hold the cell-centered modified solution: Same layout as u */ - double *uC; + /*! Array to hold the cell-centered modified solution: Same layout as m_u */ + double *m_u_c; /*! Array to hold the interface hyperbolic flux for a conservative finite-difference method * Since number of interfaces is one more than the number of cell-centers, the dimensions - * of fluxI is accordingly increased during allocation. **Does not have ghost points.** */ - double *fluxI; - - double *uL, /*!< Array to hold the left-biased reconstructed solution - at the interface. Same layout as fluxI. **No ghost points** */ - *uR, /*!< Array to hold the right-biased reconstructed solution - at the interface. Same layout as fluxI. **No ghost points** */ - *fL, /*!< Array to hold the left-biased reconstructed hyperbolic flux - at the interface. Same layout as fluxI. **No ghost points** */ - *fR; /*!< Array to hold the right-biased reconstructed hyperbolic flux - at the interface. Same layout as fluxI. **No ghost points** */ + * of m_flux_i is accordingly increased during allocation. **Does not have ghost points.** */ + double *m_flux_i; + + double *m_u_l, /*!< Array to hold the left-biased reconstructed solution + at the interface. Same layout as m_flux_i. **No ghost points** */ + *m_u_r, /*!< Array to hold the right-biased reconstructed solution + at the interface. Same layout as m_flux_i. **No ghost points** */ + *m_f_l, /*!< Array to hold the left-biased reconstructed hyperbolic flux + at the interface. Same layout as m_flux_i. **No ghost points** */ + *m_f_r; /*!< Array to hold the right-biased reconstructed hyperbolic flux + at the interface. Same layout as m_flux_i. **No ghost points** */ /*! arrays to hold approximations to the first and second derivatives to a given function - * at grid points. Layout is same as u, hyp, par, source. **Includes ghost points** */ - double *Deriv1, /*!< Array to hold approximations to the first derivative to - a given function at grid points. Layout is same as u, hyp, - par, source. **Includes ghost points** */ - *Deriv2; /*!< Array to hold approximations to the second derivative to - a given function at grid points. Layout is same as u, hyp, - par, source. **Includes ghost points** */ + * at grid points. Layout is same as m_u, m_hyp, m_par, m_source. **Includes ghost points** */ + double *m_deriv1, /*!< Array to hold approximations to the first derivative to + a given function at grid points. Layout is same as m_u, m_hyp, + m_par, m_source. **Includes ghost points** */ + *m_deriv2; /*!< Array to hold approximations to the second derivative to + a given function at grid points. Layout is same as m_u, m_hyp, + m_par, m_source. **Includes ghost points** */ /*! Boundary conditions: Number of boundary zones */ - int nBoundaryZones; + int m_n_boundary_zones; /*! Pointer to the boundary zones: boundary zone type is defined in boundaryconditions.h */ - void *boundary; - /*! Pointer to array of size #HyPar::ndims: each element is 1 if the domain is periodic along + void *m_boundary; + /*! Pointer to array of size #HyPar::m_ndims: each element is 1 if the domain is periodic along that spatial dimension; zero otherwise. */ - int *isPeriodic; + int *m_is_periodic; /*! pointer to the time-integration object */ - void *time_integrator; + void *m_time_integrator; /*! frequency (iterations) of writing iteration information (dt,CFL,norm,etc) to screen (input - \b solver.inp )*/ - int screen_op_iter; + int m_screen_op_iter; /*! frequency (iterations) of writing solution to file (input - \b solver.inp )*/ - int file_op_iter; + int m_file_op_iter; /*! flag to control if residual is written to file (input - \b solver.inp )*/ - int write_residual; + int m_write_residual; /*! mode of reading in initial solution: serial, parallel or mpi-io (input - \b solver.inp )*/ - char input_mode [_MAX_STRING_SIZE_]; + char m_input_mode [_MAX_STRING_SIZE_]; /*! type of initial solution file: ascii or binary (input - \b solver.inp )*/ - char ip_file_type [_MAX_STRING_SIZE_]; + char m_ip_file_type [_MAX_STRING_SIZE_]; /*! mode of writing solution to file: serial or parallel (input - \b solver.inp )*/ - char output_mode [_MAX_STRING_SIZE_]; + char m_output_mode [_MAX_STRING_SIZE_]; /*! solution output file format: binary, text, tecplot2d, tecplot 3d (input - \b solver.inp )*/ - char op_file_format[_MAX_STRING_SIZE_]; + char m_op_file_format[_MAX_STRING_SIZE_]; /*! overwrite solution file when writing new one? ("yes" - for steady solutions or if interested * only in the final solution; "no" - to keep the solutions written at intermediate time steps). (input - \b solver.inp )*/ - char op_overwrite [_MAX_STRING_SIZE_]; + char m_op_overwrite [_MAX_STRING_SIZE_]; /*! plot solutions during simulation? */ - char plot_solution[_MAX_STRING_SIZE_]; + char m_plot_solution[_MAX_STRING_SIZE_]; /*! filename index for files written every few iterations */ - char *filename_index; - /*! length of filename_index - should be sufficient for the number of files expected to be written */ - int index_length; + char *m_filename_index; + /*! length of m_filename_index - should be sufficient for the number of files expected to be written */ + int m_index_length; /*! solution filename extension */ - char solnfilename_extn[_MAX_STRING_SIZE_]; + char m_solnfilename_extn[_MAX_STRING_SIZE_]; /*! plot figure filename extension */ - char plotfilename_extn[_MAX_STRING_SIZE_]; + char m_plotfilename_extn[_MAX_STRING_SIZE_]; /*! output filename root */ - char op_fname_root[_MAX_STRING_SIZE_]; + char m_op_fname_root[_MAX_STRING_SIZE_]; /*! auxiliary output filename root */ - char aux_op_fname_root[_MAX_STRING_SIZE_]; + char m_aux_op_fname_root[_MAX_STRING_SIZE_]; /*! Pointer to the function to write the solution to file, assigned in InitializeSolvers() */ int (*WriteOutput) (int,int,int*,double*,double*,char*,int*); @@ -260,10 +260,10 @@ typedef struct main_parameters { /*! name of physical model (defined in the header files in folder physicalmodels) (input - \b solver.inp ) */ - char model[_MAX_STRING_SIZE_]; + char m_model[_MAX_STRING_SIZE_]; /*! object providing the physics of the PDE being solved */ - void *physics; + void *m_physics; /*! Pointer to the function to calculate the CFL number (assigned in the physical model initialization called from InitializePhysics()) */ double (*ComputeCFL) (void*,void*,double,double); @@ -275,19 +275,19 @@ typedef struct main_parameters { * (assigned in the physical model initialization called from InitializePhysics()) */ int (*FFunction) (double*,double*,int,void*,double); /*! If hyperbolic flux is split as \f$f\left(u\right) = \left[f\left(u\right)-df\left(u\right)\right] + df\left(u\right)\f$ - (see #HyPar::SplitHyperbolicFlux), + (see #HyPar::m_split_hyperbolic_flux), function to calculate \f$df\left(u\right)\f$ (assigned in the physical model initialization called from InitializePhysics()) */ int (*dFFunction) (double*,double*,int,void*,double); /*! If hyperbolic flux is split as \f$f\left(u\right) = \left[f\left(u\right)-df\left(u\right)\right] + df\left(u\right)\f$, - (see #HyPar::SplitHyperbolicFlux), + (see #HyPar::m_split_hyperbolic_flux), function to calculate \f$\left[f-df\right]\left(u\right)\f$(assigned in the physical model initialization called from InitializePhysics()) .\n Specifying this is optional; if the physical model does not explicitly specify this, then it is computed by subtracting - HyPar::dFFunction() from HyPar::FFunction(). \sa #HyPar::flag_fdf_specified */ + HyPar::dFFunction() from HyPar::FFunction(). \sa #HyPar::m_flag_fdf_specified */ int (*FdFFunction) (double*,double*,int,void*,double); /*! Flag indicating whether the physical model has explicitly specified the function to compute \f$\left[f-df\right]\left(u\right)\f$ (HyPar::FdFFunction()) or not. Relevant if the hyperbolic flux - is being partitioned. \sa #HyPar::SplitHyperbolicFlux, HyPar::dFFunction(), HyPar::FdFFunction() */ - int flag_fdf_specified; + is being partitioned. \sa #HyPar::m_split_hyperbolic_flux, HyPar::dFFunction(), HyPar::FdFFunction() */ + int m_flag_fdf_specified; /*! Pointer to the function to calculate the upwind interface flux, given the left- and * right-biased fluxes (assigned in the physical model initialization called from @@ -296,14 +296,14 @@ typedef struct main_parameters { /*! Pointer to the function to calculate the upwind interface split flux \f$df\left(u\right)\f$, given the left- and right-biased approximations (assigned in the physical model initialization called from InitializePhysics()). Relevant only if the hyperbolic flux is being partitioned as \f$f\left(u\right) = \left[f\left(u\right)-df\left(u\right)\right] + df\left(u\right)\f$ - \sa #HyPar::SplitHyperbolicFlux, HyPar::dFFunction()*/ + \sa #HyPar::m_split_hyperbolic_flux, HyPar::dFFunction()*/ int (*UpwinddF) (double*,double*,double*,double*,double*,double*,int,void*,double); /*! Pointer to the function to calculate the upwind interface split flux \f$\left[f-df\right]\left(u\right)\f$, given its left- and right-biased approximations (assigned in the physical model initialization called from InitializePhysics()). Relevant only if the hyperbolic flux is being partitioned as \f$f\left(u\right) = \left[f\left(u\right)-df\left(u\right)\right] + df\left(u\right)\f$ (see - #HyPar::SplitHyperbolicFlux, HyPar::dFFunction()), and if the split part + #HyPar::m_split_hyperbolic_flux, HyPar::dFFunction()), and if the split part \f$\left[f-df\right]\left(u\right)\f$ is being specified explicitly (see HyPar::FdFFunction(), - #HyPar::flag_fdf_specified). */ + #HyPar::m_flag_fdf_specified). */ int (*UpwindFdF) (double*,double*,double*,double*,double*,double*,int,void*,double); /*! Pointer to the function to calculate the parabolic function with no cross-derivatives (assigned in the physical model initialization called from InitializePhysics()) */ @@ -322,12 +322,12 @@ typedef struct main_parameters { /*! Pointer to the function to calculate the flux Jacobian for a given solution state (assigned in the physical model initialization called from InitializePhysics()). The advective flux Jacobian is the Jacobian of the analytical (*not* spatially discretized) advective flux for a given solution state (for example, at a grid point). - The size is (#HyPar::nvars)^2 and the matrix is stored as a 1D array in row-major format. */ + The size is (#HyPar::m_nvars)^2 and the matrix is stored as a 1D array in row-major format. */ int (*JFunction) (double*,double*,void*,int,int,int); /*! Pointer to the function to calculate the diffusion term Jacobian for a given solution state (assigned in the physical model initialization called from InitializePhysics()). The diffusion Jacobian is the Jacobian of the analytical (*not* spatially discretized) diffusion term for a given solution state (for example, at a grid point). - The size is (#HyPar::nvars)^2 and the matrix is stored as a 1D array in row-major format. */ + The size is (#HyPar::m_nvars)^2 and the matrix is stored as a 1D array in row-major format. */ int (*KFunction) (double*,double*,void*,int,int); /*! Pointer to the function to do some pre-time-integration-stage computations, if required (assigned in the physical model initialization called from InitializePhysics()) */ @@ -359,31 +359,31 @@ typedef struct main_parameters { int (*GetRightEigenvectors)(double*,double*,void*,int); /*! object containing interpolation-related parameters (of hyperbolic flux reconstruction */ - void *interp; + void *m_interp; /*! object containing arrays needed for compact finite-difference methods */ - void *compact; + void *m_compact; /*! object containing multi-stage time-integration (RK-type) related parameters */ - void *msti; + void *m_msti; /*! object containing parameters for the tridiagonal solver */ - void *lusolver; + void *m_lusolver; /*! Errors - L1, L2 and L_inf; calculated only if an exact solution file is supplied */ - double error[3]; + double m_error[3]; /*! Conservation error in the solution -- does not indicate anything if parabolic and source terms * are non-zero */ - double *ConservationError; + double *m_conservation_error; /*! check for conservation error? */ - char ConservationCheck[_MAX_STRING_SIZE_]; + char m_conservation_check[_MAX_STRING_SIZE_]; /*! Volume integral of the solution over the global domain */ - double *VolumeIntegral; + double *m_volume_integral; /*! Volume integral of the initial solution over the global domain */ - double *VolumeIntegralInitial; + double *m_volume_integral_initial; /*! Surface integral of the flux at the boundary for each time-integration stage */ - double *StageBoundaryIntegral; + double *m_stage_boundary_integral; /*! Surface integral of the flux at the boundary for a time-integration step */ - double *StepBoundaryIntegral; + double *m_step_boundary_integral; /*! Total surface integral of the flux over the global domain boundary */ - double *TotalBoundaryIntegral; + double *m_total_boundary_integral; /*! Pointer to the function to calculate the volume integral of a given function */ int (*VolumeIntegralFunction) (double*,double*,void*,void*); /*! Pointer to the function to calculate the boundary integral of the flux */ @@ -392,74 +392,74 @@ typedef struct main_parameters { int (*CalculateConservationError)(void*,void*); #ifdef with_petsc - int use_petscTS; /*!< Use PETSc time-integration? */ - double *u0; /*!< copy of solution vector */ - double *uref; /*!< copy of solution vector */ - double *rhsref; /*!< copy of the RHS vector */ - double *rhs; /*!< RHS vector */ + int m_use_petsc_ts; /*!< Use PETSc time-integration? */ + double *m_u0; /*!< copy of solution vector */ + double *m_uref; /*!< copy of solution vector */ + double *m_rhsref; /*!< copy of the RHS vector */ + double *m_rhs; /*!< RHS vector */ #endif #ifdef with_librom double* u_rom_predicted; /*!< Solution predicted using a ROM */ /*! L1, L2, Linf norms of the diff between PDE and ROM solutions */ - double rom_diff_norms[3]; + double m_rom_diff_norms[3]; /*! output filename root for ROM solution file */ - char op_rom_fname_root[_MAX_STRING_SIZE_]; + char m_op_rom_fname_root[_MAX_STRING_SIZE_]; #endif /*! flag to globally switch on/off non-linear interpolation */ - int flag_nonlinearinterp; + int m_flag_nonlinearinterp; /*! strides along each dimension for an array with ghost points */ - int *stride_with_ghosts; + int *m_stride_with_ghosts; /*! strides along each dimension for an array without ghost points */ - int *stride_without_ghosts; + int *m_stride_without_ghosts; - int count_hyp, /*!< number of times the hyperbolic function is called */ - count_par, /*!< number of times the parabolic function is called */ - count_sou; /*!< number of times the source function is called */ + int m_count_hyp, /*!< number of times the hyperbolic function is called */ + m_count_par, /*!< number of times the parabolic function is called */ + m_count_sou; /*!< number of times the source function is called */ #ifdef with_petsc - int count_RHSFunction, /*!< number of times the RHSFunction is called */ - count_IFunction, /*!< number of times the IFunction is called */ - count_IJacobian, /*!< number of times the IJacobian is called */ - count_RHSJacobian, /*!< number of times the RHSJacobian is called */ - count_IJacFunction, /*!< number of times the IJacFunction is called */ - count_RHSJacFunction; /*!< number of times the RHSJacFunction is called */ + int m_count_rhs_function, /*!< number of times the RHSFunction is called */ + m_count_i_function, /*!< number of times the IFunction is called */ + m_count_i_jacobian, /*!< number of times the IJacobian is called */ + m_count_rhs_jacobian, /*!< number of times the RHSJacobian is called */ + m_count_i_jac_function, /*!< number of times the IJacFunction is called */ + m_count_rhs_jac_function; /*!< number of times the RHSJacFunction is called */ #endif - /*! blanking array: of same size and layout as #HyPar::u (but with 1 component + /*! blanking array: of same size and layout as #HyPar::m_u (but with 1 component per grid point, it has a value 1 for all valid grid points and 0 for grid points that are blanked out. It is essentially an integer array, but the declared as a \a double type to use functions defined for the \a double data type. */ - double *iblank; + double *m_iblank; /*! Name of immersed body STL file (input - \b solver.inp )*/ - char ib_filename[_MAX_STRING_SIZE_]; + char m_ib_filename[_MAX_STRING_SIZE_]; /*! Flag to indicate if immersed boundaries are in use */ - int flag_ib; + int m_flag_ib; /*! Immersed boundary object */ - void *ib; + void *m_ib; /*! Physics-specific immersed boundary treatment function (assigned in the physical model initialization called from InitializePhysics()) */ int (*IBFunction) (void*,void*,double*,double); #if defined(HAVE_CUDA) - int use_gpu; /*!< Indicate whether to use GPU or not */ - int gpu_device_no; /*!< GPU device number to use, default 0 */ + int m_use_gpu; /*!< Indicate whether to use GPU or not */ + int m_gpu_device_no; /*!< GPU device number to use, default 0 */ - int gpu_npoints_boundary_offset[3]; /*!< number of boundary points offsets */ - int gpu_npoints_boundary[3]; /*!< number of boundary points */ + int m_gpu_npoints_boundary_offset[3]; /*!< number of boundary points offsets */ + int m_gpu_npoints_boundary[3]; /*!< number of boundary points */ - int *gpu_dim_local; /*!< A copy of #HyPar::dim_local on GPU */ - double *gpu_iblank; /*!< A copy of #HyPar::iblank on GPU */ - double *gpu_x; /*!< A copy of #HyPar::x on GPU */ - double *gpu_dxinv; /*!< A copy of #HyPar::dxinv on GPU */ - double *gpu_u; /*!< A copy of #HyPar::u on GPU */ + int *m_gpu_dim_local; /*!< A copy of #HyPar::m_dim_local on GPU */ + double *m_gpu_iblank; /*!< A copy of #HyPar::m_iblank on GPU */ + double *m_gpu_x; /*!< A copy of #HyPar::m_x on GPU */ + double *m_gpu_dxinv; /*!< A copy of #HyPar::m_dxinv on GPU */ + double *m_gpu_u; /*!< A copy of #HyPar::m_u on GPU */ - int StageBoundaryBuffer_size; /*!< size of #HyPar::StageBoundaryBuffer */ - double *StageBoundaryBuffer; /*!< Array to perform reduction */ + int m_stage_boundary_buffer_size; /*!< size of #HyPar::m_stage_boundary_buffer */ + double *m_stage_boundary_buffer; /*!< Array to perform reduction */ #endif #ifdef with_python diff --git a/include/immersedboundaries.h b/include/immersedboundaries.h index 8a87145a..6c737ae8 100644 --- a/include/immersedboundaries.h +++ b/include/immersedboundaries.h @@ -37,18 +37,18 @@ normal. \sa https://en.wikipedia.org/wiki/STL_(file_format) */ typedef struct _facet_3d_{ - double x1, /*!< x-coordinate of vertex 1 */ - x2, /*!< x-coordinate of vertex 2 */ - x3, /*!< x-coordinate of vertex 3 */ - y1, /*!< y-coordinate of vertex 1 */ - y2, /*!< y-coordinate of vertex 2 */ - y3, /*!< y-coordinate of vertex 3 */ - z1, /*!< z-coordinate of vertex 1 */ - z2, /*!< z-coordinate of vertex 2 */ - z3, /*!< z-coordinate of vertex 3 */ - nx, /*!< x-component of surface normal */ - ny, /*!< y-component of surface normal */ - nz; /*!< z-component of surface normal */ + double m_x1, /*!< x-coordinate of vertex 1 */ + m_x2, /*!< x-coordinate of vertex 2 */ + m_x3, /*!< x-coordinate of vertex 3 */ + m_y1, /*!< y-coordinate of vertex 1 */ + m_y2, /*!< y-coordinate of vertex 2 */ + m_y3, /*!< y-coordinate of vertex 3 */ + m_z1, /*!< z-coordinate of vertex 1 */ + m_z2, /*!< z-coordinate of vertex 2 */ + m_z3, /*!< z-coordinate of vertex 3 */ + m_nx, /*!< x-component of surface normal */ + m_ny, /*!< y-component of surface normal */ + m_nz; /*!< z-component of surface normal */ } Facet3D; /*! \def FacetMap @@ -65,23 +65,23 @@ typedef struct _facet_3d_{ rank. */ typedef struct _facet_map_{ - Facet3D *facet; /*!< pointer to the facet */ - int index; /*!< index of this facet in the array #Body3D::surface */ - int interp_nodes [_IB_NNODES_];/*!< indices of grid points surrounding the facet centroid */ - double interp_coeffs [_IB_NNODES_];/*!< interpolation coefficients corresponding to #FacetMap::interp_nodes */ - int interp_nodes_ns [_IB_NNODES_];/*!< indices of grid points surrounding the "near-surface" point near the centroid */ - double interp_coeffs_ns[_IB_NNODES_];/*!< interpolation coefficients corresponding to #FacetMap::interp_nodes_ns */ - - double xc, /*!< x-coordinate of centroid of #FacetMap::facet */ - yc, /*!< y-coordinate of centroid of #FacetMap::facet */ - zc, /*!< z-coordinate of centroid of #FacetMap::facet */ - xns,/*!< x-coordinate of "near surface" point of #FacetMap::facet */ - yns,/*!< y-coordinate of "near surface" point of #FacetMap::facet */ - zns;/*!< z-coordinate of "near surface" point of #FacetMap::facet */ - - double dx, /*!< #FacetMap::xns - #FacetMap::xc */ - dy, /*!< #FacetMap::yns - #FacetMap::yc */ - dz; /*!< #FacetMap::zns - #FacetMap::zc */ + Facet3D *m_facet; /*!< pointer to the facet */ + int m_index; /*!< index of this facet in the array #Body3D::m_surface */ + int m_interp_nodes [_IB_NNODES_];/*!< indices of grid points surrounding the facet centroid */ + double m_interp_coeffs [_IB_NNODES_];/*!< interpolation coefficients corresponding to #FacetMap::m_interp_nodes */ + int m_interp_nodes_ns [_IB_NNODES_];/*!< indices of grid points surrounding the "near-surface" point near the centroid */ + double m_interp_coeffs_ns[_IB_NNODES_];/*!< interpolation coefficients corresponding to #FacetMap::m_interp_nodes_ns */ + + double m_xc, /*!< x-coordinate of centroid of #FacetMap::m_facet */ + m_yc, /*!< y-coordinate of centroid of #FacetMap::m_facet */ + m_zc, /*!< z-coordinate of centroid of #FacetMap::m_facet */ + m_xns,/*!< x-coordinate of "near surface" point of #FacetMap::m_facet */ + m_yns,/*!< y-coordinate of "near surface" point of #FacetMap::m_facet */ + m_zns;/*!< z-coordinate of "near surface" point of #FacetMap::m_facet */ + + double m_dx, /*!< #FacetMap::m_xns - #FacetMap::m_xc */ + m_dy, /*!< #FacetMap::m_yns - #FacetMap::m_yc */ + m_dz; /*!< #FacetMap::m_zns - #FacetMap::m_zc */ } FacetMap; /*! \def Body3D @@ -98,15 +98,15 @@ typedef struct _facet_map_{ \sa https://en.wikipedia.org/wiki/STL_(file_format) */ typedef struct _body_3d_{ - int nfacets; /*!< number of surface facets */ - Facet3D *surface; /*!< array of surface facets */ + int m_nfacets; /*!< number of surface facets */ + Facet3D *m_surface; /*!< array of surface facets */ /* coordinates of bounding box */ - double xmin, /*!< x-coordinate of lower end of bounding box */ - xmax, /*!< x-coordinate of higher end of bounding box */ - ymin, /*!< y-coordinate of lower end of bounding box */ - ymax, /*!< y-coordinate of higher end of bounding box */ - zmin, /*!< z-coordinate of lower end of bounding box */ - zmax; /*!< z-coordinate of higher end of bounding box */ + double m_xmin, /*!< x-coordinate of lower end of bounding box */ + m_xmax, /*!< x-coordinate of higher end of bounding box */ + m_ymin, /*!< y-coordinate of lower end of bounding box */ + m_ymax, /*!< y-coordinate of higher end of bounding box */ + m_zmin, /*!< z-coordinate of lower end of bounding box */ + m_zmax; /*!< z-coordinate of higher end of bounding box */ } Body3D; /*! \def IBNode @@ -123,19 +123,19 @@ typedef struct _body_3d_{ the body. */ typedef struct _boundary_node_{ - int i, /*!< grid index along x */ - j, /*!< grid index along y */ - k, /*!< grid index along z */ - p; /*!< array index of this point */ - double x, /*!< x-coordinate of the boundary node */ - y, /*!< y-coordinate of the boundary node */ - z; /*!< z-coordinate of the boundary node */ - Facet3D *face; /*!< the nearest facet of #ImmersedBoundary::body */ - - int interp_nodes[_IB_NNODES_]; /*!< indices of interior nodes from which to extrapolate */ - double interp_coeffs[_IB_NNODES_], /*!< interpolation coefficients corresponding to #IBNode::interp_nodes */ - interp_node_distance, /*!< Distance from the immersed body surface to the interior node from which to extrapolate */ - surface_distance; /*!< Distance from this node to the immersed body surface */ + int m_i, /*!< grid index along x */ + m_j, /*!< grid index along y */ + m_k, /*!< grid index along z */ + m_p; /*!< array index of this point */ + double m_x, /*!< x-coordinate of the boundary node */ + m_y, /*!< y-coordinate of the boundary node */ + m_z; /*!< z-coordinate of the boundary node */ + Facet3D *m_face; /*!< the nearest facet of #ImmersedBoundary::m_body */ + + int m_interp_nodes[_IB_NNODES_]; /*!< indices of interior nodes from which to extrapolate */ + double m_interp_coeffs[_IB_NNODES_], /*!< interpolation coefficients corresponding to #IBNode::m_interp_nodes */ + m_interp_node_distance, /*!< Distance from the immersed body surface to the interior node from which to extrapolate */ + m_surface_distance; /*!< Distance from this node to the immersed body surface */ } IBNode; @@ -151,17 +151,17 @@ typedef struct _boundary_node_{ boundaries. */ typedef struct immersed_boundary{ - Body3D *body; /*!< immersed body */ - IBNode *boundary; /*!< immersed boundary nodes */ - FacetMap *fmap; /*!< list of "local" facets */ + Body3D *m_body; /*!< immersed body */ + IBNode *m_boundary; /*!< immersed boundary nodes */ + FacetMap *m_fmap; /*!< list of "local" facets */ - double tolerance; /*!< zero tolerance */ - double delta; /*!< small number */ - int itr_max; /*!< maximum intersections in ray-tracing method */ - int n_boundary_nodes; /*!< number of immersed boundary nodes */ - int nfacets_local; /*!< number of "local" facets */ + double m_tolerance; /*!< zero tolerance */ + double m_delta; /*!< small number */ + int m_itr_max; /*!< maximum intersections in ray-tracing method */ + int m_n_boundary_nodes; /*!< number of immersed boundary nodes */ + int m_nfacets_local; /*!< number of "local" facets */ - char mode[_MAX_STRING_SIZE_]; /*!< identifies if the simulation is 2D along a plane + char m_mode[_MAX_STRING_SIZE_]; /*!< identifies if the simulation is 2D along a plane or truly 3D. \sa IBIdentifyMode() */ } ImmersedBoundary; diff --git a/include/interpolation.h b/include/interpolation.h index e7a2a884..2b3c0b0d 100644 --- a/include/interpolation.h +++ b/include/interpolation.h @@ -174,8 +174,8 @@ int InterpSetLimiterVar(double*,double*,double*,int,void*,void*); */ typedef struct paramters_muscl { - char limiter_type[_MAX_STRING_SIZE_]; /*!< Type of slope limiter */ - double eps; /*!< Epsilon parameter for the Koren's limiter */ + char m_limiter_type[_MAX_STRING_SIZE_]; /*!< Type of slope limiter */ + double m_eps; /*!< Epsilon parameter for the Koren's limiter */ /*! pointer the limiter function */ double (*LimiterFunction) (double); @@ -192,29 +192,29 @@ int MUSCLInitialize(void*,void*); * This structure contains the variables/parameters needed by the WENO-type scheme (#_FIFTH_ORDER_WENO_, #_FIFTH_ORDER_CRWENO_, #_FIFTH_ORDER_HCWENO_). */ typedef struct parameters_weno { - int mapped; /*!< Use mapped weights? (Henrick, Aslam, J. Comput. Phys., 2005) */ - int borges; /*!< Use Borges' implementation of weights? (Borges, et. al, J. Comput. Phys., 2008) */ - int yc; /*!< Use Yamaleev-Carpenter implementation of weights? (Yamaleev, Carpenter, J. Comput. Phys., 2009) */ - int no_limiting; /*!< Remove limiting -> 5th order polynomial interpolation (freeze the WENO weights to the optimal coefficients) */ - double eps; /*!< epsilon parameter */ - double p; /*!< p parameter */ - double tol; /*!< a general tolerance parameter */ + int m_mapped; /*!< Use mapped weights? (Henrick, Aslam, J. Comput. Phys., 2005) */ + int m_borges; /*!< Use Borges' implementation of weights? (Borges, et. al, J. Comput. Phys., 2008) */ + int m_yc; /*!< Use Yamaleev-Carpenter implementation of weights? (Yamaleev, Carpenter, J. Comput. Phys., 2009) */ + int m_no_limiting; /*!< Remove limiting -> 5th order polynomial interpolation (freeze the WENO weights to the optimal coefficients) */ + double m_eps; /*!< epsilon parameter */ + double m_p; /*!< p parameter */ + double m_tol; /*!< a general tolerance parameter */ /* hybrid compact-WENO scheme related parameters * **References**: * + http://dx.doi.org/10.1006/jcph.2002.7021 * + http://dx.doi.org/10.1016/j.jcp.2003.07.006 */ - double rc, /*!< Parameter for the hybrid compact-WENO scheme */ - xi; /*!< Parameter for the hybrid compact-WENO scheme */ + double m_rc, /*!< Parameter for the hybrid compact-WENO scheme */ + m_xi; /*!< Parameter for the hybrid compact-WENO scheme */ /* Arrays to save the WENO weights */ - double *w1, /*!< Array to save the first WENO weight */ - *w2, /*!< Array to save the second WENO weight */ - *w3;/*!< Array to save the third WENO weight */ + double *m_w1, /*!< Array to save the first WENO weight */ + *m_w2, /*!< Array to save the second WENO weight */ + *m_w3;/*!< Array to save the third WENO weight */ /* size and offset for the WENO weights arrays */ - int *offset /*! Array containing the offset information for the WENO weights */, - size /*! Size of the WENO weights array */; + int *m_offset /*! Array containing the offset information for the WENO weights */, + m_size /*! Size of the WENO weights array */; } WENOParameters; @@ -268,14 +268,14 @@ int WENOCleanup(void*, int); /* calculate smoothness indicators and the WENO weights */\ double b1, b2, b3, a1, a2, a3, a_sum_inv; \ for (idx=0; idx /*! Function to calculate the grid points corresponding to a given interval */ -void FindInterval(double,double,double*,int,int*,int*); +void FindInterval(double a_val, double a_tolerance, double* a_grid, int a_n, int* a_index_low, int* a_index_high); /*! Fill the ghost cells of a global n-dimensional array */ -void fillGhostCells(const int* const, const int, double* const, const int, const int, const int* const); +void FillGhostCells(const int* const a_dim, const int a_ngpt, double* const a_u, const int a_nvars, const int a_ndims, const int* const a_periodic); /*! Function to compute trilinear interpolation coefficients */ -void TrilinearInterpCoeffs(double,double,double,double,double,double,double,double,double,double*); +void TrilinearInterpCoeffs(double a_x, double a_y, double a_z, double a_x1, double a_y1, double a_z1, double a_x2, double a_y2, double a_z2, double* a_coeffs); /*! Interpolate an n-dimensional grid variable from one grid to another */ -int InterpolateGlobalnDVar( const int* const, - double** const, - const int* const, - double* const, - const int, - const int, - const int, - const int* const); +int InterpolateGlobalnDVar(const int* const a_dim_src, + double** const a_x_src, + const int* const a_dim_dst, + double* const a_u, + const int a_nvars, + const int a_ndims, + const int a_ngpt, + const int* const a_periodic); #endif diff --git a/include/mathfunctions_cpp.h b/include/mathfunctions_cpp.h index 30d3772f..3b253795 100644 --- a/include/mathfunctions_cpp.h +++ b/include/mathfunctions_cpp.h @@ -10,7 +10,7 @@ extern "C" void FindInterval(double,double,double*,int,int*,int*); /*! Fill the ghost cells of a global n-dimensional array */ -extern "C" void fillGhostCells( const int* const, +extern "C" void FillGhostCells( const int* const, const int, double* const, const int, diff --git a/include/mpivars_struct.h b/include/mpivars_struct.h index a31f6f9b..52bf798e 100644 --- a/include/mpivars_struct.h +++ b/include/mpivars_struct.h @@ -22,43 +22,43 @@ * using the MPI library. */ typedef struct mpi_variables { - int rank; /*!< Process rank */ - int nproc; /*!< Total number of processes */ - int *iproc; /*!< Number of processes along each dimension */ - int *ip; /*!< Process rank along each dimension */ - int *is, /*!< Global start index of local domain along each dimension */ - *ie; /*!< Global end index of local domain along each dimension */ - int *bcperiodic; /*!< Flag for periodic BCs along any dimension */ + int m_rank; /*!< Process rank */ + int m_nproc; /*!< Total number of processes */ + int *m_iproc; /*!< Number of processes along each dimension */ + int *m_ip; /*!< Process rank along each dimension */ + int *m_is, /*!< Global start index of local domain along each dimension */ + *m_ie; /*!< Global end index of local domain along each dimension */ + int *m_bcperiodic; /*!< Flag for periodic BCs along any dimension */ #ifdef serial - int world; /* Dummy variable */ - int *comm; /* Dummy variable */ + int m_world; /* Dummy variable */ + int *m_comm; /* Dummy variable */ #else - MPI_Comm world; /*!< Communicator for all processes */ - MPI_Comm *comm; /*!< Sub-communicators */ + MPI_Comm m_world; /*!< Communicator for all processes */ + MPI_Comm *m_comm; /*!< Sub-communicators */ #endif - int N_IORanks; /*!< Number of IO ranks */ - int IOParticipant; /*!< Whether this rank will handle file I/O */ - int CommGroup; /*!< I/O group this rank is a part of */ - int IORank ; /*!< Rank of the process this rank will get I/O from*/ - int GroupStartRank; /*!< Starting rank of the IO group */ - int GroupEndRank; /*!< Last rank of the IO group */ + int m_N_IORanks; /*!< Number of IO ranks */ + int m_IOParticipant; /*!< Whether this rank will handle file I/O */ + int m_CommGroup; /*!< I/O group this rank is a part of */ + int m_IORank ; /*!< Rank of the process this rank will get I/O from*/ + int m_GroupStartRank; /*!< Starting rank of the IO group */ + int m_GroupEndRank; /*!< Last rank of the IO group */ #ifndef serial - MPI_Comm IOWorld; /*!< Communicator of processes participating in file I/O */ + MPI_Comm m_IOWorld; /*!< Communicator of processes participating in file I/O */ #endif - double *sendbuf, /*!< Buffer to send data */ - *recvbuf; /*!< Buffer to receive data */ - int maxbuf; /*!< Maximum buffer size */ + double *m_sendbuf, /*!< Buffer to send data */ + *m_recvbuf; /*!< Buffer to receive data */ + int m_maxbuf; /*!< Maximum buffer size */ #if defined(HAVE_CUDA) - int ncalls; - double wctime; - double wctime_total; - int *cpu_dim; - double *gpu_sendbuf, - *gpu_recvbuf; + int m_ncalls; + double m_wctime; + double m_wctime_total; + int *m_cpu_dim; + double *m_gpu_sendbuf, + *m_gpu_recvbuf; #endif } MPIVariables; diff --git a/include/petscinterface_struct.h b/include/petscinterface_struct.h index 05202892..c9b7ab99 100644 --- a/include/petscinterface_struct.h +++ b/include/petscinterface_struct.h @@ -42,78 +42,78 @@ typedef struct _petsccontext_ { /*! MPI rank */ - int rank; + int m_rank; /*! number of MPI ranks */ - int nproc; + int m_nproc; /*! array of simulation objects of type #SimulationObject */ - void *simobj; + void *m_simobj; /*! number of simulation objects */ - int nsims; + int m_nsims; /*! The shift variable in implicit time-integration */ - PetscReal shift; + PetscReal m_shift; /*! Current time */ - double waqt; + double m_waqt; /*! Simulation time at start of step */ - double t_start; + double m_t_start; /*! Current dt */ - double dt; + double m_dt; /*! Stage times */ - std::vector stage_times; + std::vector m_stage_times; /*! Current stage */ - int stage_index; + int m_stage_index; /*! A counter variable */ - int tic; + int m_tic; /*! Number of computational points (local), i.e., total number of grid points not counting the ghost points */ - int npoints; + int m_npoints; /*! Number of computational DOFs (local), i.e., total number of grid points times * the number of vector components at each grid point. */ - int ndofs; + int m_ndofs; /*! Vector of index lists of local points in each simulation domain whose size is - (#HyPar::ndims+1)*#PETScContext::npoints. + (#HyPar::m_ndims+1)*#PETScContext::m_npoints. For each point, it stores its ndims-dimensional index and its 1D index - of its location in the array #HyPar::u. */ - std::vector points; + of its location in the array #HyPar::m_u. */ + std::vector m_points; /*! Vector offsets for each simulation domain */ - int* offsets; + int* m_offsets; /* flags for implicit treatment */ /*! Flag to indicate if hyperbolic term is treated implicitly or explicitly */ - int flag_hyperbolic; + int m_flag_hyperbolic; /*! Flag to indicate if the split hyperbolic term (\a f - \a df) is treated implicitly or explicitly */ - int flag_hyperbolic_f; + int m_flag_hyperbolic_f; /*! Flag to indicate if the split hyperbolic term \a df is treated implicitly or explicitly */ - int flag_hyperbolic_df; + int m_flag_hyperbolic_df; /*! Flag to indicate if the parabolic term is treated implicitly or explicitly */ - int flag_parabolic; + int m_flag_parabolic; /*! Flag to indicate if the source term is treated implicitly or explicitly */ - int flag_source; + int m_flag_source; /*! Flag to turn on preconditioning (off by default) */ - int flag_use_precon; + int m_flag_use_precon; /*! Construct or use provided PC matrix */ - std::string precon_matrix_type; + std::string m_precon_matrix_type; /*! Flag to indicate if the system being solved for implicit time-integration is linear/nonlinear. */ - int flag_is_linear; + int m_flag_is_linear; /*! \f$\epsilon\f$ parameter for the Jacobian-free Newton-Krylov directional derivative computation */ - double jfnk_eps; + double m_jfnk_eps; /*! A vector of essentialy integer arrays of the same size and layout at the solutions (with ghost points) containing the global DOF index for each grid point in each @@ -121,24 +121,24 @@ typedef struct _petsccontext_ { It is declared as a \a double type so that its calculation can use functions defined for double-type variables. \sa PetscGlobalDOF() */ - std::vector globalDOF; + std::vector m_globalDOF; /*! iteration start time */ - struct timeval iter_start_time; + struct timeval m_iter_start_time; /*! iteration end time */ - struct timeval iter_end_time; + struct timeval m_iter_end_time; /*! iteration wallclock time (in seconds) */ - double iter_wctime; + double m_iter_wctime; /*! total time integration wall time (in seconds) */ - double ti_runtime; + double m_ti_runtime; #ifdef with_librom /*! libROM interface */ - void* rom_interface; + void* m_rom_interface; /*! ROM mode \sa #libROMInterface::m_mode */ - std::string rom_mode; + std::string m_rom_mode; /*! Array of simulation times to write solution output at */ - std::vector op_times_arr; + std::vector m_op_times_arr; #endif } PETScContext; diff --git a/include/physicalmodels/euler1d.h b/include/physicalmodels/euler1d.h index fa1a920b..57b860e5 100644 --- a/include/physicalmodels/euler1d.h +++ b/include/physicalmodels/euler1d.h @@ -80,7 +80,7 @@ */ #define _Euler1DGetFlowVar_(u,rho,v,e,P,p) \ { \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ rho = u[0]; \ v = u[1] / rho; \ e = u[2]; \ @@ -171,7 +171,7 @@ double rho ,v ,e ,P ,H ,csq; \ double rhoL,vL,eL,PL,HL,cLsq; \ double rhoR,vR,eR,PR,HR,cRsq; \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ rhoL = uL[0]; \ vL = uL[1] / rhoL; \ eL = uL[2]; \ @@ -206,7 +206,7 @@ */ #define _Euler1DEigenvalues_(u,D,p,dir) \ { \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ double rho,v,e,P,c; \ rho = u[0]; \ v = u[1] / rho; \ @@ -224,7 +224,7 @@ */ #define _Euler1DLeftEigenvectors_(u,L,p,dir) \ { \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ double rho,v,e,P,c; \ rho = u[0]; \ v = u[1] / rho; \ @@ -248,7 +248,7 @@ */ #define _Euler1DRightEigenvectors_(u,R,p,dir) \ { \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ double rho,v,e,P,c; \ rho = u[0]; \ v = u[1] / rho; \ @@ -271,8 +271,8 @@ * specific to the 1D Euler equations. */ typedef struct euler1d_parameters { - double gamma; /*!< Ratio of heat capacities (\f$\gamma\f$) */ - double grav; /*!< acceleration due to gravity */ + double m_gamma; /*!< Ratio of heat capacities (\f$\gamma\f$) */ + double m_grav; /*!< acceleration due to gravity */ /*! type of gravitational field (0 is isothermal with constant potential, @@ -283,12 +283,12 @@ typedef struct euler1d_parameters { Journal of Scientific Computing, 54, 2013, pp. 645-662. http://dx.doi.org/10.1007/s10915-012-9585-8 */ - int grav_type; + int m_grav_type; - double *grav_field; /*!< Array to store the gravity potential field */ - double *fast_jac; /*!< Array to store the linearized fast-waves Jacobian over the whole domain */ - double *solution; /*!< Array to store the reference solution for linearization */ - char upw_choice[_MAX_STRING_SIZE_]; /*!< Choice of upwinding scheme.\sa #_ROE_,#_LLF_,#_RF_,#_SWFS_ */ + double *m_grav_field; /*!< Array to store the gravity potential field */ + double *m_fast_jac; /*!< Array to store the linearized fast-waves Jacobian over the whole domain */ + double *m_solution; /*!< Array to store the reference solution for linearization */ + char m_upw_choice[_MAX_STRING_SIZE_]; /*!< Choice of upwinding scheme.\sa #_ROE_,#_LLF_,#_RF_,#_SWFS_ */ /*! Function pointer to the function that computes the "upwinding" step in source term computation. To understand the implementation of the gravitational source terms, see: diff --git a/include/physicalmodels/euler2d.h b/include/physicalmodels/euler2d.h index 76677487..e9c7c914 100644 --- a/include/physicalmodels/euler2d.h +++ b/include/physicalmodels/euler2d.h @@ -43,7 +43,7 @@ #define _Euler2DGetFlowVar_(u,rho,vx,vy,e,P,p) \ { \ - double gamma = p->gamma, vsq; \ + double gamma = p->m_gamma, vsq; \ rho = u[0]; \ vx = u[1] / rho; \ vy = u[2] / rho; \ @@ -72,7 +72,7 @@ double rho ,vx, vy, e ,P ,H ,csq, vsq; \ double rhoL,vxL,vyL,eL,PL,HL,cLsq,vsqL; \ double rhoR,vxR,vyR,eR,PR,HR,cRsq,vsqR; \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ rhoL = uL[0]; \ vxL = uL[1] / rhoL; \ vyL = uL[2] / rhoL; \ @@ -107,7 +107,7 @@ #define _Euler2DEigenvalues_(u,D,p,dir) \ { \ - double gamma = p->gamma; \ + double gamma = p->m_gamma; \ double rho,vx,vy,e,P,c,vn,vsq; \ rho = u[0]; \ vx = u[1] / rho; \ @@ -134,7 +134,7 @@ #define _Euler2DLeftEigenvectors_(u,L,p,dir) \ { \ - double ga = param->gamma, ga_minus_one=ga-1.0; \ + double ga = param->m_gamma, ga_minus_one=ga-1.0; \ double rho,vx,vy,e,P,a,un,ek,vsq; \ double nx = 0,ny = 0; \ rho = u[0]; \ @@ -188,7 +188,7 @@ #define _Euler2DRightEigenvectors_(u,R,p,dir) \ { \ - double ga = param->gamma, ga_minus_one = ga-1.0; \ + double ga = param->m_gamma, ga_minus_one = ga-1.0; \ double rho,vx,vy,e,P,un,ek,a,h0,vsq; \ double nx = 0,ny = 0; \ rho = u[0]; \ @@ -242,8 +242,8 @@ } typedef struct euler2d_parameters { - double gamma; /* Ratio of heat capacities */ - char upw_choice[_MAX_STRING_SIZE_]; /* choice of upwinding */ + double m_gamma; /* Ratio of heat capacities */ + char m_upw_choice[_MAX_STRING_SIZE_]; /* choice of upwinding */ } Euler2D; int Euler2DInitialize (void*,void*); diff --git a/include/physicalmodels/fpdoublewell.h b/include/physicalmodels/fpdoublewell.h index 373b8262..6be05681 100644 --- a/include/physicalmodels/fpdoublewell.h +++ b/include/physicalmodels/fpdoublewell.h @@ -24,8 +24,8 @@ #define _MODEL_NVARS_ 1 typedef struct fp_double_well_parameters { - double q; /* diffusion coefficient */ - double pdf_integral; /* not an input */ + double m_q; /* diffusion coefficient */ + double m_pdf_integral; /* not an input */ } FPDoubleWell; #define drift(x) (4.0*(x)*(1.0-(x)*(x))) diff --git a/include/physicalmodels/fppowersystem.h b/include/physicalmodels/fppowersystem.h index 5c410d31..28bc44ee 100644 --- a/include/physicalmodels/fppowersystem.h +++ b/include/physicalmodels/fppowersystem.h @@ -52,21 +52,21 @@ typedef struct fp_power_system_parameters { /* input parameters */ - double O_s; + double m_O_s; double H; - double E; - double V; - double g1,g2; + double m_E; + double m_V; + double m_g1,m_g2; double D; double Pm; - double l; - double q; - double tf, tcl; + double m_l; + double m_q; + double m_tf, tcl; /* computed/constant parameters */ double Pmax; - double pdf_integral; /* not an input */ + double m_pdf_integral; /* not an input */ } FPPowerSystem; int FPPowerSystemInitialize (void*,void*); diff --git a/include/physicalmodels/fppowersystem1bus.h b/include/physicalmodels/fppowersystem1bus.h index 589e2d3d..a9627b05 100644 --- a/include/physicalmodels/fppowersystem1bus.h +++ b/include/physicalmodels/fppowersystem1bus.h @@ -83,7 +83,7 @@ typedef struct fp_power_system_1bus_parameters { double omegaB, omegaS, H, D, Pm_avg, Pmax, sigma, lambda; /* calculated, not an input */ - double pdf_integral; + double m_pdf_integral; } FPPowerSystem1Bus; diff --git a/include/physicalmodels/fppowersystem3bus.h b/include/physicalmodels/fppowersystem3bus.h index 0be8634a..82b34c42 100644 --- a/include/physicalmodels/fppowersystem3bus.h +++ b/include/physicalmodels/fppowersystem3bus.h @@ -61,11 +61,11 @@ typedef struct fp_power_system__3bus_parameters { omegaB, /*!< Rotor base angular frequency \f$\omega_B\f$ */ sigma[2][2], /*!< Covariance matrix \f$\sigma\f$ */ lambda[2][2], /*!< Correlation time \f$\lambda\f$ */ - gamma, /*!< Damping rate \f$ \gamma \f$ */ + m_gamma, /*!< Damping rate \f$ \gamma \f$ */ *G, /*!< Conductance matrix \f$ G \f$ */ *B; /*!< Susceptance matrix \f$ B \f$ */ - double pdf_integral; /*!< Integral of the probability density function over the domain */ + double m_pdf_integral; /*!< Integral of the probability density function over the domain */ } FPPowerSystem3Bus; diff --git a/include/physicalmodels/linearadr.h b/include/physicalmodels/linearadr.h index 2cca380d..7ae9c2fa 100644 --- a/include/physicalmodels/linearadr.h +++ b/include/physicalmodels/linearadr.h @@ -37,24 +37,24 @@ typedef struct linearadr_parameters { /*! Is the advection field constant (1) or spatially-varying (0) */ - int constant_advection; + int m_constant_advection; /*! Filename of file to read in spatially-varying advection field from */ - char adv_filename[_MAX_STRING_SIZE_]; + char m_adv_filename[_MAX_STRING_SIZE_]; /*! Size of the advection array: depends on whether advection coeff is constant or spatially-varying */ - int adv_arr_size; + int m_adv_arr_size; /*! advection speed for each variable along each dimension */ - double *a; + double *m_a; /*! diffusion coefficient for each variable along each dimension */ - double *d; + double *m_d; /*! turn off upwinding and just take arithmetic average of left and right biased fluxes? */ - char centered_flux[_MAX_STRING_SIZE_]; + char m_centered_flux[_MAX_STRING_SIZE_]; } LinearADR; diff --git a/include/physicalmodels/navierstokes2d.h b/include/physicalmodels/navierstokes2d.h index 09ef8ae0..e5ff1749 100644 --- a/include/physicalmodels/navierstokes2d.h +++ b/include/physicalmodels/navierstokes2d.h @@ -372,23 +372,23 @@ * the 2D Navier-Stokes equations. */ typedef struct navierstokes2d_parameters { - double gamma; /*!< Ratio of heat capacities */ - char upw_choice[_MAX_STRING_SIZE_]; /*!< choice of upwinding */ - double grav_x, /*!< acceleration due to gravity in x */ - grav_y; /*!< acceleration due to gravity in y */ - double rho0; /*!< reference density at zero altitude for flows with gravity */ - double p0; /*!< reference pressure at zero altitude for flows with gravity */ - double Re; /*!< Reynolds number */ - double Pr; /*!< Prandtl number */ + double m_gamma; /*!< Ratio of heat capacities */ + char m_upw_choice[_MAX_STRING_SIZE_]; /*!< choice of upwinding */ + double m_grav_x, /*!< acceleration due to gravity in x */ + m_grav_y; /*!< acceleration due to gravity in y */ + double m_rho0; /*!< reference density at zero altitude for flows with gravity */ + double m_p0; /*!< reference pressure at zero altitude for flows with gravity */ + double m_Re; /*!< Reynolds number */ + double m_Pr; /*!< Prandtl number */ double Minf; /*!< Freestream Mach number */ double C1, /*!< Sutherlands law constants */ C2; /*!< Sutherlands law constants */ - double R; /*!< universal Gas constant */ + double m_R; /*!< universal Gas constant */ - double *grav_field_f, /*!< density variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ - *grav_field_g; /*!< pressure variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ + double *m_grav_field_f, /*!< density variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ + *m_grav_field_g; /*!< pressure variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ - double *fast_jac, /*!< "Fast" Jacobian of the flux function (comprising the acoustic modes) */ + double *m_fast_jac, /*!< "Fast" Jacobian of the flux function (comprising the acoustic modes) */ *solution; /*!< array to store the solution at the beginning of each time step */ /* choice of hydrostatic balance */ @@ -401,10 +401,10 @@ typedef struct navierstokes2d_parameters { double N_bv; /*!< the Brunt-Vaisala frequency for #NavierStokes2D::HB = 3 */ #if defined(HAVE_CUDA) - double *gpu_grav_field_f; - double *gpu_grav_field_g; - double *gpu_fast_jac; - double *gpu_solution; + double *m_gpu_grav_field_f; + double *m_gpu_grav_field_g; + double *m_gpu_fast_jac; + double *m_gpu_solution; #endif } NavierStokes2D; diff --git a/include/physicalmodels/navierstokes3d.h b/include/physicalmodels/navierstokes3d.h index cab0d184..0834fa53 100644 --- a/include/physicalmodels/navierstokes3d.h +++ b/include/physicalmodels/navierstokes3d.h @@ -480,28 +480,28 @@ * the 3D Navier-Stokes equations. */ typedef struct navierstokes3d_parameters { - double gamma; /*!< Ratio of heat capacities */ - double Re; /*!< Reynolds number */ - double Pr; /*!< Prandtl number */ + double m_gamma; /*!< Ratio of heat capacities */ + double m_Re; /*!< Reynolds number */ + double m_Pr; /*!< Prandtl number */ double Minf; /*!< Freestream Mach number */ double C1, /*!< Sutherlands law constant */ C2; /*!< Sutherlands law constant */ - double grav_x, /*!< acceleration due to gravity in x */ - grav_y, /*!< acceleration due to gravity in y */ - grav_z; /*!< acceleration due to gravity in z */ - double rho0; /*!< reference density at zero altitude for flows with gravity */ - double p0; /*!< reference pressure at zero altitude for flows with gravity */ - double R; /*!< universal Gas constant */ - char upw_choice[_MAX_STRING_SIZE_]; /*!< choice of upwinding */ - - double *grav_field_f, /*!< density variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ - *grav_field_g; /*!< pressure variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ - - double *fast_jac, /*!< "Fast" Jacobian of the flux function (comprising the acoustic modes) */ + double m_grav_x, /*!< acceleration due to gravity in x */ + m_grav_y, /*!< acceleration due to gravity in y */ + m_grav_z; /*!< acceleration due to gravity in z */ + double m_rho0; /*!< reference density at zero altitude for flows with gravity */ + double m_p0; /*!< reference pressure at zero altitude for flows with gravity */ + double m_R; /*!< universal Gas constant */ + char m_upw_choice[_MAX_STRING_SIZE_]; /*!< choice of upwinding */ + + double *m_grav_field_f, /*!< density variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ + *m_grav_field_g; /*!< pressure variation function (\f$\varrho\f$) for hydrostatic equilibrium for flows with gravity */ + + double *m_fast_jac, /*!< "Fast" Jacobian of the flux function (comprising the acoustic modes) */ *solution; /*!< array to store the solution at the beginning of each time step */ /*! Type of immersed boundary wall: isothermal or adiabatic */ - char ib_wall_type[_MAX_STRING_SIZE_]; + char m_ib_wall_type[_MAX_STRING_SIZE_]; /*! Immersed body wall temperature, if isothermal */ double T_ib_wall; @@ -514,21 +514,21 @@ typedef struct navierstokes3d_parameters { 3 - stratified atmosphere with a Brunt-Vaisala frequency) */; double N_bv; /*!< the Brunt-Vaisala frequency for #NavierStokes3D::HB = 3 */ - char ib_write_surface_data[_MAX_STRING_SIZE_]; /*!< Flag to indicate whether to analyze and write surface data for - immersed body, if present. Applicable only if #HyPar::flag_ib is 1 */ + char m_ib_write_surface_data[_MAX_STRING_SIZE_]; /*!< Flag to indicate whether to analyze and write surface data for + immersed body, if present. Applicable only if #HyPar::m_flag_ib is 1 */ /*! Time scale to ramp up the application of immersed boundary conditions, - applicable only if #HyPar::flag_ib is 1 */ - double t_ib_ramp; + applicable only if #HyPar::m_flag_ib is 1 */ + double m_t_ib_ramp; /*! The "gentleness" with which to ramp up the application of immersed boundary conditions, - applicable only if #HyPar::flag_ib is 1 */ - double t_ib_width; + applicable only if #HyPar::m_flag_ib is 1 */ + double m_t_ib_width; /*! Type of ramp up the application of immersed boundary conditions (linear, exponential, etc.), - applicable only if #HyPar::flag_ib is 1 */ - char ib_ramp_type[_MAX_STRING_SIZE_]; + applicable only if #HyPar::m_flag_ib is 1 */ + char m_ib_ramp_type[_MAX_STRING_SIZE_]; /*! Isothermal immersed boundary temperature tolerance: if ghost point temperature differs from wall temperature by more than this factor, set it to the wall @@ -542,10 +542,10 @@ typedef struct navierstokes3d_parameters { double *gpu_QDerivZ; double *gpu_FViscous; double *gpu_FDeriv; - double *gpu_grav_field_f; - double *gpu_grav_field_g; - double *gpu_fast_jac; - double *gpu_solution; + double *m_gpu_grav_field_f; + double *m_gpu_grav_field_g; + double *m_gpu_fast_jac; + double *m_gpu_solution; #endif } NavierStokes3D; diff --git a/include/physicalmodels/numa2d.h b/include/physicalmodels/numa2d.h index a38e4bda..7dd26ca7 100644 --- a/include/physicalmodels/numa2d.h +++ b/include/physicalmodels/numa2d.h @@ -72,22 +72,22 @@ { \ s[0] = 0.0; \ s[1] = 0.0; \ - s[2] = -param->g*drho; \ + s[2] = -param->m_g*drho; \ s[3] = 0.0; \ } #define _Numa2DComputePressure_(params,T0,dT,P0,dP) \ { \ - double gamma = params->gamma; \ + double gamma = params->m_gamma; \ double Pref = params->Pref; \ - double R = params->R; \ + double R = params->m_R; \ double P_total = Pref * raiseto((R*(T0+dT)/Pref),gamma); \ dP = P_total - P0; \ } #define _Numa2DComputeLinearizedPressure_(params,T0,dT,P0,dP) \ { \ - double gamma = params->gamma; \ + double gamma = params->m_gamma; \ dP = (gamma*P0/T0) * dT; \ } @@ -107,11 +107,11 @@ } typedef struct numa2d_parameters { - double gamma; /* Ratio of heat capacities */ - double R; /* Universal gas constant */ - double g; /* acceleration due to gravity */ - int init_atmos; /* choice of initial atmosphere */ - double mu; /* coefficient of dynamic viscosity */ + double m_gamma; /* Ratio of heat capacities */ + double m_R; /* Universal gas constant */ + double m_g; /* acceleration due to gravity */ + int m_init_atmos; /* choice of initial atmosphere */ + double m_mu; /* coefficient of dynamic viscosity */ /* pressure & temperature at zero altitude */ double Pref, Tref; @@ -120,7 +120,7 @@ typedef struct numa2d_parameters { void (*StandardAtmosphere)(void*,double,double*,double*,double*,double*); /* choice of upwinding scheme */ - char upwind[_MAX_STRING_SIZE_]; + char m_upwind[_MAX_STRING_SIZE_]; } Numa2D; int Numa2DInitialize (void*,void*); diff --git a/include/physicalmodels/numa3d.h b/include/physicalmodels/numa3d.h index 86a844cc..e5e94d3e 100644 --- a/include/physicalmodels/numa3d.h +++ b/include/physicalmodels/numa3d.h @@ -94,24 +94,24 @@ #define _Numa3DSetSource_(s,param,uvel,vvel,drho,rho0) \ { \ s[0] = 0.0; \ - s[1] = 2.0*param->Omega*vvel*(rho0+drho); \ - s[2] = -2.0*param->Omega*uvel*(rho0+drho); \ - s[3] = -param->g*drho; \ + s[1] = 2.0*param->m_Omega*vvel*(rho0+drho); \ + s[2] = -2.0*param->m_Omega*uvel*(rho0+drho); \ + s[3] = -param->m_g*drho; \ s[4] = 0.0; \ } #define _Numa3DComputePressure_(params,T0,dT,P0,dP) \ { \ - double gamma = params->gamma; \ + double gamma = params->m_gamma; \ double Pref = params->Pref; \ - double R = params->R; \ + double R = params->m_R; \ double P_total = Pref * raiseto((R*(T0+dT)/Pref),gamma); \ dP = P_total - P0; \ } #define _Numa3DComputeLinearizedPressure_(params,T0,dT,P0,dP) \ { \ - double gamma = params->gamma; \ + double gamma = params->m_gamma; \ dP = (gamma*P0/T0) * dT; \ } @@ -126,11 +126,11 @@ } typedef struct numa3d_parameters { - double gamma; /* Ratio of heat capacities */ - double R; /* Universal gas constant */ - double Omega; /* Angular speed of Earth */ - double g; /* acceleration due to gravity */ - int init_atmos; /* choice of initial atmosphere */ + double m_gamma; /* Ratio of heat capacities */ + double m_R; /* Universal gas constant */ + double m_Omega; /* Angular speed of Earth */ + double m_g; /* acceleration due to gravity */ + int m_init_atmos; /* choice of initial atmosphere */ /* pressure & temperature at zero altitude */ double Pref, Tref; @@ -139,7 +139,7 @@ typedef struct numa3d_parameters { void (*StandardAtmosphere)(void*,double,double*,double*,double*,double*); /* choice of upwinding scheme */ - char upwind[_MAX_STRING_SIZE_]; + char m_upwind[_MAX_STRING_SIZE_]; } Numa3D; int Numa3DInitialize (void*,void*); diff --git a/include/physicalmodels/shallowwater1d.h b/include/physicalmodels/shallowwater1d.h index 4cc0d900..dd7254f0 100644 --- a/include/physicalmodels/shallowwater1d.h +++ b/include/physicalmodels/shallowwater1d.h @@ -94,7 +94,7 @@ { \ double h,v,c; \ _ShallowWater1DGetFlowVar_(u,h,v); \ - c = sqrt(p->g*h); \ + c = sqrt(p->m_g*h); \ D[0*_MODEL_NVARS_+0] = (v+c); D[0*_MODEL_NVARS_+1] = 0; \ D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = (v-c); \ } @@ -118,7 +118,7 @@ { \ double h,v,c; \ _ShallowWater1DGetFlowVar_(u,h,v); \ - c = sqrt(p->g*h); \ + c = sqrt(p->m_g*h); \ R[0*_MODEL_NVARS_+0] = 1.0; \ R[1*_MODEL_NVARS_+0] = v+c; \ R[0*_MODEL_NVARS_+1] = 1.0; \ @@ -135,11 +135,11 @@ * specific to the 1D ShallowWater equations. */ typedef struct shallowwater1d_parameters { - double g; /*!< Acceleration due to gravity */ - int bt_type, /*!< 1 -> bottom topography is periodic, 0 -> bottom topography is not periodic */ - topo_flag; /*!< Flag to indicate if topography file was provided */ - double *b; /*!< Array to store the bottom topography \f$b(x)\f$ */ - char upw_choice[_MAX_STRING_SIZE_]; /*!< Choice of upwinding scheme.\sa #_ROE_, #_LLF_*/ + double m_g; /*!< Acceleration due to gravity */ + int m_bt_type, /*!< 1 -> bottom topography is periodic, 0 -> bottom topography is not periodic */ + m_topo_flag; /*!< Flag to indicate if topography file was provided */ + double *m_b; /*!< Array to store the bottom topography \f$b(x)\f$ */ + char m_upw_choice[_MAX_STRING_SIZE_]; /*!< Choice of upwinding scheme.\sa #_ROE_, #_LLF_*/ /*! Function pointer to the function that computes the "upwinding" step in source term computation. To understand the implementation of the gravitational source terms, see: + Xing, Y., Shu, C.-W., "High order finite difference WENO schemes with the diff --git a/include/physicalmodels/shallowwater2d.h b/include/physicalmodels/shallowwater2d.h index 05656577..e90e6682 100644 --- a/include/physicalmodels/shallowwater2d.h +++ b/include/physicalmodels/shallowwater2d.h @@ -130,7 +130,7 @@ { \ double h,uvel,vvel,c; \ _ShallowWater2DGetFlowVar_(u,h,uvel,vvel); \ - c = sqrt(p->g*h); \ + c = sqrt(p->m_g*h); \ if (dir == _XDIR_) { \ D[0*_MODEL_NVARS_+0] = uvel-c; D[0*_MODEL_NVARS_+1] = 0; D[0*_MODEL_NVARS_+2] = 0; \ D[1*_MODEL_NVARS_+0] = 0; D[1*_MODEL_NVARS_+1] = uvel; D[1*_MODEL_NVARS_+2] = 0; \ @@ -155,7 +155,7 @@ { \ double h,uvel,vvel,c; \ _ShallowWater2DGetFlowVar_(u,h,uvel,vvel); \ - c = sqrt(p->g*h); \ + c = sqrt(p->m_g*h); \ \ if (dir == _XDIR_) { \ L[0*_MODEL_NVARS_+0] = 0.5 + uvel/(2*c); \ @@ -198,7 +198,7 @@ { \ double h,uvel,vvel,c; \ _ShallowWater2DGetFlowVar_(u,h,uvel,vvel); \ - c = sqrt(p->g*h); \ + c = sqrt(p->m_g*h); \ \ if (dir == _XDIR_) { \ R[0*_MODEL_NVARS_+0] = 1.0; \ @@ -238,14 +238,14 @@ * specific to the 2D ShallowWater equations. */ typedef struct shallowwater2d_parameters { - int bt_type, /*!< 1 -> bottom topography is periodic, 0 -> bottom topography is not periodic */ - topo_flag; /*!< Flag to indicate if topography file was provided */ - double g, /*!< Acceleration due to gravity */ - *b, /*!< Array to store the bottom topography \f$b(x,y)\f$ */ + int m_bt_type, /*!< 1 -> bottom topography is periodic, 0 -> bottom topography is not periodic */ + m_topo_flag; /*!< Flag to indicate if topography file was provided */ + double m_g, /*!< Acceleration due to gravity */ + *m_b, /*!< Array to store the bottom topography \f$b(x,y)\f$ */ fhat, /*!< Coriolis parameter */ - beta, /*!< beta-plane approximation parameter for Coriolis force */ + m_beta, /*!< beta-plane approximation parameter for Coriolis force */ D; /*!< Channel width for Coriolis force calculation */ - char upw_choice[_MAX_STRING_SIZE_]; /*!< Choice of upwinding scheme.\sa #_ROE_, #_LLF_*/ + char m_upw_choice[_MAX_STRING_SIZE_]; /*!< Choice of upwinding scheme.\sa #_ROE_, #_LLF_*/ /*! Function pointer to the function that computes the "upwinding" step in source term computation. To understand the implementation of the gravitational source terms, see: + Xing, Y., Shu, C.-W., "High order finite difference WENO schemes with the diff --git a/include/physicalmodels/vlasov.h b/include/physicalmodels/vlasov.h index 848d2351..4b027822 100644 --- a/include/physicalmodels/vlasov.h +++ b/include/physicalmodels/vlasov.h @@ -57,65 +57,65 @@ typedef struct vlasov_parameters { /*! Use a self-consistent electric field? Requires FFTW library */ - int self_consistent_electric_field; + int m_self_consistent_electric_field; /*! Number of spatial dimensions */ - int ndims_x; + int m_ndims_x; /*! Number of velocity dimensions */ - int ndims_v; + int m_ndims_v; /*! Number of spatial grid points (local) */ - int npts_local_x; + int m_npts_local_x; /*! Number of spatial grid points (global) */ - long npts_global_x; + long m_npts_global_x; /*! Number of spatial grid points with ghosts (local) */ - int npts_local_x_wghosts; + int m_npts_local_x_wghosts; /*! Number of spatial grid points with ghosts (global) */ - long npts_global_x_wghosts; + long m_npts_global_x_wghosts; /*! electric field */ - double *e_field; + double *m_e_field; /*! potential field */ - double *potential; + double *m_potential; /*! Pointer to MPI object of type #MPIVariables */ - void *m; + void *m_mpi; /*! Solve Vlasov equation in the log form */ - int use_log_form; + int m_use_log_form; #ifdef fftw /*! Buffer sum */ - double *sum_buffer; + double *m_sum_buffer; /*! Forward FFT plan */ - fftw_plan plan_forward_e; + fftw_plan m_plan_forward_e; /*! Backward FFT plan */ - fftw_plan plan_backward_e; + fftw_plan m_plan_backward_e; /*! buffer */ - fftw_complex *phys_buffer_e; + fftw_complex *m_phys_buffer_e; /*! buffer */ - fftw_complex *fourier_buffer_e; + fftw_complex *m_fourier_buffer_e; /*! */ - ptrdiff_t alloc_local; + ptrdiff_t m_alloc_local; /*! */ - ptrdiff_t local_ni, local_i_start; + ptrdiff_t m_local_ni, m_local_i_start; /*! */ - ptrdiff_t local_no, local_o_start; + ptrdiff_t m_local_no, m_local_o_start; /*! Forward FFT plan */ - fftw_plan plan_forward_phi; + fftw_plan m_plan_forward_phi; /*! Backward FFT plan */ - fftw_plan plan_backward_phi; + fftw_plan m_plan_backward_phi; /*! buffer */ - fftw_complex *phys_buffer_phi; + fftw_complex *m_phys_buffer_phi; /*! buffer */ - fftw_complex *fourier_buffer_phi; + fftw_complex *m_fourier_buffer_phi; #endif } Vlasov; diff --git a/include/single_simulation.h b/include/single_simulation.h index c46dfaeb..53664f8e 100644 --- a/include/single_simulation.h +++ b/include/single_simulation.h @@ -147,7 +147,7 @@ class SingleSimulation : public Simulation /*! Create duplicate MPI communicators */ inline int mpiCommDup() { - MPI_Comm_dup(MPI_COMM_WORLD, &(m_sim->mpi.world)); + MPI_Comm_dup(MPI_COMM_WORLD, &(m_sim->mpi.m_world)); return 0; } #endif @@ -156,7 +156,7 @@ class SingleSimulation : public Simulation /*! Set flag whether to use PETSc time integration */ inline void usePetscTS(PetscBool a_flag) { - m_sim->solver.use_petscTS = a_flag; + m_sim->solver.m_use_petsc_ts = a_flag; } /*! Run the simulation using PETSc time integrators */ diff --git a/include/sparse_grids_simulation.h b/include/sparse_grids_simulation.h index 7e931b5a..6fa70983 100644 --- a/include/sparse_grids_simulation.h +++ b/include/sparse_grids_simulation.h @@ -105,8 +105,8 @@ class SparseGridsSimulation : public Simulation if (m_nsims_sg > 0) { m_is_periodic.resize(m_ndims); for (int d=0; dsolver.isPeriodic[d] = m_sims_sg[0].solver.isPeriodic[d]; + m_is_periodic[d] = ( m_sims_sg[0].solver.m_is_periodic[d] == 1 ? true : false); + m_sim_fg->solver.m_is_periodic[d] = m_sims_sg[0].solver.m_is_periodic[d]; } } return retval; @@ -135,11 +135,11 @@ class SparseGridsSimulation : public Simulation int retval = ::InitializePhysicsData( (void*) &(m_sims_sg[ns]), -1, m_nsims_sg, - m_sim_fg->solver.dim_global); + m_sim_fg->solver.m_dim_global); if (retval) { fprintf(stderr, "Error in SparseGridsSimulation::InitializePhysicsData()\n"); fprintf(stderr, " InitializePhysicsData returned with error code %d on rank %d.\n", - retval, m_sims_sg[ns].mpi.rank); + retval, m_sims_sg[ns].mpi.m_rank); return retval; } } @@ -155,11 +155,11 @@ class SparseGridsSimulation : public Simulation /* some modifications to output filename roots */ for (int i=0; isolver.op_fname_root, "op_fg"); - strcpy(m_sim_fg->solver.aux_op_fname_root, "ts0_fg"); + strcpy(m_sim_fg->solver.m_op_fname_root, "op_fg"); + strcpy(m_sim_fg->solver.m_aux_op_fname_root, "ts0_fg"); return retval; } @@ -184,7 +184,7 @@ class SparseGridsSimulation : public Simulation fprintf(stderr, " m_sim_fg is not allocated on rank %d!\n", m_rank); return 1; } - MPI_Comm_dup(MPI_COMM_WORLD, &(m_sim_fg->mpi.world)); + MPI_Comm_dup(MPI_COMM_WORLD, &(m_sim_fg->mpi.m_world)); return 0; } #endif @@ -193,7 +193,7 @@ class SparseGridsSimulation : public Simulation /*! Set flag whether to use PETSc time integration */ inline void usePetscTS(PetscBool a_flag) { - m_sim_fg->solver.use_petscTS = a_flag; + m_sim_fg->solver.m_use_petsc_ts = a_flag; } /*! Run the simulation using PETSc time integrators */ @@ -302,7 +302,7 @@ class SparseGridsSimulation : public Simulation int ); /*! Fill ghost cells for interpolation */ - void fillGhostCells( const GridDimensions&, + void FillGhostCells( const GridDimensions&, const int, double* const, const int ); diff --git a/include/timeintegration_struct.h b/include/timeintegration_struct.h index f229181a..ec479310 100644 --- a/include/timeintegration_struct.h +++ b/include/timeintegration_struct.h @@ -28,69 +28,69 @@ */ typedef struct time_integration_variables { /*! Current iteration number */ - int iter; + int m_iter; /*! Total number of iterations */ - int n_iter; + int m_n_iter; /*! Restart iteration number (0 for a non-restart simulation) */ - int restart_iter; + int m_restart_iter; /*! Current solution time */ - double waqt; + double m_waqt; /*! Time step size */ - double dt; + double m_dt; /*! Norm of the change in the solution at a time step */ - double norm; + double m_norm; /*! Maximum CFL at a time step */ - double max_cfl; + double m_max_cfl; /*! Maximum diffusion number at a time step */ - double max_diff; + double m_max_diff; /*! Array of simulation objects of type #SimulationObject */ - void *simulation; + void *m_simulation; /*! Number of simulation objects */ - int nsims; + int m_nsims; /*! Offsets (positions) for the solution of each simulation domain in * the big array containing all the solutions */ - long *u_offsets; + long *m_u_offsets; /*! Local size of the solution of each simulation domain */ - long *u_sizes; + long *m_u_sizes; /*! Offsets (positions) for the boundary flux of each simulation domain in * the big array containing all the boundary fluxes */ - int *bf_offsets; + int *m_bf_offsets; /*! Size of the boundary flux of each simulation domain */ - int *bf_sizes; + int *m_bf_sizes; /*! Array to store the current solution */ - double *u; + double *m_u; /*! Array to store the right-hand side */ - double *rhs; + double *m_rhs; /*! Local size of the solution vector */ - long u_size_total; + long m_u_size_total; /*! Local size of the boundary flux vector */ - long bf_size_total; + long m_bf_size_total; /*! Arrays to store stage values for a multi-stage time-integration method */ - double **U; + double **m_U; /*! Arrays to store stage right-hand-sides for a multi-stage time-integration method */ - double **Udot; + double **m_Udot; /*! MPI rank of this process */ - int rank; + int m_rank; /*! Number of MPI processes */ - int nproc; + int m_nproc; /*! Array to store the flux integral at the physical boundary at each stage of a multi-stage time-integration method (to compute conservation errors) */ - double **BoundaryFlux; + double **m_BoundaryFlux; /*! Pointer to file to write residual history if required */ - void *ResidualFile; + void *m_ResidualFile; /*! Pointer to the function that takes one time step using the desired method */ int (*TimeIntegrate) (void*); @@ -98,21 +98,21 @@ typedef struct time_integration_variables { int (*RHSFunction) (double*,double*,void*,void*,double); /*! iteration start time */ - struct timeval iter_start_time; + struct timeval m_iter_start_time; /*! iteration end time */ - struct timeval iter_end_time; + struct timeval m_iter_end_time; /*! iteration wallclock time (in seconds) */ - double iter_wctime; - double iter_wctime_total; + double m_iter_wctime; + double m_iter_wctime_total; #if defined(HAVE_CUDA) /*! Arrays to store stage values for a multi-stage time-integration method */ - double *gpu_U; + double *m_gpu_U; /*! Arrays to store stage right-hand-sides for a multi-stage time-integration method */ - double *gpu_Udot; + double *m_gpu_Udot; /*! Array to store the flux integral at the physical boundary at each stage of a multi-stage time-integration method (to compute conservation errors) */ - double *gpu_BoundaryFlux; + double *m_gpu_BoundaryFlux; #endif } TimeIntegration; diff --git a/include/tridiagLU.h b/include/tridiagLU.h index b9a34208..5f1c5d8a 100644 --- a/include/tridiagLU.h +++ b/include/tridiagLU.h @@ -10,7 +10,7 @@ Parallel direct solver for tridiagonal systems - tridiagLU (a,b,c,x,n,ns,r,m) - Parallel tridiagonal solver + TridiagLU(a,b,c,x,n,ns,r,m) - Parallel tridiagonal solver Solves the tridiagonal system in parallel by reordering the points such that the first point of each subdomain is placed @@ -24,7 +24,7 @@ solve (tridiagLUGS) or the recursive-doubling (tridiagLURD) algorithms. - tridiagLUGS(a,b,c,x,n,ns,r,m) - Tridiagonal solver based on + TridiagLUGS(a,b,c,x,n,ns,r,m) - Tridiagonal solver based on "gather and solve" Each of the "ns" systems is gathered on one processor, @@ -70,7 +70,7 @@ */ -/*! Jacobi method \sa tridiagIterJacobi(), blocktridiagIterJacobi() */ +/*! Jacobi method \sa TridiagIterJacobi(), BlockTridiagIterJacobi() */ #define _TRIDIAG_JACOBI_ "jacobi" /*! "Gather-and-solve" method \sa tridiagLUGS */ #define _TRIDIAG_GS_ "gather-and-solve" @@ -83,46 +83,46 @@ */ typedef struct _tridiagLU_ { - /* Parameters for tridiagLU() */ + /* Parameters for TridiagLU() */ /*! Choice of solver for solving the reduced system. May be #_TRIDIAG_JACOBI_ or #_TRIDIAG_GS_. */ - char reducedsolvetype[50]; - - int evaluate_norm; /*!< calculate norm at each iteration? (relevant only for iterative solvers) */ - int maxiter; /*!< maximum number of iterations (relevant only for iterative solvers) */ - double atol, /*!< absolute tolerance (relevant only for iterative solvers) */ - rtol; /*!< relative tolerace (relevant only for iterative solvers) */ - int exititer; /*!< number of iterations it ran for (relevant only for iterative solvers) */ - double exitnorm; /*!< error norm at exit (relevant only for iterative solvers) */ - int verbose; /*!< print iterations and norms (relevant only for iterative solvers) */ - - double total_time; /*!< Total wall time in seconds */ - double stage1_time; /*!< Wall time (in seconds) for stage 1 of tridiagLU() or blocktridiagLU() */ - double stage2_time; /*!< Wall time (in seconds) for stage 2 of tridiagLU() or blocktridiagLU() */ - double stage3_time; /*!< Wall time (in seconds) for stage 3 of tridiagLU() or blocktridiagLU() */ - double stage4_time; /*!< Wall time (in seconds) for stage 4 of tridiagLU() or blocktridiagLU() */ + char m_reducedsolvetype[50]; + + int m_evaluate_norm; /*!< calculate norm at each iteration? (relevant only for iterative solvers) */ + int m_maxiter; /*!< maximum number of iterations (relevant only for iterative solvers) */ + double m_atol, /*!< absolute tolerance (relevant only for iterative solvers) */ + m_rtol; /*!< relative tolerace (relevant only for iterative solvers) */ + int m_exititer; /*!< number of iterations it ran for (relevant only for iterative solvers) */ + double m_exitnorm; /*!< error norm at exit (relevant only for iterative solvers) */ + int m_verbose; /*!< print iterations and norms (relevant only for iterative solvers) */ + + double m_total_time; /*!< Total wall time in seconds */ + double m_stage1_time; /*!< Wall time (in seconds) for stage 1 of TridiagLU() or BlockTridiagLU() */ + double m_stage2_time; /*!< Wall time (in seconds) for stage 2 of TridiagLU() or BlockTridiagLU() */ + double m_stage3_time; /*!< Wall time (in seconds) for stage 3 of TridiagLU() or BlockTridiagLU() */ + double m_stage4_time; /*!< Wall time (in seconds) for stage 4 of TridiagLU() or BlockTridiagLU() */ #ifdef with_scalapack - int blacs_ctxt; /*!< Context variable for ScaLAPACK (relevant if compiled with ScaLAPACK + int m_blacs_ctxt; /*!< Context variable for ScaLAPACK (relevant if compiled with ScaLAPACK support (-Dwith_scalapack) \sa tridiagScaLPK */ #endif -} TridiagLU; +} TridiagLU_Params; -int tridiagLU (double*,double*,double*,double*,int,int,void*,void*); -int tridiagLUGS (double*,double*,double*,double*,int,int,void*,void*); -int tridiagIterJacobi (double*,double*,double*,double*,int,int,void*,void*); -int tridiagLUInit (void*,void*); +int TridiagLU(double*,double*,double*,double*,int,int,void*,void*); +int TridiagLUGS(double*,double*,double*,double*,int,int,void*,void*); +int TridiagIterJacobi(double*,double*,double*,double*,int,int,void*,void*); +int TridiagLUInit(void*,void*); /* Block solvers */ -int blocktridiagLU (double*,double*,double*,double*,int,int,int,void*,void*); -int blocktridiagIterJacobi (double*,double*,double*,double*,int,int,int,void*,void*); +int BlockTridiagLU(double*,double*,double*,double*,int,int,int,void*,void*); +int BlockTridiagIterJacobi(double*,double*,double*,double*,int,int,int,void*,void*); #ifdef with_scalapack /* ScaLAPACK interface */ -int tridiagScaLPK (double*,double*,double*,double*,int,int,void*,void*); +int TridiagScaLPK(double*,double*,double*,double*,int,int,void*,void*); #endif #endif diff --git a/src/BandedMatrix/BandedMatrixDestroy.c b/src/BandedMatrix/BandedMatrixDestroy.c index 71a9ee41..45e8757f 100644 --- a/src/BandedMatrix/BandedMatrixDestroy.c +++ b/src/BandedMatrix/BandedMatrixDestroy.c @@ -7,13 +7,13 @@ #include /*! Free up allocations inside a banded matrix object */ -int BandedMatrixDestroy(void *A /*!< Banded matrix object of type #BandedMatrix */) +int BandedMatrixDestroy(void *a_A /*!< Banded matrix object of type #BandedMatrix */) { - BandedMatrix *B = (BandedMatrix*) A; + BandedMatrix *B = (BandedMatrix*) a_A; - if (B->ncol) free(B->ncol); - if (B->nrow) free(B->nrow); - if (B->data) free(B->data); + if (B->m_ncol) free(B->m_ncol); + if (B->m_nrow) free(B->m_nrow); + if (B->m_data) free(B->m_data); return(0); } diff --git a/src/BandedMatrix/BandedMatrixInitialize.c b/src/BandedMatrix/BandedMatrixInitialize.c index f460ce00..a01c3cc5 100644 --- a/src/BandedMatrix/BandedMatrixInitialize.c +++ b/src/BandedMatrix/BandedMatrixInitialize.c @@ -7,17 +7,17 @@ #include /*! Initialize a newly-created banded matrix object. */ -int BandedMatrixInitialize(void *A /*!< Banded matrix object of type BandedMatrix*/) +int BandedMatrixInitialize(void *a_A /*!< Banded matrix object of type BandedMatrix*/) { - BandedMatrix *B = (BandedMatrix*) A; + BandedMatrix *B = (BandedMatrix*) a_A; - B->nbands = 0; - B->nrows_local = 0; - B->BlockSize = 0; + B->m_nbands = 0; + B->m_nrows_local = 0; + B->m_BlockSize = 0; - B->ncol = NULL; - B->nrow = NULL; - B->data = NULL; + B->m_ncol = NULL; + B->m_nrow = NULL; + B->m_data = NULL; return(0); } diff --git a/src/BandedMatrix/BandedMatrixPreallocate.c b/src/BandedMatrix/BandedMatrixPreallocate.c index 229696cb..c082e264 100644 --- a/src/BandedMatrix/BandedMatrixPreallocate.c +++ b/src/BandedMatrix/BandedMatrixPreallocate.c @@ -8,21 +8,21 @@ /*! Preallocate memory for a banded matrix object. */ int BandedMatrixPreallocate( - void *A, /*!< Banded matrix object of the type BandedMatrix */ - int nbands, /*!< Number of bands */ - int nrows_local, /*!< Local number of rows */ - int BlockSize /*!< Block size */ + void *a_A, /*!< Banded matrix object of the type BandedMatrix */ + int a_nbands, /*!< Number of bands */ + int a_nrows_local, /*!< Local number of rows */ + int a_BlockSize /*!< Block size */ ) { - BandedMatrix *B = (BandedMatrix*) A; + BandedMatrix *B = (BandedMatrix*) a_A; - B->nbands = nbands; - B->nrows_local = nrows_local; - B->BlockSize = BlockSize; + B->m_nbands = a_nbands; + B->m_nrows_local = a_nrows_local; + B->m_BlockSize = a_BlockSize; - B->ncol = (int*) calloc (nrows_local*nbands, sizeof(int)); - B->nrow = (int*) calloc (nrows_local, sizeof(int)); - B->data = (double*) calloc (nrows_local*nbands*BlockSize*BlockSize, sizeof(double)); + B->m_ncol = (int*) calloc (a_nrows_local*a_nbands, sizeof(int)); + B->m_nrow = (int*) calloc (a_nrows_local, sizeof(int)); + B->m_data = (double*) calloc (a_nrows_local*a_nbands*a_BlockSize*a_BlockSize, sizeof(double)); return(0); } diff --git a/src/BoundaryConditions/BCCleanup.c b/src/BoundaryConditions/BCCleanup.c index 80077808..f2af9217 100644 --- a/src/BoundaryConditions/BCCleanup.c +++ b/src/BoundaryConditions/BCCleanup.c @@ -9,31 +9,31 @@ #include /*! Cleans up a boundary object of type #DomainBoundary */ -int BCCleanup( void *b, /*!< Boundary object of type #DomainBoundary*/ - int flag_gpu /*!< Flag indicating if GPU is being used */ ) +int BCCleanup( void *a_b, /*!< Boundary object of type #DomainBoundary*/ + int a_flag_gpu /*!< Flag indicating if GPU is being used */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; - free(boundary->xmin); - free(boundary->xmax); - free(boundary->is); - free(boundary->ie); - if (boundary->DirichletValue) free(boundary->DirichletValue); - if (boundary->SpongeValue ) free(boundary->SpongeValue ); - if (boundary->FlowVelocity ) free(boundary->FlowVelocity ); + DomainBoundary *boundary = (DomainBoundary*) a_b; + free(boundary->m_xmin); + free(boundary->m_xmax); + free(boundary->m_is); + free(boundary->m_ie); + if (boundary->m_DirichletValue) free(boundary->m_DirichletValue); + if (boundary->m_SpongeValue ) free(boundary->m_SpongeValue ); + if (boundary->m_FlowVelocity ) free(boundary->m_FlowVelocity ); - if (boundary->UnsteadyDirichletSize) free(boundary->UnsteadyDirichletSize); - if (boundary->UnsteadyDirichletData) free(boundary->UnsteadyDirichletData); + if (boundary->m_UnsteadyDirichletSize) free(boundary->m_UnsteadyDirichletSize); + if (boundary->m_UnsteadyDirichletData) free(boundary->m_UnsteadyDirichletData); - if (boundary->UnsteadyTemperatureSize) free(boundary->UnsteadyTemperatureSize); - if (boundary->UnsteadyTimeLevels) free(boundary->UnsteadyTimeLevels); - if (boundary->UnsteadyTemperatureData) free(boundary->UnsteadyTemperatureData); + if (boundary->m_UnsteadyTemperatureSize) free(boundary->m_UnsteadyTemperatureSize); + if (boundary->m_UnsteadyTimeLevels) free(boundary->m_UnsteadyTimeLevels); + if (boundary->m_UnsteadyTemperatureData) free(boundary->m_UnsteadyTemperatureData); #if defined(HAVE_CUDA) - if (flag_gpu) { - gpuFree(boundary->gpu_bounds); - gpuFree(boundary->gpu_is); - gpuFree(boundary->gpu_ie); - if (boundary->FlowVelocity) gpuFree(boundary->gpu_FlowVelocity ); + if (a_flag_gpu) { + gpuFree(boundary->m_gpu_bounds); + gpuFree(boundary->m_gpu_is); + gpuFree(boundary->m_gpu_ie); + if (boundary->m_FlowVelocity) gpuFree(boundary->m_gpu_FlowVelocity ); } #endif diff --git a/src/BoundaryConditions/BCDirichlet.c b/src/BoundaryConditions/BCDirichlet.c index f6a22776..9593e942 100644 --- a/src/BoundaryConditions/BCDirichlet.c +++ b/src/BoundaryConditions/BCDirichlet.c @@ -11,27 +11,27 @@ /*! Applies (steady) Dirichlet boundary conditions for the solution: the ghost points at the physical boundaries are set to specified values */ int BCDirichletU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { - int p; _ArrayIndex1DWO_(ndims,size ,indexb,boundary->is,ghosts,p); - _ArrayCopy1D_((boundary->DirichletValue),(phi+nvars*p),nvars); - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + int p; _ArrayIndex1DWO_(a_ndims,a_size ,indexb,boundary->m_is,a_ghosts,p); + _ArrayCopy1D_((boundary->m_DirichletValue),(a_phi+a_nvars*p),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } return(0); diff --git a/src/BoundaryConditions/BCExtrapolate.c b/src/BoundaryConditions/BCExtrapolate.c index ff8a2239..73016fcd 100644 --- a/src/BoundaryConditions/BCExtrapolate.c +++ b/src/BoundaryConditions/BCExtrapolate.c @@ -11,37 +11,37 @@ /*! Apply the extrapolative boundary condition: Values at the physical boundary ghost points are extrapolated from the interior points adjacent to the boundary */ int BCExtrapolateU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); int p1,p2; - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); - _ArrayCopy1D_((phi+nvars*p2),(phi+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); + _ArrayCopy1D_((a_phi+a_nvars*p2),(a_phi+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } return(0); diff --git a/src/BoundaryConditions/BCIO.c b/src/BoundaryConditions/BCIO.c index 12cd82fe..d5267f0a 100644 --- a/src/BoundaryConditions/BCIO.c +++ b/src/BoundaryConditions/BCIO.c @@ -16,21 +16,21 @@ \n\n This function needs to be better documented. */ -int BCReadTurbulentInflowData(void *b,void *m,int ndims,int nvars,int *DomainSize) +int BCReadTurbulentInflowData(void *a_b,void *a_m,int a_ndims,int a_nvars,int *a_DomainSize) { - DomainBoundary *boundary = (DomainBoundary*) b; - MPIVariables *mpi = (MPIVariables*) m; + DomainBoundary *boundary = (DomainBoundary*) a_b; + MPIVariables *mpi = (MPIVariables*) a_m; - char *filename = boundary->UnsteadyDirichletFilename; + char *filename = boundary->m_UnsteadyDirichletFilename; int *inflow_size = NULL; double *inflow_data = NULL; double *buffer = NULL; - int dim = boundary->dim; - int face= boundary->face; + int dim = boundary->m_dim; + int face= boundary->m_face; int d; - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Reading turbulent inflow boundary data from %s.\n",filename); @@ -39,7 +39,7 @@ int BCReadTurbulentInflowData(void *b,void *m,int ndims,int nvars,int *DomainSiz /* calculate the number of processors that sit on unsteady boundary */ int nproc = 1; - for (d=0; diproc[d]; nproc /= mpi->iproc[dim]; + for (d=0; dm_iproc[d]; nproc /= mpi->m_iproc[dim]; in = fopen(filename,"rb"); if (!in) { @@ -48,30 +48,30 @@ int BCReadTurbulentInflowData(void *b,void *m,int ndims,int nvars,int *DomainSiz } int count = 0; while ((!feof(in)) && (count < nproc)) { - int rank[ndims], size[ndims]; - ferr = fread(rank,sizeof(int),ndims,in); - if (ferr != ndims) { + int rank[a_ndims], size[a_ndims]; + ferr = fread(rank,sizeof(int),a_ndims,in); + if (ferr != a_ndims) { fprintf(stderr,"Error in BCReadTurbulentInflowData(): Error (1) in file reading, count %d.\n",count); return(1); } - if (rank[dim] != (face > 0 ? 0 : mpi->iproc[dim]-1) ) { + if (rank[dim] != (face > 0 ? 0 : mpi->m_iproc[dim]-1) ) { fprintf(stderr,"Error in BCReadTurbulentInflowData(): Error (2) in file reading, count %d.\n",count); return(1); } - ferr = fread(size,sizeof(int),ndims,in); - if (ferr != ndims) { + ferr = fread(size,sizeof(int),a_ndims,in); + if (ferr != a_ndims) { fprintf(stderr,"Error in BCReadTurbulentInflowData(): Error (3) in file reading, count %d.\n",count); return(1); } int flag = 1; - for (d=0; diproc,rank); + int rank1D = MPIRank1D(a_ndims,mpi->m_iproc,rank); if (!rank1D) { - int index[ndims]; - inflow_size = (int*) calloc (ndims, sizeof(int)); - _ArrayCopy1D_(size,inflow_size,ndims); + int index[a_ndims]; + inflow_size = (int*) calloc (a_ndims, sizeof(int)); + _ArrayCopy1D_(size,inflow_size,a_ndims); inflow_data = (double*) calloc (data_size, sizeof(double)); - ArrayCopynD(ndims,buffer,inflow_data,size,0,0,index,nvars); + ArrayCopynD(a_ndims,buffer,inflow_data,size,0,0,index,a_nvars); } else { #ifndef serial MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - MPI_Isend(size,ndims,MPI_INT,rank1D,2152,mpi->world,&req[0]); - MPI_Isend(buffer,data_size,MPI_DOUBLE,rank1D,2153,mpi->world,&req[1]); + MPI_Isend(size,a_ndims,MPI_INT,rank1D,2152,mpi->m_world,&req[0]); + MPI_Isend(buffer,data_size,MPI_DOUBLE,rank1D,2153,mpi->m_world,&req[1]); MPI_Status status_arr[3]; MPI_Waitall(2,&req[0],status_arr); #else @@ -116,15 +116,15 @@ int BCReadTurbulentInflowData(void *b,void *m,int ndims,int nvars,int *DomainSiz } else { #ifndef serial - if (mpi->ip[dim] == (face > 0 ? 0 : mpi->iproc[dim]-1) ) { + if (mpi->m_ip[dim] == (face > 0 ? 0 : mpi->m_iproc[dim]-1) ) { MPI_Request req = MPI_REQUEST_NULL; - inflow_size = (int*) calloc (ndims,sizeof(int)); - MPI_Irecv(inflow_size,ndims,MPI_INT,0,2152,mpi->world,&req); + inflow_size = (int*) calloc (a_ndims,sizeof(int)); + MPI_Irecv(inflow_size,a_ndims,MPI_INT,0,2152,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); - int data_size = nvars; - for (d=0; dworld,&req); + MPI_Irecv(inflow_data,data_size,MPI_DOUBLE,0,2153,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); } #else @@ -132,8 +132,8 @@ int BCReadTurbulentInflowData(void *b,void *m,int ndims,int nvars,int *DomainSiz #endif } - boundary->UnsteadyDirichletSize = inflow_size; - boundary->UnsteadyDirichletData = inflow_data; + boundary->m_UnsteadyDirichletSize = inflow_size; + boundary->m_UnsteadyDirichletData = inflow_data; return(0); } @@ -144,23 +144,23 @@ int BCReadTurbulentInflowData(void *b,void *m,int ndims,int nvars,int *DomainSiz \n\n This function needs to be better documented. */ -int BCReadTemperatureData(void *b,void *m,int ndims,int nvars,int *DomainSize) +int BCReadTemperatureData(void *a_b,void *a_m,int a_ndims,int a_nvars,int *a_DomainSize) { - DomainBoundary *boundary = (DomainBoundary*) b; - MPIVariables *mpi = (MPIVariables*) m; + DomainBoundary *boundary = (DomainBoundary*) a_b; + MPIVariables *mpi = (MPIVariables*) a_m; - char *filename = boundary->UnsteadyTemperatureFilename; + char *filename = boundary->m_UnsteadyTemperatureFilename; int *temperature_field_size = NULL; double *time_level_data = NULL; double *temperature_field_data = NULL; double *time_buffer = NULL; double *data_buffer = NULL; - int dim = boundary->dim; - int face= boundary->face; + int dim = boundary->m_dim; + int face= boundary->m_face; int d; - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Reading boundary temperature data from %s.\n",filename); @@ -169,7 +169,7 @@ int BCReadTemperatureData(void *b,void *m,int ndims,int nvars,int *DomainSize) /* calculate the number of processors that sit on this temperature boundary */ int nproc = 1; - for (d=0; diproc[d]; nproc /= mpi->iproc[dim]; + for (d=0; dm_iproc[d]; nproc /= mpi->m_iproc[dim]; in = fopen(filename,"rb"); if (!in) { @@ -180,18 +180,18 @@ int BCReadTemperatureData(void *b,void *m,int ndims,int nvars,int *DomainSize) int count = 0; while ((!feof(in)) && (count < nproc)) { - int rank[ndims], size[ndims]; - ferr = fread(rank,sizeof(int),ndims,in); - if (ferr != ndims) { + int rank[a_ndims], size[a_ndims]; + ferr = fread(rank,sizeof(int),a_ndims,in); + if (ferr != a_ndims) { fprintf(stderr,"Error in BCReadTemperatureData(): Error (1) in file reading, count %d.\n",count); return(1); } - if (rank[dim] != (face > 0 ? 0 : mpi->iproc[dim]-1) ) { + if (rank[dim] != (face > 0 ? 0 : mpi->m_iproc[dim]-1) ) { fprintf(stderr,"Error in BCReadTemperatureData(): Error (2) in file reading, count %d.\n",count); return(1); } - ferr = fread(size,sizeof(int),ndims,in); - if (ferr != ndims) { + ferr = fread(size,sizeof(int),a_ndims,in); + if (ferr != a_ndims) { fprintf(stderr,"Error in BCReadTemperatureData(): Error (3) in file reading, count %d.\n",count); return(1); } @@ -205,7 +205,7 @@ int BCReadTemperatureData(void *b,void *m,int ndims,int nvars,int *DomainSize) } int data_size = 1; - for (d=0; diproc,rank); + int rank1D = MPIRank1D(a_ndims,mpi->m_iproc,rank); if (!rank1D) { - int index[ndims]; + int index[a_ndims]; - temperature_field_size = (int*) calloc (ndims, sizeof(int)); - _ArrayCopy1D_(size,temperature_field_size,ndims); + temperature_field_size = (int*) calloc (a_ndims, sizeof(int)); + _ArrayCopy1D_(size,temperature_field_size,a_ndims); time_level_data = (double*) calloc (size[dim], sizeof(double)); _ArrayCopy1D_(time_buffer,time_level_data,size[dim]); temperature_field_data = (double*) calloc (data_size, sizeof(double)); - ArrayCopynD(ndims,data_buffer,temperature_field_data,size,0,0,index,1); + ArrayCopynD(a_ndims,data_buffer,temperature_field_data,size,0,0,index,1); } else { #ifndef serial MPI_Request req[3] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - MPI_Isend(size,ndims,MPI_INT,rank1D,2152,mpi->world,&req[0]); - MPI_Isend(time_buffer,size[dim],MPI_DOUBLE,rank1D,2154,mpi->world,&req[2]); - MPI_Isend(data_buffer,data_size,MPI_DOUBLE,rank1D,2153,mpi->world,&req[1]); + MPI_Isend(size,a_ndims,MPI_INT,rank1D,2152,mpi->m_world,&req[0]); + MPI_Isend(time_buffer,size[dim],MPI_DOUBLE,rank1D,2154,mpi->m_world,&req[2]); + MPI_Isend(data_buffer,data_size,MPI_DOUBLE,rank1D,2153,mpi->m_world,&req[1]); MPI_Status status_arr[3]; MPI_Waitall(3,&req[0],status_arr); #else @@ -260,29 +260,29 @@ int BCReadTemperatureData(void *b,void *m,int ndims,int nvars,int *DomainSize) } else { #ifndef serial - if (mpi->ip[dim] == (face > 0 ? 0 : mpi->iproc[dim]-1) ) { + if (mpi->m_ip[dim] == (face > 0 ? 0 : mpi->m_iproc[dim]-1) ) { MPI_Request req = MPI_REQUEST_NULL; - temperature_field_size = (int*) calloc (ndims,sizeof(int)); - MPI_Irecv(temperature_field_size,ndims,MPI_INT,0,2152,mpi->world,&req); + temperature_field_size = (int*) calloc (a_ndims,sizeof(int)); + MPI_Irecv(temperature_field_size,a_ndims,MPI_INT,0,2152,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); int flag = 1; - for (d=0; drank); + fprintf(stderr,"Error in BCReadTemperatureData(): Error (4) (dimension mismatch) in file reading, rank %d.\n",mpi->m_rank); return(1); } time_level_data = (double*) calloc (temperature_field_size[dim],sizeof(double)); - MPI_Irecv(time_level_data, temperature_field_size[dim], MPI_DOUBLE,0,2154,mpi->world,&req); + MPI_Irecv(time_level_data, temperature_field_size[dim], MPI_DOUBLE,0,2154,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); int data_size = 1; - for (d=0; dworld,&req); + MPI_Irecv(temperature_field_data,data_size,MPI_DOUBLE,0,2153,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); } @@ -292,9 +292,9 @@ int BCReadTemperatureData(void *b,void *m,int ndims,int nvars,int *DomainSize) } - boundary->UnsteadyTemperatureSize = temperature_field_size; - boundary->UnsteadyTimeLevels = time_level_data; - boundary->UnsteadyTemperatureData = temperature_field_data; + boundary->m_UnsteadyTemperatureSize = temperature_field_size; + boundary->m_UnsteadyTimeLevels = time_level_data; + boundary->m_UnsteadyTemperatureData = temperature_field_data; return(0); } diff --git a/src/BoundaryConditions/BCInitialize.c b/src/BoundaryConditions/BCInitialize.c index 03f03b31..fad49f1c 100644 --- a/src/BoundaryConditions/BCInitialize.c +++ b/src/BoundaryConditions/BCInitialize.c @@ -9,47 +9,47 @@ /*! Assign the function pointers for boundary condition application depending on the boundary type, for a given boundary object */ -int BCInitialize( void *b, /*!< Boundary object of type #DomainBoundary*/ - int flag_gpu /*!< Flag to indicate if GPU is being used */ ) +int BCInitialize( void *a_b, /*!< Boundary object of type #DomainBoundary*/ + int a_flag_gpu /*!< Flag to indicate if GPU is being used */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; #if defined(HAVE_CUDA) - if (flag_gpu) { + if (a_flag_gpu) { - if (!strcmp(boundary->bctype,_PERIODIC_)) { + if (!strcmp(boundary->m_bctype,_PERIODIC_)) { boundary->BCFunctionU = gpuBCPeriodicU; - } else if (!strcmp(boundary->bctype,_SLIP_WALL_)) { + } else if (!strcmp(boundary->m_bctype,_SLIP_WALL_)) { boundary->BCFunctionU = gpuBCSlipWallU; } else { fprintf(stderr,"[GPU] Error in BCInitialize(): \"%s\" is not a supported boundary condition.\n", - boundary->bctype); + boundary->m_bctype); return 1; } } else { #endif - if (!strcmp(boundary->bctype,_PERIODIC_ )) boundary->BCFunctionU = BCPeriodicU; - else if (!strcmp(boundary->bctype,_EXTRAPOLATE_ )) boundary->BCFunctionU = BCExtrapolateU; - else if (!strcmp(boundary->bctype,_DIRICHLET_ )) boundary->BCFunctionU = BCDirichletU; - else if (!strcmp(boundary->bctype,_REFLECT_ )) boundary->BCFunctionU = BCReflectU; - else if (!strcmp(boundary->bctype,_SPONGE_ )) boundary->BCFunctionU = BCSpongeUDummy; - else if (!strcmp(boundary->bctype,_NOSLIP_WALL_ )) boundary->BCFunctionU = BCNoslipWallU; - else if (!strcmp(boundary->bctype,_SLIP_WALL_ )) boundary->BCFunctionU = BCSlipWallU; - else if (!strcmp(boundary->bctype,_THERMAL_SLIP_WALL_ )) boundary->BCFunctionU = BCThermalSlipWallU; - else if (!strcmp(boundary->bctype,_THERMAL_NOSLIP_WALL_ )) boundary->BCFunctionU = BCThermalNoslipWallU; - else if (!strcmp(boundary->bctype,_SW_SLIP_WALL_ )) boundary->BCFunctionU = BCSWSlipWallU; - else if (!strcmp(boundary->bctype,_SUBSONIC_OUTFLOW_ )) boundary->BCFunctionU = BCSubsonicOutflowU; - else if (!strcmp(boundary->bctype,_SUBSONIC_INFLOW_ )) boundary->BCFunctionU = BCSubsonicInflowU; - else if (!strcmp(boundary->bctype,_SUBSONIC_AMBIVALENT_ )) boundary->BCFunctionU = BCSubsonicAmbivalentU; - else if (!strcmp(boundary->bctype,_SUPERSONIC_OUTFLOW_ )) boundary->BCFunctionU = BCSupersonicOutflowU; - else if (!strcmp(boundary->bctype,_SUPERSONIC_INFLOW_ )) boundary->BCFunctionU = BCSupersonicInflowU; - else if (!strcmp(boundary->bctype,_TURBULENT_SUPERSONIC_INFLOW_ )) boundary->BCFunctionU = BCTurbulentSupersonicInflowU; - else if (!strcmp(boundary->bctype,_NO_FLUX_BC_ )) boundary->BCFunctionU = BCNoFluxU; + if (!strcmp(boundary->m_bctype,_PERIODIC_ )) boundary->BCFunctionU = BCPeriodicU; + else if (!strcmp(boundary->m_bctype,_EXTRAPOLATE_ )) boundary->BCFunctionU = BCExtrapolateU; + else if (!strcmp(boundary->m_bctype,_DIRICHLET_ )) boundary->BCFunctionU = BCDirichletU; + else if (!strcmp(boundary->m_bctype,_REFLECT_ )) boundary->BCFunctionU = BCReflectU; + else if (!strcmp(boundary->m_bctype,_SPONGE_ )) boundary->BCFunctionU = BCSpongeUDummy; + else if (!strcmp(boundary->m_bctype,_NOSLIP_WALL_ )) boundary->BCFunctionU = BCNoslipWallU; + else if (!strcmp(boundary->m_bctype,_SLIP_WALL_ )) boundary->BCFunctionU = BCSlipWallU; + else if (!strcmp(boundary->m_bctype,_THERMAL_SLIP_WALL_ )) boundary->BCFunctionU = BCThermalSlipWallU; + else if (!strcmp(boundary->m_bctype,_THERMAL_NOSLIP_WALL_ )) boundary->BCFunctionU = BCThermalNoslipWallU; + else if (!strcmp(boundary->m_bctype,_SW_SLIP_WALL_ )) boundary->BCFunctionU = BCSWSlipWallU; + else if (!strcmp(boundary->m_bctype,_SUBSONIC_OUTFLOW_ )) boundary->BCFunctionU = BCSubsonicOutflowU; + else if (!strcmp(boundary->m_bctype,_SUBSONIC_INFLOW_ )) boundary->BCFunctionU = BCSubsonicInflowU; + else if (!strcmp(boundary->m_bctype,_SUBSONIC_AMBIVALENT_ )) boundary->BCFunctionU = BCSubsonicAmbivalentU; + else if (!strcmp(boundary->m_bctype,_SUPERSONIC_OUTFLOW_ )) boundary->BCFunctionU = BCSupersonicOutflowU; + else if (!strcmp(boundary->m_bctype,_SUPERSONIC_INFLOW_ )) boundary->BCFunctionU = BCSupersonicInflowU; + else if (!strcmp(boundary->m_bctype,_TURBULENT_SUPERSONIC_INFLOW_ )) boundary->BCFunctionU = BCTurbulentSupersonicInflowU; + else if (!strcmp(boundary->m_bctype,_NO_FLUX_BC_ )) boundary->BCFunctionU = BCNoFluxU; else { fprintf(stderr,"Error in BCInitialize(): \"%s\" is not a supported boundary condition.\n", - boundary->bctype); + boundary->m_bctype); return(1); } diff --git a/src/BoundaryConditions/BCNoFlux.c b/src/BoundaryConditions/BCNoFlux.c index 49eeec89..7003f1d7 100644 --- a/src/BoundaryConditions/BCNoFlux.c +++ b/src/BoundaryConditions/BCNoFlux.c @@ -20,50 +20,50 @@ the interior (to enforce zero-normal velocity at the boundary face). */ int BCNoFluxU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_ (bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_ (indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_ (bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_ (indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_ (indexb,indexi,ndims); - _ArrayAdd1D_ (indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_ (indexb,indexi,a_ndims); + _ArrayAdd1D_ (indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_ (ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_ (ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_ (a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_ (a_ndims,a_size,indexi,a_ghosts,p2); - if (nvars == 4) { - phi[nvars*p1+0] = phi[nvars*p2+0]; - phi[nvars*p1+1] = (dim == _XDIR_ ? -phi[nvars*p2+1] : phi[nvars*p2+1] ); - phi[nvars*p1+2] = (dim == _YDIR_ ? -phi[nvars*p2+2] : phi[nvars*p2+2] ); - phi[nvars*p1+3] = phi[nvars*p2+3]; - } else if (nvars == 5) { - phi[nvars*p1+0] = phi[nvars*p2+0]; - phi[nvars*p1+1] = (dim == _XDIR_ ? -phi[nvars*p2+1] : phi[nvars*p2+1] ); - phi[nvars*p1+2] = (dim == _YDIR_ ? -phi[nvars*p2+2] : phi[nvars*p2+2] ); - phi[nvars*p1+3] = (dim == _ZDIR_ ? -phi[nvars*p2+3] : phi[nvars*p2+3] ); - phi[nvars*p1+4] = phi[nvars*p2+4]; + if (a_nvars == 4) { + a_phi[a_nvars*p1+0] = a_phi[a_nvars*p2+0]; + a_phi[a_nvars*p1+1] = (dim == _XDIR_ ? -a_phi[a_nvars*p2+1] : a_phi[a_nvars*p2+1] ); + a_phi[a_nvars*p1+2] = (dim == _YDIR_ ? -a_phi[a_nvars*p2+2] : a_phi[a_nvars*p2+2] ); + a_phi[a_nvars*p1+3] = a_phi[a_nvars*p2+3]; + } else if (a_nvars == 5) { + a_phi[a_nvars*p1+0] = a_phi[a_nvars*p2+0]; + a_phi[a_nvars*p1+1] = (dim == _XDIR_ ? -a_phi[a_nvars*p2+1] : a_phi[a_nvars*p2+1] ); + a_phi[a_nvars*p1+2] = (dim == _YDIR_ ? -a_phi[a_nvars*p2+2] : a_phi[a_nvars*p2+2] ); + a_phi[a_nvars*p1+3] = (dim == _ZDIR_ ? -a_phi[a_nvars*p2+3] : a_phi[a_nvars*p2+3] ); + a_phi[a_nvars*p1+4] = a_phi[a_nvars*p2+4]; } - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } return(0); diff --git a/src/BoundaryConditions/BCNoslipWall.c b/src/BoundaryConditions/BCNoslipWall.c index 079c2866..55868f14 100644 --- a/src/BoundaryConditions/BCNoslipWall.c +++ b/src/BoundaryConditions/BCNoslipWall.c @@ -18,106 +18,106 @@ (#NavierStokes2D, #NavierStokes3D). */ int BCNoslipWallU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 2) { + if (a_ndims == 2) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,gamma); + _NavierStokes2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,vvel,energy,pressure,gamma); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; - uvel_gpt = 2.0*boundary->FlowVelocity[0] - uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[1] - vvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[0] - uvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[1] - vvel; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; - uvel_gpt = 2.0*boundary->FlowVelocity[0] - uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[1] - vvel; - wvel_gpt = 2.0*boundary->FlowVelocity[2] - wvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[0] - uvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[1] - vvel; + wvel_gpt = 2.0*boundary->m_FlowVelocity[2] - wvel; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCPeriodic.c b/src/BoundaryConditions/BCPeriodic.c index 1bfcf7d3..1a08312e 100644 --- a/src/BoundaryConditions/BCPeriodic.c +++ b/src/BoundaryConditions/BCPeriodic.c @@ -17,41 +17,41 @@ to minimize communication. */ int BCPeriodicU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; - MPIVariables *mpi = (MPIVariables*) m; + DomainBoundary *boundary = (DomainBoundary*) a_b; + MPIVariables *mpi = (MPIVariables*) a_m; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if ((boundary->on_this_proc) && (mpi->iproc[dim] == 1)) { - int bounds[ndims], index1[ndims], index2[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(index1,ndims,0); - _ArraySetValue_(index2,ndims,0); + if ((boundary->m_on_this_proc) && (mpi->m_iproc[dim] == 1)) { + int bounds[a_ndims], index1[a_ndims], index2[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(index1,a_ndims,0); + _ArraySetValue_(index2,a_ndims,0); int done = 0; while (!done) { int p1 = 0, p2 = 0; - _ArrayCopy1D_(index1,index2,ndims); + _ArrayCopy1D_(index1,index2,a_ndims); if (face == 1) { - index2[dim] = index1[dim] + size[dim]-ghosts; - _ArrayIndex1DWO_(ndims,size,index1,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,index2,ghosts,p2); + index2[dim] = index1[dim] + a_size[dim]-a_ghosts; + _ArrayIndex1DWO_(a_ndims,a_size,index1,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,index2,a_ghosts,p2); } else if (face == -1) { - _ArrayIndex1DWO_(ndims,size,index1,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,index1,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,index1,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,index1,a_ghosts,p2); } - _ArrayCopy1D_((phi+nvars*p2),(phi+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,bounds,index1,done); + _ArrayCopy1D_((a_phi+a_nvars*p2),(a_phi+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index1,done); } } diff --git a/src/BoundaryConditions/BCPeriodic_GPU.cu b/src/BoundaryConditions/BCPeriodic_GPU.cu index 1ff5797b..1431be99 100644 --- a/src/BoundaryConditions/BCPeriodic_GPU.cu +++ b/src/BoundaryConditions/BCPeriodic_GPU.cu @@ -69,18 +69,18 @@ extern "C" int gpuBCPeriodicU( DomainBoundary *boundary = (DomainBoundary*) b; MPIVariables *mpi = (MPIVariables*) m; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if ((boundary->on_this_proc) && (mpi->iproc[dim] == 1)) { + if ((boundary->m_on_this_proc) && (mpi->m_iproc[dim] == 1)) { int nblocks; - nblocks = (boundary->gpu_npoints_bounds-1) / GPU_THREADS_PER_BLOCK + 1; + nblocks = (boundary->m_gpu_npoints_bounds-1) / GPU_THREADS_PER_BLOCK + 1; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; float milliseconds = 0; - int memory_accessed = 2*boundary->gpu_npoints_bounds*nvars*sizeof(double); + int memory_accessed = 2*boundary->m_gpu_npoints_bounds*nvars*sizeof(double); checkCuda( cudaEventCreate(&startEvent)); checkCuda( cudaEventCreate(&stopEvent)); @@ -88,9 +88,9 @@ extern "C" int gpuBCPeriodicU( checkCuda( cudaEventRecord(startEvent, 0) ); #endif - BCPeriodicU_kernel<<>>(boundary->gpu_npoints_bounds, - boundary->gpu_npoints_local_wghosts, face, ndims, dim, ghosts, nvars, - boundary->gpu_bounds, size, boundary->gpu_is, phi + BCPeriodicU_kernel<<>>(boundary->m_gpu_npoints_bounds, + boundary->m_gpu_npoints_local_wghosts, face, ndims, dim, ghosts, nvars, + boundary->m_gpu_bounds, size, boundary->m_gpu_is, phi ); cudaDeviceSynchronize(); @@ -175,18 +175,18 @@ extern "C" int gpuBCPeriodicU( DomainBoundary *boundary = (DomainBoundary*) b; MPIVariables *mpi = (MPIVariables*) m; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if ((boundary->on_this_proc) && (mpi->iproc[dim] == 1)) { + if ((boundary->m_on_this_proc) && (mpi->m_iproc[dim] == 1)) { int nblocks; - nblocks = (boundary->gpu_npoints_bounds-1) / GPU_THREADS_PER_BLOCK + 1; + nblocks = (boundary->m_gpu_npoints_bounds-1) / GPU_THREADS_PER_BLOCK + 1; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; float milliseconds = 0; - int memory_accessed = 2*boundary->gpu_npoints_bounds*nvars*sizeof(double); + int memory_accessed = 2*boundary->m_gpu_npoints_bounds*nvars*sizeof(double); checkCuda(cudaEventCreate(&startEvent)); checkCuda(cudaEventCreate(&stopEvent)); @@ -194,9 +194,9 @@ extern "C" int gpuBCPeriodicU( checkCuda(cudaEventRecord(startEvent, 0)); #endif - BCPeriodicU_kernel<<>>(boundary->gpu_npoints_bounds, - boundary->gpu_npoints_local_wghosts, face, ndims, dim, ghosts, nvars, - boundary->gpu_bounds, size, boundary->gpu_is, phi + BCPeriodicU_kernel<<>>(boundary->m_gpu_npoints_bounds, + boundary->m_gpu_npoints_local_wghosts, face, ndims, dim, ghosts, nvars, + boundary->m_gpu_bounds, size, boundary->m_gpu_is, phi ); cudaDeviceSynchronize(); diff --git a/src/BoundaryConditions/BCReflect.c b/src/BoundaryConditions/BCReflect.c index 10559e88..06f59964 100644 --- a/src/BoundaryConditions/BCReflect.c +++ b/src/BoundaryConditions/BCReflect.c @@ -12,37 +12,37 @@ adjacent to the boundary. */ int BCReflectU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); - _ArrayScaleCopy1D_((phi+nvars*p2),(-1.0),(phi+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); + _ArrayScaleCopy1D_((a_phi+a_nvars*p2),(-1.0),(a_phi+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } return(0); diff --git a/src/BoundaryConditions/BCSWSlipWall.c b/src/BoundaryConditions/BCSWSlipWall.c index f2c8f21b..27eeadd0 100644 --- a/src/BoundaryConditions/BCSWSlipWall.c +++ b/src/BoundaryConditions/BCSWSlipWall.c @@ -19,92 +19,92 @@ face is equal to the specified wall velocity. */ int BCSWSlipWallU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 1) { + if (a_ndims == 1) { - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double h, uvel; double h_gpt, uvel_gpt; - _ShallowWater1DGetFlowVar_((phi+nvars*p2),h,uvel); + _ShallowWater1DGetFlowVar_((a_phi+a_nvars*p2),h,uvel); /* set the ghost point values */ h_gpt = h; - uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[_XDIR_] - uvel; - phi[nvars*p1+0] = h_gpt; - phi[nvars*p1+1] = h_gpt * uvel_gpt; + a_phi[a_nvars*p1+0] = h_gpt; + a_phi[a_nvars*p1+1] = h_gpt * uvel_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 2) { + } else if (a_ndims == 2) { - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double h, uvel, vvel; double h_gpt, uvel_gpt, vvel_gpt; - _ShallowWater2DGetFlowVar_((phi+nvars*p2),h,uvel,vvel); + _ShallowWater2DGetFlowVar_((a_phi+a_nvars*p2),h,uvel,vvel); /* set the ghost point values */ h_gpt = h; if (dim == _XDIR_) { - uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[_XDIR_] - uvel; vvel_gpt = vvel; } else if (dim == _YDIR_) { uvel_gpt = uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[_YDIR_] - vvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[_YDIR_] - vvel; } else { uvel_gpt = 0.0; vvel_gpt = 0.0; } - phi[nvars*p1+0] = h_gpt; - phi[nvars*p1+1] = h_gpt * uvel_gpt; - phi[nvars*p1+2] = h_gpt * vvel_gpt; + a_phi[a_nvars*p1+0] = h_gpt; + a_phi[a_nvars*p1+1] = h_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = h_gpt * vvel_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCSlipWall.c b/src/BoundaryConditions/BCSlipWall.c index a095de69..0925dca3 100644 --- a/src/BoundaryConditions/BCSlipWall.c +++ b/src/BoundaryConditions/BCSlipWall.c @@ -20,99 +20,99 @@ face is equal to the specified wall velocity. */ int BCSlipWallU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 1) { + if (a_ndims == 1) { /* create a fake physics object */ Euler1D physics; double gamma; - gamma = physics.gamma = boundary->gamma; + gamma = physics.m_gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, energy, pressure; double rho_gpt, uvel_gpt, energy_gpt, pressure_gpt; - _Euler1DGetFlowVar_((phi+nvars*p2),rho,uvel,energy,pressure,(&physics)); + _Euler1DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,energy,pressure,(&physics)); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; - uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[_XDIR_] - uvel; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * uvel_gpt*uvel_gpt; - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 2) { + } else if (a_ndims == 2) { /* create a fake physics object */ Euler2D physics; double gamma; - gamma = physics.gamma = boundary->gamma; + gamma = physics.m_gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; - _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; if (dim == _XDIR_) { - uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[_XDIR_] - uvel; vvel_gpt = vvel; } else if (dim == _YDIR_) { uvel_gpt = uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[_YDIR_] - vvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[_YDIR_] - vvel; } else { uvel_gpt = 0.0; vvel_gpt = 0.0; @@ -120,56 +120,56 @@ int BCSlipWallU( energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; if (dim == _XDIR_) { - uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[_XDIR_] - uvel; vvel_gpt = vvel; wvel_gpt = wvel; } else if (dim == _YDIR_) { uvel_gpt = uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[_YDIR_] - vvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[_YDIR_] - vvel; wvel_gpt = wvel; } else if (dim == _ZDIR_) { uvel_gpt = uvel; vvel_gpt = vvel; - wvel_gpt = 2.0*boundary->FlowVelocity[_ZDIR_] - wvel; + wvel_gpt = 2.0*boundary->m_FlowVelocity[_ZDIR_] - wvel; } else { uvel_gpt = 0.0; vvel_gpt = 0.0; @@ -179,13 +179,13 @@ int BCSlipWallU( + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCSlipWall_GPU.cu b/src/BoundaryConditions/BCSlipWall_GPU.cu index c499b54a..5df28064 100644 --- a/src/BoundaryConditions/BCSlipWall_GPU.cu +++ b/src/BoundaryConditions/BCSlipWall_GPU.cu @@ -167,36 +167,36 @@ extern "C" int gpuBCSlipWallU( { DomainBoundary *boundary = (DomainBoundary*) b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; if (ndims == 2) { - if (boundary->on_this_proc) { + if (boundary->m_on_this_proc) { int bounds[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,ndims); int ngrid_points = 1; for(int i = 0; i < ndims; i++) ngrid_points *= bounds[i]; int nblocks = (ngrid_points - 1) / GPU_THREADS_PER_BLOCK + 1; - gpuMemcpy( boundary->gpu_ie, boundary->ie, ndims*sizeof(int), gpuMemcpyHostToDevice ); - gpuMemcpy( boundary->gpu_is, boundary->is, ndims*sizeof(int), gpuMemcpyHostToDevice ); + gpuMemcpy( boundary->m_gpu_ie, boundary->m_ie, ndims*sizeof(int), gpuMemcpyHostToDevice ); + gpuMemcpy( boundary->m_gpu_is, boundary->m_is, ndims*sizeof(int), gpuMemcpyHostToDevice ); BCSlipWallU_dim2_kernel<<>>( - ngrid_points, dim, face, ghosts, ndims, nvars, boundary->gamma, - gpu_size, boundary->gpu_ie, boundary->gpu_is, boundary->gpu_FlowVelocity, gpu_phi); + ngrid_points, dim, face, ghosts, ndims, nvars, boundary->m_gamma, + gpu_size, boundary->m_gpu_ie, boundary->m_gpu_is, boundary->m_gpu_FlowVelocity, gpu_phi); } } else if (ndims == 3) { - if (boundary->on_this_proc) { + if (boundary->m_on_this_proc) { int bounds[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,ndims); int ngrid_points = 1; for(int i = 0; i < ndims; i++) ngrid_points *= bounds[i]; int nblocks = (ngrid_points - 1) / GPU_THREADS_PER_BLOCK + 1; BCSlipWallU_dim3_kernel<<>>( - ngrid_points, dim, face, ghosts, ndims, nvars, boundary->gamma, - gpu_size, boundary->gpu_ie, boundary->gpu_is, boundary->gpu_FlowVelocity, gpu_phi); + ngrid_points, dim, face, ghosts, ndims, nvars, boundary->m_gamma, + gpu_size, boundary->m_gpu_ie, boundary->m_gpu_is, boundary->m_gpu_FlowVelocity, gpu_phi); } } else { @@ -304,18 +304,18 @@ extern "C" int gpuBCSlipWallU( { DomainBoundary *boundary = (DomainBoundary*) b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; if (ndims == 3) { - if (boundary->on_this_proc) { - int nblocks = (boundary->gpu_npoints_bounds - 1) / GPU_THREADS_PER_BLOCK + 1; + if (boundary->m_on_this_proc) { + int nblocks = (boundary->m_gpu_npoints_bounds - 1) / GPU_THREADS_PER_BLOCK + 1; BCSlipWallU_dim3_kernel<<>>( - boundary->gpu_npoints_bounds, boundary->gpu_npoints_local_wghosts, - face, ndims, dim, ghosts, nvars, boundary->gamma, - boundary->gpu_bounds, size, boundary->gpu_is, boundary->gpu_FlowVelocity, phi); + boundary->m_gpu_npoints_bounds, boundary->m_gpu_npoints_local_wghosts, + face, ndims, dim, ghosts, nvars, boundary->m_gamma, + boundary->m_gpu_bounds, size, boundary->m_gpu_is, boundary->m_gpu_FlowVelocity, phi); } } else { diff --git a/src/BoundaryConditions/BCSponge.c b/src/BoundaryConditions/BCSponge.c index 521dde53..b556e430 100644 --- a/src/BoundaryConditions/BCSponge.c +++ b/src/BoundaryConditions/BCSponge.c @@ -24,43 +24,43 @@ respectively, along the spatial dimension of the sponge. */ int BCSpongeSource( - void *b, /*!< Boundary object of type #DomainBoundary */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int ghosts, /*!< Number of ghost points */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - double *grid, /*!< 1D array with the spatial coordinates of the grid points, one dimension after the other */ - double *u, /*!< Solution */ - double *source /*!< Source term to which the sponge term is added */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int a_ghosts, /*!< Number of ghost points */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + double *a_grid, /*!< 1D array with the spatial coordinates of the grid points, one dimension after the other */ + double *a_u, /*!< Solution */ + double *a_source /*!< Source term to which the sponge term is added */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; - int dim = boundary->dim; - int face = boundary->face; - double *uref = boundary->SpongeValue; - double *xmin = boundary->xmin; - double *xmax = boundary->xmax; + DomainBoundary *boundary = (DomainBoundary*) a_b; + int dim = boundary->m_dim; + int face = boundary->m_face; + double *uref = boundary->m_SpongeValue; + double *xmin = boundary->m_xmin; + double *xmax = boundary->m_xmax; int v; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { - int i = indexb[dim] + boundary->is[dim]; + int i = indexb[dim] + boundary->m_is[dim]; double x, xstart, xend; - _GetCoordinate_(dim,i,size,ghosts,grid,x); + _GetCoordinate_(dim,i,a_size,a_ghosts,a_grid,x); xstart = xmin[dim]; xend = xmax[dim]; /* calculate sigma */ double sigma; if (face > 0) sigma = (x - xstart) / (xend - xstart); else sigma = (x - xend ) / (xstart - xend); - /* add to the source term */ - int p; _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p); - for (v=0; vm_is,a_ghosts,p); + for (v=0; vdim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 2) { + if (a_ndims == 2) { /* create a fake physics object */ Euler2D physics; double gamma; - gamma = physics.gamma = boundary->gamma; + gamma = physics.m_gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); /* boundary normal (pointing into the domain) */ @@ -61,79 +61,79 @@ int BCSubsonicAmbivalentU( nx *= (double) face; ny *= (double) face; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims], indexj[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims], indexj[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; double rho, uvel, vvel, energy, pressure; /* compute boundary face velocity - 2nd order */ - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - _ArrayCopy1D_(indexi,indexj,ndims); + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + _ArrayCopy1D_(indexi,indexj,a_ndims); if (face == 1) { indexi[dim] = 0; indexj[dim] = indexi[dim] + 1; } else if (face == -1) { - indexi[dim] = size[dim]-1; + indexi[dim] = a_size[dim]-1; indexj[dim] = indexi[dim] - 1; } - _ArrayIndex1D_(ndims,size,indexi,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexj,ghosts,p2); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexj,a_ghosts,p2); double uvel1, uvel2, uvelb, vvel1, vvel2, vvelb; - _Euler2DGetFlowVar_((phi+nvars*p1),rho,uvel1,vvel1,energy,pressure,(&physics)); - _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel2,vvel2,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p1),rho,uvel1,vvel1,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel2,vvel2,energy,pressure,(&physics)); uvelb = 1.5*uvel1 - 0.5*uvel2; vvelb = 1.5*vvel1 - 0.5*vvel2; double vel_normal = uvelb*nx + vvelb*ny; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ - _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); /* set the ghost point values */ double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; if (vel_normal > 0) { /* inflow */ - rho_gpt = boundary->FlowDensity; + rho_gpt = boundary->m_FlowDensity; pressure_gpt = pressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; } else { /* outflow */ rho_gpt = rho; - pressure_gpt = boundary->FlowPressure; + pressure_gpt = boundary->m_FlowPressure; uvel_gpt = uvel; vvel_gpt = vvel; } energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); /* boundary normal (pointing into the domain) */ @@ -155,62 +155,62 @@ int BCSubsonicAmbivalentU( ny *= (double) face; nz *= (double) face; - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims], indexj[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims], indexj[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; double rho, uvel, vvel, wvel, energy, pressure; /* compute boundary face velocity - 2nd order */ - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - _ArrayCopy1D_(indexi,indexj,ndims); + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + _ArrayCopy1D_(indexi,indexj,a_ndims); if (face == 1) { indexi[dim] = 0; indexj[dim] = indexi[dim] + 1; } else if (face == -1) { - indexi[dim] = size[dim]-1; + indexi[dim] = a_size[dim]-1; indexj[dim] = indexi[dim] - 1; } - _ArrayIndex1D_(ndims,size,indexi,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexj,ghosts,p2); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexj,a_ghosts,p2); double uvel1, uvel2, uvelb, vvel1, vvel2, vvelb, wvel1, wvel2, wvelb; - _NavierStokes3DGetFlowVar_((phi+nvars*p1),_NavierStokes3D_stride_,rho,uvel1,vvel1,wvel1,energy,pressure,gamma); - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel2,vvel2,wvel2,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p1),_NavierStokes3D_stride_,rho,uvel1,vvel1,wvel1,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel2,vvel2,wvel2,energy,pressure,gamma); uvelb = 1.5*uvel1 - 0.5*uvel2; vvelb = 1.5*vvel1 - 0.5*vvel2; wvelb = 1.5*wvel1 - 0.5*wvel2; double vel_normal = uvelb*nx + vvelb*ny + wvelb*nz; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; if (vel_normal > 0) { /* inflow */ - rho_gpt = boundary->FlowDensity; + rho_gpt = boundary->m_FlowDensity; pressure_gpt = pressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; - wvel_gpt = boundary->FlowVelocity[2]; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; + wvel_gpt = boundary->m_FlowVelocity[2]; } else { /* outflow */ rho_gpt = rho; - pressure_gpt = boundary->FlowPressure; + pressure_gpt = boundary->m_FlowPressure; uvel_gpt = uvel; vvel_gpt = vvel; wvel_gpt = wvel; @@ -219,13 +219,13 @@ int BCSubsonicAmbivalentU( + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCSubsonicInflow.c b/src/BoundaryConditions/BCSubsonicInflow.c index 7455b32e..d9a277c9 100644 --- a/src/BoundaryConditions/BCSubsonicInflow.c +++ b/src/BoundaryConditions/BCSubsonicInflow.c @@ -18,108 +18,108 @@ (#Euler2D, #NavierStokes2D, #NavierStokes3D). */ int BCSubsonicInflowU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 2) { + if (a_ndims == 2) { /* create a fake physics object */ Euler2D physics; double gamma; - gamma = physics.gamma = boundary->gamma; + gamma = physics.m_gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; - _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); /* set the ghost point values */ - rho_gpt = boundary->FlowDensity; + rho_gpt = boundary->m_FlowDensity; pressure_gpt = pressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ - rho_gpt = boundary->FlowDensity; + rho_gpt = boundary->m_FlowDensity; pressure_gpt = pressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; - wvel_gpt = boundary->FlowVelocity[2]; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; + wvel_gpt = boundary->m_FlowVelocity[2]; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCSubsonicOutflow.c b/src/BoundaryConditions/BCSubsonicOutflow.c index a7ca1321..64d0051e 100644 --- a/src/BoundaryConditions/BCSubsonicOutflow.c +++ b/src/BoundaryConditions/BCSubsonicOutflow.c @@ -17,96 +17,96 @@ Navier-Stokes systems (#Euler2D, #NavierStokes2D, #NavierStokes3D). */ int BCSubsonicOutflowU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 2) { + if (a_ndims == 2) { /* create a fake physics object */ Euler2D physics; double gamma; - gamma = physics.gamma = boundary->gamma; + gamma = physics.m_gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; - _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; /* useless statement to avoid compiler warning */ - pressure_gpt = boundary->FlowPressure; + pressure_gpt = boundary->m_FlowPressure; uvel_gpt = uvel; vvel_gpt = vvel; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; /* useless statement to avoid compiler warning */ - pressure_gpt = boundary->FlowPressure; + pressure_gpt = boundary->m_FlowPressure; uvel_gpt = uvel; vvel_gpt = vvel; wvel_gpt = wvel; @@ -114,13 +114,13 @@ int BCSubsonicOutflowU( + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCSupersonicInflow.c b/src/BoundaryConditions/BCSupersonicInflow.c index 1ddd414e..ece98345 100644 --- a/src/BoundaryConditions/BCSupersonicInflow.c +++ b/src/BoundaryConditions/BCSupersonicInflow.c @@ -22,82 +22,82 @@ the flow variables. */ int BCSupersonicInflowU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - if (ndims == 2) { + if (a_ndims == 2) { double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { - int p1; _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); + int p1; _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); /* set the ghost point values */ double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; - rho_gpt = boundary->FlowDensity; - pressure_gpt = boundary->FlowPressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; + rho_gpt = boundary->m_FlowDensity; + pressure_gpt = boundary->m_FlowPressure; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { - int p1; _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); + int p1; _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); /* set the ghost point values */ double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - rho_gpt = boundary->FlowDensity; - pressure_gpt = boundary->FlowPressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; - wvel_gpt = boundary->FlowVelocity[2]; + rho_gpt = boundary->m_FlowDensity; + pressure_gpt = boundary->m_FlowPressure; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; + wvel_gpt = boundary->m_FlowVelocity[2]; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCSupersonicOutflow.c b/src/BoundaryConditions/BCSupersonicOutflow.c index 4d410880..d5498eea 100644 --- a/src/BoundaryConditions/BCSupersonicOutflow.c +++ b/src/BoundaryConditions/BCSupersonicOutflow.c @@ -22,48 +22,48 @@ in such a complicated fashion. */ int BCSupersonicOutflowU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 2) { + if (a_ndims == 2) { /* create a fake physics object */ Euler2D physics; double gamma; - gamma = physics.gamma = boundary->gamma; + gamma = physics.m_gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, energy_gpt, pressure_gpt; - _Euler2DGetFlowVar_((phi+nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); + _Euler2DGetFlowVar_((a_phi+a_nvars*p2),rho,uvel,vvel,energy,pressure,(&physics)); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; @@ -72,41 +72,41 @@ int BCSupersonicOutflowU( energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } - } else if (ndims == 3) { + } else if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + if (boundary->m_on_this_proc) { + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ rho_gpt = rho; pressure_gpt = pressure; @@ -117,13 +117,13 @@ int BCSupersonicOutflowU( + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCThermalNoslipWall.c b/src/BoundaryConditions/BCThermalNoslipWall.c index 47f5ea10..a1600099 100644 --- a/src/BoundaryConditions/BCThermalNoslipWall.c +++ b/src/BoundaryConditions/BCThermalNoslipWall.c @@ -25,81 +25,81 @@ \f$ T = P/\rho\f$. */ int BCThermalNoslipWallU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 3) { + if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { + if (boundary->m_on_this_proc) { - int *temperature_field_size = boundary->UnsteadyTemperatureSize; + int *temperature_field_size = boundary->m_UnsteadyTemperatureSize; int n_time_levels = temperature_field_size[dim]; - double *time_levels = boundary->UnsteadyTimeLevels; - double *temperature_data = boundary->UnsteadyTemperatureData; + double *time_levels = boundary->m_UnsteadyTimeLevels; + double *temperature_data = boundary->m_UnsteadyTemperatureData; int it = n_time_levels - 1; - while ((time_levels[it] > waqt) && (it > 0)) it--; + while ((time_levels[it] > a_waqt) && (it > 0)) it--; - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* get the specified temperature */ - int index1[ndims]; _ArrayCopy1D_(indexb,index1,ndims); + int index1[a_ndims]; _ArrayCopy1D_(indexb,index1,a_ndims); index1[dim] = it; - int q; _ArrayIndex1D_(ndims,temperature_field_size,index1,0,q); + int q; _ArrayIndex1D_(a_ndims,temperature_field_size,index1,0,q); double temperature_b = temperature_data[q]; /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; rho_gpt = rho; - uvel_gpt = 2.0*boundary->FlowVelocity[0] - uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[1] - vvel; - wvel_gpt = 2.0*boundary->FlowVelocity[2] - wvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[0] - uvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[1] - vvel; + wvel_gpt = 2.0*boundary->m_FlowVelocity[2] - wvel; pressure_gpt = rho_gpt * temperature_b; energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCThermalSlipWall.c b/src/BoundaryConditions/BCThermalSlipWall.c index 8e832e2a..59f68240 100644 --- a/src/BoundaryConditions/BCThermalSlipWall.c +++ b/src/BoundaryConditions/BCThermalSlipWall.c @@ -25,78 +25,78 @@ \f$ T = P/\rho\f$. */ int BCThermalSlipWallU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; - int face = boundary->face; + int dim = boundary->m_dim; + int face = boundary->m_face; - if (ndims == 3) { + if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { + if (boundary->m_on_this_proc) { - int *temperature_field_size = boundary->UnsteadyTemperatureSize; + int *temperature_field_size = boundary->m_UnsteadyTemperatureSize; int n_time_levels = temperature_field_size[dim]; - double *time_levels = boundary->UnsteadyTimeLevels; - double *temperature_data = boundary->UnsteadyTemperatureData; + double *time_levels = boundary->m_UnsteadyTimeLevels; + double *temperature_data = boundary->m_UnsteadyTemperatureData; int it = n_time_levels - 1; - while ((time_levels[it] > waqt) && (it > 0)) it--; + while ((time_levels[it] > a_waqt) && (it > 0)) it--; - int bounds[ndims], indexb[ndims], indexi[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + int bounds[a_ndims], indexb[a_ndims], indexi[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { int p1, p2; - _ArrayCopy1D_(indexb,indexi,ndims); - _ArrayAdd1D_(indexi,indexi,boundary->is,ndims); - if (face == 1) indexi[dim] = ghosts-1-indexb[dim]; - else if (face == -1) indexi[dim] = size[dim]-indexb[dim]-1; + _ArrayCopy1D_(indexb,indexi,a_ndims); + _ArrayAdd1D_(indexi,indexi,boundary->m_is,a_ndims); + if (face == 1) indexi[dim] = a_ghosts-1-indexb[dim]; + else if (face == -1) indexi[dim] = a_size[dim]-indexb[dim]-1; else return(1); - _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); - _ArrayIndex1D_(ndims,size,indexi,ghosts,p2); + _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,indexi,a_ghosts,p2); /* get the specified temperature */ - int index1[ndims]; _ArrayCopy1D_(indexb,index1,ndims); + int index1[a_ndims]; _ArrayCopy1D_(indexb,index1,a_ndims); index1[dim] = it; - int q; _ArrayIndex1D_(ndims,temperature_field_size,index1,0,q); + int q; _ArrayIndex1D_(a_ndims,temperature_field_size,index1,0,q); double temperature_b = temperature_data[q]; /* flow variables in the interior */ double rho, uvel, vvel, wvel, energy, pressure; - _NavierStokes3DGetFlowVar_((phi+nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); + _NavierStokes3DGetFlowVar_((a_phi+a_nvars*p2),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,gamma); /* set the ghost point values */ double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; rho_gpt = rho; if (dim == _XDIR_) { - uvel_gpt = 2.0*boundary->FlowVelocity[_XDIR_] - uvel; + uvel_gpt = 2.0*boundary->m_FlowVelocity[_XDIR_] - uvel; vvel_gpt = vvel; wvel_gpt = wvel; } else if (dim == _YDIR_) { uvel_gpt = uvel; - vvel_gpt = 2.0*boundary->FlowVelocity[_YDIR_] - vvel; + vvel_gpt = 2.0*boundary->m_FlowVelocity[_YDIR_] - vvel; wvel_gpt = wvel; } else if (dim == _ZDIR_) { uvel_gpt = uvel; vvel_gpt = vvel; - wvel_gpt = 2.0*boundary->FlowVelocity[_ZDIR_] - wvel; + wvel_gpt = 2.0*boundary->m_FlowVelocity[_ZDIR_] - wvel; } else { uvel_gpt = 0.0; vvel_gpt = 0.0; @@ -107,13 +107,13 @@ int BCThermalSlipWallU( + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/BoundaryConditions/BCTurbulentSupersonicInflow.c b/src/BoundaryConditions/BCTurbulentSupersonicInflow.c index 7dc86b2d..1d1cc5da 100644 --- a/src/BoundaryConditions/BCTurbulentSupersonicInflow.c +++ b/src/BoundaryConditions/BCTurbulentSupersonicInflow.c @@ -19,61 +19,61 @@ interaction problem (for which this boundary condition was written). */ int BCTurbulentSupersonicInflowU( - void *b, /*!< Boundary object of type #DomainBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables/DoFs per grid point */ - int *size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi, /*!< The solution array on which to apply the boundary condition */ - double waqt /*!< Current solution time */ + void *a_b, /*!< Boundary object of type #DomainBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables/DoFs per grid point */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_phi, /*!< The solution array on which to apply the boundary condition */ + double a_waqt /*!< Current solution time */ ) { - DomainBoundary *boundary = (DomainBoundary*) b; + DomainBoundary *boundary = (DomainBoundary*) a_b; - int dim = boundary->dim; + int dim = boundary->m_dim; - double *inflow_data = boundary->UnsteadyDirichletData; - int *inflow_size = boundary->UnsteadyDirichletSize; + double *inflow_data = boundary->m_UnsteadyDirichletData; + int *inflow_size = boundary->m_UnsteadyDirichletSize; - if (ndims == 3) { + if (a_ndims == 3) { /* create a fake physics object */ double gamma; - gamma = boundary->gamma; + gamma = boundary->m_gamma; double inv_gamma_m1 = 1.0/(gamma-1.0); - if (boundary->on_this_proc) { + if (boundary->m_on_this_proc) { /* the following bit is hardcoded for the inflow data * representing fluctuations in a domain of length 2pi */ - double xt = boundary->FlowVelocity[dim] * waqt; + double xt = boundary->m_FlowVelocity[dim] * a_waqt; int N = inflow_size[dim]; double L = 2.0 * (4.0*atan(1.0)); int it = ((int) ((xt/L) * ((double)N))) % N; - int bounds[ndims], indexb[ndims]; - _ArraySubtract1D_(bounds,boundary->ie,boundary->is,ndims); - _ArraySetValue_(indexb,ndims,0); + int bounds[a_ndims], indexb[a_ndims]; + _ArraySubtract1D_(bounds,boundary->m_ie,boundary->m_is,a_ndims); + _ArraySetValue_(indexb,a_ndims,0); int done = 0; while (!done) { - int p1; _ArrayIndex1DWO_(ndims,size,indexb,boundary->is,ghosts,p1); + int p1; _ArrayIndex1DWO_(a_ndims,a_size,indexb,boundary->m_is,a_ghosts,p1); /* set the ghost point values - mean flow */ double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - rho_gpt = boundary->FlowDensity; - pressure_gpt = boundary->FlowPressure; - uvel_gpt = boundary->FlowVelocity[0]; - vvel_gpt = boundary->FlowVelocity[1]; - wvel_gpt = boundary->FlowVelocity[2]; + rho_gpt = boundary->m_FlowDensity; + pressure_gpt = boundary->m_FlowPressure; + uvel_gpt = boundary->m_FlowVelocity[0]; + vvel_gpt = boundary->m_FlowVelocity[1]; + wvel_gpt = boundary->m_FlowVelocity[2]; /* calculate the turbulent fluctuations */ double duvel , dvvel , dwvel ; - int index1[ndims]; _ArrayCopy1D_(indexb,index1,ndims); + int index1[a_ndims]; _ArrayCopy1D_(indexb,index1,a_ndims); index1[dim] = it; - int q; _ArrayIndex1D_(ndims,inflow_size,index1,0,q); - duvel = inflow_data[q*nvars+1]; - dvvel = inflow_data[q*nvars+2]; - dwvel = inflow_data[q*nvars+3]; + int q; _ArrayIndex1D_(a_ndims,inflow_size,index1,0,q); + duvel = inflow_data[q*a_nvars+1]; + dvvel = inflow_data[q*a_nvars+2]; + dwvel = inflow_data[q*a_nvars+3]; /* add the turbulent fluctuations to the velocity field */ uvel_gpt += duvel; @@ -84,13 +84,13 @@ int BCTurbulentSupersonicInflowU( energy_gpt = inv_gamma_m1*pressure_gpt + 0.5 * rho_gpt * (uvel_gpt*uvel_gpt + vvel_gpt*vvel_gpt + wvel_gpt*wvel_gpt); - phi[nvars*p1+0] = rho_gpt; - phi[nvars*p1+1] = rho_gpt * uvel_gpt; - phi[nvars*p1+2] = rho_gpt * vvel_gpt; - phi[nvars*p1+3] = rho_gpt * wvel_gpt; - phi[nvars*p1+4] = energy_gpt; + a_phi[a_nvars*p1+0] = rho_gpt; + a_phi[a_nvars*p1+1] = rho_gpt * uvel_gpt; + a_phi[a_nvars*p1+2] = rho_gpt * vvel_gpt; + a_phi[a_nvars*p1+3] = rho_gpt * wvel_gpt; + a_phi[a_nvars*p1+4] = energy_gpt; - _ArrayIncrementIndex_(ndims,bounds,indexb,done); + _ArrayIncrementIndex_(a_ndims,bounds,indexb,done); } } diff --git a/src/CommonFunctions/CommonFunctions.c b/src/CommonFunctions/CommonFunctions.c index d381e018..590dbd76 100644 --- a/src/CommonFunctions/CommonFunctions.c +++ b/src/CommonFunctions/CommonFunctions.c @@ -15,37 +15,37 @@ \a width is 5, or "41" if \a width is 2, or "1" if \a width is 1. */ void GetStringFromInteger( - int a, /*!< the integer to convert to a string */ - char *A, /*!< the string */ - int width /*!< desired width of the string */ + int a_a, /*!< the integer to convert to a string */ + char *a_A, /*!< the string */ + int a_width /*!< desired width of the string */ ) { - if (width > _MAX_STRING_SIZE_-1) { - fprintf(stderr,"Error in GetStringFromInteger(): requested width is larger than _MAX_STRING_SIZE_.\n"); + if (a_width > _MAX_STRING_SIZE_-1) { + fprintf(stderr,"Error in GetStringFromInteger(): requested a_width is larger than _MAX_STRING_SIZE_.\n"); } int i; - for (i=0; i 0) { - array[i] = log(array[i]); + for (size_t i = 0; i < a_array_size; ++i) { + if (a_array[i] > 0) { + a_array[i] = log(a_array[i]); } else { - fprintf(stderr, "Error: Logarithm of non-positive value (%f) at index %zu\n", array[i], i); + fprintf(stderr, "Error: Logarithm of non-positive value (%f) at index %zu\n", a_array[i], i); // Handle error appropriately, for example by setting to NaN, zero, or skipping - array[i] = NAN; // Set to NaN + a_array[i] = NAN; // Set to NaN } } return; @@ -54,11 +54,11 @@ void takeLog( double* const array, /*!< the array to take log of */ /*! Take the exponential of each element of the array */ -void takeExp( double* const array, /*!< the array to take log of */ - const int array_size /*!< size of the array */ ) +void takeExp( double* const a_array, /*!< the array to take log of */ + const int a_array_size /*!< size of the array */ ) { - for (size_t i = 0; i < array_size; ++i) { - array[i] = exp(array[i]); + for (size_t i = 0; i < a_array_size; ++i) { + a_array[i] = exp(a_array[i]); } return; } diff --git a/src/FirstDerivative/FirstDerivativeFirstOrder.c b/src/FirstDerivative/FirstDerivativeFirstOrder.c index 01c0a93a..c70f5b7a 100644 --- a/src/FirstDerivative/FirstDerivativeFirstOrder.c +++ b/src/FirstDerivative/FirstDerivativeFirstOrder.c @@ -35,34 +35,34 @@ typedef HyPar SolverContext; through all grid lines along \b dir. */ int FirstDerivativeFirstOrder( - double *Df, /*!< Array to hold the computed first derivative (with ghost points) */ - double *f, /*!< Array containing the grid point function values whose first + double *a_Df, /*!< Array to hold the computed first derivative (with ghost points) */ + double *a_f, /*!< Array containing the grid point function values whose first derivative is to be computed (with ghost points) */ - int dir, /*!< The spatial dimension along which the derivative is computed */ - int bias, /*!< Forward or backward differencing for non-central + int a_dir, /*!< The spatial dimension along which the derivative is computed */ + int a_bias, /*!< Forward or backward differencing for non-central finite-difference schemes (-1: backward, 1: forward)*/ - void *s, /*!< Solver object of type #SolverContext */ - void *m /*!< MPI object of type #MPIContext */ + void *a_s, /*!< Solver object of type #SolverContext */ + void *a_m /*!< MPI object of type #MPIContext */ ) { - SolverContext *solver = (SolverContext*) s; + SolverContext *solver = (SolverContext*) a_s; int i, j, v; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; - if ((!Df) || (!f)) { + if ((!a_Df) || (!a_f)) { fprintf(stderr, "Error in FirstDerivativeSecondOrder(): input arrays not allocated.\n"); return(1); } /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along - dimension "dir" */ + dimension "a_dir" */ int indexC[ndims], index_outer[ndims], bounds_outer[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); #pragma omp parallel for schedule(auto) default(shared) private(i,j,v,index_outer,indexC) @@ -72,24 +72,24 @@ int FirstDerivativeFirstOrder( /* left boundary */ for (i = -ghosts; i < -ghosts+1; i++) { int qC, qR; - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC ); - indexC[dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR ); - for (v=0; vghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; - if ((!Df) || (!f)) { + if ((!a_Df) || (!a_f)) { fprintf(stderr, "Error in FirstDerivativeFourthOrder(): input arrays not allocated.\n"); return(1); } - static double one_twelve = 1.0/12.0; + static double s_one_twelve = 1.0/12.0; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along - dimension "dir" */ + dimension "a_dir" */ int indexC[ndims], index_outer[ndims], bounds_outer[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); #pragma omp parallel for schedule(auto) default(shared) private(i,j,v,index_outer,indexC) @@ -73,55 +73,55 @@ int FirstDerivativeFourthOrderCentral( /* left boundary */ for (i = -ghosts; i < -ghosts+1; i++) { int qC, qp1, qp2, qp3, qp4; - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC ); - indexC[dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp1); - indexC[dir] = i+2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp2); - indexC[dir] = i+3; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp3); - indexC[dir] = i+4; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp4); + indexC[a_dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC ); + indexC[a_dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp1); + indexC[a_dir] = i+2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp2); + indexC[a_dir] = i+3; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp3); + indexC[a_dir] = i+4; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp4); for (v=0; vghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; if ((!Df) || (!f)) { fprintf(stderr, "Error in FirstDerivativeFourthOrder(): input arrays not allocated.\n"); @@ -181,7 +181,7 @@ int gpuFirstDerivativeFourthOrderCentral( #endif FirstDerivativeFourthOrderCentral_boundary_kernel<<>>( - N_outer, ghosts, ndims, nvars, dir, solver->gpu_dim_local, f, Df + N_outer, ghosts, ndims, nvars, dir, solver->m_gpu_dim_local, f, Df ); #if defined(GPU_STAT) @@ -201,7 +201,7 @@ int gpuFirstDerivativeFourthOrderCentral( #endif FirstDerivativeFourthOrderCentral_interior_kernel<<>>( - npoints_grid, ghosts, ndims, nvars, dir, solver->gpu_dim_local, f, Df + npoints_grid, ghosts, ndims, nvars, dir, solver->m_gpu_dim_local, f, Df ); cudaDeviceSynchronize(); @@ -234,7 +234,7 @@ void FirstDerivativeFourthOrderCentral_boundary_kernel( { int j = threadIdx.x + (blockDim.x * blockIdx.x); if (j < N_outer) { - double one_twelve = 1.0/12.0; + double s_one_twelve = 1.0/12.0; int i, v; int indexC[GPU_MAX_NDIMS], index_outer[GPU_MAX_NDIMS], bounds_outer[GPU_MAX_NDIMS]; @@ -251,7 +251,7 @@ void FirstDerivativeFourthOrderCentral_boundary_kernel( indexC[dir] = i+3; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp3); indexC[dir] = i+4; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp4); for (v=0; vghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; if ((!Df) || (!f)) { fprintf(stderr, "Error in FirstDerivativeFourthOrder(): input arrays not allocated.\n"); @@ -389,7 +389,7 @@ int gpuFirstDerivativeFourthOrderCentral( #endif FirstDerivativeFourthOrderCentral_boundary_kernel<<>>( - N_outer, solver->npoints_local_wghosts, ghosts, ndims, nvars, dir, solver->gpu_dim_local, f, Df + N_outer, solver->m_npoints_local_wghosts, ghosts, ndims, nvars, dir, solver->m_gpu_dim_local, f, Df ); #if defined(GPU_STAT) @@ -409,7 +409,7 @@ int gpuFirstDerivativeFourthOrderCentral( #endif FirstDerivativeFourthOrderCentral_interior_kernel<<>>( - npoints_grid, solver->npoints_local_wghosts, ghosts, ndims, nvars, dir, solver->gpu_dim_local, f, Df + npoints_grid, solver->npoints_local_wghosts, ghosts, ndims, nvars, dir, solver->m_gpu_dim_local, f, Df ); cudaDeviceSynchronize(); diff --git a/src/FirstDerivative/FirstDerivativeSecondOrder.c b/src/FirstDerivative/FirstDerivativeSecondOrder.c index 553f2e35..94785b55 100644 --- a/src/FirstDerivative/FirstDerivativeSecondOrder.c +++ b/src/FirstDerivative/FirstDerivativeSecondOrder.c @@ -34,34 +34,34 @@ typedef HyPar SolverContext; through all grid lines along \b dir. */ int FirstDerivativeSecondOrderCentral( - double *Df, /*!< Array to hold the computed first derivative (with ghost points) */ - double *f, /*!< Array containing the grid point function values whose first + double *a_Df, /*!< Array to hold the computed first derivative (with ghost points) */ + double *a_f, /*!< Array containing the grid point function values whose first derivative is to be computed (with ghost points) */ - int dir, /*!< The spatial dimension along which the derivative is computed */ - int bias, /*!< Forward or backward differencing for non-central + int a_dir, /*!< The spatial dimension along which the derivative is computed */ + int a_bias, /*!< Forward or backward differencing for non-central finite-difference schemes (-1: backward, 1: forward)*/ - void *s, /*!< Solver object of type #SolverContext */ - void *m /*!< MPI object of type #MPIContext */ + void *a_s, /*!< Solver object of type #SolverContext */ + void *a_m /*!< MPI object of type #MPIContext */ ) { - SolverContext *solver = (SolverContext*) s; + SolverContext *solver = (SolverContext*) a_s; int i, j, v; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; - if ((!Df) || (!f)) { + if ((!a_Df) || (!a_f)) { fprintf(stderr, "Error in FirstDerivativeSecondOrder(): input arrays not allocated.\n"); return(1); } /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along - dimension "dir" */ + dimension "a_dir" */ int indexC[ndims], index_outer[ndims], bounds_outer[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); #pragma omp parallel for schedule(auto) default(shared) private(i,j,v,index_outer,indexC) @@ -71,26 +71,26 @@ int FirstDerivativeSecondOrderCentral( /* left boundary */ for (i = -ghosts; i < -ghosts+1; i++) { int qC, qR, qRR; - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC ); - indexC[dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR ); - indexC[dir] = i+2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qRR); - for (v=0; vip[dir] == 0) { + if (mpi->m_ip[a_dir] == 0) { /* left physical boundary: overwrite the leftmost value with biased finite-difference */ #pragma omp parallel for schedule(auto) default(shared) private(i,j,v,index_outer,indexC) for (j=0; jip[dir] == (mpi->iproc[dir]-1)) { + if (mpi->m_ip[a_dir] == (mpi->m_iproc[a_dir]-1)) { /* right physical boundary: overwrite the rightmost value with biased finite-difference */ #pragma omp parallel for schedule(auto) default(shared) private(i,j,v,index_outer,indexC) for (j=0; jboundary; - MPIVariables *mpi = (MPIVariables*) m; - int nb = solver->nBoundaryZones; + HyPar *solver = (HyPar*) a_s; + DomainBoundary *boundary = (DomainBoundary*) solver->m_boundary; + MPIVariables *mpi = (MPIVariables*) a_m; + int nb = solver->m_n_boundary_zones; int* dim_local; #if defined(HAVE_CUDA) - if (solver->use_gpu) { - dim_local = solver->gpu_dim_local; + if (solver->m_use_gpu) { + dim_local = solver->m_gpu_dim_local; } else { #endif - dim_local = solver->dim_local; + dim_local = solver->m_dim_local; #if defined(HAVE_CUDA) } #endif - /* Apply domain boundary conditions to x */ + /* Apply domain boundary conditions to a_x */ int n; for (n = 0; n < nb; n++) { - boundary[n].BCFunctionU(&boundary[n],mpi,solver->ndims,solver->nvars, - dim_local,solver->ghosts,x,waqt); + boundary[n].BCFunctionU(&boundary[n],mpi,solver->m_ndims,solver->m_nvars, + dim_local,solver->m_ghosts,a_x,a_waqt); } return(0); diff --git a/src/HyParFunctions/ApplyIBConditions.c b/src/HyParFunctions/ApplyIBConditions.c index 48b32dab..8ec8cb90 100644 --- a/src/HyParFunctions/ApplyIBConditions.c +++ b/src/HyParFunctions/ApplyIBConditions.c @@ -11,24 +11,24 @@ Call the physics-specific function that applies the immersed boundary conditions on the immersed boundary points. */ -int ApplyIBConditions(void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ - double *x, /*!< The solution vector to apply immersed BCs on */ - double waqt /*!< Current simulation time */ +int ApplyIBConditions(void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ + double *a_x, /*!< The solution vector to apply immersed BCs on */ + double a_waqt /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; /* Apply immersed boundary conditions, if applicable */ #if defined(HAVE_CUDA) - if (solver->use_gpu) { - if (solver->flag_ib) { + if (solver->m_use_gpu) { + if (solver->m_flag_ib) { fprintf(stderr, "ERROR: immersed boundaries have not yet been implemented on GPU.\n"); } } else { #endif - if (solver->flag_ib) solver->IBFunction(solver,mpi,x,waqt); + if (solver->m_flag_ib) solver->IBFunction(solver,mpi,a_x,a_waqt); #if defined(HAVE_CUDA) } #endif diff --git a/src/HyParFunctions/BoundaryIntegral.c b/src/HyParFunctions/BoundaryIntegral.c index 3fededbc..9879a703 100644 --- a/src/HyParFunctions/BoundaryIntegral.c +++ b/src/HyParFunctions/BoundaryIntegral.c @@ -15,17 +15,17 @@ cancel out. */ int BoundaryIntegral( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int d,v,k; double *local_integral = (double*) calloc (nvars,sizeof(double)); @@ -38,21 +38,21 @@ int BoundaryIntegral( double dxinv[ndims], dS = 1.0; for (k=0; kdxinv,dxinv[k]); + _GetCoordinate_(k,dim[k]/2,dim,ghosts,solver->m_dxinv,dxinv[k]); } for (k=0; kStepBoundaryIntegral[(2*d+0)*nvars+v])*dS; - local_integral[v] += (solver->StepBoundaryIntegral[(2*d+1)*nvars+v])*dS; + local_integral[v] += (solver->m_step_boundary_integral[(2*d+0)*nvars+v])*dS; + local_integral[v] += (solver->m_step_boundary_integral[(2*d+1)*nvars+v])*dS; } } /* add across process to calculate global boundary integral * (internal (MPI) boundaries must cancel out) */ - IERR MPISum_double(global_integral,local_integral,nvars,&mpi->world); CHECKERR(ierr); + IERR MPISum_double(global_integral,local_integral,nvars,&mpi->m_world); CHECKERR(ierr); /* add to the total boundary integral */ - _ArrayAXPY_(global_integral,1.0,solver->TotalBoundaryIntegral,nvars); + _ArrayAXPY_(global_integral,1.0,solver->m_total_boundary_integral,nvars); free(local_integral); free(global_integral); diff --git a/src/HyParFunctions/CalculateConservationError.c b/src/HyParFunctions/CalculateConservationError.c index dbaf50f2..c95360f2 100644 --- a/src/HyParFunctions/CalculateConservationError.c +++ b/src/HyParFunctions/CalculateConservationError.c @@ -14,25 +14,25 @@ of the simulation to the current simulation time. */ int CalculateConservationError( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - int v,nvars = solver->nvars; + HyPar *solver = (HyPar*) a_s; + int v,nvars = solver->m_nvars; double error; double base[nvars]; for (v=0; vVolumeIntegralInitial[v]) > 1.0) - base[v] = absolute(solver->VolumeIntegralInitial[v]); + if (absolute(solver->m_volume_integral_initial[v]) > 1.0) + base[v] = absolute(solver->m_volume_integral_initial[v]); else base[v] = 1.0; } for (v=0; vVolumeIntegral[v]+solver->TotalBoundaryIntegral[v]-solver->VolumeIntegralInitial[v]) - * (solver->VolumeIntegral[v]+solver->TotalBoundaryIntegral[v]-solver->VolumeIntegralInitial[v]); - solver->ConservationError[v] = sqrt(error)/base[v]; + error = (solver->m_volume_integral[v]+solver->m_total_boundary_integral[v]-solver->m_volume_integral_initial[v]) + * (solver->m_volume_integral[v]+solver->m_total_boundary_integral[v]-solver->m_volume_integral_initial[v]); + solver->m_conservation_error[v] = sqrt(error)/base[v]; } return(0); diff --git a/src/HyParFunctions/CalculateError.c b/src/HyParFunctions/CalculateError.c index 135e2678..4d8c3138 100644 --- a/src/HyParFunctions/CalculateError.c +++ b/src/HyParFunctions/CalculateError.c @@ -23,31 +23,31 @@ int ExactSolution(void*,void*,double*,char*,int*); in the same format as the initial solution. */ int CalculateError( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int exact_flag = 0, i, size; double sum = 0, global_sum = 0; double *uex = NULL; _DECLARE_IERR_; - size = solver->nvars; - for (i = 0; i < solver->ndims; i++) - size *= (solver->dim_local[i]+2*solver->ghosts); + size = solver->m_nvars; + for (i = 0; i < solver->m_ndims; i++) + size *= (solver->m_dim_local[i]+2*solver->m_ghosts); uex = (double*) calloc (size, sizeof(double)); char fname_root[_MAX_STRING_SIZE_] = "exact"; - if (solver->nsims > 1) { + if (solver->m_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } - static const double tolerance = 1e-15; + static const double s_tolerance = 1e-15; IERR ExactSolution( solver, mpi, uex, @@ -58,7 +58,7 @@ int CalculateError( /* No exact solution */ IERR TimeError(solver,mpi,NULL); CHECKERR(ierr); - solver->error[0] = solver->error[1] = solver->error[2] = -1; + solver->m_error[0] = solver->m_error[1] = solver->m_error[2] = -1; } else { @@ -67,52 +67,52 @@ int CalculateError( /* calculate solution norms (for relative error) */ double solution_norm[3] = {0.0,0.0,0.0}; /* L1 */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solution_norm[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solution_norm[0] = global_sum/((double)solver->m_npoints_global); /* L2 */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solution_norm[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solution_norm[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* Linf */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,uex); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,uex); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); solution_norm[2] = global_sum; /* compute error = difference between exact and numerical solution */ - _ArrayAXPY_(solver->u,-1.0,uex,size); + _ArrayAXPY_(solver->m_u,-1.0,uex,size); /* calculate L1 norm of error */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solver->error[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_error[0] = global_sum/((double)solver->m_npoints_global); /* calculate L2 norm of error */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solver->error[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_error[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* calculate Linf norm of error */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,uex); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); - solver->error[2] = global_sum; + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,uex); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_error[2] = global_sum; /* decide whether to normalize and report relative errors, or report absolute errors. */ - if ( (solution_norm[0] > tolerance) - && (solution_norm[1] > tolerance) - && (solution_norm[2] > tolerance) ) { - solver->error[0] /= solution_norm[0]; - solver->error[1] /= solution_norm[1]; - solver->error[2] /= solution_norm[2]; + if ( (solution_norm[0] > s_tolerance) + && (solution_norm[1] > s_tolerance) + && (solution_norm[2] > s_tolerance) ) { + solver->m_error[0] /= solution_norm[0]; + solver->m_error[1] /= solution_norm[1]; + solver->m_error[2] /= solution_norm[2]; } } diff --git a/src/HyParFunctions/CalculateROMDiff.c b/src/HyParFunctions/CalculateROMDiff.c index 3048781f..123722f5 100644 --- a/src/HyParFunctions/CalculateROMDiff.c +++ b/src/HyParFunctions/CalculateROMDiff.c @@ -21,91 +21,91 @@ * solution and the predicted solution by libROM. * error in the solution if the exact solution is */ -int CalculateROMDiff( void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ ) +int CalculateROMDiff( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar* solver = (HyPar*) s; - MPIVariables* mpi = (MPIVariables*) m; + HyPar* solver = (HyPar*) a_s; + MPIVariables* mpi = (MPIVariables*) a_m; double sum = 0, global_sum = 0; - static const double tolerance = 1e-15; + static const double s_tolerance = 1e-15; - int size = solver->npoints_local_wghosts * solver->nvars; + int size = solver->m_npoints_local_wghosts * solver->m_nvars; double* u_diff = (double*) calloc (size, sizeof(double)); /* calculate solution norms (for relative error) */ double solution_norm[3] = {0.0,0.0,0.0}; /* L1 */ - sum = ArraySumAbsnD ( solver->nvars, - solver->ndims, - solver->dim_local, - solver->ghosts, - solver->index, - solver->u ); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solution_norm[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD ( solver->m_nvars, + solver->m_ndims, + solver->m_dim_local, + solver->m_ghosts, + solver->m_index, + solver->m_u ); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solution_norm[0] = global_sum/((double)solver->m_npoints_global); /* L2 */ - sum = ArraySumSquarenD ( solver->nvars, - solver->ndims, - solver->dim_local, - solver->ghosts, - solver->index, - solver->u ); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solution_norm[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD ( solver->m_nvars, + solver->m_ndims, + solver->m_dim_local, + solver->m_ghosts, + solver->m_index, + solver->m_u ); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solution_norm[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* Linf */ - sum = ArrayMaxnD ( solver->nvars, - solver->ndims, - solver->dim_local, - solver->ghosts, - solver->index - ,solver->u ); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD ( solver->m_nvars, + solver->m_ndims, + solver->m_dim_local, + solver->m_ghosts, + solver->m_index + ,solver->m_u ); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); solution_norm[2] = global_sum; /* set u_diff to PDE solution */ - _ArrayCopy1D_(solver->u, u_diff, size); + _ArrayCopy1D_(solver->m_u, u_diff, size); /* subtract the ROM solutions */ - _ArrayAXPY_(solver->u_rom_predicted, -1.0, u_diff, size); + _ArrayAXPY_(solver->m_u_rom_predicted, -1.0, u_diff, size); /* calculate L1 norm of error */ - sum = ArraySumAbsnD ( solver->nvars, - solver->ndims, - solver->dim_local, - solver->ghosts, - solver->index, + sum = ArraySumAbsnD ( solver->m_nvars, + solver->m_ndims, + solver->m_dim_local, + solver->m_ghosts, + solver->m_index, u_diff ); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solver->rom_diff_norms[0] = global_sum/((double)solver->npoints_global); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_rom_diff_norms[0] = global_sum/((double)solver->m_npoints_global); /* calculate L2 norm of error */ - sum = ArraySumSquarenD ( solver->nvars, - solver->ndims, - solver->dim_local, - solver->ghosts, - solver->index, + sum = ArraySumSquarenD ( solver->m_nvars, + solver->m_ndims, + solver->m_dim_local, + solver->m_ghosts, + solver->m_index, u_diff ); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solver->rom_diff_norms[1] = sqrt(global_sum/((double)solver->npoints_global)); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_rom_diff_norms[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* calculate Linf norm of error */ - sum = ArrayMaxnD ( solver->nvars, - solver->ndims, - solver->dim_local, - solver->ghosts, - solver->index, + sum = ArrayMaxnD ( solver->m_nvars, + solver->m_ndims, + solver->m_dim_local, + solver->m_ghosts, + solver->m_index, u_diff ); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); - solver->rom_diff_norms[2] = global_sum; + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_rom_diff_norms[2] = global_sum; /* decide whether to normalize and report relative diff norms, or report absolute diff norms. */ - if ( (solution_norm[0] > tolerance) - && (solution_norm[1] > tolerance) - && (solution_norm[2] > tolerance) ) { - solver->rom_diff_norms[0] /= solution_norm[0]; - solver->rom_diff_norms[1] /= solution_norm[1]; - solver->rom_diff_norms[2] /= solution_norm[2]; + if ( (solution_norm[0] > s_tolerance) + && (solution_norm[1] > s_tolerance) + && (solution_norm[2] > s_tolerance) ) { + solver->m_rom_diff_norms[0] /= solution_norm[0]; + solver->m_rom_diff_norms[1] /= solution_norm[1]; + solver->m_rom_diff_norms[2] /= solution_norm[2]; } free(u_diff); diff --git a/src/HyParFunctions/ComputeRHSOperators.c b/src/HyParFunctions/ComputeRHSOperators.c index d4454ff4..50f66ae7 100644 --- a/src/HyParFunctions/ComputeRHSOperators.c +++ b/src/HyParFunctions/ComputeRHSOperators.c @@ -30,7 +30,7 @@ where \a n is the size of the matrix, followed by all the non-zero elements (each line contains the indices \a i,\a j and the value \a val of one non-zero element). - + This function is called after #HyPar::file_op_iter iterations (i.e. + + This function is called after #HyPar::m_file_op_iter iterations (i.e. the same frequency at which solution files are written). + If a splitting for the hyperbolic flux is defined, then the Jacobians of the complete hyperbolic term, as well as the split terms are computed. @@ -41,57 +41,57 @@ \b -Dcompute_rhs_operators, and run on a single processor. This is very slow for larger domains, and should be used only for the numerical analysis of test cases. - + The current solution stored in #HyPar::u is used as the reference state + + The current solution stored in #HyPar::m_u is used as the reference state at which the Jacobians are computed (this is relevant to know for non-linear right-hand-sides functions). Note: Parabolic terms have not yet been included. */ int ComputeRHSOperators( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type MPIVariables */ double t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int i, j, size, ndof; double *f, *f0, *u, *u0, *rhs, *drhs; FILE *fout; char filename[_MAX_STRING_SIZE_]; - if (mpi->nproc > 1) return(0); + if (mpi->m_nproc > 1) return(0); - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; int index[ndims]; double epsilon = 1e-6; double tolerance = 1e-15; /* allocate arrays */ - size = solver->npoints_local_wghosts * nvars; + size = solver->m_npoints_local_wghosts * nvars; u = (double*) calloc (size,sizeof(double)); u0 = (double*) calloc (size,sizeof(double)); rhs = (double*) calloc (size,sizeof(double)); drhs = (double*) calloc (size,sizeof(double)); - ndof = solver->npoints_local * nvars; + ndof = solver->m_npoints_local * nvars; f = (double*) calloc (ndof,sizeof(double)); f0 = (double*) calloc (ndof,sizeof(double)); /* copy the current solution to u0 */ - _ArrayCopy1D_(solver->u,u0,size); + _ArrayCopy1D_(solver->m_u,u0,size); /* apply boundary conditions to the solution u0 */ - IERR solver->ApplyBoundaryConditions(solver,mpi,u0,NULL,t);CHECKERR(ierr); - IERR solver->ApplyIBConditions(solver,mpi,u0,t);CHECKERR(ierr); + IERR solver->ApplyBoundaryConditions(solver,mpi,u0,NULL,a_t);CHECKERR(ierr); + IERR solver->ApplyIBConditions(solver,mpi,u0,a_t);CHECKERR(ierr); IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u0); CHECKERR(ierr); /* compute linearized matrix for the hyperbolic FFunction */ if (solver->FFunction) { strcpy(filename,"Mat_FFunction_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); strcat(filename,".dat"); printf("ComputeRHSOperators(): Computing linearized matrix operator for FFunction. ndof=%d.\n",ndof); printf("ComputeRHSOperators(): Writing to sparse matrix file %s.\n",filename); @@ -99,7 +99,7 @@ int ComputeRHSOperators( fprintf(fout,"%d\n",ndof); /* compute the FFunction of u0 */ _ArraySetValue_(f0,ndof,0.0); - IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,t,1,solver->FFunction, + IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,a_t,1,solver->FFunction, solver->Upwind); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); /* transfer to an array f0 which as no ghost points */ @@ -117,11 +117,11 @@ int ComputeRHSOperators( /* add a perturbation */ u[nvars*p+v] += epsilon; /* apply boundary conditions to the perturbed solution u */ - IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t);CHECKERR(ierr); - IERR solver->ApplyIBConditions(solver,mpi,u,t);CHECKERR(ierr); + IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t);CHECKERR(ierr); + IERR solver->ApplyIBConditions(solver,mpi,u,a_t);CHECKERR(ierr); IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); CHECKERR(ierr); /* compute the FFunction of u */ - IERR solver->HyperbolicFunction(rhs,u,solver,mpi,t,1,solver->FFunction, + IERR solver->HyperbolicFunction(rhs,u,solver,mpi,a_t,1,solver->FFunction, solver->Upwind); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); /* transfer to an array f which as no ghost points */ @@ -142,7 +142,7 @@ int ComputeRHSOperators( functions, if dFFunction is available */ if (solver->dFFunction) { strcpy(filename,"Mat_FdFFunction_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); strcat(filename,".dat"); printf("ComputeRHSOperators(): Computing linearized matrix operator for (FFunction-dFFunction). ndof=%d.\n",ndof); printf("ComputeRHSOperators(): Writing to sparse matrix file %s.\n",filename); @@ -150,14 +150,14 @@ int ComputeRHSOperators( fprintf(fout,"%d\n",ndof); /* compute the FFunction of u0 */ _ArraySetValue_(f0,ndof,0.0); - if (solver->flag_fdf_specified) { - IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,t,1,solver->FdFFunction, + if (solver->m_flag_fdf_specified) { + IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,a_t,1,solver->FdFFunction, solver->UpwindFdF); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); } else { - IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,t,1,solver->FFunction, + IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,a_t,1,solver->FFunction, solver->Upwind); CHECKERR(ierr); - IERR solver->HyperbolicFunction(drhs,u0,solver,mpi,t,0,solver->dFFunction, + IERR solver->HyperbolicFunction(drhs,u0,solver,mpi,a_t,0,solver->dFFunction, solver->UpwinddF); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); _ArrayAXPY_(drhs,1.0,rhs,size); @@ -177,18 +177,18 @@ int ComputeRHSOperators( /* add a perturbation */ u[nvars*p+v] += epsilon; /* apply boundary conditions to the perturbed solution u */ - IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t);CHECKERR(ierr); - IERR solver->ApplyIBConditions(solver,mpi,u,t);CHECKERR(ierr); + IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t);CHECKERR(ierr); + IERR solver->ApplyIBConditions(solver,mpi,u,a_t);CHECKERR(ierr); IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); CHECKERR(ierr); /* compute the FFunction of u */ - if (solver->flag_fdf_specified) { - IERR solver->HyperbolicFunction(rhs,u,solver,mpi,t,1,solver->FdFFunction, + if (solver->m_flag_fdf_specified) { + IERR solver->HyperbolicFunction(rhs,u,solver,mpi,a_t,1,solver->FdFFunction, solver->UpwindFdF); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); } else { - IERR solver->HyperbolicFunction(rhs,u,solver,mpi,t,1,solver->FFunction, + IERR solver->HyperbolicFunction(rhs,u,solver,mpi,a_t,1,solver->FFunction, solver->Upwind); CHECKERR(ierr); - IERR solver->HyperbolicFunction(drhs,u,solver,mpi,t,0,solver->dFFunction, + IERR solver->HyperbolicFunction(drhs,u,solver,mpi,a_t,0,solver->dFFunction, solver->UpwinddF); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); _ArrayAXPY_(drhs,1.0,rhs,size); @@ -208,7 +208,7 @@ int ComputeRHSOperators( fclose(fout); strcpy(filename,"Mat_dFFunction_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); strcat(filename,".dat"); printf("ComputeRHSOperators(): Computing linearized matrix operator for dFFunction. ndof=%d.\n",ndof); printf("ComputeRHSOperators(): Writing to sparse matrix file %s.\n",filename); @@ -216,7 +216,7 @@ int ComputeRHSOperators( fprintf(fout,"%d\n",ndof); /* compute the FFunction of u0 */ _ArraySetValue_(f0,ndof,0.0); - IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,t,0,solver->dFFunction, + IERR solver->HyperbolicFunction(rhs,u0,solver,mpi,a_t,0,solver->dFFunction, solver->UpwinddF); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); /* transfer to an array f0 which as no ghost points */ @@ -234,11 +234,11 @@ int ComputeRHSOperators( /* add a perturbation */ u[nvars*p+v] += epsilon; /* apply boundary conditions to the perturbed solution u */ - IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t);CHECKERR(ierr); - IERR solver->ApplyIBConditions(solver,mpi,u,t);CHECKERR(ierr); + IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t);CHECKERR(ierr); + IERR solver->ApplyIBConditions(solver,mpi,u,a_t);CHECKERR(ierr); IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); CHECKERR(ierr); /* compute the FFunction of u */ - IERR solver->HyperbolicFunction(rhs,u,solver,mpi,t,0,solver->dFFunction, + IERR solver->HyperbolicFunction(rhs,u,solver,mpi,a_t,0,solver->dFFunction, solver->UpwinddF); CHECKERR(ierr); _ArrayScale1D_(rhs,-1.0,size); /* transfer to an array f which as no ghost points */ @@ -259,7 +259,7 @@ int ComputeRHSOperators( /* compute linearized matrix for the source SFunction */ if (solver->SFunction) { strcpy(filename,"Mat_SFunction_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); strcat(filename,".dat"); printf("ComputeRHSOperators(): Computing linearized matrix operator for SFunction. ndof=%d.\n",ndof); printf("ComputeRHSOperators(): Writing to sparse matrix file %s.\n",filename); @@ -267,7 +267,7 @@ int ComputeRHSOperators( fprintf(fout,"%d\n",ndof); /* compute the FFunction of u0 */ _ArraySetValue_(f0,ndof,0.0); - IERR solver->SourceFunction(rhs,u0,solver,mpi,t); CHECKERR(ierr); + IERR solver->SourceFunction(rhs,u0,solver,mpi,a_t); CHECKERR(ierr); /* transfer to an array f0 which as no ghost points */ IERR ArrayCopynD(ndims,rhs,f0,dim,ghosts,0,index,nvars); CHECKERR(ierr); for (i=0; iApplyBoundaryConditions(solver,mpi,u,NULL,t);CHECKERR(ierr); - IERR solver->ApplyIBConditions(solver,mpi,u,t);CHECKERR(ierr); + IERR solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t);CHECKERR(ierr); + IERR solver->ApplyIBConditions(solver,mpi,u,a_t);CHECKERR(ierr); IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); CHECKERR(ierr); /* compute the SFunction of u */ - IERR solver->SourceFunction(rhs,u,solver,mpi,t); CHECKERR(ierr); + IERR solver->SourceFunction(rhs,u,solver,mpi,a_t); CHECKERR(ierr); /* transfer to an array f which as no ghost points */ _ArraySetValue_(f,ndof,0.0); IERR ArrayCopynD(ndims,rhs,f,dim,ghosts,0,index,nvars); CHECKERR(ierr); diff --git a/src/HyParFunctions/ExactSolution.c b/src/HyParFunctions/ExactSolution.c index d9dd4523..56becb7e 100644 --- a/src/HyParFunctions/ExactSolution.c +++ b/src/HyParFunctions/ExactSolution.c @@ -14,45 +14,45 @@ /*! Read in the exact solution, if available. */ int ExactSolution( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *uex, /*!< Array to hold the exact solution, if available */ - char *fname, /*!< Filename root from which to read exact solution */ - int *flag /*!< Flag to indicate if exact solution was available */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_uex, /*!< Array to hold the exact solution, if available */ + char *a_fname, /*!< Filename root from which to read exact solution */ + int *a_flag /*!< Flag to indicate if exact solution was available */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int same_size = 1; - for (int i=0; indims; i++) { - if (solver->dim_global[i] != solver->dim_global_ex[i]) same_size = 0; + for (int i=0; im_ndims; i++) { + if (solver->m_dim_global[i] != solver->m_dim_global_ex[i]) same_size = 0; } if (same_size) { - ReadArray( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->ghosts, + ReadArray( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, solver, - m, + a_m, NULL, - uex, - fname, - flag); + a_uex, + a_fname, + a_flag); } else { - ReadArraywInterp( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->dim_global_ex, - solver->ghosts, + ReadArraywInterp( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_dim_global_ex, + solver->m_ghosts, solver, - m, + a_m, NULL, - uex, - fname, - flag); + a_uex, + a_fname, + a_flag); } return(0); diff --git a/src/HyParFunctions/HyperbolicFunction.c b/src/HyParFunctions/HyperbolicFunction.c index 4f166596..8cf50db0 100644 --- a/src/HyParFunctions/HyperbolicFunction.c +++ b/src/HyParFunctions/HyperbolicFunction.c @@ -29,12 +29,12 @@ static int DefaultUpwinding (double*,double*,double*,double*,double*,double are computed using the function ReconstructHyperbolic(). */ int HyperbolicFunction( - double *hyp, /*!< Array to hold the computed hyperbolic term (shares the same layout as u */ - double *u, /*!< Solution array */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current simulation time */ - int LimFlag, /*!< Flag to indicate if the nonlinear coefficients for solution-dependent + double *a_hyp, /*!< Array to hold the computed hyperbolic term (shares the same layout as u */ + double *a_u, /*!< Solution array */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current simulation time */ + int a_LimFlag, /*!< Flag to indicate if the nonlinear coefficients for solution-dependent interpolation method should be recomputed (see ReconstructHyperbolic() for an explanation on why this is needed) */ /*! Function pointer to the flux function for the hyperbolic term */ @@ -43,28 +43,28 @@ int HyperbolicFunction( int(*UpwindFunction)(double*,double*,double*,double*,double*,double*,int,void*,double) ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int d, v, i, done; - double *FluxI = solver->fluxI; /* interface flux */ - double *FluxC = solver->fluxC; /* cell centered flux */ + double *FluxI = solver->m_flux_i; /* interface flux */ + double *FluxC = solver->m_flux_c; /* cell centered flux */ _DECLARE_IERR_; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int size = solver->npoints_local_wghosts; - double *x = solver->x; - double *dxinv = solver->dxinv; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int size = solver->m_npoints_local_wghosts; + double *x = solver->m_x; + double *dxinv = solver->m_dxinv; int index[ndims], index1[ndims], index2[ndims], dim_interface[ndims]; - LimFlag = (LimFlag && solver->flag_nonlinearinterp && solver->SetInterpLimiterVar); + a_LimFlag = (a_LimFlag && solver->m_flag_nonlinearinterp && solver->SetInterpLimiterVar); - _ArraySetValue_(hyp,size*nvars,0.0); - _ArraySetValue_(solver->StageBoundaryIntegral,2*ndims*nvars,0.0); + _ArraySetValue_(a_hyp,size*nvars,0.0); + _ArraySetValue_(solver->m_stage_boundary_integral,2*ndims*nvars,0.0); if (!FluxFunction) return(0); /* zero hyperbolic term */ - solver->count_hyp++; + solver->m_count_hyp++; #if defined(CPU_STAT) double cpu_time = 0.0; @@ -78,9 +78,9 @@ int HyperbolicFunction( int size_interface = 1; for (i = 0; i < ndims; i++) size_interface *= dim_interface[i]; /* evaluate cell-centered flux */ - IERR FluxFunction(FluxC,u,d,solver,t); CHECKERR(ierr); + IERR FluxFunction(FluxC,a_u,d,solver,a_t); CHECKERR(ierr); /* compute interface fluxes */ - IERR ReconstructHyperbolic(FluxI,FluxC,u,x+offset,d,solver,mpi,t,LimFlag,UpwindFunction); + IERR ReconstructHyperbolic(FluxI,FluxC,a_u,x+offset,d,solver,mpi,a_t,a_LimFlag,UpwindFunction); CHECKERR(ierr); /* calculate the first derivative */ @@ -97,13 +97,13 @@ int HyperbolicFunction( _ArrayIndex1D_(ndims,dim ,index ,ghosts,p); _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1); _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); - for (v=0; vStageBoundaryIntegral[(2*d+0)*nvars+v] -= FluxI[nvars*p1+v]; + for (v=0; vm_stage_boundary_integral[(2*d+0)*nvars+v] -= FluxI[nvars*p1+v]; if (index[d] == dim[d]-1) - for (v=0; vStageBoundaryIntegral[(2*d+1)*nvars+v] += FluxI[nvars*p2+v]; + for (v=0; vm_stage_boundary_integral[(2*d+1)*nvars+v] += FluxI[nvars*p2+v]; _ArrayIncrementIndex_(ndims,dim,index,done); } @@ -120,7 +120,7 @@ int HyperbolicFunction( printf("HyperbolicFunction CPU time = %8.6lf\n", cpu_time); #endif - if (solver->flag_ib) _ArrayBlockMultiply_(hyp,solver->iblank,size,nvars); + if (solver->m_flag_ib) _ArrayBlockMultiply_(a_hyp,solver->m_iblank,size,nvars); return(0); } @@ -142,7 +142,7 @@ int HyperbolicFunction( \hat{\bf u}^L_{j+1/2} &= \mathcal{I}\left({\bf u}_j,+1\right), \\ \hat{\bf u}^R_{j+1/2} &= \mathcal{I}\left({\bf u}_j,-1\right), \f} - The specific choice of \f$\mathcal{I}\f$ is set based on #HyPar::spatial_scheme_hyp. + The specific choice of \f$\mathcal{I}\f$ is set based on #HyPar::m_spatial_scheme_hyp. \b Upwinding: The final flux at the interface is computed as \f{equation}{ @@ -165,58 +165,58 @@ int HyperbolicFunction( + LimFlag = 0 means reuse the the previously computed coefficients. */ int ReconstructHyperbolic( - double *fluxI, /*!< Array to hold the computed interface fluxes. This array does not + double *a_fluxI, /*!< Array to hold the computed interface fluxes. This array does not have ghost points. The dimensions are the same as those of u without - ghost points in all dimensions, except along dir, where it is one more */ - double *fluxC, /*!< Array of the flux function computed at the cell centers - (same layout as u) */ - double *u, /*!< Solution array */ - double *x, /*!< Array of spatial coordinates */ - int dir, /*!< Spatial dimension along which to reconstruct the interface fluxes */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current solution time */ - int LimFlag, /*!< Flag to indicate if the nonlinear coefficients for solution-dependent + ghost points in all dimensions, except along a_dir, where it is one more */ + double *a_fluxC, /*!< Array of the flux function computed at the cell centers + (same layout as a_u) */ + double *a_u, /*!< Solution array */ + double *a_x, /*!< Array of spatial coordinates */ + int a_dir, /*!< Spatial dimension along which to reconstruct the interface fluxes */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current solution time */ + int a_LimFlag, /*!< Flag to indicate if the nonlinear coefficients for solution-dependent interpolation method should be recomputed */ /*! Function pointer to the upwinding function for the interface flux computation. If NULL, DefaultUpwinding() will be used. */ int(*UpwindFunction)(double*,double*,double*,double*,double*,double*,int,void*,double) ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; _DECLARE_IERR_; double *uC = NULL; - double *uL = solver->uL; - double *uR = solver->uR; - double *fluxL = solver->fL; - double *fluxR = solver->fR; + double *uL = solver->m_u_l; + double *uR = solver->m_u_r; + double *fluxL = solver->m_f_l; + double *fluxR = solver->m_f_r; /* precalculate the non-linear interpolation coefficients if required else reuse the weights previously calculated */ - if (LimFlag) IERR solver->SetInterpLimiterVar(fluxC,u,x,dir,solver,mpi); + if (a_LimFlag) IERR solver->SetInterpLimiterVar(a_fluxC,a_u,a_x,a_dir,solver,mpi); - /* if defined, calculate the modified u-function to be used for upwinding + /* if defined, calculate the modified a_u-function to be used for upwinding e.g.: used in well-balanced schemes for Euler/Navier-Stokes with gravity - otherwise, just copy u to uC */ + otherwise, just copy a_u to uC */ if (solver->UFunction) { - uC = solver->uC; - IERR solver->UFunction(uC,u,dir,solver,mpi,t); CHECKERR(ierr); - } else uC = u; + uC = solver->m_u_c; + IERR solver->UFunction(uC,a_u,a_dir,solver,mpi,a_t); CHECKERR(ierr); + } else uC = a_u; /* Interpolation -> to calculate left and right-biased interface flux and state variable*/ - IERR solver->InterpolateInterfacesHyp(uL ,uC ,u,x, 1,dir,solver,mpi,1); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(uR ,uC ,u,x,-1,dir,solver,mpi,1); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(fluxL,fluxC,u,x, 1,dir,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(fluxR,fluxC,u,x,-1,dir,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(uL ,uC ,a_u,a_x, 1,a_dir,solver,mpi,1); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(uR ,uC ,a_u,a_x,-1,a_dir,solver,mpi,1); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(fluxL,a_fluxC,a_u,a_x, 1,a_dir,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(fluxR,a_fluxC,a_u,a_x,-1,a_dir,solver,mpi,0); CHECKERR(ierr); /* Upwind -> to calculate the final interface flux */ - if (UpwindFunction) { IERR UpwindFunction (fluxI,fluxL,fluxR,uL ,uR ,u ,dir,solver,t); CHECKERR(ierr); } - else { IERR DefaultUpwinding (fluxI,fluxL,fluxR,NULL,NULL,NULL,dir,solver,t); CHECKERR(ierr); } + if (UpwindFunction) { IERR UpwindFunction (a_fluxI,fluxL,fluxR,uL ,uR ,a_u ,a_dir,solver,a_t); CHECKERR(ierr); } + else { IERR DefaultUpwinding (a_fluxI,fluxL,fluxR,NULL,NULL,NULL,a_dir,solver,a_t); CHECKERR(ierr); } return(0); } @@ -224,35 +224,35 @@ int ReconstructHyperbolic( /*! If no upwinding scheme is specified, this function defines the "upwind" flux as the arithmetic mean of the left- and right-biased fluxes. */ int DefaultUpwinding( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ double t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done; - int *dim = solver->dim_local; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; int index_outer[ndims], index_inter[ndims]; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int v; for (v=0; vfluxI; /* interface flux */ double *gpu_FluxC = solver->fluxC; /* cell centered flux */ - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int size = solver->npoints_local_wghosts; - double *gpu_x = solver->gpu_x; - double *gpu_dxinv = solver->gpu_dxinv; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int size = solver->m_npoints_local_wghosts; + double *gpu_x = solver->m_gpu_x; + double *gpu_dxinv = solver->m_gpu_dxinv; double *gpu_FluxI_p1, *gpu_FluxI_p2; LimFlag = (LimFlag && solver->flag_nonlinearinterp && solver->SetInterpLimiterVar); @@ -238,8 +238,8 @@ extern "C" int gpuHyperbolicFunction( /* compute interface fluxes */ ReconstructHyperbolic(gpu_FluxI,gpu_FluxC,gpu_u,gpu_x+offset,d,solver,mpi,t,LimFlag,UpwindFunction); - gpu_FluxI_p1 = solver->StageBoundaryBuffer+(solver->gpu_npoints_boundary_offset[d]*nvars); - gpu_FluxI_p2 = solver->StageBoundaryBuffer+(solver->gpu_npoints_boundary_offset[d]+solver->gpu_npoints_boundary[d])*nvars; + gpu_FluxI_p1 = solver->StageBoundaryBuffer+(solver->m_gpu_npoints_boundary_offset[d]*nvars); + gpu_FluxI_p2 = solver->StageBoundaryBuffer+(solver->m_gpu_npoints_boundary_offset[d]+solver->m_gpu_npoints_boundary[d])*nvars; #if defined(GPU_STAT) checkCuda( cudaEventRecord(start, 0) ); @@ -248,13 +248,13 @@ extern "C" int gpuHyperbolicFunction( if (ndims == 3) { HyperbolicFunction_dim3_kernel<<>>( npoints_grid, d, nvars, ghosts, offset, - solver->gpu_dim_local, gpu_FluxI, gpu_dxinv, + solver->m_gpu_dim_local, gpu_FluxI, gpu_dxinv, hyp, gpu_FluxI_p1, gpu_FluxI_p2 ); } else if (ndims == 2) { HyperbolicFunction_dim2_kernel<<>>( npoints_grid, d, nvars, ghosts, offset, - solver->gpu_dim_local, gpu_FluxI, gpu_dxinv, + solver->m_gpu_dim_local, gpu_FluxI, gpu_dxinv, hyp, gpu_FluxI_p1, gpu_FluxI_p2 ); } else { @@ -274,11 +274,11 @@ extern "C" int gpuHyperbolicFunction( #endif StageBoundaryIntegral_kernel<<<1, GPU_THREADS_PER_BLOCK, GPU_THREADS_PER_BLOCK*nvars*sizeof(double)>>>( - solver->gpu_npoints_boundary[d], nvars, -1, gpu_FluxI_p1, + solver->m_gpu_npoints_boundary[d], nvars, -1, gpu_FluxI_p1, solver->StageBoundaryIntegral + 2*d*nvars ); StageBoundaryIntegral_kernel<<<1, GPU_THREADS_PER_BLOCK, GPU_THREADS_PER_BLOCK*nvars*sizeof(double)>>>( - solver->gpu_npoints_boundary[d], nvars, 1, gpu_FluxI_p2, + solver->m_gpu_npoints_boundary[d], nvars, 1, gpu_FluxI_p2, solver->StageBoundaryIntegral + (2*d+1)*nvars ); cudaDeviceSynchronize(); @@ -288,13 +288,13 @@ extern "C" int gpuHyperbolicFunction( checkCuda( cudaEventSynchronize(stop) ); checkCuda( cudaEventElapsedTime(&milliseconds, start, stop) ); printf("%-50s GPU time = %.6f dir = %d bandwidth (GB/s) = %.2f\n", - "StageBoundaryIntegral", milliseconds*1e-3, d, (1e-6*2*solver->gpu_npoints_boundary[d]*nvars*sizeof(double))/milliseconds); + "StageBoundaryIntegral", milliseconds*1e-3, d, (1e-6*2*solver->m_gpu_npoints_boundary[d]*nvars*sizeof(double))/milliseconds); #endif offset += dim[d] + 2*ghosts; } - if (solver->flag_ib) gpuArrayBlockMultiply(hyp, solver->gpu_iblank, size, nvars); + if (solver->flag_ib) gpuArrayBlockMultiply(hyp, solver->m_gpu_iblank, size, nvars); #if defined(GPU_STAT) checkCuda(cudaEventDestroy(start)); @@ -492,13 +492,13 @@ extern "C" int gpuHyperbolicFunction( double *FluxI = solver->fluxI; /* interface flux */ double *FluxC = solver->fluxC; /* cell centered flux */ - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int size = solver->npoints_local_wghosts; - double *x = solver->gpu_x; - double *dxinv = solver->gpu_dxinv; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int size = solver->m_npoints_local_wghosts; + double *x = solver->m_gpu_x; + double *dxinv = solver->m_gpu_dxinv; double *FluxI_p1, *FluxI_p2; LimFlag = (LimFlag && solver->flag_nonlinearinterp && solver->SetInterpLimiterVar); @@ -529,8 +529,8 @@ extern "C" int gpuHyperbolicFunction( /* compute interface fluxes */ ReconstructHyperbolic(FluxI,FluxC,u,x+offset,d,solver,mpi,t,LimFlag,UpwindFunction); - FluxI_p1 = solver->StageBoundaryBuffer+(solver->gpu_npoints_boundary_offset[d]*nvars); - FluxI_p2 = solver->StageBoundaryBuffer+(solver->gpu_npoints_boundary_offset[d]+solver->gpu_npoints_boundary[d])*nvars; + FluxI_p1 = solver->StageBoundaryBuffer+(solver->m_gpu_npoints_boundary_offset[d]*nvars); + FluxI_p2 = solver->StageBoundaryBuffer+(solver->m_gpu_npoints_boundary_offset[d]+solver->m_gpu_npoints_boundary[d])*nvars; #if defined(GPU_STAT) checkCuda( cudaEventRecord(start, 0) ); @@ -538,7 +538,7 @@ extern "C" int gpuHyperbolicFunction( if (ndims == 3) { HyperbolicFunction_dim3_kernel<<>>( npoints_grid, size, npoints_dim_interface, d, nvars, ghosts, offset, - solver->gpu_dim_local, FluxI, dxinv, + solver->m_gpu_dim_local, FluxI, dxinv, hyp, FluxI_p1, FluxI_p2 ); } else { @@ -558,11 +558,11 @@ extern "C" int gpuHyperbolicFunction( #endif StageBoundaryIntegral_kernel<<<1, GPU_THREADS_PER_BLOCK, GPU_THREADS_PER_BLOCK*nvars*sizeof(double)>>>( - solver->gpu_npoints_boundary[d], nvars, -1, FluxI_p1, + solver->m_gpu_npoints_boundary[d], nvars, -1, FluxI_p1, solver->StageBoundaryIntegral + 2*d*nvars ); StageBoundaryIntegral_kernel<<<1, GPU_THREADS_PER_BLOCK, GPU_THREADS_PER_BLOCK*nvars*sizeof(double)>>>( - solver->gpu_npoints_boundary[d], nvars, 1, FluxI_p2, + solver->m_gpu_npoints_boundary[d], nvars, 1, FluxI_p2, solver->StageBoundaryIntegral + (2*d+1)*nvars ); cudaDeviceSynchronize(); @@ -572,12 +572,12 @@ extern "C" int gpuHyperbolicFunction( checkCuda( cudaEventSynchronize(stop) ); checkCuda( cudaEventElapsedTime(&milliseconds, start, stop) ); printf("%-50s GPU time = %.6f dir = %d bandwidth (GB/s) = %.2f\n", - "StageBoundaryIntegral", milliseconds*1e-3, d, (1e-6*2*solver->gpu_npoints_boundary[d]*nvars*sizeof(double))/milliseconds); + "StageBoundaryIntegral", milliseconds*1e-3, d, (1e-6*2*solver->m_gpu_npoints_boundary[d]*nvars*sizeof(double))/milliseconds); #endif offset += dim[d] + 2*ghosts; } - if (solver->flag_ib) gpuArrayBlockMultiply(hyp, solver->gpu_iblank, size, nvars); + if (solver->flag_ib) gpuArrayBlockMultiply(hyp, solver->m_gpu_iblank, size, nvars); #if defined(GPU_STAT) checkCuda(cudaEventDestroy(start)); @@ -703,9 +703,9 @@ int DefaultUpwinding( HyPar *solver = (HyPar*) s; int done; - int *dim = solver->dim_local; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int bounds_outer[ndims], bounds_inter[ndims]; _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; diff --git a/src/HyParFunctions/IncrementFilename.c b/src/HyParFunctions/IncrementFilename.c index e51b5b99..9fbe8f57 100644 --- a/src/HyParFunctions/IncrementFilename.c +++ b/src/HyParFunctions/IncrementFilename.c @@ -44,30 +44,30 @@ can be of arbitrary length. */ void IncrementFilenameIndex( - char *f, /*!< Character string representing the integer */ - int len /*!< Length of the string */ + char *a_f, /*!< Character string representing the integer */ + int a_len /*!< Length of the string */ ) { int i; - for (i=len-1; i>=0; i--) { - if (f[i] == '9') { - f[i] = '0'; + for (i=a_len-1; i>=0; i--) { + if (a_f[i] == '9') { + a_f[i] = '0'; if (!i) fprintf(stderr,"Warning: file increment hit max limit. Resetting to zero.\n"); } else { - f[i]++; + a_f[i]++; break; } } } /*! Resets the index to "0000..." of a desired length. */ -void ResetFilenameIndex( char *f, /*!< Character string representing the integer */ - int len /*!< Length of the string */ ) +void ResetFilenameIndex( char *a_f, /*!< Character string representing the integer */ + int a_len /*!< Length of the string */ ) { - if (!f) return; + if (!a_f) return; int i; - for (i = 0; i < len; i++) { - f[i] = '0'; + for (i = 0; i < a_len; i++) { + a_f[i] = '0'; } return; } diff --git a/src/HyParFunctions/NonLinearInterpolation.c b/src/HyParFunctions/NonLinearInterpolation.c index 78c23ed1..50d0446f 100644 --- a/src/HyParFunctions/NonLinearInterpolation.c +++ b/src/HyParFunctions/NonLinearInterpolation.c @@ -26,43 +26,43 @@ is called with the argument \b LimFlag = 0. */ int NonLinearInterpolation( - double *u, /*!< Solution array */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current solution time */ - /*! The flux function \f${\bf f}_d\left({\bf u}\right)\f$, whose + double *a_u, /*!< Solution array */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current solution time */ + /*! The flux function \f${\bf f}_d\left({\bf u}\a_right)\f$, whose properties (typically smoothness) is used to evaluate the nonlinear coefficients */ int (*FluxFunction)(double*,double*,int,void*,double) ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - double *FluxC = solver->fluxC; /* cell centered flux */ + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + double *FluxC = solver->m_flux_c; /* cell centered flux */ _DECLARE_IERR_; - int flag = (FluxFunction && solver->flag_nonlinearinterp && solver->SetInterpLimiterVar); + int flag = (FluxFunction && solver->m_flag_nonlinearinterp && solver->SetInterpLimiterVar); if (flag) {; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *x = solver->x; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *x = solver->m_x; int size = 1, d; for (d=0; dApplyBoundaryConditions(solver,mpi,u,NULL,t); CHECKERR(ierr); - IERR solver->ApplyIBConditions(solver,mpi,u,t); CHECKERR(ierr); - IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); CHECKERR(ierr); + IERR solver->ApplyBoundaryConditions(solver,mpi,a_u,NULL,a_t); CHECKERR(ierr); + IERR solver->ApplyIBConditions(solver,mpi,a_u,a_t); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,a_u); CHECKERR(ierr); int offset = 0; for (d = 0; d < ndims; d++) { /* evaluate cell-centered flux */ - IERR FluxFunction(FluxC,u,d,solver,t); CHECKERR(ierr); + IERR FluxFunction(FluxC,a_u,d,solver,a_t); CHECKERR(ierr); /* calculate non-linear interpolation coefficients */ - IERR solver->SetInterpLimiterVar(FluxC,u,x+offset,d,solver,mpi);CHECKERR(ierr); + IERR solver->SetInterpLimiterVar(FluxC,a_u,x+offset,d,solver,mpi);CHECKERR(ierr); offset += dim[d] + 2*ghosts; } } diff --git a/src/HyParFunctions/ParabolicFunctionCons1Stage.c b/src/HyParFunctions/ParabolicFunctionCons1Stage.c index 74b68cf8..941bde4c 100644 --- a/src/HyParFunctions/ParabolicFunctionCons1Stage.c +++ b/src/HyParFunctions/ParabolicFunctionCons1Stage.c @@ -18,46 +18,46 @@ \f{equation}{ \left.{\bf P}\left({\bf u}\right)\right|_j = \sum_{d=0}^{D-1} \frac { \hat{\bf g}_{j+1/2} - \hat{\bf g}_{j-1/2} } {\Delta x_d^2}, \f} - where \f$d\f$ is the spatial dimension index, \f$D\f$ is the total number of spatial dimensions (#HyPar::ndims), and \f$j\f$ is + where \f$d\f$ is the spatial dimension index, \f$D\f$ is the total number of spatial dimensions (#HyPar::m_ndims), and \f$j\f$ is the grid index along \f$d\f$. \f$\hat{\bf g}_d\f$ is the numerical approximation to the second primitive of \f${\bf g}_d\left({\bf u}\right)\f$, computed using #HyPar::InterpolateInterfacesPar. \b Note: this form of the parabolic term \b does \b not allow for cross-derivatives. To use this form of the parabolic term: - + specify \b "par_space_type" in solver.inp as \b "conservative-1stage" (#HyPar::spatial_type_par). + + specify \b "par_space_type" in solver.inp as \b "conservative-1stage" (#HyPar::m_spatial_type_par). + the physical model must specify \f${\bf g}_d\left({\bf u}\right)\f$ through #HyPar::GFunction. \b Reference: Liu, Y., Shu, C.-W., Zhang, M., "High order finite difference WENO schemes for nonlinear degenerate parabolic equations", SIAM J. Sci. Comput., 33 (2), 2011, pp. 939-965, http://dx.doi.org/10.1137/100791002 */ int ParabolicFunctionCons1Stage( - double *par, /*!< array to hold the computed parabolic term */ - double *u, /*!< solution */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_par, /*!< array to hold the computed parabolic term */ + double *a_u, /*!< solution */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - double *FluxI = solver->fluxI; /* interface flux array */ - double *Func = solver->fluxC; /* diffusion function array */ + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + double *FluxI = solver->m_flux_i; /* interface flux array */ + double *Func = solver->m_flux_c; /* diffusion function array */ int d, v, i, done; _DECLARE_IERR_; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *dxinv = solver->dxinv; - int size = solver->npoints_local_wghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *dxinv = solver->m_dxinv; + int size = solver->m_npoints_local_wghosts; int index[ndims], index1[ndims], index2[ndims], dim_interface[ndims]; - _ArraySetValue_(par,size*nvars,0.0); + _ArraySetValue_(a_par,size*nvars,0.0); if (!solver->GFunction) return(0); /* zero parabolic term */ - solver->count_par++; + solver->m_count_par++; int offset = 0; for (d = 0; d < ndims; d++) { @@ -66,7 +66,7 @@ int ParabolicFunctionCons1Stage( int size_interface = 1; for (i = 0; i < ndims; i++) size_interface *= dim_interface[i]; /* evaluate cell-centered flux */ - IERR solver->GFunction(Func,u,d,solver,t); CHECKERR(ierr); + IERR solver->GFunction(Func,a_u,d,solver,a_t); CHECKERR(ierr); /* compute interface fluxes */ IERR solver->InterpolateInterfacesPar(FluxI,Func,d,solver,mpi); CHECKERR(ierr); @@ -80,7 +80,7 @@ int ParabolicFunctionCons1Stage( _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1); _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); for (v=0; vflag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars); + if (solver->m_flag_ib) _ArrayBlockMultiply_(a_par,solver->m_iblank,size,nvars); return(0); } diff --git a/src/HyParFunctions/ParabolicFunctionNC1.5Stage.c b/src/HyParFunctions/ParabolicFunctionNC1.5Stage.c index fc8772a4..478d1362 100644 --- a/src/HyParFunctions/ParabolicFunctionNC1.5Stage.c +++ b/src/HyParFunctions/ParabolicFunctionNC1.5Stage.c @@ -14,7 +14,7 @@ \f{equation}{ {\bf P}\left({\bf u}\right) = \sum_{d1=0}^{D-1}\sum_{d2=0}^{D-1} \frac {\partial^2 h_{d1,d2}\left(\bf u\right)} {\partial x_{d1} \partial x_{d2}}, \f} - where \f$d1\f$ and \f$d2\f$ are spatial dimension indices, and \f$D\f$ is the total number of spatial dimensions (#HyPar::ndims). This term is + where \f$d1\f$ and \f$d2\f$ are spatial dimension indices, and \f$D\f$ is the total number of spatial dimensions (#HyPar::m_ndims). This term is discretized at a grid point as: \f{equation}{ \left.{\bf P}\left({\bf u}\right)\right|_j = \sum_{d1=0}^{D-1} \sum_{d2=0}^{D-1} \frac { \mathcal{D}_{d1}\mathcal{D}_{d2} \left[ {\bf h}_{d1,d2} \right] } {\Delta x_{d1} \Delta x_{d2}}, @@ -27,46 +27,46 @@ \b Note: this form of the parabolic term \b does \b allow for cross-derivatives (\f$ d1 \ne d2 \f$). To use this form of the parabolic term: - + specify \b "par_space_type" in solver.inp as \b "nonconservative-1.5stage" (#HyPar::spatial_type_par). + + specify \b "par_space_type" in solver.inp as \b "nonconservative-1.5stage" (#HyPar::m_spatial_type_par). + the physical model must specify \f${\bf h}_{d1,d2}\left({\bf u}\right)\f$ through #HyPar::HFunction. \sa ParabolicFunctionNC2Stage() */ int ParabolicFunctionNC1_5Stage( - double *par, /*!< array to hold the computed parabolic term */ - double *u, /*!< solution */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_par, /*!< array to hold the computed parabolic term */ + double *a_u, /*!< solution */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - double *Func = solver->fluxC; - double *Deriv1 = solver->Deriv1; - double *Deriv2 = solver->Deriv2; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + double *Func = solver->m_flux_c; + double *Deriv1 = solver->m_deriv1; + double *Deriv2 = solver->m_deriv2; int d, d1, d2, v, p, done; double dxinv1, dxinv2; _DECLARE_IERR_; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *dxinv = solver->dxinv; - int size = solver->npoints_local_wghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *dxinv = solver->m_dxinv; + int size = solver->m_npoints_local_wghosts; if (!solver->HFunction) return(0); /* zero parabolic terms */ - solver->count_par++; + solver->m_count_par++; int index[ndims]; - _ArraySetValue_(par,size*nvars,0.0); + _ArraySetValue_(a_par,size*nvars,0.0); for (d1 = 0; d1 < ndims; d1++) { for (d2 = 0; d2 < ndims; d2++) { /* calculate the diffusion function */ - IERR solver->HFunction(Func,u,d1,d2,solver,t); CHECKERR(ierr); + IERR solver->HFunction(Func,a_u,d1,d2,solver,a_t); CHECKERR(ierr); if (d1 == d2) { /* second derivative with respect to the same independent variable */ IERR solver->SecondDerivativePar(Deriv2,Func,d1,solver,mpi); CHECKERR(ierr); @@ -83,13 +83,13 @@ int ParabolicFunctionNC1_5Stage( _ArrayIndex1D_(ndims,dim,index,ghosts,p); _GetCoordinate_(d1,index[d1],dim,ghosts,dxinv,dxinv1); _GetCoordinate_(d2,index[d2],dim,ghosts,dxinv,dxinv2); - for (v=0; vflag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars); + if (solver->m_flag_ib) _ArrayBlockMultiply_(a_par,solver->m_iblank,size,nvars); return(0); } diff --git a/src/HyParFunctions/ParabolicFunctionNC1Stage.c b/src/HyParFunctions/ParabolicFunctionNC1Stage.c index 8c62d141..df3ce280 100644 --- a/src/HyParFunctions/ParabolicFunctionNC1Stage.c +++ b/src/HyParFunctions/ParabolicFunctionNC1Stage.c @@ -18,50 +18,50 @@ \f{equation}{ \left.{\bf P}\left({\bf u}\right)\right|_j = \sum_{d=0}^{D-1} \frac { \mathcal{L}_d \left[ {\bf g}_d \right] } {\Delta x_d^2}, \f} - where \f$d\f$ is the spatial dimension index, \f$D\f$ is the total number of spatial dimensions (#HyPar::ndims), and \f$j\f$ is + where \f$d\f$ is the spatial dimension index, \f$D\f$ is the total number of spatial dimensions (#HyPar::m_ndims), and \f$j\f$ is the grid index along \f$d\f$. \f$\mathcal{L}_d\f$ represents the finite-difference approximation to the Laplacian along the \f$d\f$ spatial dimension, computed using #HyPar::SecondDerivativePar. \b Note: this form of the parabolic term \b does \b not allow for cross-derivatives. To use this form of the parabolic term: - + specify \b "par_space_type" in solver.inp as \b "nonconservative-1stage" (#HyPar::spatial_type_par). + + specify \b "par_space_type" in solver.inp as \b "nonconservative-1stage" (#HyPar::m_spatial_type_par). + the physical model must specify \f${\bf g}_d\left({\bf u}\right)\f$ through #HyPar::GFunction. */ int ParabolicFunctionNC1Stage( - double *par, /*!< array to hold the computed parabolic term */ - double *u, /*!< solution */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_par, /*!< array to hold the computed parabolic term */ + double *a_u, /*!< solution */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - double *Func = solver->fluxC; - double *Deriv2 = solver->Deriv2; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + double *Func = solver->m_flux_c; + double *Deriv2 = solver->m_deriv2; int d, v, i, done; _DECLARE_IERR_; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *dxinv = solver->dxinv; - int size = solver->npoints_local_wghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *dxinv = solver->m_dxinv; + int size = solver->m_npoints_local_wghosts; if (!solver->GFunction) return(0); /* zero parabolic terms */ - solver->count_par++; + solver->m_count_par++; int index[ndims]; - _ArraySetValue_(par,size*nvars,0.0); + _ArraySetValue_(a_par,size*nvars,0.0); int offset = 0; for (d = 0; d < ndims; d++) { int size_deriv = 1; for (i=0; iGFunction(Func,u,d,solver,t); CHECKERR(ierr); + IERR solver->GFunction(Func,a_u,d,solver,a_t); CHECKERR(ierr); IERR solver->SecondDerivativePar(Deriv2,Func,d,solver,mpi); CHECKERR(ierr); /* calculate the final term - second derivative of the diffusion function */ @@ -70,7 +70,7 @@ int ParabolicFunctionNC1Stage( while (!done) { _ArrayIndex1D_(ndims,dim,index,ghosts,p); for (v=0; vflag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars); + if (solver->m_flag_ib) _ArrayBlockMultiply_(a_par,solver->m_iblank,size,nvars); return(0); } diff --git a/src/HyParFunctions/ParabolicFunctionNC2Stage.c b/src/HyParFunctions/ParabolicFunctionNC2Stage.c index e2458e44..8ab030a1 100644 --- a/src/HyParFunctions/ParabolicFunctionNC2Stage.c +++ b/src/HyParFunctions/ParabolicFunctionNC2Stage.c @@ -14,7 +14,7 @@ \f{equation}{ {\bf P}\left({\bf u}\right) = \sum_{d1=0}^{D-1}\sum_{d2=0}^{D-1} \frac {\partial^2 h_{d1,d2}\left(\bf u\right)} {\partial x_{d1} \partial x_{d2}}, \f} - where \f$d1\f$ and \f$d2\f$ are spatial dimension indices, and \f$D\f$ is the total number of spatial dimensions (#HyPar::ndims). This term is + where \f$d1\f$ and \f$d2\f$ are spatial dimension indices, and \f$D\f$ is the total number of spatial dimensions (#HyPar::m_ndims). This term is discretized at a grid point as: \f{equation}{ \left.{\bf P}\left({\bf u}\right)\right|_j = \sum_{d1=0}^{D-1} \sum_{d2=0}^{D-1} \frac { \mathcal{D}_{d1}\mathcal{D}_{d2} \left[ {\bf h}_{d1,d2} \right] } {\Delta x_{d1} \Delta x_{d2}}, @@ -32,48 +32,48 @@ of \f$n\f$, the first derivative is also computed with a \f$n\f$-th order approximation. To use this form of the parabolic term: - + specify \b "par_space_type" in solver.inp as \b "nonconservative-2stage" (#HyPar::spatial_type_par). + + specify \b "par_space_type" in solver.inp as \b "nonconservative-2stage" (#HyPar::m_spatial_type_par). + the physical model must specify \f${\bf h}_{d1,d2}\left({\bf u}\right)\f$ through #HyPar::HFunction. \sa ParabolicFunctionNC1_5Stage() */ int ParabolicFunctionNC2Stage( - double *par, /*!< array to hold the computed parabolic term */ - double *u, /*!< solution */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_par, /*!< array to hold the computed parabolic term */ + double *a_u, /*!< solution */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - double *Func = solver->fluxC; - double *Deriv1 = solver->Deriv1; - double *Deriv2 = solver->Deriv2; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + double *Func = solver->m_flux_c; + double *Deriv1 = solver->m_deriv1; + double *Deriv2 = solver->m_deriv2; int d, d1, d2, v, p, done; double dxinv1, dxinv2; _DECLARE_IERR_; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *dxinv = solver->dxinv; - int size = solver->npoints_local_wghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *dxinv = solver->m_dxinv; + int size = solver->m_npoints_local_wghosts; printf("HFunction is defined? = %p\n", solver->HFunction); if (!solver->HFunction) return(0); /* zero parabolic terms */ - solver->count_par++; + solver->m_count_par++; int index[ndims]; - _ArraySetValue_(par,size*nvars,0.0); + _ArraySetValue_(a_par,size*nvars,0.0); for (d1 = 0; d1 < ndims; d1++) { for (d2 = 0; d2 < ndims; d2++) { /* calculate the diffusion function */ - IERR solver->HFunction(Func,u,d1,d2,solver,t); CHECKERR(ierr); + IERR solver->HFunction(Func,a_u,d1,d2,solver,a_t); CHECKERR(ierr); IERR solver->FirstDerivativePar(Deriv1,Func ,d1, 1,solver,mpi); CHECKERR(ierr); IERR MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,Deriv1); CHECKERR(ierr); IERR solver->FirstDerivativePar(Deriv2,Deriv1,d2,-1,solver,mpi); CHECKERR(ierr); @@ -84,13 +84,13 @@ int ParabolicFunctionNC2Stage( _ArrayIndex1D_(ndims,dim,index,ghosts,p); _GetCoordinate_(d1,index[d1],dim,ghosts,dxinv,dxinv1); _GetCoordinate_(d2,index[d2],dim,ghosts,dxinv,dxinv2); - for (v=0; vflag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,nvars); + if (solver->m_flag_ib) _ArrayBlockMultiply_(a_par,solver->m_iblank,size,nvars); return(0); } diff --git a/src/HyParFunctions/ParabolicFunctionNC2Stage_GPU.cu b/src/HyParFunctions/ParabolicFunctionNC2Stage_GPU.cu index d799e358..9cf1c029 100644 --- a/src/HyParFunctions/ParabolicFunctionNC2Stage_GPU.cu +++ b/src/HyParFunctions/ParabolicFunctionNC2Stage_GPU.cu @@ -81,11 +81,11 @@ int ParabolicFunctionNC2Stage_GPU( int d1, d2; _DECLARE_IERR_; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int size = solver->npoints_local_wghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int size = solver->m_npoints_local_wghosts; if (!solver->HFunction) return(0); /* zero parabolic terms */ solver->count_par++; @@ -107,7 +107,7 @@ int ParabolicFunctionNC2Stage_GPU( int nblocks = (ngrid_points - 1) / GPU_THREADS_PER_BLOCK + 1; ParabolicFunctionNC2Stage_kernel<<>>( ghosts, d1, d2, ndims, nvars, ngrid_points, - solver->gpu_dim_local, solver->gpu_dxinv, solver->Deriv2, par + solver->m_gpu_dim_local, solver->m_gpu_dxinv, solver->Deriv2, par ); /* diff --git a/src/HyParFunctions/SourceFunction.c b/src/HyParFunctions/SourceFunction.c index 313715d9..84cf7bd5 100644 --- a/src/HyParFunctions/SourceFunction.c +++ b/src/HyParFunctions/SourceFunction.c @@ -20,57 +20,57 @@ boundary treatment, the sponge BC function is called. */ int SourceFunction( - double *source, /*!< the computed source term */ - double *u, /*!< solution */ - void *s, /*!< solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_source, /*!< the computed source term */ + double *a_u, /*!< solution */ + void *a_s, /*!< solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; /* initialize to zero */ - int size = solver->ndof_cells_wghosts; + int size = solver->m_ndof_cells_wghosts; #if defined(HAVE_CUDA) - if (solver->use_gpu) { - gpuArraySetValue(source,size, 0.0); + if (solver->m_use_gpu) { + gpuArraySetValue(a_source,size, 0.0); } else { #endif - _ArraySetValue_(source,size,0.0); + _ArraySetValue_(a_source,size,0.0); #if defined(HAVE_CUDA) } #endif - /* call the source function of the physics model, if available */ + /* call the a_source function of the physics model, if available */ if (solver->SFunction) { - solver->SFunction(source,u,solver,mpi,t); - solver->count_sou++; + solver->SFunction(a_source,a_u,solver,mpi,a_t); + solver->m_count_sou++; } - /* Apart from other source terms, implement sponge BC as a source */ - DomainBoundary* boundary = (DomainBoundary*) solver->boundary; + /* Apart from other a_source terms, implement sponge BC as a a_source */ + DomainBoundary* boundary = (DomainBoundary*) solver->m_boundary; int n; - int nb = solver->nBoundaryZones; + int nb = solver->m_n_boundary_zones; #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { for (n = 0; n < nb; n++) { - if (!strcmp(boundary[n].bctype,_SPONGE_)) { + if (!strcmp(boundary[n].m_bctype,_SPONGE_)) { fprintf(stderr,"ERROR: Sponge BC not yet implemented on GPU.\n"); } } } else { #endif for (n = 0; n < nb; n++) { - if (!strcmp(boundary[n].bctype,_SPONGE_)) { + if (!strcmp(boundary[n].m_bctype,_SPONGE_)) { BCSpongeSource( &boundary[n], - solver->ndims, - solver->nvars, - solver->ghosts, - solver->dim_local, - solver->x, - u, - source ); + solver->m_ndims, + solver->m_nvars, + solver->m_ghosts, + solver->m_dim_local, + solver->m_x, + a_u, + a_source ); } } #if defined(HAVE_CUDA) diff --git a/src/HyParFunctions/VolumeIntegral.c b/src/HyParFunctions/VolumeIntegral.c index 6967dc27..01c17ca9 100644 --- a/src/HyParFunctions/VolumeIntegral.c +++ b/src/HyParFunctions/VolumeIntegral.c @@ -12,19 +12,19 @@ /*! Compute the volume integral of the solution. */ int VolumeIntegral( - double *VolumeIntegral, /*!< The computed volume integral */ - double *u, /*!< Solution */ - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + double *a_VolumeIntegral, /*!< The computed volume integral */ + double *a_u, /*!< Solution */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int d,v; /* calculate local volume integral of the solution */ @@ -35,13 +35,13 @@ int VolumeIntegral( while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double dxinv[ndims]; - for (d=0; ddxinv,dxinv[d]); } + for (d=0; dm_dxinv,dxinv[d]); } double dV = 1.0; for (d=0; dworld); CHECKERR(ierr); + IERR MPISum_double(a_VolumeIntegral,local_integral,nvars,&mpi->m_world); CHECKERR(ierr); free(local_integral); return(0); diff --git a/src/IOFunctions/ReadArray.c b/src/IOFunctions/ReadArray.c index ef453a0f..c7c473f4 100644 --- a/src/IOFunctions/ReadArray.c +++ b/src/IOFunctions/ReadArray.c @@ -18,74 +18,74 @@ static int ReadArrayMPI_IO (int,int,int*,int*,int,void*,void*,double*,double* #endif /*! Read in a vector field from file: wrapper function that calls - the appropriate function depending on input mode (#HyPar::input_mode).\n\n - The mode and type of input are specified through #HyPar::input_mode and - #HyPar::ip_file_type. A vector field is read from file and stored in an array. + the appropriate function depending on input mode (#HyPar::m_input_mode).\n\n + The mode and type of input are specified through #HyPar::m_input_mode and + #HyPar::m_ip_file_type. A vector field is read from file and stored in an array. */ int ReadArray( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *x, /*!< Grid associated with the array (can be NULL) */ - double *u, /*!< Array to hold the vector field */ - char *fname_root, /*!< Filename root */ - int *read_flag /*!< Flag to indicate if the file was read */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_x, /*!< Grid associated with the array (can be NULL) */ + double *a_u, /*!< Array to hold the vector field */ + char *a_fname_root, /*!< Filename root */ + int *a_read_flag /*!< Flag to indicate if the file was read */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; _DECLARE_IERR_; - if (!strcmp(solver->input_mode,"serial")) { - IERR ReadArraySerial(ndims,nvars,dim_global,dim_local,ghosts,s,m,x,u,fname_root,read_flag); + if (!strcmp(solver->m_input_mode,"serial")) { + IERR ReadArraySerial(a_ndims,a_nvars,a_dim_global,a_dim_local,a_ghosts,a_s,a_m,a_x,a_u,a_fname_root,a_read_flag); CHECKERR(ierr); #ifndef serial - } else if (!strcmp(solver->input_mode,"parallel")) { - ReadArrayParallel(ndims,nvars,dim_global,dim_local,ghosts,s,m,x,u,fname_root,read_flag); + } else if (!strcmp(solver->m_input_mode,"parallel")) { + ReadArrayParallel(a_ndims,a_nvars,a_dim_global,a_dim_local,a_ghosts,a_s,a_m,a_x,a_u,a_fname_root,a_read_flag); CHECKERR(ierr); - } else if (!strcmp(solver->input_mode,"mpi-io" )) { - ReadArrayMPI_IO(ndims,nvars,dim_global,dim_local,ghosts,s,m,x,u,fname_root,read_flag); + } else if (!strcmp(solver->m_input_mode,"mpi-io" )) { + ReadArrayMPI_IO(a_ndims,a_nvars,a_dim_global,a_dim_local,a_ghosts,a_s,a_m,a_x,a_u,a_fname_root,a_read_flag); CHECKERR(ierr); #endif } else { - fprintf(stderr,"Error: Illegal value (%s) for input_mode.\n",solver->input_mode); + fprintf(stderr,"Error: Illegal value (%s) for input_mode.\n",solver->m_input_mode); return(1); } - if (x) { + if (a_x) { int offset, d; - /* exchange MPI-boundary values of x between processors */ + /* exchange MPI-boundary values of a_x between processors */ offset = 0; - for (d = 0; d < ndims; d++) { - IERR MPIExchangeBoundaries1D(mpi,&x[offset],dim_local[d], - ghosts,d,ndims); CHECKERR(ierr); - offset += (dim_local [d] + 2*ghosts); + for (d = 0; d < a_ndims; d++) { + IERR MPIExchangeBoundaries1D(mpi,&a_x[offset],a_dim_local[d], + a_ghosts,d,a_ndims); CHECKERR(ierr); + offset += (a_dim_local [d] + 2*a_ghosts); } - /* fill in ghost values of x at physical boundaries by extrapolation */ + /* fill in ghost values of a_x at physical boundaries by extrapolation */ offset = 0; - for (d = 0; d < ndims; d++) { - double *X = &x[offset]; - int *dim = dim_local, i; - if (mpi->ip[d] == 0) { + for (d = 0; d < a_ndims; d++) { + double *X = &a_x[offset]; + int *dim = a_dim_local, i; + if (mpi->m_ip[d] == 0) { /* fill left boundary along this dimension */ - for (i = 0; i < ghosts; i++) { - int delta = ghosts - i; - X[i] = X[ghosts] + ((double) delta) * (X[ghosts]-X[ghosts+1]); + for (i = 0; i < a_ghosts; i++) { + int delta = a_ghosts - i; + X[i] = X[a_ghosts] + ((double) delta) * (X[a_ghosts]-X[a_ghosts+1]); } } - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { /* fill right boundary along this dimension */ - for (i = dim[d]+ghosts; i < dim[d]+2*ghosts; i++) { - int delta = i - (dim[d]+ghosts-1); - X[i] = X[dim[d]+ghosts-1] - + ((double) delta) * (X[dim[d]+ghosts-1]-X[dim[d]+ghosts-2]); + for (i = dim[d]+a_ghosts; i < dim[d]+2*a_ghosts; i++) { + int delta = i - (dim[d]+a_ghosts-1); + X[i] = X[dim[d]+a_ghosts-1] + + ((double) delta) * (X[dim[d]+a_ghosts-1]-X[dim[d]+a_ghosts-2]); } } - offset += (dim[d] + 2*ghosts); + offset += (dim[d] + 2*a_ghosts); } } @@ -148,96 +148,96 @@ int ReadArray( For serial runs, this is the only input mode (of course!). */ int ReadArraySerial( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *x, /*!< Grid associated with the array (can be NULL) */ - double *u, /*!< Array to hold the vector field being read */ - char *fname_root, /*!< Filename root */ - int *read_flag /*!< Flag to indicate if the file was read */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_x, /*!< Grid associated with the array (can be NULL) */ + double *a_u, /*!< Array to hold the vector field being read */ + char *a_fname_root, /*!< Filename root */ + int *a_read_flag /*!< Flag to indicate if the file was read */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - int i, d, ferr, index[ndims]; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + int i, d, ferr, index[a_ndims]; double *ug = NULL, *xg = NULL; _DECLARE_IERR_; - *read_flag = 0; + *a_read_flag = 0; /* Only root process reads from the file */ - if (!mpi->rank) { + if (!mpi->m_rank) { - if (!strcmp(solver->ip_file_type,"ascii")) { + if (!strcmp(solver->m_ip_file_type,"ascii")) { char filename[_MAX_STRING_SIZE_]; - strcpy(filename,fname_root); + strcpy(filename,a_fname_root); strcat(filename,".inp"); FILE *in; in = fopen(filename,"r"); - if (!in) *read_flag = 0; + if (!in) *a_read_flag = 0; else { - *read_flag = 1; + *a_read_flag = 1; /* Reading from file */ printf("Reading array from ASCII file %s (Serial mode).\n",filename); int size,offset; /* allocate global solution array */ - size = 1; for (d=0; dip_file_type,"bin")) || (!strcmp(solver->ip_file_type,"binary"))) { + } else if ((!strcmp(solver->m_ip_file_type,"bin")) || (!strcmp(solver->m_ip_file_type,"binary"))) { char filename[_MAX_STRING_SIZE_]; - strcpy(filename,fname_root); + strcpy(filename,a_fname_root); strcat(filename,".inp"); FILE *in; in = fopen(filename,"rb"); - if (!in) *read_flag = 0; + if (!in) *a_read_flag = 0; else { - *read_flag = 1; + *a_read_flag = 1; printf("Reading array from binary file %s (Serial mode).\n",filename); size_t bytes; int size; /* allocate global solution array */ - size = 1; for (d=0; dworld); CHECKERR(ierr); + /* Broadcast a_read_flag to all processes */ + IERR MPIBroadcast_integer(a_read_flag,1,0,&mpi->m_world); CHECKERR(ierr); - if (*read_flag) { + if (*a_read_flag) { /* partition global array to all processes */ - IERR MPIPartitionArraynD(ndims,mpi,(mpi->rank?NULL:ug),u,dim_global, - dim_local,ghosts,nvars); CHECKERR(ierr); + IERR MPIPartitionArraynD(a_ndims,mpi,(mpi->m_rank?NULL:ug),a_u,a_dim_global, + a_dim_local,a_ghosts,a_nvars); CHECKERR(ierr); - if (x) { - /* partition x vector across the processes */ + if (a_x) { + /* partition a_x vector across the processes */ int offset_global = 0, offset_local = 0; - for (d=0; drank?NULL:&xg[offset_global]), - &x[offset_local+ghosts], - mpi->is[d],mpi->ie[d],dim_local[d],0); CHECKERR(ierr); - offset_global += dim_global[d]; - offset_local += dim_local [d] + 2*ghosts; + for (d=0; dm_rank?NULL:&xg[offset_global]), + &a_x[offset_local+a_ghosts], + mpi->m_is[d],mpi->m_ie[d],a_dim_local[d],0); CHECKERR(ierr); + offset_global += a_dim_global[d]; + offset_local += a_dim_local [d] + 2*a_ghosts; } } /* free global arrays */ - if (!mpi->rank) { + if (!mpi->m_rank) { free(ug); free(xg); } @@ -339,66 +339,66 @@ int ReadArraySerial( the input file "solver.inp" is set to "parallel n" where n is the number of IO ranks. */ int ReadArrayParallel( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *x, /*!< Grid associated with the array (can be NULL) */ - double *u, /*!< Array to hold the vector field being read */ - char *fname_root, /*!< Filename root */ - int *read_flag /*!< Flag to indicate if file was read */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_x, /*!< Grid associated with the array (can be NULL) */ + double *a_u, /*!< Array to hold the vector field being read */ + char *a_fname_root, /*!< Filename root */ + int *a_read_flag /*!< Flag to indicate if file was read */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int proc,d; _DECLARE_IERR_; - *read_flag = 1; + *a_read_flag = 1; char filename_root[_MAX_STRING_SIZE_]; - strcpy(filename_root,fname_root); + strcpy(filename_root,a_fname_root); strcat(filename_root,"_par.inp"); /* check for existence of the file */ - if (mpi->IOParticipant) { + if (mpi->m_IOParticipant) { FILE *in; char filename[_MAX_STRING_SIZE_]; - MPIGetFilename(filename_root,&mpi->IOWorld,filename); + MPIGetFilename(filename_root,&mpi->m_IOWorld,filename); in = fopen(filename,"rb"); - if (!in) *read_flag = 0; + if (!in) *a_read_flag = 0; else { - *read_flag = 1; + *a_read_flag = 1; fclose(in); } } - IERR MPIMin_integer(read_flag,read_flag,1,&mpi->world); + IERR MPIMin_integer(a_read_flag,a_read_flag,1,&mpi->m_world); - if (*read_flag) { + if (*a_read_flag) { - if (!mpi->rank) printf("Reading from binary file %s.xxx (parallel mode).\n",filename_root); + if (!mpi->m_rank) printf("Reading from binary file %s.xxx (parallel mode).\n",filename_root); /* calculate size of the local grid on this rank */ - int sizex = 0; for (d=0; dIOParticipant) { + if (mpi->m_IOParticipant) { /* if this rank is responsible for file I/O */ double *read_buffer = NULL; int read_size_x, read_size_u, read_total_size; - int is[ndims], ie[ndims]; + int is[a_ndims], ie[a_ndims]; /* open the file */ FILE *in; int bytes; char filename[_MAX_STRING_SIZE_]; - MPIGetFilename(filename_root,&mpi->IOWorld,filename); + MPIGetFilename(filename_root,&mpi->m_IOWorld,filename); in = fopen(filename,"rb"); if (!in) { @@ -413,13 +413,13 @@ int ReadArrayParallel( return(1); } - /* read and send the data for the other processors in this IO rank's group */ - for (proc=mpi->GroupStartRank+1; procGroupEndRank; proc++) { + /* read and send the data for the other processors in this IO rank'a_s group */ + for (proc=mpi->m_GroupStartRank+1; procm_GroupEndRank; proc++) { /* get the local domain limits for process proc */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); /* calculate the size of its local data and allocate read buffer */ - read_size_x = 0; for (d=0; dworld,&req); + MPI_Isend(read_buffer,read_total_size,MPI_DOUBLE,proc,1100,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); free(read_buffer); } @@ -443,24 +443,24 @@ int ReadArrayParallel( /* all other processes, just receive the data from * the rank responsible for file I/O */ MPI_Request req = MPI_REQUEST_NULL; - MPI_Irecv(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->IORank,1100,mpi->world,&req); + MPI_Irecv(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->m_IORank,1100,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); } /* copy the grid */ - if (x) { + if (a_x) { int offset1 = 0, offset2 = 0; - for (d = 0; d < ndims; d++) { - _ArrayCopy1D_((buffer+offset2),(x+offset1+ghosts),dim_local[d]); - offset1 += (dim_local[d]+2*ghosts); - offset2 += dim_local[d]; + for (d = 0; d < a_ndims; d++) { + _ArrayCopy1D_((buffer+offset2),(a_x+offset1+a_ghosts),a_dim_local[d]); + offset1 += (a_dim_local[d]+2*a_ghosts); + offset2 += a_dim_local[d]; } } /* copy the solution */ - int index[ndims]; - IERR ArrayCopynD(ndims,(buffer+sizex),u,dim_local,0,ghosts,index,nvars); + int index[a_ndims]; + IERR ArrayCopynD(a_ndims,(buffer+sizex),a_u,a_dim_local,0,a_ghosts,index,a_nvars); CHECKERR(ierr); /* free buffers */ @@ -511,69 +511,69 @@ int ReadArrayParallel( the input file "solver.inp" is set to "mpi-io n" where n is the number of IO ranks. */ int ReadArrayMPI_IO( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *x, /*!< Grid associated with the array (can be NULL) */ - double *u, /*!< Array to hold the vector field being read */ - char *fname_root, /*!< Filename root */ - int *read_flag /*!< Flag to indicate if file was read */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_x, /*!< Grid associated with the array (can be NULL) */ + double *a_u, /*!< Array to hold the vector field being read */ + char *a_fname_root, /*!< Filename root */ + int *a_read_flag /*!< Flag to indicate if file was read */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int proc,d; _DECLARE_IERR_; - *read_flag = 0; + *a_read_flag = 0; char filename[_MAX_STRING_SIZE_]; - strcpy(filename,fname_root); + strcpy(filename,a_fname_root); strcat(filename,"_mpi.inp"); /* check for existence of file */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; in = fopen(filename,"rb"); - if (!in) *read_flag = 0; + if (!in) *a_read_flag = 0; else { - *read_flag = 1; + *a_read_flag = 1; fclose(in); } } - IERR MPIBroadcast_integer(read_flag,1,0,&mpi->world); + IERR MPIBroadcast_integer(a_read_flag,1,0,&mpi->m_world); - if (*read_flag) { + if (*a_read_flag) { - if (!mpi->rank) printf("Reading from binary file %s (MPI-IO mode).\n",filename); + if (!mpi->m_rank) printf("Reading from binary file %s (MPI-IO mode).\n",filename); /* calculate size of the local grid on this rank */ - int sizex = 0; for (d=0; dIOParticipant) { + if (mpi->m_IOParticipant) { /* if this rank is responsible for file I/O */ double *read_buffer = NULL; int read_size_x, read_size_u, read_total_size; - int is[ndims], ie[ndims], size; + int is[a_ndims], ie[a_ndims], size; /* calculate offset */ long long offset = 0; - for (proc=0; proc < mpi->rank; proc++) { + for (proc=0; proc < mpi->m_rank; proc++) { /* get the local domain limits for process proc */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); /* calculate the size of its local grid */ - size = 0; for (d=0; dIOWorld,filename,MPI_MODE_RDONLY,MPI_INFO_NULL,&in); + error = MPI_File_open(mpi->m_IOWorld,filename,MPI_MODE_RDONLY,MPI_INFO_NULL,&in); if (error != MPI_SUCCESS) { fprintf(stderr,"Error in ReadArrayMPI_IO(): Unable to open %s.\n",filename); return(1); @@ -594,20 +594,20 @@ int ReadArrayMPI_IO( /* Read own data */ MPI_File_read(in,buffer,(sizex+sizeu)*sizeof(double),MPI_BYTE,&status); - /* read and send the data for the other processors in this IO rank's group */ - for (proc=mpi->GroupStartRank+1; procGroupEndRank; proc++) { + /* read and send the data for the other processors in this IO rank'a_s group */ + for (proc=mpi->m_GroupStartRank+1; procm_GroupEndRank; proc++) { /* get the local domain limits for process proc */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); /* calculate the size of its local data and allocate read buffer */ - read_size_x = 0; for (d=0; dworld,&req); + MPI_Isend(read_buffer,read_total_size,MPI_DOUBLE,proc,1100,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); free(read_buffer); } @@ -620,24 +620,24 @@ int ReadArrayMPI_IO( /* all other processes, just receive the data from * the rank responsible for file I/O */ MPI_Request req = MPI_REQUEST_NULL; - MPI_Irecv(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->IORank,1100,mpi->world,&req); + MPI_Irecv(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->m_IORank,1100,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); } /* copy the grid */ - if (x) { + if (a_x) { int offset1 = 0, offset2 = 0; - for (d = 0; d < ndims; d++) { - _ArrayCopy1D_((buffer+offset2),(x+offset1+ghosts),dim_local[d]); - offset1 += (dim_local[d]+2*ghosts); - offset2 += dim_local[d]; + for (d = 0; d < a_ndims; d++) { + _ArrayCopy1D_((buffer+offset2),(a_x+offset1+a_ghosts),a_dim_local[d]); + offset1 += (a_dim_local[d]+2*a_ghosts); + offset2 += a_dim_local[d]; } } /* copy the solution */ - int index[ndims]; - IERR ArrayCopynD(ndims,(buffer+sizex),u,dim_local,0,ghosts,index,nvars); + int index[a_ndims]; + IERR ArrayCopynD(a_ndims,(buffer+sizex),a_u,a_dim_local,0,a_ghosts,index,a_nvars); CHECKERR(ierr); /* free buffers */ diff --git a/src/IOFunctions/ReadArraywInterp.c b/src/IOFunctions/ReadArraywInterp.c index 215fabfc..33baa93b 100644 --- a/src/IOFunctions/ReadArraywInterp.c +++ b/src/IOFunctions/ReadArraywInterp.c @@ -21,72 +21,72 @@ static int ReadArraywInterpSerial(int,int,int*,int*,int*,int,void*,void*,double* can only differ by factors that are integer powers of 2. This is a wrapper function that calls - the appropriate function depending on input mode (#HyPar::input_mode).\n\n - The mode and type of input are specified through #HyPar::input_mode and - #HyPar::ip_file_type. A vector field is read from file and stored in an array. + the appropriate function depending on input mode (#HyPar::m_input_mode).\n\n + The mode and type of input are specified through #HyPar::m_input_mode and + #HyPar::m_ip_file_type. A vector field is read from file and stored in an array. */ -int ReadArraywInterp( int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local size in each dimension */ - int *dim_global_src,/*!< Integer array of size ndims with global size of the data in each dimension */ - int ghosts, /*!< Number of ghost points */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *x, /*!< Grid associated with the array (can be NULL) */ - double *u, /*!< Array to hold the vector field */ - char *fname_root, /*!< Filename root */ - int *read_flag /*!< Flag to indicate if the file was read */ +int ReadArraywInterp( int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local size in each dimension */ + int *a_dim_global_src,/*!< Integer array of size ndims with global size of the data in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_x, /*!< Grid associated with the array (can be NULL) */ + double *a_u, /*!< Array to hold the vector field */ + char *a_fname_root, /*!< Filename root */ + int *a_read_flag /*!< Flag to indicate if the file was read */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; _DECLARE_IERR_; - int retval = ReadArraywInterpSerial( ndims, - nvars, - dim_global, - dim_local, - dim_global_src, - ghosts, - s, - m, - x, - u, - fname_root, - read_flag ); + int retval = ReadArraywInterpSerial( a_ndims, + a_nvars, + a_dim_global, + a_dim_local, + a_dim_global_src, + a_ghosts, + a_s, + a_m, + a_x, + a_u, + a_fname_root, + a_read_flag ); if (retval) return retval; - if (x) { + if (a_x) { int offset, d; - /* exchange MPI-boundary values of x between processors */ + /* exchange MPI-boundary values of a_x between processors */ offset = 0; - for (d = 0; d < ndims; d++) { - IERR MPIExchangeBoundaries1D(mpi,&x[offset],dim_local[d], - ghosts,d,ndims); CHECKERR(ierr); - offset += (dim_local [d] + 2*ghosts); + for (d = 0; d < a_ndims; d++) { + IERR MPIExchangeBoundaries1D(mpi,&a_x[offset],a_dim_local[d], + a_ghosts,d,a_ndims); CHECKERR(ierr); + offset += (a_dim_local [d] + 2*a_ghosts); } - /* fill in ghost values of x at physical boundaries by extrapolation */ + /* fill in ghost values of a_x at physical boundaries by extrapolation */ offset = 0; - for (d = 0; d < ndims; d++) { - double *X = &x[offset]; - int *dim = dim_local, i; - if (mpi->ip[d] == 0) { + for (d = 0; d < a_ndims; d++) { + double *X = &a_x[offset]; + int *dim = a_dim_local, i; + if (mpi->m_ip[d] == 0) { /* fill left boundary along this dimension */ - for (i = 0; i < ghosts; i++) { - int delta = ghosts - i; - X[i] = X[ghosts] + ((double) delta) * (X[ghosts]-X[ghosts+1]); + for (i = 0; i < a_ghosts; i++) { + int delta = a_ghosts - i; + X[i] = X[a_ghosts] + ((double) delta) * (X[a_ghosts]-X[a_ghosts+1]); } } - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { /* fill right boundary along this dimension */ - for (i = dim[d]+ghosts; i < dim[d]+2*ghosts; i++) { - int delta = i - (dim[d]+ghosts-1); - X[i] = X[dim[d]+ghosts-1] - + ((double) delta) * (X[dim[d]+ghosts-1]-X[dim[d]+ghosts-2]); + for (i = dim[d]+a_ghosts; i < dim[d]+2*a_ghosts; i++) { + int delta = i - (dim[d]+a_ghosts-1); + X[i] = X[dim[d]+a_ghosts-1] + + ((double) delta) * (X[dim[d]+a_ghosts-1]-X[dim[d]+a_ghosts-2]); } } - offset += (dim[d] + 2*ghosts); + offset += (dim[d] + 2*a_ghosts); } } @@ -156,99 +156,99 @@ int ReadArraywInterp( int ndims, /*!< Number of spatial dimensions \n */ -int ReadArraywInterpSerial( int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local size in each dimension */ - int *dim_global_src,/*!< Integer array of size ndims with global size of the data in each dimension */ - int ghosts, /*!< Number of ghost points */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *x, /*!< Grid associated with the array (can be NULL) */ - double *u, /*!< Array to hold the vector field being read */ - char *fname_root, /*!< Filename root */ - int *read_flag /*!< Flag to indicate if the file was read */ +int ReadArraywInterpSerial( int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local size in each dimension */ + int *a_dim_global_src,/*!< Integer array of size ndims with global size of the data in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_x, /*!< Grid associated with the array (can be NULL) */ + double *a_u, /*!< Array to hold the vector field being read */ + char *a_fname_root, /*!< Filename root */ + int *a_read_flag /*!< Flag to indicate if the file was read */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - int i, d, ferr, index[ndims]; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + int i, d, ferr, index[a_ndims]; double *ug_src = NULL, *xg_src = NULL; double *ug = NULL, *xg = NULL; _DECLARE_IERR_; - *read_flag = 0; + *a_read_flag = 0; /* Only root process reads from the file */ - if (!mpi->rank) { + if (!mpi->m_rank) { /* read data from file - this data is of dimensions given by dim_global_sec */ - if (!strcmp(solver->ip_file_type,"ascii")) { + if (!strcmp(solver->m_ip_file_type,"ascii")) { char filename[_MAX_STRING_SIZE_]; - strcpy(filename,fname_root); + strcpy(filename,a_fname_root); strcat(filename,".inp"); FILE *in; in = fopen(filename,"r"); - if (!in) *read_flag = 0; + if (!in) *a_read_flag = 0; else { - *read_flag = 1; + *a_read_flag = 1; /* Reading from file */ printf("Reading array from ASCII file %s (Serial mode).\n",filename); int size,offset; /* allocate global solution array */ - size = 1; for (d=0; dip_file_type,"bin")) || (!strcmp(solver->ip_file_type,"binary"))) { + } else if ((!strcmp(solver->m_ip_file_type,"bin")) || (!strcmp(solver->m_ip_file_type,"binary"))) { char filename[_MAX_STRING_SIZE_]; - strcpy(filename,fname_root); + strcpy(filename,a_fname_root); strcat(filename,".inp"); FILE *in; in = fopen(filename,"rb"); - if (!in) *read_flag = 0; + if (!in) *a_read_flag = 0; else { - *read_flag = 1; + *a_read_flag = 1; printf("Reading array from binary file %s (Serial mode).\n",filename); size_t bytes; int size; /* allocate global solution array */ - size = 1; for (d=0; disPeriodic); + a_nvars, + a_ndims, + solver->m_is_periodic); free(ug_src); /* interpolate from the data read in to a global array * with specified dimensions */ - int ierr = InterpolateGlobalnDVar( dim_global, + int ierr = InterpolateGlobalnDVar( a_dim_global, &ug, - dim_global_src, + a_dim_global_src, ug_src_wg, - nvars, - ghosts, - ndims, - solver->isPeriodic ); + a_nvars, + a_ghosts, + a_ndims, + solver->m_is_periodic ); if (ierr) { fprintf(stderr, "Error in ReadArraywInterpSerial()\n"); fprintf(stderr, " InterpolateGlobalnDVar() returned with error!\n"); return ierr; } - if (x) { + if (a_x) { fprintf(stderr,"Error in ReadArraywInterpSerial()\n"); - fprintf(stderr," Not yet implemented for x\n"); - //InterpolateGlobal1DVar(xg_src, dim_global_src, xg, dim_global); + fprintf(stderr," Not yet implemented for a_x\n"); + //InterpolateGlobal1DVar(xg_src, a_dim_global_src, xg, a_dim_global); } if (xg_src) free(xg_src); @@ -316,40 +316,40 @@ int ReadArraywInterpSerial( int ndims, /*!< Number of spatial dimen fprintf(stderr,"Error in ReadArraywInterp() - ug is NULL!\n"); return 1; } - if ((xg == NULL) && (x != NULL)) { + if ((xg == NULL) && (a_x != NULL)) { fprintf(stderr,"Error in ReadArraywInterp() - xg is NULL!\n"); return 1; } } - /* Broadcast read_flag to all processes */ - IERR MPIBroadcast_integer(read_flag,1,0,&mpi->world); CHECKERR(ierr); + /* Broadcast a_read_flag to all processes */ + IERR MPIBroadcast_integer(a_read_flag,1,0,&mpi->m_world); CHECKERR(ierr); - if (*read_flag) { + if (*a_read_flag) { /* partition global array to all processes */ - IERR MPIPartitionArraynDwGhosts( ndims, + IERR MPIPartitionArraynDwGhosts( a_ndims, mpi, - (mpi->rank?NULL:ug), - u,dim_global, - dim_local, - ghosts, - nvars ); CHECKERR(ierr); + (mpi->m_rank?NULL:ug), + a_u,a_dim_global, + a_dim_local, + a_ghosts, + a_nvars ); CHECKERR(ierr); -// if (x) { -// /* partition x vector across the processes */ +// if (a_x) { +// /* partition a_x vector across the processes */ // int offset_global = 0, offset_local = 0; -// for (d=0; drank?NULL:&xg[offset_global]), -// &x[offset_local+ghosts], -// mpi->is[d],mpi->ie[d],dim_local[d],0); CHECKERR(ierr); -// offset_global += dim_global[d]; -// offset_local += dim_local [d] + 2*ghosts; +// for (d=0; dm_rank?NULL:&xg[offset_global]), +// &a_x[offset_local+a_ghosts], +// mpi->m_is[d],mpi->m_ie[d],a_dim_local[d],0); CHECKERR(ierr); +// offset_global += a_dim_global[d]; +// offset_local += a_dim_local [d] + 2*a_ghosts; // } // } /* free global arrays */ - if (!mpi->rank) { + if (!mpi->m_rank) { free(ug); free(xg); } diff --git a/src/IOFunctions/WriteArray.c b/src/IOFunctions/WriteArray.c index 13ebf404..1676d951 100644 --- a/src/IOFunctions/WriteArray.c +++ b/src/IOFunctions/WriteArray.c @@ -21,39 +21,39 @@ static int WriteArrayParallel (int,int,int*,int*,int,double*,double*,void*,void* #endif /*! Write out a vector field, stored as an array, to file: wrapper function that calls - the appropriate function depending on output mode (#HyPar::output_mode). The - output file format is determined by #HyPar::op_file_format + the appropriate function depending on output mode (#HyPar::m_output_mode). The + output file format is determined by #HyPar::m_op_file_format */ int WriteArray( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - double *x, /*!< Array of spatial coordinates (i.e. the grid) */ - double *u, /*!< Vector field to write */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - char* fname_root /*!< Filename root (extension is added automatically). For unsteady output, + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_x, /*!< Array of spatial coordinates (i.e. the grid) */ + double *a_u, /*!< Vector field to write */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + char* a_fname_root /*!< Filename root (extension is added automatically). For unsteady output, a numerical index is added that is the same as for the solution output files. */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*)m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*)a_m; _DECLARE_IERR_; /* if WriteOutput() is NULL, then return */ if (!solver->WriteOutput) return(0); #ifndef serial - if (!strcmp(solver->output_mode,"serial")) { + if (!strcmp(solver->m_output_mode,"serial")) { #endif - IERR WriteArraySerial(ndims,nvars,dim_global,dim_local,ghosts,x,u, - solver,mpi,fname_root); CHECKERR(ierr); + IERR WriteArraySerial(a_ndims,a_nvars,a_dim_global,a_dim_local,a_ghosts,a_x,a_u, + solver,mpi,a_fname_root); CHECKERR(ierr); #ifndef serial } else { - IERR WriteArrayParallel(ndims,nvars,dim_global,dim_local,ghosts,x,u, - solver,mpi,fname_root); CHECKERR(ierr); + IERR WriteArrayParallel(a_ndims,a_nvars,a_dim_global,a_dim_local,a_ghosts,a_x,a_u, + solver,mpi,a_fname_root); CHECKERR(ierr); } #endif @@ -67,41 +67,41 @@ int WriteArray( problems for which the entire global domain will not fit on one node. This approach is also not very scalable. + Supports binary and ASCII formats (specified through - #HyPar::op_file_format). + #HyPar::m_op_file_format). \sa WriteBinary(), WriteText(), WriteTecplot2D(), WriteTecplot3D() */ int WriteArraySerial( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - double *x, /*!< Array of spatial coordinates (i.e. the grid) */ - double *u, /*!< Vector field to write */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - char* fname_root /*!< Filename root (extension is added automatically). For unsteady output, + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_x, /*!< Array of spatial coordinates (i.e. the grid) */ + double *a_u, /*!< Vector field to write */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + char* a_fname_root /*!< Filename root (extension is added automatically). For unsteady output, a numerical index is added that is the same as for the solution output files. */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*)m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*)a_m; int d; _DECLARE_IERR_; /* root process: allocate global output arrays */ double *ug, *xg; - if (!mpi->rank) { + if (!mpi->m_rank) { int size_global; size_global = 1; - for (d=0; drank?NULL:&xg[offset_global]), - &x[offset_local+ghosts], - mpi->is[d],mpi->ie[d],dim_local[d],0); CHECKERR(ierr); - offset_global += dim_global[d]; - offset_local += dim_local [d] + 2*ghosts; + for (d=0; dm_rank?NULL:&xg[offset_global]), + &a_x[offset_local+a_ghosts], + mpi->m_is[d],mpi->m_ie[d],a_dim_local[d],0); CHECKERR(ierr); + offset_global += a_dim_global[d]; + offset_local += a_dim_local [d] + 2*a_ghosts; } - if (!mpi->rank) { + if (!mpi->m_rank) { /* write output file to disk */ char filename[_MAX_STRING_SIZE_] = ""; - strcat(filename,fname_root); - if (!strcmp(solver->op_overwrite,"no")) { + strcat(filename,a_fname_root); + if (!strcmp(solver->m_op_overwrite,"no")) { strcat(filename,"_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); } - strcat(filename,solver->solnfilename_extn); + strcat(filename,solver->m_solnfilename_extn); printf("Writing solution file %s.\n",filename); - IERR solver->WriteOutput(ndims,nvars,dim_global,xg,ug,filename, - solver->index); CHECKERR(ierr); + IERR solver->WriteOutput(a_ndims,a_nvars,a_dim_global,xg,ug,filename, + solver->m_index); CHECKERR(ierr); /* Clean up output arrays */ free(xg); @@ -181,7 +181,7 @@ int WriteArraySerial( #MPIVariables::N_IORanks such blocks in each file). + To stitch all the local data in these files into the global solution, and write that out to a binary file can be done by Extras/ParallelOutput.c. - + If #HyPar::op_overwrite is set to 0, the vector field at the various simulation times are appended + + If #HyPar::m_op_overwrite is set to 0, the vector field at the various simulation times are appended to each of the .bin.nnnn. The code Extras/ParallelOutput.c will take care of writing the global solution at each simulation time to a different file (in binary format) (the same files that WriteArraySerial() would have written out if serial file output was chosen). @@ -192,65 +192,65 @@ int WriteArraySerial( */ #ifndef serial int WriteArrayParallel( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables per grid point */ - int *dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ - int *dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ - int ghosts, /*!< Number of ghost points */ - double *x, /*!< Array of spatial coordinates (i.e. the grid) */ - double *u, /*!< Vector field to write */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - char* fname_root /*!< Filename root (extension is added automatically). For unsteady output, + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables per grid point */ + int *a_dim_global, /*!< Integer array of size ndims with global grid size in each dimension */ + int *a_dim_local, /*!< Integer array of size ndims with local grid size in each dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_x, /*!< Array of spatial coordinates (i.e. the grid) */ + double *a_u, /*!< Vector field to write */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + char* a_fname_root /*!< Filename root (extension is added automatically). For unsteady output, a numerical index is added that is the same as for the solution output files. */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int proc,d; _DECLARE_IERR_; - static int count = 0; + static int s_count = 0; char filename_root[_MAX_STRING_SIZE_]; - strcpy(filename_root,fname_root); - strcat(filename_root,solver->solnfilename_extn); - if (!mpi->rank) printf("Writing solution file %s.xxxx (parallel mode).\n",filename_root); + strcpy(filename_root,a_fname_root); + strcat(filename_root,solver->m_solnfilename_extn); + if (!mpi->m_rank) printf("Writing solution file %s.xxxx (parallel mode).\n",filename_root); /* calculate size of the local grid on this rank */ - int sizex = 0; for (d=0; dIOParticipant) { + if (mpi->m_IOParticipant) { /* if this rank is responsible for file I/O */ double *write_buffer = NULL; int write_size_x, write_size_u, write_total_size; - int is[ndims], ie[ndims]; + int is[a_ndims], ie[a_ndims]; /* open the file */ FILE *out; int bytes; char filename[_MAX_STRING_SIZE_]; - MPIGetFilename(filename_root,&mpi->IOWorld,filename); + MPIGetFilename(filename_root,&mpi->m_IOWorld,filename); - if (!strcmp(solver->op_overwrite,"no")) { - if ((!count) && (!solver->restart_iter)) { + if (!strcmp(solver->m_op_overwrite,"no")) { + if ((!s_count) && (!solver->m_restart_iter)) { /* open a new file, since this function is being called the first time and this is not a restart run*/ out = fopen(filename,"wb"); @@ -274,7 +274,7 @@ int WriteArrayParallel( return(1); } } - count++; + s_count++; /* Write own data and free buffer */ bytes = fwrite(buffer,sizeof(double),(sizex+sizeu),out); @@ -284,18 +284,18 @@ int WriteArrayParallel( } free(buffer); - /* receive and write the data for the other processors in this IO rank's group */ - for (proc=mpi->GroupStartRank+1; procGroupEndRank; proc++) { + /* receive and write the data for the other processors in this IO rank'a_s group */ + for (proc=mpi->m_GroupStartRank+1; procm_GroupEndRank; proc++) { /* get the local domain limits for process proc */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); /* calculate the size of its local data and allocate write buffer */ - write_size_x = 0; for (d=0; dworld,&req); + MPI_Irecv(write_buffer,write_total_size,MPI_DOUBLE,proc,1449,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); /* write the data */ bytes = fwrite(write_buffer,sizeof(double),write_total_size,out); @@ -313,7 +313,7 @@ int WriteArrayParallel( /* all other processes, just send the data to the rank responsible for file I/O */ MPI_Request req = MPI_REQUEST_NULL; - MPI_Isend(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->IORank,1449,mpi->world,&req); + MPI_Isend(buffer,(sizex+sizeu),MPI_DOUBLE,mpi->m_IORank,1449,mpi->m_world,&req); MPI_Wait(&req,MPI_STATUS_IGNORE); free(buffer); diff --git a/src/IOFunctions/WriteBinary.c b/src/IOFunctions/WriteBinary.c index 7d853547..fc8ccb22 100644 --- a/src/IOFunctions/WriteBinary.c +++ b/src/IOFunctions/WriteBinary.c @@ -32,55 +32,55 @@ 0 <= i{ndims-1} < dim[ndims=1]-1\n */ int WriteBinary( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables at each grid point */ - int *dim, /*!< Integer array with the number of grid points + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables at each grid point */ + int *a_dim, /*!< Integer array with the number of grid points in each spatial dimension as its entries */ - double *x, /*!< Array of spatial coordinates representing a + double *a_x, /*!< Array of spatial coordinates representing a Cartesian grid (no ghost points) */ - double *u, /*!< Array containing the vector field to write + double *a_u, /*!< Array containing the vector field to write (no ghost points) */ - char *f, /*!< Filename */ + char *a_f, /*!< Filename */ int *index /*!< Preallocated integer array of size ndims */ ) { int size, d; size_t bytes; FILE *out; - out = fopen(f,"wb"); + out = fopen(a_f,"wb"); if (!out) { - fprintf(stderr,"Error: could not open %s for writing.\n",f); + fprintf(stderr,"Error: could not open %s for writing.\n",a_f); return(1); } - /* write ndims, nvars */ - bytes = fwrite(&ndims,sizeof(int),1,out); + /* write a_ndims, a_nvars */ + bytes = fwrite(&a_ndims,sizeof(int),1,out); if ((int)bytes != 1) { - fprintf(stderr,"Error in WriteBinary(): Unable to write ndims to output file.\n"); + fprintf(stderr,"Error in WriteBinary(): Unable to write a_ndims to output file.\n"); } - bytes = fwrite(&nvars,sizeof(int),1,out); + bytes = fwrite(&a_nvars,sizeof(int),1,out); if ((int)bytes != 1) { - fprintf(stderr,"Error in WriteBinary(): Unable to write nvars to output file.\n"); + fprintf(stderr,"Error in WriteBinary(): Unable to write a_nvars to output file.\n"); } /* write dimensions */ - bytes = fwrite(dim,sizeof(int),ndims,out); - if ((int)bytes != ndims) { + bytes = fwrite(a_dim,sizeof(int),a_ndims,out); + if ((int)bytes != a_ndims) { fprintf(stderr,"Error in WriteBinary(): Unable to write dimensions to output file.\n"); } /* write grid */ size = 0; - for (d = 0; d < ndims; d++) size += dim[d]; - bytes = fwrite(x,sizeof(double),size,out); + for (d = 0; d < a_ndims; d++) size += a_dim[d]; + bytes = fwrite(a_x,sizeof(double),size,out); if ((int)bytes != size) { fprintf(stderr,"Error in WriteBinary(): Unable to write grid to output file.\n"); } /* write solution */ size = 1; - for (d = 0; d < ndims; d++) size *= dim[d]; size *= nvars; - bytes = fwrite(u,sizeof(double),size,out); + for (d = 0; d < a_ndims; d++) size *= a_dim[d]; size *= a_nvars; + bytes = fwrite(a_u,sizeof(double),size,out); if ((int)bytes != size) { fprintf(stderr,"Error in WriteBinary(): Unable to write solution to output file.\n"); } diff --git a/src/IOFunctions/WriteTecplot2D.c b/src/IOFunctions/WriteTecplot2D.c index 92d33197..ce8c34d7 100644 --- a/src/IOFunctions/WriteTecplot2D.c +++ b/src/IOFunctions/WriteTecplot2D.c @@ -17,38 +17,38 @@ format as WriteText(). */ int WriteTecplot2D( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables at each grid point */ - int *dim, /*!< Integer array with the number of grid points + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables at each grid point */ + int *a_dim, /*!< Integer array with the number of grid points in each spatial dimension as its entries */ - double *x, /*!< Array of spatial coordinates representing a + double *a_x, /*!< Array of spatial coordinates representing a Cartesian grid (no ghost points) */ - double *u, /*!< Array containing the vector field to write + double *a_u, /*!< Array containing the vector field to write (no ghost points) */ - char *f, /*!< Filename */ - int *index /*!< Preallocated integer array of size ndims */ + char *a_f, /*!< Filename */ + int *a_index /*!< Preallocated integer array of size ndims */ ) { - if (ndims !=2) { + if (a_ndims !=2) { fprintf(stderr,"Error in WriteTecplot2D(): This functions is hardcoded for 2-dimensional "); - fprintf(stderr,"problems only. Instead, ndims=%d.\n",ndims); + fprintf(stderr,"problems only. Instead, a_ndims=%d.\n",a_ndims); return(1); } int i; - int imax = dim[0]; - int jmax = dim[1]; + int imax = a_dim[0]; + int jmax = a_dim[1]; FILE *out; - out = fopen(f,"w"); + out = fopen(a_f,"w"); if (!out) { - fprintf(stderr,"Error: could not open %s for writing.\n",f); + fprintf(stderr,"Error: could not open %s for writing.\n",a_f); return(1); } /* writing tecplot data file headers */ fprintf(out,"VARIABLES=\"I\",\"J\",\"X\",\"Y\","); char varname[3] = "00"; - for (i = 0; i < nvars; i++) { + for (i = 0; i < a_nvars; i++) { fprintf(out,"\"%s\",",varname); if (varname[1] == '9') { varname[0]++; varname[1] = '0'; } else varname[1]++; @@ -57,18 +57,18 @@ int WriteTecplot2D( fprintf(out,"ZONE I=%d,J=%d,F=POINT\n",imax,jmax); /* writing the data */ - int done = 0; _ArraySetValue_(index,ndims,0); + int done = 0; _ArraySetValue_(a_index,a_ndims,0); while (!done) { int i, p; - _ArrayIndex1D_(ndims,dim,index,0,p); - for (i=0; irank ); + mpi->m_rank ); return 1; } - int nfacets_local = IB->nfacets_local; - FacetMap *fmap = IB->fmap; + int nfacets_local = IB->m_nfacets_local; + FacetMap *fmap = IB->m_fmap; if ((nfacets_local == 0) && (local_var != NULL)) { fprintf(stderr, "Error in IBAssembleGlobalFacetData()\n"); @@ -54,9 +54,9 @@ int IBAssembleGlobalFacetData(void* m, /*!< MPI object of MPI_Status status; #endif - if (!mpi->rank) { + if (!mpi->m_rank) { - int nfacets_global = IB->body->nfacets; + int nfacets_global = IB->m_body->m_nfacets; /* allocate arrays for whole domain */ *global_var = (double*) calloc (nfacets_global*nvars, sizeof(double)); @@ -68,12 +68,12 @@ int IBAssembleGlobalFacetData(void* m, /*!< MPI object of /* local data */ for (int n = 0; n < nfacets_local; n++) { - _ArrayAXPY_((local_var+n), 1.0, ((*global_var)+fmap[n].index), nvars); - check[fmap[n].index]++; + _ArrayAXPY_((local_var+n), 1.0, ((*global_var)+fmap[n].m_index), nvars); + check[fmap[n].m_index]++; } #ifndef serial - for (int proc = 1; proc < mpi->nproc; proc++) { + for (int proc = 1; proc < mpi->m_nproc; proc++) { int nf_incoming; MPI_Recv(&nf_incoming, 1, MPI_INT, proc, 98927, MPI_COMM_WORLD, &status); @@ -83,8 +83,8 @@ int IBAssembleGlobalFacetData(void* m, /*!< MPI object of int *indices_incoming = (int*) calloc(nf_incoming, sizeof(int)); double *var_incoming = (double*) calloc(nf_incoming*nvars, sizeof(double)); - MPI_Recv(indices_incoming, nf_incoming, MPI_INT, proc, 98928, mpi->world, &status); - MPI_Recv(var_incoming, nf_incoming*nvars, MPI_DOUBLE, proc, 98929, mpi->world, &status); + MPI_Recv(indices_incoming, nf_incoming, MPI_INT, proc, 98928, mpi->m_world, &status); + MPI_Recv(var_incoming, nf_incoming*nvars, MPI_DOUBLE, proc, 98929, mpi->m_world, &status); for (int n = 0; n < nf_incoming; n++) { _ArrayAXPY_((var_incoming+n), 1.0, ((*global_var)+indices_incoming[n]), nvars); @@ -116,10 +116,10 @@ int IBAssembleGlobalFacetData(void* m, /*!< MPI object of if (nfacets_local > 0) { int i, *indices = (int*) calloc (nfacets_local, sizeof(int)); - for (i = 0; i < nfacets_local; i++) indices[i] = fmap[i].index; + for (i = 0; i < nfacets_local; i++) indices[i] = fmap[i].m_index; - MPI_Send(indices, nfacets_local, MPI_INT, 0, 98928, mpi->world); - MPI_Send(local_var, nfacets_local*nvars, MPI_DOUBLE, 0, 98929, mpi->world); + MPI_Send(indices, nfacets_local, MPI_INT, 0, 98928, mpi->m_world); + MPI_Send(local_var, nfacets_local*nvars, MPI_DOUBLE, 0, 98929, mpi->m_world); free(indices); } diff --git a/src/ImmersedBoundaries/IBCleanup.c b/src/ImmersedBoundaries/IBCleanup.c index 18103d12..e9848cec 100644 --- a/src/ImmersedBoundaries/IBCleanup.c +++ b/src/ImmersedBoundaries/IBCleanup.c @@ -8,16 +8,16 @@ /*! */ -int IBCleanup(void *s /*!< Object of type #ImmersedBoundary */) +int IBCleanup(void *a_s /*!< Object of type #ImmersedBoundary */) { - ImmersedBoundary *ib = (ImmersedBoundary*) s; + ImmersedBoundary *ib = (ImmersedBoundary*) a_s; if (!ib) return(0); - free(ib->body->surface); - free(ib->body); + free(ib->m_body->m_surface); + free(ib->m_body); - if (ib->n_boundary_nodes > 0) free(ib->boundary); - if (ib->nfacets_local > 0) free(ib->fmap); + if (ib->m_n_boundary_nodes > 0) free(ib->m_boundary); + if (ib->m_nfacets_local > 0) free(ib->m_fmap); return(0); } diff --git a/src/ImmersedBoundaries/IBComputeBoundingBox.c b/src/ImmersedBoundaries/IBComputeBoundingBox.c index f4ac28c4..24bb2f4f 100644 --- a/src/ImmersedBoundaries/IBComputeBoundingBox.c +++ b/src/ImmersedBoundaries/IBComputeBoundingBox.c @@ -6,37 +6,37 @@ #include /*! Compute the bounding box for a given body. */ -int IBComputeBoundingBox(Body3D *b /*!< The body */) +int IBComputeBoundingBox(Body3D *a_b /*!< The body */) { - b->xmin = b->xmax = b->surface[0].x1; - b->ymin = b->ymax = b->surface[0].y1; - b->zmin = b->zmax = b->surface[0].z1; + a_b->m_xmin = a_b->m_xmax = a_b->m_surface[0].m_x1; + a_b->m_ymin = a_b->m_ymax = a_b->m_surface[0].m_y1; + a_b->m_zmin = a_b->m_zmax = a_b->m_surface[0].m_z1; int n; - for (n = 0; n < b->nfacets; n++) { - if (b->surface[n].x1 < b->xmin) b->xmin = b->surface[n].x1; - if (b->surface[n].x2 < b->xmin) b->xmin = b->surface[n].x2; - if (b->surface[n].x3 < b->xmin) b->xmin = b->surface[n].x3; - - if (b->surface[n].y1 < b->ymin) b->ymin = b->surface[n].y1; - if (b->surface[n].y2 < b->ymin) b->ymin = b->surface[n].y2; - if (b->surface[n].y3 < b->ymin) b->ymin = b->surface[n].y3; - - if (b->surface[n].z1 < b->zmin) b->zmin = b->surface[n].z1; - if (b->surface[n].z2 < b->zmin) b->zmin = b->surface[n].z2; - if (b->surface[n].z3 < b->zmin) b->zmin = b->surface[n].z3; - - if (b->surface[n].x1 > b->xmax) b->xmax = b->surface[n].x1; - if (b->surface[n].x2 > b->xmax) b->xmax = b->surface[n].x2; - if (b->surface[n].x3 > b->xmax) b->xmax = b->surface[n].x3; - - if (b->surface[n].y1 > b->ymax) b->ymax = b->surface[n].y1; - if (b->surface[n].y2 > b->ymax) b->ymax = b->surface[n].y2; - if (b->surface[n].y3 > b->ymax) b->ymax = b->surface[n].y3; - - if (b->surface[n].z1 > b->zmax) b->zmax = b->surface[n].z1; - if (b->surface[n].z2 > b->zmax) b->zmax = b->surface[n].z2; - if (b->surface[n].z3 > b->zmax) b->zmax = b->surface[n].z3; + for (n = 0; n < a_b->m_nfacets; n++) { + if (a_b->m_surface[n].m_x1 < a_b->m_xmin) a_b->m_xmin = a_b->m_surface[n].m_x1; + if (a_b->m_surface[n].m_x2 < a_b->m_xmin) a_b->m_xmin = a_b->m_surface[n].m_x2; + if (a_b->m_surface[n].m_x3 < a_b->m_xmin) a_b->m_xmin = a_b->m_surface[n].m_x3; + + if (a_b->m_surface[n].m_y1 < a_b->m_ymin) a_b->m_ymin = a_b->m_surface[n].m_y1; + if (a_b->m_surface[n].m_y2 < a_b->m_ymin) a_b->m_ymin = a_b->m_surface[n].m_y2; + if (a_b->m_surface[n].m_y3 < a_b->m_ymin) a_b->m_ymin = a_b->m_surface[n].m_y3; + + if (a_b->m_surface[n].m_z1 < a_b->m_zmin) a_b->m_zmin = a_b->m_surface[n].m_z1; + if (a_b->m_surface[n].m_z2 < a_b->m_zmin) a_b->m_zmin = a_b->m_surface[n].m_z2; + if (a_b->m_surface[n].m_z3 < a_b->m_zmin) a_b->m_zmin = a_b->m_surface[n].m_z3; + + if (a_b->m_surface[n].m_x1 > a_b->m_xmax) a_b->m_xmax = a_b->m_surface[n].m_x1; + if (a_b->m_surface[n].m_x2 > a_b->m_xmax) a_b->m_xmax = a_b->m_surface[n].m_x2; + if (a_b->m_surface[n].m_x3 > a_b->m_xmax) a_b->m_xmax = a_b->m_surface[n].m_x3; + + if (a_b->m_surface[n].m_y1 > a_b->m_ymax) a_b->m_ymax = a_b->m_surface[n].m_y1; + if (a_b->m_surface[n].m_y2 > a_b->m_ymax) a_b->m_ymax = a_b->m_surface[n].m_y2; + if (a_b->m_surface[n].m_y3 > a_b->m_ymax) a_b->m_ymax = a_b->m_surface[n].m_y3; + + if (a_b->m_surface[n].m_z1 > a_b->m_zmax) a_b->m_zmax = a_b->m_surface[n].m_z1; + if (a_b->m_surface[n].m_z2 > a_b->m_zmax) a_b->m_zmax = a_b->m_surface[n].m_z2; + if (a_b->m_surface[n].m_z3 > a_b->m_zmax) a_b->m_zmax = a_b->m_surface[n].m_z3; } return(0); } diff --git a/src/ImmersedBoundaries/IBComputeFacetVar.c b/src/ImmersedBoundaries/IBComputeFacetVar.c index beaeb1a4..9d01674b 100644 --- a/src/ImmersedBoundaries/IBComputeFacetVar.c +++ b/src/ImmersedBoundaries/IBComputeFacetVar.c @@ -17,7 +17,7 @@ * value. * * The variable should be a grid variable with size/layout the - * same as the solution variable (#HyPar::u) with the appropriate + * same as the solution variable (#HyPar::m_u) with the appropriate * number of ghost points. * * If the incoming variable has multiple components, this @@ -30,29 +30,29 @@ * * The interpolation is bi/tri-linear (second-order). */ -int IBComputeFacetVar(void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int IBComputeFacetVar(void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ const double* const var, /*!< Variable to compute the interpolated value of */ int nvars, /*!< Number of components in var */ double** const face_var /*!< Array to store the interpolated value; must be NULL at input */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ImmersedBoundary *IB = (ImmersedBoundary*) solver->ib; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ImmersedBoundary *IB = (ImmersedBoundary*) solver->m_ib; - if (!solver->flag_ib) return(0); + if (!solver->m_flag_ib) return(0); if ((*face_var) != NULL) { fprintf(stderr,"Error in IBComputeFacetVar()\n"); fprintf(stderr," face_var is not NULL on rank %d\n", - mpi->rank ); + mpi->m_rank ); return 1; } - int nfacets_local = IB->nfacets_local; - FacetMap *fmap = IB->fmap; + int nfacets_local = IB->m_nfacets_local; + FacetMap *fmap = IB->m_fmap; if (nfacets_local > 0) { (*face_var) = (double*) calloc (nvars*nfacets_local, sizeof(double)); @@ -63,8 +63,8 @@ int IBComputeFacetVar(void* s, /*!< Solver object of type #H int *nodes, j, k; double *v_c = (*face_var) + n*nvars; - alpha = &(fmap[n].interp_coeffs[0]); - nodes = &(fmap[n].interp_nodes[0]); + alpha = &(fmap[n].m_interp_coeffs[0]); + nodes = &(fmap[n].m_interp_nodes[0]); _ArraySetValue_(v_c,nvars,0.0); for (j=0; j<_IB_NNODES_; j++) { for (k=0; kib; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ImmersedBoundary *IB = (ImmersedBoundary*) solver->m_ib; - if (!solver->flag_ib) return(0); + if (!solver->m_flag_ib) return(0); if ((*grad_var) != NULL) { fprintf(stderr,"Error in IBComputeNormalGradient()\n"); fprintf(stderr," grad_var is not NULL on rank %d\n", - mpi->rank ); + mpi->m_rank ); return 1; } - int nfacets_local = IB->nfacets_local; - FacetMap *fmap = IB->fmap; + int nfacets_local = IB->m_nfacets_local; + FacetMap *fmap = IB->m_fmap; if (nfacets_local > 0) { (*grad_var) = (double*) calloc (nvars*nfacets_local, sizeof(double)); @@ -62,8 +62,8 @@ int IBComputeNormalGradient(void* s, /*!< Solver object of t int *nodes, j, k; double v_c[nvars]; - alpha = &(fmap[n].interp_coeffs[0]); - nodes = &(fmap[n].interp_nodes[0]); + alpha = &(fmap[n].m_interp_coeffs[0]); + nodes = &(fmap[n].m_interp_nodes[0]); _ArraySetValue_(v_c,nvars,0.0); for (j=0; j<_IB_NNODES_; j++) { for (k=0; knx; - double ny = fmap[n].facet->ny; - double nz = fmap[n].facet->nz; + double nx = fmap[n].m_facet->m_nx; + double ny = fmap[n].m_facet->m_ny; + double nz = fmap[n].m_facet->m_nz; for (k=0; k xc) */ - int *jj, /*!< j-index of the surrounding node at the high end - (i.e. smallest j such that y[j] > yc) */ - int *kk, /*!< k-index of the surrounding node at the high end - (i.e. smallest k such that z[k] > zc) */ - int *inodes, /*!< array to store the indices of the surrounding nodes */ - double *icoeffs /*!< array to store the interpolation coefficients of the surrounding nodes */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_xc, /*!< x-coordinate of the point */ + double a_yc, /*!< y-coordinate of the point */ + double a_zc, /*!< z-coordinate of the point */ + double *a_x, /*!< array of x-coordinates of the grid */ + double *a_y, /*!< array of y-coordinates of the grid */ + double *a_z, /*!< array of z-coordinates of the grid */ + int *a_dim, /*!< local dimensions of the grid */ + int a_ghosts, /*!< number of ghost points */ + char *a_mode, /*!< "mode", i.e., #ImmersedBoundary::mode */ + int *a_ii, /*!< i-index of the surrounding node at the high end + (i.e. smallest i such that a_x[i] > a_xc) */ + int *a_jj, /*!< j-index of the surrounding node at the high end + (i.e. smallest j such that a_y[j] > a_yc) */ + int *a_kk, /*!< k-index of the surrounding node at the high end + (i.e. smallest k such that a_z[k] > a_zc) */ + int *a_inodes, /*!< array to store the indices of the surrounding nodes */ + double *a_icoeffs /*!< array to store the interpolation coefficients of the surrounding nodes */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int i, j, k, ic, jc, kc; ic = jc = kc = -1; - double xmin = 0.5 * (x[ghosts-1] + x[ghosts]), - xmax = 0.5 * (x[dim[0]+ghosts-1] + x[dim[0]+ghosts]), - ymin = 0.5 * (y[ghosts-1] + y[ghosts]), - ymax = 0.5 * (y[dim[1]+ghosts-1] + y[dim[1]+ghosts]), - zmin = 0.5 * (z[ghosts-1] + z[ghosts]), - zmax = 0.5 * (z[dim[2]+ghosts-1] + z[dim[2]+ghosts]); + double xmin = 0.5 * (a_x[a_ghosts-1] + a_x[a_ghosts]), + xmax = 0.5 * (a_x[a_dim[0]+a_ghosts-1] + a_x[a_dim[0]+a_ghosts]), + ymin = 0.5 * (a_y[a_ghosts-1] + a_y[a_ghosts]), + ymax = 0.5 * (a_y[a_dim[1]+a_ghosts-1] + a_y[a_dim[1]+a_ghosts]), + zmin = 0.5 * (a_z[a_ghosts-1] + a_z[a_ghosts]), + zmax = 0.5 * (a_z[a_dim[2]+a_ghosts-1] + a_z[a_dim[2]+a_ghosts]); - for (i = 0; i < dim[0]+2*ghosts-1; i++) { - if (isInside(xc,x[i],x[i+1])) { + for (i = 0; i < a_dim[0]+2*a_ghosts-1; i++) { + if (isInside(a_xc,a_x[i],a_x[i+1])) { ic = i; break; } } - if (ic <= ghosts-1) ic = ghosts; - else if (ic >= dim[0]+ghosts-1) ic = dim[0]+ghosts-2; + if (ic <= a_ghosts-1) ic = a_ghosts; + else if (ic >= a_dim[0]+a_ghosts-1) ic = a_dim[0]+a_ghosts-2; - for (j = 0; j < dim[1]+2*ghosts-1; j++) { - if (isInside(yc,y[j],y[j+1])) { + for (j = 0; j < a_dim[1]+2*a_ghosts-1; j++) { + if (isInside(a_yc,a_y[j],a_y[j+1])) { jc = j; break; } } - if (jc <= ghosts-1) jc = ghosts; - else if (jc >= dim[1]+ghosts-1) jc = dim[1]+ghosts-2; + if (jc <= a_ghosts-1) jc = a_ghosts; + else if (jc >= a_dim[1]+a_ghosts-1) jc = a_dim[1]+a_ghosts-2; - for (k = 0; k < dim[2]+2*ghosts-1; k++) { - if (isInside(zc,z[k],z[k+1])) { + for (k = 0; k < a_dim[2]+2*a_ghosts-1; k++) { + if (isInside(a_zc,a_z[k],a_z[k+1])) { kc = k; break; } } - if (kc <= ghosts-1) kc = ghosts; - else if (kc >= dim[2]+ghosts-1) kc = dim[2]+ghosts-2; + if (kc <= a_ghosts-1) kc = a_ghosts; + else if (kc >= a_dim[2]+a_ghosts-1) kc = a_dim[2]+a_ghosts-2; - if (!strcmp(mode,_IB_XY_)) { kc = ghosts; zc = 0.5*(zmin+zmax); } - else if (!strcmp(mode,_IB_XZ_)) { jc = ghosts; yc = 0.5*(ymin+ymax); } - else if (!strcmp(mode,_IB_YZ_)) { ic = ghosts; xc = 0.5*(xmin+xmax); } + if (!strcmp(a_mode,_IB_XY_)) { kc = a_ghosts; a_zc = 0.5*(zmin+zmax); } + else if (!strcmp(a_mode,_IB_XZ_)) { jc = a_ghosts; a_yc = 0.5*(ymin+ymax); } + else if (!strcmp(a_mode,_IB_YZ_)) { ic = a_ghosts; a_xc = 0.5*(xmin+xmax); } if (ic == -1) { - fprintf(stderr,"Error in interpNodesCoeffs() (in ImmersedBoundaries/IBCreateFacetMapping.c) on rank %d: ic = -1.\n", mpi->rank); + fprintf(stderr,"Error in interpNodesCoeffs() (in ImmersedBoundaries/IBCreateFacetMapping.c) on rank %d: ic = -1.\n", mpi->m_rank); return(1); } if (jc == -1) { - fprintf(stderr,"Error in interpNodesCoeffs() (in ImmersedBoundaries/IBCreateFacetMapping.c) on rank %d: jc = -1.\n", mpi->rank); + fprintf(stderr,"Error in interpNodesCoeffs() (in ImmersedBoundaries/IBCreateFacetMapping.c) on rank %d: jc = -1.\n", mpi->m_rank); return(1); } if (kc == -1) { - fprintf(stderr,"Error in interpNodesCoeffs() (in ImmersedBoundaries/IBCreateFacetMapping.c) on rank %d: kc = -1.\n", mpi->rank); + fprintf(stderr,"Error in interpNodesCoeffs() (in ImmersedBoundaries/IBCreateFacetMapping.c) on rank %d: kc = -1.\n", mpi->m_rank); return(1); } ic++; jc++; kc++; - if (ii) *ii = ic; - if (jj) *jj = jc; - if (kk) *kk = kc; + if (a_ii) *a_ii = ic; + if (a_jj) *a_jj = jc; + if (a_kk) *a_kk = kc; int pc[_IB_NNODES_], index[_IB_NDIMS_]; - index[0]=ic-1-ghosts; index[1]=jc-1-ghosts; index[2]=kc-1-ghosts; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[0]); - index[0]=ic-ghosts ; index[1]=jc-1-ghosts; index[2]=kc-1-ghosts; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[1]); - index[0]=ic-1-ghosts; index[1]=jc-ghosts ; index[2]=kc-1-ghosts; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[2]); - index[0]=ic-ghosts ; index[1]=jc-ghosts ; index[2]=kc-1-ghosts; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[3]); - index[0]=ic-1-ghosts; index[1]=jc-1-ghosts; index[2]=kc-ghosts ; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[4]); - index[0]=ic-ghosts ; index[1]=jc-1-ghosts; index[2]=kc-ghosts ; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[5]); - index[0]=ic-1-ghosts; index[1]=jc-ghosts ; index[2]=kc-ghosts ; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[6]); - index[0]=ic-ghosts ; index[1]=jc-ghosts ; index[2]=kc-ghosts ; _ArrayIndex1D_(_IB_NDIMS_,dim,index,ghosts,pc[7]); - _ArrayCopy1D_(pc,inodes,_IB_NNODES_); + index[0]=ic-1-a_ghosts; index[1]=jc-1-a_ghosts; index[2]=kc-1-a_ghosts; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[0]); + index[0]=ic-a_ghosts ; index[1]=jc-1-a_ghosts; index[2]=kc-1-a_ghosts; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[1]); + index[0]=ic-1-a_ghosts; index[1]=jc-a_ghosts ; index[2]=kc-1-a_ghosts; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[2]); + index[0]=ic-a_ghosts ; index[1]=jc-a_ghosts ; index[2]=kc-1-a_ghosts; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[3]); + index[0]=ic-1-a_ghosts; index[1]=jc-1-a_ghosts; index[2]=kc-a_ghosts ; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[4]); + index[0]=ic-a_ghosts ; index[1]=jc-1-a_ghosts; index[2]=kc-a_ghosts ; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[5]); + index[0]=ic-1-a_ghosts; index[1]=jc-a_ghosts ; index[2]=kc-a_ghosts ; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[6]); + index[0]=ic-a_ghosts ; index[1]=jc-a_ghosts ; index[2]=kc-a_ghosts ; _ArrayIndex1D_(_IB_NDIMS_,a_dim,index,a_ghosts,pc[7]); + _ArrayCopy1D_(pc,a_inodes,_IB_NNODES_); double coeffs[_IB_NNODES_]; - TrilinearInterpCoeffs(x[ic-1],x[ic],y[jc-1],y[jc],z[kc-1],z[kc],xc,yc,zc,&coeffs[0]); - _ArrayCopy1D_(coeffs,icoeffs,_IB_NNODES_); + TrilinearInterpCoeffs(a_x[ic-1],a_x[ic],a_y[jc-1],a_y[jc],a_z[kc-1],a_z[kc],a_xc,a_yc,a_zc,&coeffs[0]); + _ArrayCopy1D_(coeffs,a_icoeffs,_IB_NNODES_); return(0); } @@ -141,46 +141,46 @@ static int interpNodesCoeffs( Note: each MPI rank has a copy of the entire immersed body, i.e., all the facets. */ int IBCreateFacetMapping( - void *ib, /*!< Immersed boundary object of type #ImmersedBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - double *X, /*!< Array of local spatial coordinates */ - int *dim, /*!< Local dimensions */ - int ghosts /*!< Number of ghost points */ + void *a_ib, /*!< Immersed boundary object of type #ImmersedBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_X, /*!< Array of local spatial coordinates */ + int *a_dim, /*!< Local dimensions */ + int a_ghosts /*!< Number of ghost points */ ) { - ImmersedBoundary *IB = (ImmersedBoundary*) ib; - MPIVariables *mpi = (MPIVariables*) m; - Body3D *body = IB->body; - int nfacets = body->nfacets, n, count, ierr; - Facet3D *facets = body->surface; - - double *x = X, - *y = (x + dim[0] + 2*ghosts), - *z = (y + dim[1] + 2*ghosts); - - double xmin = 0.5 * (x[ghosts-1] + x[ghosts]), - xmax = 0.5 * (x[dim[0]+ghosts-1] + x[dim[0]+ghosts]), - ymin = 0.5 * (y[ghosts-1] + y[ghosts]), - ymax = 0.5 * (y[dim[1]+ghosts-1] + y[dim[1]+ghosts]), - zmin = 0.5 * (z[ghosts-1] + z[ghosts]), - zmax = 0.5 * (z[dim[2]+ghosts-1] + z[dim[2]+ghosts]); + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; + MPIVariables *mpi = (MPIVariables*) a_m; + Body3D *body = IB->m_body; + int nfacets = body->m_nfacets, n, count, ierr; + Facet3D *facets = body->m_surface; + + double *x = a_X, + *y = (x + a_dim[0] + 2*a_ghosts), + *z = (y + a_dim[1] + 2*a_ghosts); + + double xmin = 0.5 * (x[a_ghosts-1] + x[a_ghosts]), + xmax = 0.5 * (x[a_dim[0]+a_ghosts-1] + x[a_dim[0]+a_ghosts]), + ymin = 0.5 * (y[a_ghosts-1] + y[a_ghosts]), + ymax = 0.5 * (y[a_dim[1]+a_ghosts-1] + y[a_dim[1]+a_ghosts]), + zmin = 0.5 * (z[a_ghosts-1] + z[a_ghosts]), + zmax = 0.5 * (z[a_dim[2]+a_ghosts-1] + z[a_dim[2]+a_ghosts]); count = 0; for (n = 0; n < nfacets; n++) { /* find facet centroid */ double xc, yc, zc; - xc = (facets[n].x1 + facets[n].x2 + facets[n].x3) / 3.0; - yc = (facets[n].y1 + facets[n].y2 + facets[n].y3) / 3.0; - zc = (facets[n].z1 + facets[n].z2 + facets[n].z3) / 3.0; + xc = (facets[n].m_x1 + facets[n].m_x2 + facets[n].m_x3) / 3.0; + yc = (facets[n].m_y1 + facets[n].m_y2 + facets[n].m_y3) / 3.0; + zc = (facets[n].m_z1 + facets[n].m_z2 + facets[n].m_z3) / 3.0; - if (!strcmp(IB->mode,_IB_3D_)) { + if (!strcmp(IB->m_mode,_IB_3D_)) { if (isInside(xc,xmin,xmax) && isInside(yc,ymin,ymax) && isInside(zc,zmin,zmax)) count++; - } else if (!strcmp(IB->mode,_IB_XY_)) { + } else if (!strcmp(IB->m_mode,_IB_XY_)) { if (isInside(xc,xmin,xmax) && isInside(yc,ymin,ymax)) count++; - } else if (!strcmp(IB->mode,_IB_XZ_)) { + } else if (!strcmp(IB->m_mode,_IB_XZ_)) { if (isInside(xc,xmin,xmax) && isInside(zc,zmin,zmax)) count++; - } else if (!strcmp(IB->mode,_IB_YZ_)) { + } else if (!strcmp(IB->m_mode,_IB_YZ_)) { if (isInside(yc,ymin,ymax) && isInside(zc,zmin,zmax)) count++; } } @@ -194,44 +194,44 @@ int IBCreateFacetMapping( for (n = 0; n < nfacets; n++) { double xc, yc, zc; - xc = (facets[n].x1 + facets[n].x2 + facets[n].x3) / 3.0; - yc = (facets[n].y1 + facets[n].y2 + facets[n].y3) / 3.0; - zc = (facets[n].z1 + facets[n].z2 + facets[n].z3) / 3.0; + xc = (facets[n].m_x1 + facets[n].m_x2 + facets[n].m_x3) / 3.0; + yc = (facets[n].m_y1 + facets[n].m_y2 + facets[n].m_y3) / 3.0; + zc = (facets[n].m_z1 + facets[n].m_z2 + facets[n].m_z3) / 3.0; int flag = 0; - if (!strcmp(IB->mode,_IB_3D_)) { + if (!strcmp(IB->m_mode,_IB_3D_)) { if (isInside(xc,xmin,xmax) && isInside(yc,ymin,ymax) && isInside(zc,zmin,zmax)) flag = 1; - } else if (!strcmp(IB->mode,_IB_XY_)) { + } else if (!strcmp(IB->m_mode,_IB_XY_)) { if (isInside(xc,xmin,xmax) && isInside(yc,ymin,ymax)) flag = 1; - } else if (!strcmp(IB->mode,_IB_XZ_)) { + } else if (!strcmp(IB->m_mode,_IB_XZ_)) { if (isInside(xc,xmin,xmax) && isInside(zc,zmin,zmax)) flag = 1; - } else if (!strcmp(IB->mode,_IB_YZ_)) { + } else if (!strcmp(IB->m_mode,_IB_YZ_)) { if (isInside(yc,ymin,ymax) && isInside(zc,zmin,zmax)) flag = 1; } if (flag == 1) { - fmap[count].facet = facets + n; - fmap[count].index = n; + fmap[count].m_facet = facets + n; + fmap[count].m_index = n; - fmap[count].xc = xc; - fmap[count].yc = yc; - fmap[count].zc = zc; + fmap[count].m_xc = xc; + fmap[count].m_yc = yc; + fmap[count].m_zc = zc; int ic,jc, kc; ierr = interpNodesCoeffs( mpi, xc, yc, zc, x, y, z, - dim, - ghosts, - IB->mode, + a_dim, + a_ghosts, + IB->m_mode, &ic, &jc, &kc, - fmap[count].interp_nodes, - fmap[count].interp_coeffs ); + fmap[count].m_interp_nodes, + fmap[count].m_interp_coeffs ); if (ierr) { fprintf(stderr, "Error in IBCreateFacetMapping(): \n"); fprintf(stderr, " interpNodesCoeffs() returned with error code %d on rank %d.\n", - ierr, mpi->rank ); + ierr, mpi->m_rank ); return(ierr); } @@ -239,40 +239,40 @@ int IBCreateFacetMapping( double dy = y[jc] - y[jc-1]; double dz = z[kc] - z[kc-1]; double ds; - if (!strcmp(IB->mode,_IB_XY_)) ds = min(dx,dy); - else if (!strcmp(IB->mode,_IB_XZ_)) ds = min(dx,dz); - else if (!strcmp(IB->mode,_IB_YZ_)) ds = min(dy,dz); + if (!strcmp(IB->m_mode,_IB_XY_)) ds = min(dx,dy); + else if (!strcmp(IB->m_mode,_IB_XZ_)) ds = min(dx,dz); + else if (!strcmp(IB->m_mode,_IB_YZ_)) ds = min(dy,dz); else ds = min3(dx,dy,dz); - double nx = fmap[count].facet->nx; - double ny = fmap[count].facet->ny; - double nz = fmap[count].facet->nz; + double nx = fmap[count].m_facet->m_nx; + double ny = fmap[count].m_facet->m_ny; + double nz = fmap[count].m_facet->m_nz; - if (nx == 0.0) nx += IB->delta*ds; - if (ny == 0.0) ny += IB->delta*ds; - if (nz == 0.0) nz += IB->delta*ds; + if (nx == 0.0) nx += IB->m_delta*ds; + if (ny == 0.0) ny += IB->m_delta*ds; + if (nz == 0.0) nz += IB->m_delta*ds; double xns = xc + sign(nx)*ds; double yns = yc + sign(ny)*ds; double zns = zc + sign(nz)*ds; - fmap[count].dx = xns - xc; - fmap[count].dy = yns - yc; - fmap[count].dz = zns - zc; + fmap[count].m_dx = xns - xc; + fmap[count].m_dy = yns - yc; + fmap[count].m_dz = zns - zc; ierr = interpNodesCoeffs( mpi, xns, yns, zns, x, y, z, - dim, - ghosts, - IB->mode, + a_dim, + a_ghosts, + IB->m_mode, NULL,NULL,NULL, - fmap[count].interp_nodes_ns, - fmap[count].interp_coeffs_ns ); + fmap[count].m_interp_nodes_ns, + fmap[count].m_interp_coeffs_ns ); if (ierr) { fprintf(stderr, "Error in IBCreateFacetMapping(): \n"); fprintf(stderr, " interpNodesCoeffs() returned with error code %d on rank %d.\n", - ierr, mpi->rank ); + ierr, mpi->m_rank ); return(ierr); } @@ -280,13 +280,13 @@ int IBCreateFacetMapping( } } - IB->nfacets_local = nfacets_local; - IB->fmap = fmap; + IB->m_nfacets_local = nfacets_local; + IB->m_fmap = fmap; } else { - IB->nfacets_local = 0; - IB->fmap = NULL; + IB->m_nfacets_local = 0; + IB->m_fmap = NULL; } diff --git a/src/ImmersedBoundaries/IBIdentifyBody.c b/src/ImmersedBoundaries/IBIdentifyBody.c index 97f85268..c4c201fc 100644 --- a/src/ImmersedBoundaries/IBIdentifyBody.c +++ b/src/ImmersedBoundaries/IBIdentifyBody.c @@ -18,32 +18,32 @@ originally written by Dr. Jay Sitaraman. */ int IBIdentifyBody( - void *ib, /*!< Immersed boundary object of type #ImmersedBoundary */ - int *dim_g, /*!< global dimensions */ - int *dim_l, /*!< local dimensions */ - int ghosts, /*!< number of ghost points */ - void *m, /*!< MPI object of type #MPIVariables */ - double *X, /*!< Array of global spatial coordinates */ - double *blank /*!< Blanking array: for grid points within the + void *a_ib, /*!< Immersed boundary object of type #ImmersedBoundary */ + int *a_dim_g, /*!< global dimensions */ + int *a_dim_l, /*!< local dimensions */ + int a_ghosts, /*!< number of ghost points */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_X, /*!< Array of global spatial coordinates */ + double *a_blank /*!< Blanking array: for grid points within the body, this value will be set to 0 */ ) { - ImmersedBoundary *IB = (ImmersedBoundary*) ib; - MPIVariables *mpi = (MPIVariables*) m; - Body3D *body = IB->body; - double *x = X, - *y = X+dim_g[0], - *z = X+dim_g[0]+dim_g[1], - eps = IB->tolerance; - int itr_max = IB->itr_max, + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; + MPIVariables *mpi = (MPIVariables*) a_m; + Body3D *body = IB->m_body; + double *x = a_X, + *y = a_X+a_dim_g[0], + *z = a_X+a_dim_g[0]+a_dim_g[1], + eps = IB->m_tolerance; + int itr_max = IB->m_itr_max, i, j, k, n, v; - double xmax = body->xmax, - xmin = body->xmin, - ymax = body->ymax, - ymin = body->ymin, - zmax = body->zmax, - zmin = body->zmin; + double xmax = body->m_xmax, + xmin = body->m_xmin, + ymax = body->m_ymax, + ymin = body->m_ymin, + zmax = body->m_zmax, + zmin = body->m_zmin; double fac = 1.5; double Lx, Ly, Lz; @@ -62,12 +62,12 @@ int IBIdentifyBody( zmin = zc - fac * Lz/2; int imin, imax, jmin, jmax, kmin, kmax; - imin = dim_g[0]-1; imax = 0; - jmin = dim_g[1]-1; jmax = 0; - kmin = dim_g[2]-1; kmax = 0; - for (i = 0; i < dim_g[0]; i++) { - for (j = 0; j < dim_g[1]; j++) { - for (k = 0; k < dim_g[2]; k++) { + imin = a_dim_g[0]-1; imax = 0; + jmin = a_dim_g[1]-1; jmax = 0; + kmin = a_dim_g[2]-1; kmax = 0; + for (i = 0; i < a_dim_g[0]; i++) { + for (j = 0; j < a_dim_g[1]; j++) { + for (k = 0; k < a_dim_g[2]; k++) { if ( ((x[i]-xmin)*(x[i]-xmax) < 0) && ((y[j]-ymin)*(y[j]-ymax) < 0) && ((z[k]-zmin)*(z[k]-zmax) < 0)) { @@ -85,13 +85,13 @@ int IBIdentifyBody( double *cof[5], *xd, *dist; xd = (double*) calloc (itr_max,sizeof(double)); dist = (double*) calloc (itr_max,sizeof(double)); - for (v = 0; v < 5; v++) cof[v] = (double*) calloc(body->nfacets, sizeof(double)); + for (v = 0; v < 5; v++) cof[v] = (double*) calloc(body->m_nfacets, sizeof(double)); - for (n = 0; n < body->nfacets; n++) { - cof[0][n] = body->surface[n].y1 - body->surface[n].y3; - cof[1][n] = body->surface[n].y2 - body->surface[n].y3; - cof[2][n] = body->surface[n].z1 - body->surface[n].z3; - cof[3][n] = body->surface[n].z2 - body->surface[n].z3; + for (n = 0; n < body->m_nfacets; n++) { + cof[0][n] = body->m_surface[n].m_y1 - body->m_surface[n].m_y3; + cof[1][n] = body->m_surface[n].m_y2 - body->m_surface[n].m_y3; + cof[2][n] = body->m_surface[n].m_z1 - body->m_surface[n].m_z3; + cof[3][n] = body->m_surface[n].m_z2 - body->m_surface[n].m_z3; double den = cof[0][n]*cof[3][n] - cof[1][n]*cof[2][n]; if (absolute(den) > eps) cof[4][n] = 1.0 / den; else cof[4][n] = 0; @@ -101,24 +101,24 @@ int IBIdentifyBody( for (j = jmin; j <= jmax; j++) { for (k = kmin; k <= kmax; k++) { int itr = 0; - for (n = 0; n < body->nfacets; n++) { + for (n = 0; n < body->m_nfacets; n++) { if (cof[4][n] != 0) { double yy, zz; - yy = body->surface[n].y3 - y[j]; - zz = body->surface[n].z3 - z[k]; + yy = body->m_surface[n].m_y3 - y[j]; + zz = body->m_surface[n].m_z3 - z[k]; double l1, l2, l3; l1 = (cof[1][n]*zz - cof[3][n]*yy) * cof[4][n]; l2 = (cof[2][n]*yy - cof[0][n]*zz) * cof[4][n]; l3 = 1 - l1 - l2; if ((l1 > -eps) && (l2 > -eps) && (l3 > -eps)){ - xd[itr] = l1*body->surface[n].x1 + l2*body->surface[n].x2 + l3*body->surface[n].x3; + xd[itr] = l1*body->m_surface[n].m_x1 + l2*body->m_surface[n].m_x2 + l3*body->m_surface[n].m_x3; dist[itr] = absolute(x[imin]-xd[itr]); itr++; } } } if (itr > itr_max) { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error: In IBIdentyBody() - itr > %d. Recompilation of code needed.\n",itr_max); fprintf(stderr,"Increase the value of \"itr_max\" in IBIdentyBody().\n"); } @@ -160,17 +160,17 @@ int IBIdentifyBody( inside = 1; /* this point is inside */ /* check if (i,j,k) lies within this process */ - /* if so, set blank */ - if ( ((i-mpi->is[0])*(i-mpi->ie[0]) <= 0) - && ((j-mpi->is[1])*(j-mpi->ie[1]) <= 0) - && ((k-mpi->is[2])*(k-mpi->ie[2]) <= 0)) { + /* if so, set a_blank */ + if ( ((i-mpi->m_is[0])*(i-mpi->m_ie[0]) <= 0) + && ((j-mpi->m_is[1])*(j-mpi->m_ie[1]) <= 0) + && ((k-mpi->m_is[2])*(k-mpi->m_ie[2]) <= 0)) { /* calculate local indices */ int index[_IB_NDIMS_]; - index[0] = i-mpi->is[0]; - index[1] = j-mpi->is[1]; - index[2] = k-mpi->is[2]; - int p; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,p); - blank[p] = 0; + index[0] = i-mpi->m_is[0]; + index[1] = j-mpi->m_is[1]; + index[2] = k-mpi->m_is[2]; + int p; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,p); + a_blank[p] = 0; count++; } } else { diff --git a/src/ImmersedBoundaries/IBIdentifyBoundary.c b/src/ImmersedBoundaries/IBIdentifyBoundary.c index 72929658..1826b53a 100644 --- a/src/ImmersedBoundaries/IBIdentifyBoundary.c +++ b/src/ImmersedBoundaries/IBIdentifyBoundary.c @@ -13,59 +13,59 @@ a grid point outside the body. */ static int CountBoundaryPoints( - int imax, /*!< Number of grid points in x */ - int jmax, /*!< Number of grid points in y */ - int kmax, /*!< Number of grid points in z */ - int ghosts, /*!< Number of ghost points */ - double *blank /*!< blanking array where entries are zero + int a_imax, /*!< Number of grid points in x */ + int a_jmax, /*!< Number of grid points in y */ + int a_kmax, /*!< Number of grid points in z */ + int a_ghosts, /*!< Number of ghost points */ + double *a_blank /*!< blanking array where entries are zero for grid points inside, and one for grid points outside. */ ) { static int dim[_IB_NDIMS_], indexC[_IB_NDIMS_], indexN[_IB_NDIMS_], i, j, k, p, q, count; - dim[0] = imax; - dim[1] = jmax; - dim[2] = kmax; + dim[0] = a_imax; + dim[1] = a_jmax; + dim[2] = a_kmax; count = 0; - for (i = 0; i < imax; i++) { - for (j = 0; j < jmax; j++) { - for (k = 0; k < kmax; k++) { + for (i = 0; i < a_imax; i++) { + for (j = 0; j < a_jmax; j++) { + for (k = 0; k < a_kmax; k++) { indexC[0] = i; indexC[1] = j; indexC[2] = k; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexC,ghosts,p); + _ArrayIndex1D_(_IB_NDIMS_,dim,indexC,a_ghosts,p); /* if this point is inside the body (0), find out if any */ /* of the neighboring points are outside (1) */ - if (!blank[p]){ + if (!a_blank[p]){ int g, flag = 0; - for (g = 1; g <= ghosts; g++){ + for (g = 1; g <= a_ghosts; g++){ _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[0] += g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[0] -= g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[1] += g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[1] -= g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[2] += g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[2] -= g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; } if (flag) count++; @@ -78,68 +78,68 @@ static int CountBoundaryPoints( /*! Set the indices of the immersed boundary points.*/ static int SetBoundaryPoints( - int imax, /*!< Number of grid points in x */ - int jmax, /*!< Number of grid points in y */ - int kmax, /*!< Number of grid points in z */ - int ghosts, /*!< Number of ghost points */ - double *blank, /*!< blanking array where entries are zero + int a_imax, /*!< Number of grid points in x */ + int a_jmax, /*!< Number of grid points in y */ + int a_kmax, /*!< Number of grid points in z */ + int a_ghosts, /*!< Number of ghost points */ + double *a_blank, /*!< blanking array where entries are zero for grid points inside, and one for grid points outside. */ - void *b /*!< Array of immersed boundary points of type #IBNode */ + void *a_b /*!< Array of immersed boundary points of type #IBNode */ ) { - IBNode *boundary = (IBNode*) b; + IBNode *boundary = (IBNode*) a_b; static int dim[_IB_NDIMS_], indexC[_IB_NDIMS_], indexN[_IB_NDIMS_], i, j, k, p, q, count; - dim[0] = imax; - dim[1] = jmax; - dim[2] = kmax; + dim[0] = a_imax; + dim[1] = a_jmax; + dim[2] = a_kmax; count = 0; - for (i = 0; i < imax; i++) { - for (j = 0; j < jmax; j++) { - for (k = 0; k < kmax; k++) { + for (i = 0; i < a_imax; i++) { + for (j = 0; j < a_jmax; j++) { + for (k = 0; k < a_kmax; k++) { indexC[0] = i; indexC[1] = j; indexC[2] = k; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexC,ghosts,p); + _ArrayIndex1D_(_IB_NDIMS_,dim,indexC,a_ghosts,p); /* if this point is inside the body (0), find out if any */ /* of the neighboring points are outside (1) */ - if (!blank[p]){ + if (!a_blank[p]){ int g, flag = 0; - for (g = 1; g <= ghosts; g++){ + for (g = 1; g <= a_ghosts; g++){ _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[0] += g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[0] -= g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[1] += g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[1] -= g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[2] += g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; _ArrayCopy1D_(indexC,indexN,_IB_NDIMS_); indexN[2] -= g; - _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,ghosts,q); - if (blank[q]) flag = 1; + _ArrayIndex1D_(_IB_NDIMS_,dim,indexN,a_ghosts,q); + if (a_blank[q]) flag = 1; } if (flag) { - boundary[count].i = i; - boundary[count].j = j; - boundary[count].k = k; - boundary[count].p = p; + boundary[count].m_i = i; + boundary[count].m_j = j; + boundary[count].m_k = k; + boundary[count].m_p = p; count++; } } @@ -156,31 +156,31 @@ static int SetBoundaryPoints( + allocate the array of immersed boundary points and set their indices. */ int IBIdentifyBoundary( - void *ib, /*!< Immersed boundary object of type #ImmersedBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - int *dim_l, /*!< local dimensions */ - int ghosts, /*!< number of ghost points */ - double *blank /*!< Blanking array: for grid points within the + void *a_ib, /*!< Immersed boundary object of type #ImmersedBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int *a_dim_l, /*!< local dimensions */ + int a_ghosts, /*!< number of ghost points */ + double *a_blank /*!< Blanking array: for grid points within the immersed body, this value will be set to 0 */ ) { - ImmersedBoundary *IB = (ImmersedBoundary*) ib; - MPIVariables *mpi = (MPIVariables*) m; - Body3D *body = IB->body; + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; + MPIVariables *mpi = (MPIVariables*) a_m; + Body3D *body = IB->m_body; - int imax = dim_l[0], - jmax = dim_l[1], - kmax = dim_l[2]; + int imax = a_dim_l[0], + jmax = a_dim_l[1], + kmax = a_dim_l[2]; - int n_boundary_nodes = CountBoundaryPoints(imax,jmax,kmax,ghosts,blank); - IB->n_boundary_nodes = n_boundary_nodes; - if (n_boundary_nodes == 0) IB->boundary = NULL; + int n_boundary_nodes = CountBoundaryPoints(imax,jmax,kmax,a_ghosts,a_blank); + IB->m_n_boundary_nodes = n_boundary_nodes; + if (n_boundary_nodes == 0) IB->m_boundary = NULL; else { - IB->boundary = (IBNode*) calloc (n_boundary_nodes, sizeof(IBNode)); - int check = SetBoundaryPoints(imax,jmax,kmax,ghosts,blank,IB->boundary); + IB->m_boundary = (IBNode*) calloc (n_boundary_nodes, sizeof(IBNode)); + int check = SetBoundaryPoints(imax,jmax,kmax,a_ghosts,a_blank,IB->m_boundary); if (check != n_boundary_nodes) { fprintf(stderr,"Error in IBIdentifyBoundary(): Inconsistency encountered when setting boundary indices. "); - fprintf(stderr,"on rank %d.\n",mpi->rank); + fprintf(stderr,"on rank %d.\n",mpi->m_rank); fprintf(stderr,"SetBoundaryPoints() returned %d, while n_boundary_nodes is %d.\n",check,n_boundary_nodes); } } diff --git a/src/ImmersedBoundaries/IBIdentifyMode.c b/src/ImmersedBoundaries/IBIdentifyMode.c index b2eab5ba..7d8eed64 100644 --- a/src/ImmersedBoundaries/IBIdentifyMode.c +++ b/src/ImmersedBoundaries/IBIdentifyMode.c @@ -22,27 +22,27 @@ simulation. */ int IBIdentifyMode( - double *X, /*!< Array of global spatial coordinates */ - int *dim, /*!< global dimensions */ - void *ib /*!< Immersed boundary object of type #ImmersedBoundary */ + double *a_X, /*!< Array of global spatial coordinates */ + int *a_dim, /*!< global dimensions */ + void *a_ib /*!< Immersed boundary object of type #ImmersedBoundary */ ) { - ImmersedBoundary *IB = (ImmersedBoundary*) ib; - Body3D *body = IB->body; + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; + Body3D *body = IB->m_body; - double *x = X, *y = x + dim[0], *z = y + dim[1]; + double *x = a_X, *y = x + a_dim[0], *z = y + a_dim[1]; double grid_xmin = x[0], - grid_xmax = x[dim[0]-1], + grid_xmax = x[a_dim[0]-1], grid_ymin = y[0], - grid_ymax = y[dim[1]-1], + grid_ymax = y[a_dim[1]-1], grid_zmin = z[0], - grid_zmax = z[dim[2]-1]; + grid_zmax = z[a_dim[2]-1]; - if ( (grid_xmin > body->xmin) && (grid_xmax < body->xmax) ) strcpy(IB->mode,_IB_YZ_); - else if ( (grid_ymin > body->ymin) && (grid_ymax < body->ymax) ) strcpy(IB->mode,_IB_XZ_); - else if ( (grid_zmin > body->zmin) && (grid_zmax < body->zmax) ) strcpy(IB->mode,_IB_XY_); - else strcpy(IB->mode,_IB_3D_); + if ( (grid_xmin > body->m_xmin) && (grid_xmax < body->m_xmax) ) strcpy(IB->m_mode,_IB_YZ_); + else if ( (grid_ymin > body->m_ymin) && (grid_ymax < body->m_ymax) ) strcpy(IB->m_mode,_IB_XZ_); + else if ( (grid_zmin > body->m_zmin) && (grid_zmax < body->m_zmax) ) strcpy(IB->m_mode,_IB_XY_); + else strcpy(IB->m_mode,_IB_3D_); return(0); } diff --git a/src/ImmersedBoundaries/IBInterpCoeffs.c b/src/ImmersedBoundaries/IBInterpCoeffs.c index 7c16aad2..39ebc975 100644 --- a/src/ImmersedBoundaries/IBInterpCoeffs.c +++ b/src/ImmersedBoundaries/IBInterpCoeffs.c @@ -20,30 +20,30 @@ coefficients to interpolate a variable from the surrounding points to the probe tip. */ int IBInterpCoeffs( - void *ib, /*!< Immersed boundary object of type #ImmersedBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - double *X, /*!< Array of (local) spatial coordinates */ - int *dim_l, /*!< Integer array of local grid size in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *blank /*!< Blanking array: for grid points within the + void *a_ib, /*!< Immersed boundary object of type #ImmersedBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_X, /*!< Array of (local) spatial coordinates */ + int *a_dim_l, /*!< Integer array of local grid size in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + double *a_blank /*!< Blanking array: for grid points within the body, this value will be set to 0 */ ) { - ImmersedBoundary *IB = (ImmersedBoundary*) ib; - MPIVariables *mpi = (MPIVariables*) m; - IBNode *boundary = IB->boundary; + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; + MPIVariables *mpi = (MPIVariables*) a_m; + IBNode *boundary = IB->m_boundary; - double eps = IB->tolerance; - int maxiter = IB->itr_max, - n_boundary = IB->n_boundary_nodes; + double eps = IB->m_tolerance; + int maxiter = IB->m_itr_max, + n_boundary = IB->m_n_boundary_nodes; - int imax = dim_l[0], - jmax = dim_l[1], - kmax = dim_l[2]; + int imax = a_dim_l[0], + jmax = a_dim_l[1], + kmax = a_dim_l[2]; - int is = mpi->is[0], - js = mpi->is[1], - ks = mpi->is[2]; + int is = mpi->m_is[0], + js = mpi->m_is[1], + ks = mpi->m_is[2]; static int index[_IB_NDIMS_]; @@ -57,31 +57,31 @@ int IBInterpCoeffs( double ds, dist; double xtip, ytip, ztip; - index[0] = i = boundary[dg].i; - index[1] = j = boundary[dg].j; - index[2] = k = boundary[dg].k; - _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,p); + index[0] = i = boundary[dg].m_i; + index[1] = j = boundary[dg].m_j; + index[2] = k = boundary[dg].m_k; + _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,p); - xb = boundary[dg].x; - yb = boundary[dg].y; - zb = boundary[dg].z; + xb = boundary[dg].m_x; + yb = boundary[dg].m_y; + zb = boundary[dg].m_z; - nx = boundary[dg].face->nx; - ny = boundary[dg].face->ny; - nz = boundary[dg].face->nz; - xx = boundary[dg].face->x1; - yy = boundary[dg].face->y1; - zz = boundary[dg].face->z1; + nx = boundary[dg].m_face->m_nx; + ny = boundary[dg].m_face->m_ny; + nz = boundary[dg].m_face->m_nz; + xx = boundary[dg].m_face->m_x1; + yy = boundary[dg].m_face->m_y1; + zz = boundary[dg].m_face->m_z1; dist = nx*(xx-xb) + ny*(yy-yb) + nz*(zz-zb); double x1, x2, y1, y2, z1, z2; - _GetCoordinate_(0,(i+1),dim_l,ghosts,X,x1); - _GetCoordinate_(0,(i-1),dim_l,ghosts,X,x2); - _GetCoordinate_(1,(j+1),dim_l,ghosts,X,y1); - _GetCoordinate_(1,(j-1),dim_l,ghosts,X,y2); - _GetCoordinate_(2,(k+1),dim_l,ghosts,X,z1); - _GetCoordinate_(2,(k-1),dim_l,ghosts,X,z2); + _GetCoordinate_(0,(i+1),a_dim_l,a_ghosts,a_X,x1); + _GetCoordinate_(0,(i-1),a_dim_l,a_ghosts,a_X,x2); + _GetCoordinate_(1,(j+1),a_dim_l,a_ghosts,a_X,y1); + _GetCoordinate_(1,(j-1),a_dim_l,a_ghosts,a_X,y2); + _GetCoordinate_(2,(k+1),a_dim_l,a_ghosts,a_X,z1); + _GetCoordinate_(2,(k-1),a_dim_l,a_ghosts,a_X,z2); dx = 0.5 * (x1 - x2); dy = 0.5 * (y1 - y2); dz = 0.5 * (z1 - z2); @@ -102,71 +102,71 @@ int IBInterpCoeffs( if (xtip > xb) { double xx; - _GetCoordinate_(0,itip,dim_l,ghosts,X,xx); - while ((xx < xtip) && (itip < imax+ghosts-1)) { + _GetCoordinate_(0,itip,a_dim_l,a_ghosts,a_X,xx); + while ((xx < xtip) && (itip < imax+a_ghosts-1)) { itip++; - _GetCoordinate_(0,itip,dim_l,ghosts,X,xx); + _GetCoordinate_(0,itip,a_dim_l,a_ghosts,a_X,xx); } } else { double xx; - _GetCoordinate_(0,(itip-1),dim_l,ghosts,X,xx); - while ((xx > xtip) && (itip > -ghosts)) { + _GetCoordinate_(0,(itip-1),a_dim_l,a_ghosts,a_X,xx); + while ((xx > xtip) && (itip > -a_ghosts)) { itip--; - _GetCoordinate_(0,(itip-1),dim_l,ghosts,X,xx); + _GetCoordinate_(0,(itip-1),a_dim_l,a_ghosts,a_X,xx); } } if (ytip > yb) { double yy; - _GetCoordinate_(1,jtip,dim_l,ghosts,X,yy); - while ((yy < ytip) && (jtip < jmax+ghosts-1)) { + _GetCoordinate_(1,jtip,a_dim_l,a_ghosts,a_X,yy); + while ((yy < ytip) && (jtip < jmax+a_ghosts-1)) { jtip++; - _GetCoordinate_(1,jtip,dim_l,ghosts,X,yy); + _GetCoordinate_(1,jtip,a_dim_l,a_ghosts,a_X,yy); } } else { double yy; - _GetCoordinate_(1,(jtip-1),dim_l,ghosts,X,yy); - while ((yy > ytip) && (jtip > -ghosts)) { + _GetCoordinate_(1,(jtip-1),a_dim_l,a_ghosts,a_X,yy); + while ((yy > ytip) && (jtip > -a_ghosts)) { jtip--; - _GetCoordinate_(1,(jtip-1),dim_l,ghosts,X,yy); + _GetCoordinate_(1,(jtip-1),a_dim_l,a_ghosts,a_X,yy); } } if (ztip > zb) { double zz; - _GetCoordinate_(2,ktip,dim_l,ghosts,X,zz); - while ((zz < ztip) && (ktip < kmax+ghosts-1)) { + _GetCoordinate_(2,ktip,a_dim_l,a_ghosts,a_X,zz); + while ((zz < ztip) && (ktip < kmax+a_ghosts-1)) { ktip++; - _GetCoordinate_(2,ktip,dim_l,ghosts,X,zz); + _GetCoordinate_(2,ktip,a_dim_l,a_ghosts,a_X,zz); } } else { double zz; - _GetCoordinate_(2,(ktip-1),dim_l,ghosts,X,zz); - while ((zz > ztip) && (ktip > -ghosts)) { + _GetCoordinate_(2,(ktip-1),a_dim_l,a_ghosts,a_X,zz); + while ((zz > ztip) && (ktip > -a_ghosts)) { ktip--; - _GetCoordinate_(2,(ktip-1),dim_l,ghosts,X,zz); + _GetCoordinate_(2,(ktip-1),a_dim_l,a_ghosts,a_X,zz); } } int ptip[_IB_NNODES_]; - index[0] = itip ; index[1] = jtip ; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[0]); - index[0] = itip-1; index[1] = jtip ; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[1]); - index[0] = itip ; index[1] = jtip-1; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[2]); - index[0] = itip ; index[1] = jtip ; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[3]); - index[0] = itip-1; index[1] = jtip-1; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[4]); - index[0] = itip ; index[1] = jtip-1; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[5]); - index[0] = itip-1; index[1] = jtip ; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[6]); - index[0] = itip-1; index[1] = jtip-1; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[7]); + index[0] = itip ; index[1] = jtip ; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[0]); + index[0] = itip-1; index[1] = jtip ; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[1]); + index[0] = itip ; index[1] = jtip-1; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[2]); + index[0] = itip ; index[1] = jtip ; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[3]); + index[0] = itip-1; index[1] = jtip-1; index[2] = ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[4]); + index[0] = itip ; index[1] = jtip-1; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[5]); + index[0] = itip-1; index[1] = jtip ; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[6]); + index[0] = itip-1; index[1] = jtip-1; index[2] = ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[7]); int nflow = 0; - nflow += blank[ptip[0]]; - nflow += blank[ptip[1]]; - nflow += blank[ptip[2]]; - nflow += blank[ptip[3]]; - nflow += blank[ptip[4]]; - nflow += blank[ptip[5]]; - nflow += blank[ptip[6]]; - nflow += blank[ptip[7]]; + nflow += a_blank[ptip[0]]; + nflow += a_blank[ptip[1]]; + nflow += a_blank[ptip[2]]; + nflow += a_blank[ptip[3]]; + nflow += a_blank[ptip[4]]; + nflow += a_blank[ptip[5]]; + nflow += a_blank[ptip[6]]; + nflow += a_blank[ptip[7]]; if (nflow == _IB_NNODES_) { is_it_in = 1; } else if (nflow < _IB_NNODES_) { @@ -176,7 +176,7 @@ int IBInterpCoeffs( ztip += nz*absolute(ds); } else { fprintf(stderr,"Error in IBInterpCoeffs() (Bug in code) - counting interior points surrounding probe tip \n"); - fprintf(stderr,"on rank %d.\n", mpi->rank); + fprintf(stderr,"on rank %d.\n", mpi->m_rank); fprintf(stderr,"Value of nflow is %d but can only be positive and <= %d.\n",nflow,_IB_NNODES_); return(1); } @@ -184,39 +184,39 @@ int IBInterpCoeffs( if (!is_it_in) { fprintf(stderr,"Error in IBInterpCoeffs() on rank %d - interior point not found for immersed boundary point (%d,%d,%d)!\n", - mpi->rank, i, j, k); + mpi->m_rank, i, j, k); return(1); } double tlx[2],tly[2],tlz[2]; - _GetCoordinate_(0,(itip-1),dim_l,ghosts,X,tlx[0]); - _GetCoordinate_(0,(itip ),dim_l,ghosts,X,tlx[1]); - _GetCoordinate_(1,(jtip-1),dim_l,ghosts,X,tly[0]); - _GetCoordinate_(1,(jtip ),dim_l,ghosts,X,tly[1]); - _GetCoordinate_(2,(ktip-1),dim_l,ghosts,X,tlz[0]); - _GetCoordinate_(2,(ktip ),dim_l,ghosts,X,tlz[1]); + _GetCoordinate_(0,(itip-1),a_dim_l,a_ghosts,a_X,tlx[0]); + _GetCoordinate_(0,(itip ),a_dim_l,a_ghosts,a_X,tlx[1]); + _GetCoordinate_(1,(jtip-1),a_dim_l,a_ghosts,a_X,tly[0]); + _GetCoordinate_(1,(jtip ),a_dim_l,a_ghosts,a_X,tly[1]); + _GetCoordinate_(2,(ktip-1),a_dim_l,a_ghosts,a_X,tlz[0]); + _GetCoordinate_(2,(ktip ),a_dim_l,a_ghosts,a_X,tlz[1]); int ptip[_IB_NNODES_]; - index[0]=itip-1; index[1]=jtip-1; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[0]); - index[0]=itip ; index[1]=jtip-1; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[1]); - index[0]=itip-1; index[1]=jtip ; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[2]); - index[0]=itip ; index[1]=jtip ; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[3]); - index[0]=itip-1; index[1]=jtip-1; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[4]); - index[0]=itip ; index[1]=jtip-1; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[5]); - index[0]=itip-1; index[1]=jtip ; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[6]); - index[0]=itip ; index[1]=jtip ; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,dim_l,index,ghosts,ptip[7]); - _ArrayCopy1D_(ptip,boundary[dg].interp_nodes,_IB_NNODES_); + index[0]=itip-1; index[1]=jtip-1; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[0]); + index[0]=itip ; index[1]=jtip-1; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[1]); + index[0]=itip-1; index[1]=jtip ; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[2]); + index[0]=itip ; index[1]=jtip ; index[2]=ktip-1; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[3]); + index[0]=itip-1; index[1]=jtip-1; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[4]); + index[0]=itip ; index[1]=jtip-1; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[5]); + index[0]=itip-1; index[1]=jtip ; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[6]); + index[0]=itip ; index[1]=jtip ; index[2]=ktip ; _ArrayIndex1D_(_IB_NDIMS_,a_dim_l,index,a_ghosts,ptip[7]); + _ArrayCopy1D_(ptip,boundary[dg].m_interp_nodes,_IB_NNODES_); double coeffs[_IB_NNODES_]; TrilinearInterpCoeffs(tlx[0],tlx[1],tly[0],tly[1],tlz[0],tlz[1],xtip,ytip,ztip,&coeffs[0]); - _ArrayCopy1D_(coeffs,boundary[dg].interp_coeffs,_IB_NNODES_); + _ArrayCopy1D_(coeffs,boundary[dg].m_interp_coeffs,_IB_NNODES_); double tipdist = absolute(nx*(xx-xtip) + ny*(yy-ytip) + nz*(zz-ztip)); - boundary[dg].interp_node_distance = tipdist; - boundary[dg].surface_distance = absolute(dist); + boundary[dg].m_interp_node_distance = tipdist; + boundary[dg].m_surface_distance = absolute(dist); if (tipdist < eps) { fprintf(stderr,"Warning in IBInterpCoeffs() on rank %d - how can probe tip be on surface? Tipdist = %e\n", - mpi->rank,tipdist); + mpi->m_rank,tipdist); } } diff --git a/src/ImmersedBoundaries/IBNearestFacetNormal.c b/src/ImmersedBoundaries/IBNearestFacetNormal.c index 3ee13ede..1031f556 100644 --- a/src/ImmersedBoundaries/IBNearestFacetNormal.c +++ b/src/ImmersedBoundaries/IBNearestFacetNormal.c @@ -23,66 +23,66 @@ is defined in. */ int IBNearestFacetNormal( - void *ib, /*!< Immersed boundary object of type #ImmersedBoundary */ - void *m, /*!< MPI object of type #MPIVariables */ - double *X, /*!< Array of (local) spatial coordinates */ - double large_distance, /*!< A large distance */ - int *dim_l, /*!< Integer array of local grid size in each spatial dimension */ - int ghosts /*!< Number of ghost points */ + void *a_ib, /*!< Immersed boundary object of type #ImmersedBoundary */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_X, /*!< Array of (local) spatial coordinates */ + double a_large_distance, /*!< A large distance */ + int *a_dim_l, /*!< Integer array of local grid size in each spatial dimension */ + int a_ghosts /*!< Number of ghost points */ ) { - ImmersedBoundary *IB = (ImmersedBoundary*) ib; - MPIVariables *mpi = (MPIVariables*) m; - Body3D *body = IB->body; - Facet3D *surface = body->surface; - IBNode *boundary = IB->boundary; + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; + MPIVariables *mpi = (MPIVariables*) a_m; + Body3D *body = IB->m_body; + Facet3D *surface = body->m_surface; + IBNode *boundary = IB->m_boundary; - double eps = IB->tolerance; - int nb = IB->n_boundary_nodes, - nf = body->nfacets; + double eps = IB->m_tolerance; + int nb = IB->m_n_boundary_nodes, + nf = body->m_nfacets; int i, j, k, dg, n; for (dg = 0; dg < nb; dg++) { - i = boundary[dg].i; - j = boundary[dg].j; - k = boundary[dg].k; + i = boundary[dg].m_i; + j = boundary[dg].m_j; + k = boundary[dg].m_k; double xp, yp, zp; - _GetCoordinate_(0,i,dim_l,ghosts,X,xp); - _GetCoordinate_(1,j,dim_l,ghosts,X,yp); - _GetCoordinate_(2,k,dim_l,ghosts,X,zp); - boundary[dg].x = xp; - boundary[dg].y = yp; - boundary[dg].z = zp; + _GetCoordinate_(0,i,a_dim_l,a_ghosts,a_X,xp); + _GetCoordinate_(1,j,a_dim_l,a_ghosts,a_X,yp); + _GetCoordinate_(2,k,a_dim_l,a_ghosts,a_X,zp); + boundary[dg].m_x = xp; + boundary[dg].m_y = yp; + boundary[dg].m_z = zp; - double dist_min = large_distance; + double dist_min = a_large_distance; int n_min = -1; for (n = 0; n < nf; n++) { double x1, x2, x3; double y1, y2, y3; double z1, z2, z3; - x1 = surface[n].x1; x2 = surface[n].x2; x3 = surface[n].x3; - y1 = surface[n].y1; y2 = surface[n].y2; y3 = surface[n].y3; - z1 = surface[n].z1; z2 = surface[n].z2; z3 = surface[n].z3; - double dist = surface[n].nx*(xp-surface[n].x1) - + surface[n].ny*(yp-surface[n].y1) - + surface[n].nz*(zp-surface[n].z1); + x1 = surface[n].m_x1; x2 = surface[n].m_x2; x3 = surface[n].m_x3; + y1 = surface[n].m_y1; y2 = surface[n].m_y2; y3 = surface[n].m_y3; + z1 = surface[n].m_z1; z2 = surface[n].m_z2; z3 = surface[n].m_z3; + double dist = surface[n].m_nx*(xp-surface[n].m_x1) + + surface[n].m_ny*(yp-surface[n].m_y1) + + surface[n].m_nz*(zp-surface[n].m_z1); if (dist > 0) continue; if (absolute(dist) < dist_min) { short is_it_in = 0; double x_int, y_int, z_int; - x_int = xp - dist * surface[n].nx; - y_int = yp - dist * surface[n].ny; - z_int = zp - dist * surface[n].nz; - if (absolute(surface[n].nx) > eps) { + x_int = xp - dist * surface[n].m_nx; + y_int = yp - dist * surface[n].m_ny; + z_int = zp - dist * surface[n].m_nz; + if (absolute(surface[n].m_nx) > eps) { double den = (z2-z3)*(y1-y3)-(y2-y3)*(z1-z3); double l1, l2, l3; l1 = ((y2-y3)*(z3-z_int)-(z2-z3)*(y3-y_int)) / den; l2 = ((z1-z3)*(y3-y_int)-(y1-y3)*(z3-z_int)) / den; l3 = 1 - l1 - l2; if ((l1 > -eps) && (l2 > -eps) && (l3 > -eps)) is_it_in = 1; - } else if (absolute(surface[n].ny) > eps) { + } else if (absolute(surface[n].m_ny) > eps) { double den = (x2-x3)*(z1-z3)-(z2-z3)*(x1-x3); double l1, l2, l3; l1 = ((z2-z3)*(x3-x_int)-(x2-x3)*(z3-z_int)) / den; @@ -105,9 +105,9 @@ int IBNearestFacetNormal( } if (n_min == -1) { for (n = 0; n < nf; n++) { - double dist = surface[n].nx*(xp-surface[n].x1) - + surface[n].ny*(yp-surface[n].y1) - + surface[n].nz*(zp-surface[n].z1); + double dist = surface[n].m_nx*(xp-surface[n].m_x1) + + surface[n].m_ny*(yp-surface[n].m_y1) + + surface[n].m_nz*(zp-surface[n].m_z1); if (dist > eps) continue; else { if (absolute(dist) < dist_min) { @@ -120,9 +120,9 @@ int IBNearestFacetNormal( if (n_min == -1) { fprintf(stderr,"Error in IBNearestFacetNormal(): no nearest normal found for boundary node (%d,%d,%d) ",i,j,k); - fprintf(stderr,"on rank %d.\n",mpi->rank); + fprintf(stderr,"on rank %d.\n",mpi->m_rank); return(1); - } else boundary[dg].face = &surface[n_min]; + } else boundary[dg].m_face = &surface[n_min]; } return(0); diff --git a/src/ImmersedBoundaries/IBReadBodySTL.c b/src/ImmersedBoundaries/IBReadBodySTL.c index 22509a0a..a81b182d 100644 --- a/src/ImmersedBoundaries/IBReadBodySTL.c +++ b/src/ImmersedBoundaries/IBReadBodySTL.c @@ -21,16 +21,16 @@ int IBReadBodySTL( Body3D **body, /*!< 3D body to be allocated and read from file */ char *filename, /*!< Filename */ - void *m, /*!< MPI object of type #MPIVariables */ + void *a_m, /*!< MPI object of type #MPIVariables */ int *stat /*!< Status (0: success; non-0: failure) */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int n, ierr; *stat = 0; if ((*body) != NULL) { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in IBReadBodySTL(): pointer to immersed body not NULL.\n"); } *stat = -1; @@ -38,7 +38,7 @@ int IBReadBodySTL( } /* Rank 0 reads in file */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; in = fopen(filename,"r"); @@ -64,8 +64,8 @@ int IBReadBodySTL( if (nfacets > 0) { (*body) = (Body3D*) calloc (1,sizeof(Body3D)); - (*body)->nfacets = nfacets; - (*body)->surface = (Facet3D*) calloc (nfacets,sizeof(Facet3D)); + (*body)->m_nfacets = nfacets; + (*body)->m_surface = (Facet3D*) calloc (nfacets,sizeof(Facet3D)); /* Read in STL data */ in = fopen(filename,"r"); @@ -82,9 +82,9 @@ int IBReadBodySTL( ierr = fscanf(in,"%lf",&t1); ierr = fscanf(in,"%lf",&t2); ierr = fscanf(in,"%lf",&t3); - (*body)->surface[n].nx = t1; - (*body)->surface[n].ny = t2; - (*body)->surface[n].nz = t3; + (*body)->m_surface[n].m_nx = t1; + (*body)->m_surface[n].m_ny = t2; + (*body)->m_surface[n].m_nz = t3; } ierr = fscanf(in,"%s",word); if (strcmp(word, "outer")) { @@ -104,9 +104,9 @@ int IBReadBodySTL( ierr = fscanf(in,"%lf",&t1); ierr = fscanf(in,"%lf",&t2); ierr = fscanf(in,"%lf",&t3); - (*body)->surface[n].x1 = t1; - (*body)->surface[n].y1 = t2; - (*body)->surface[n].z1 = t3; + (*body)->m_surface[n].m_x1 = t1; + (*body)->m_surface[n].m_y1 = t2; + (*body)->m_surface[n].m_z1 = t3; } ierr = fscanf(in,"%s",word); if (strcmp(word, "vertex")) { @@ -116,9 +116,9 @@ int IBReadBodySTL( ierr = fscanf(in,"%lf",&t1); ierr = fscanf(in,"%lf",&t2); ierr = fscanf(in,"%lf",&t3); - (*body)->surface[n].x2 = t1; - (*body)->surface[n].y2 = t2; - (*body)->surface[n].z2 = t3; + (*body)->m_surface[n].m_x2 = t1; + (*body)->m_surface[n].m_y2 = t2; + (*body)->m_surface[n].m_z2 = t3; } ierr = fscanf(in,"%s",word); if (strcmp(word, "vertex")) { @@ -128,9 +128,9 @@ int IBReadBodySTL( ierr = fscanf(in,"%lf",&t1); ierr = fscanf(in,"%lf",&t2); ierr = fscanf(in,"%lf",&t3); - (*body)->surface[n].x3 = t1; - (*body)->surface[n].y3 = t2; - (*body)->surface[n].z3 = t3; + (*body)->m_surface[n].m_x3 = t1; + (*body)->m_surface[n].m_y3 = t2; + (*body)->m_surface[n].m_z3 = t3; } } } @@ -141,7 +141,7 @@ int IBReadBodySTL( /* done reading STL file */ if (n != nfacets) { fprintf(stderr,"Error in IBReadBodySTL(): Inconsistency in number of facets read.\n"); - free((*body)->surface); + free((*body)->m_surface); free(*body); *stat = 1; } @@ -152,54 +152,54 @@ int IBReadBodySTL( } } - MPIBroadcast_integer(stat,1,0,&mpi->world); + MPIBroadcast_integer(stat,1,0,&mpi->m_world); if ((*stat)) return(0); /* Distribute the body to all MPI ranks */ int nfacets; - if (!mpi->rank) nfacets = (*body)->nfacets; - MPIBroadcast_integer(&nfacets,1,0,&mpi->world); + if (!mpi->m_rank) nfacets = (*body)->m_nfacets; + MPIBroadcast_integer(&nfacets,1,0,&mpi->m_world); - if (mpi->rank) { + if (mpi->m_rank) { (*body) = (Body3D*) calloc (1,sizeof(Body3D)); - (*body)->nfacets = nfacets; - (*body)->surface = (Facet3D*) calloc (nfacets,sizeof(Facet3D)); + (*body)->m_nfacets = nfacets; + (*body)->m_surface = (Facet3D*) calloc (nfacets,sizeof(Facet3D)); } int bufdim = 12; double *buffer = (double*) calloc (bufdim*nfacets,sizeof(double)); - if (!mpi->rank) { + if (!mpi->m_rank) { for (n=0; nsurface[n].x1; - buffer[n*bufdim+ 1] = (*body)->surface[n].x2; - buffer[n*bufdim+ 2] = (*body)->surface[n].x3; - buffer[n*bufdim+ 3] = (*body)->surface[n].y1; - buffer[n*bufdim+ 4] = (*body)->surface[n].y2; - buffer[n*bufdim+ 5] = (*body)->surface[n].y3; - buffer[n*bufdim+ 6] = (*body)->surface[n].z1; - buffer[n*bufdim+ 7] = (*body)->surface[n].z2; - buffer[n*bufdim+ 8] = (*body)->surface[n].z3; - buffer[n*bufdim+ 9] = (*body)->surface[n].nx; - buffer[n*bufdim+10] = (*body)->surface[n].ny; - buffer[n*bufdim+11] = (*body)->surface[n].nz; + buffer[n*bufdim+ 0] = (*body)->m_surface[n].m_x1; + buffer[n*bufdim+ 1] = (*body)->m_surface[n].m_x2; + buffer[n*bufdim+ 2] = (*body)->m_surface[n].m_x3; + buffer[n*bufdim+ 3] = (*body)->m_surface[n].m_y1; + buffer[n*bufdim+ 4] = (*body)->m_surface[n].m_y2; + buffer[n*bufdim+ 5] = (*body)->m_surface[n].m_y3; + buffer[n*bufdim+ 6] = (*body)->m_surface[n].m_z1; + buffer[n*bufdim+ 7] = (*body)->m_surface[n].m_z2; + buffer[n*bufdim+ 8] = (*body)->m_surface[n].m_z3; + buffer[n*bufdim+ 9] = (*body)->m_surface[n].m_nx; + buffer[n*bufdim+10] = (*body)->m_surface[n].m_ny; + buffer[n*bufdim+11] = (*body)->m_surface[n].m_nz; } } - MPIBroadcast_double(buffer,(nfacets*bufdim),0,&mpi->world); - if (mpi->rank) { + MPIBroadcast_double(buffer,(nfacets*bufdim),0,&mpi->m_world); + if (mpi->m_rank) { for (n=0; nsurface[n].x1 = buffer[n*bufdim+ 0]; - (*body)->surface[n].x2 = buffer[n*bufdim+ 1]; - (*body)->surface[n].x3 = buffer[n*bufdim+ 2]; - (*body)->surface[n].y1 = buffer[n*bufdim+ 3]; - (*body)->surface[n].y2 = buffer[n*bufdim+ 4]; - (*body)->surface[n].y3 = buffer[n*bufdim+ 5]; - (*body)->surface[n].z1 = buffer[n*bufdim+ 6]; - (*body)->surface[n].z2 = buffer[n*bufdim+ 7]; - (*body)->surface[n].z3 = buffer[n*bufdim+ 8]; - (*body)->surface[n].nx = buffer[n*bufdim+ 9]; - (*body)->surface[n].ny = buffer[n*bufdim+10]; - (*body)->surface[n].nz = buffer[n*bufdim+11]; + (*body)->m_surface[n].m_x1 = buffer[n*bufdim+ 0]; + (*body)->m_surface[n].m_x2 = buffer[n*bufdim+ 1]; + (*body)->m_surface[n].m_x3 = buffer[n*bufdim+ 2]; + (*body)->m_surface[n].m_y1 = buffer[n*bufdim+ 3]; + (*body)->m_surface[n].m_y2 = buffer[n*bufdim+ 4]; + (*body)->m_surface[n].m_y3 = buffer[n*bufdim+ 5]; + (*body)->m_surface[n].m_z1 = buffer[n*bufdim+ 6]; + (*body)->m_surface[n].m_z2 = buffer[n*bufdim+ 7]; + (*body)->m_surface[n].m_z3 = buffer[n*bufdim+ 8]; + (*body)->m_surface[n].m_nx = buffer[n*bufdim+ 9]; + (*body)->m_surface[n].m_ny = buffer[n*bufdim+10]; + (*body)->m_surface[n].m_nz = buffer[n*bufdim+11]; } } free(buffer); diff --git a/src/ImmersedBoundaries/IBWriteBodySTL.c b/src/ImmersedBoundaries/IBWriteBodySTL.c index 6f54ffea..07b43f3e 100644 --- a/src/ImmersedBoundaries/IBWriteBodySTL.c +++ b/src/ImmersedBoundaries/IBWriteBodySTL.c @@ -23,33 +23,33 @@ int IBWriteBodySTL( Body3D *body, /*!< 3D body to write to file */ char *filename, /*!< Filename */ - void *m, /*!< MPI object of type #MPIVariables */ + void *a_m, /*!< MPI object of type #MPIVariables */ int rank, /*!< MPI rank that does the writing */ int *stat /*!< Status (0: success; non-0: failure) */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; - if (mpi->rank == rank) { + if (mpi->m_rank == rank) { FILE *out; out = fopen(filename,"w"); if (!out) { fprintf(stderr,"Error in IBWriteBodySTL(): Unable to open file "); - fprintf(stderr,"%s for writing on rank %d.\n",filename,mpi->rank); + fprintf(stderr,"%s for writing on rank %d.\n",filename,mpi->m_rank); *stat = 1; } else { fprintf(out,"solid TEST\n"); int n; - for (n = 0; n < body->nfacets; n++) { + for (n = 0; n < body->m_nfacets; n++) { fprintf(out," facet normal %1.16e %1.16e %1.16e\n", - body->surface[n].nx,body->surface[n].ny,body->surface[n].nz); + body->m_surface[n].m_nx,body->m_surface[n].m_ny,body->m_surface[n].m_nz); fprintf(out," outer loop\n"); fprintf(out," vertex %1.16e %1.16e %1.16e\n", - body->surface[n].x1,body->surface[n].y1,body->surface[n].z1); + body->m_surface[n].m_x1,body->m_surface[n].m_y1,body->m_surface[n].m_z1); fprintf(out," vertex %1.16e %1.16e %1.16e\n", - body->surface[n].x2,body->surface[n].y2,body->surface[n].z2); + body->m_surface[n].m_x2,body->m_surface[n].m_y2,body->m_surface[n].m_z2); fprintf(out," vertex %1.16e %1.16e %1.16e\n", - body->surface[n].x3,body->surface[n].y3,body->surface[n].z3); + body->m_surface[n].m_x3,body->m_surface[n].m_y3,body->m_surface[n].m_z3); fprintf(out," endloop\n"); fprintf(out," endfacet\n"); } diff --git a/src/InterpolationFunctions/CompactSchemeCleanup.c b/src/InterpolationFunctions/CompactSchemeCleanup.c index bfaf37c0..e22d15f2 100644 --- a/src/InterpolationFunctions/CompactSchemeCleanup.c +++ b/src/InterpolationFunctions/CompactSchemeCleanup.c @@ -11,17 +11,17 @@ /*! Cleans up all allocations related to the compact finite difference methods. */ -int CompactSchemeCleanup(void *s /*!< CompactScheme object of type #CompactScheme */ ) +int CompactSchemeCleanup(void *a_s /*!< CompactScheme object of type #CompactScheme */ ) { - CompactScheme *compact = (CompactScheme*) s; + CompactScheme *compact = (CompactScheme*) a_s; - if (compact->A) free(compact->A); - if (compact->B) free(compact->B); - if (compact->C) free(compact->C); - if (compact->R) free(compact->R); + if (compact->m_A) free(compact->m_A); + if (compact->m_B) free(compact->m_B); + if (compact->m_C) free(compact->m_C); + if (compact->m_R) free(compact->m_R); - if (compact->sendbuf) free(compact->sendbuf); - if (compact->recvbuf) free(compact->recvbuf); + if (compact->m_sendbuf) free(compact->m_sendbuf); + if (compact->m_recvbuf) free(compact->m_recvbuf); return(0); } diff --git a/src/InterpolationFunctions/CompactSchemeInitialize.c b/src/InterpolationFunctions/CompactSchemeInitialize.c index 5cef5792..4671ccba 100644 --- a/src/InterpolationFunctions/CompactSchemeInitialize.c +++ b/src/InterpolationFunctions/CompactSchemeInitialize.c @@ -15,30 +15,30 @@ to store the tridiagonal system. */ int CompactSchemeInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ char *type /*!< Type of interpolation */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - CompactScheme *compact = (CompactScheme*) solver->compact; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact = (CompactScheme*) solver->m_compact; - int nvars = solver->nvars; - int ndims = solver->ndims; + int nvars = solver->m_nvars; + int ndims = solver->m_ndims; int size = 1, d; - for (d=0; dndims; d++) size *= (solver->dim_local[d]+1); - size *= solver->nvars; - if (!strcmp(solver->interp_type,_CHARACTERISTIC_)) size *= solver->nvars; + for (d=0; dm_ndims; d++) size *= (solver->m_dim_local[d]+1); + size *= solver->m_nvars; + if (!strcmp(solver->m_interp_type,_CHARACTERISTIC_)) size *= solver->m_nvars; - compact->A = (double*) calloc (size, sizeof(double)); - compact->B = (double*) calloc (size, sizeof(double)); - compact->C = (double*) calloc (size, sizeof(double)); - compact->R = (double*) calloc (size, sizeof(double)); + compact->m_A = (double*) calloc (size, sizeof(double)); + compact->m_B = (double*) calloc (size, sizeof(double)); + compact->m_C = (double*) calloc (size, sizeof(double)); + compact->m_R = (double*) calloc (size, sizeof(double)); - compact->sendbuf = (double*) calloc (size, sizeof(double)); - compact->recvbuf = (double*) calloc (size, sizeof(double)); + compact->m_sendbuf = (double*) calloc (size, sizeof(double)); + compact->m_recvbuf = (double*) calloc (size, sizeof(double)); return(0); } diff --git a/src/InterpolationFunctions/Interp1PrimFifthOrderCRWENO.c b/src/InterpolationFunctions/Interp1PrimFifthOrderCRWENO.c index e7e5264c..ad425bd6 100644 --- a/src/InterpolationFunctions/Interp1PrimFifthOrderCRWENO.c +++ b/src/InterpolationFunctions/Interp1PrimFifthOrderCRWENO.c @@ -39,7 +39,7 @@ + &\ \omega_3\ \times\ \left[ \frac{2}{3}\hat{\bf f}_{j+1/2} + \frac{1}{3}\hat{\bf f}_{j+3/2} = \frac{1}{6} \left( f_j + 5f_{j+1} \right) \right] \\ \Rightarrow &\ \left(\frac{2}{3}\omega_1+\frac{1}{3}\omega_2\right)\hat{\bf f}_{j-1/2} + \left[\frac{1}{3}\omega_1+\frac{2}{3}(\omega_2+\omega_3)\right]\hat{\bf f}_{j+1/2} + \frac{1}{3}\omega_3\hat{\bf f}_{j+3/2} = \frac{\omega_1}{6}{\bf f}_{j-1} + \frac{5(\omega_1+\omega_2)+\omega_3}{6}{\bf f}_j + \frac{\omega_2+5\omega_3}{6}{\bf f}_{j+1}, \f} - where \f$\omega_k; k=1,2,3\f$ are the nonlinear WENO weights computed in WENOFifthOrderCalculateWeights() (note that the \f$\omega\f$ are different for each component of the vector \f$\hat{\bf f}\f$). The resulting tridiagonal system is solved using tridiagLU() (see also #TridiagLU, tridiagLU.h). + where \f$\omega_k; k=1,2,3\f$ are the nonlinear WENO weights computed in WENOFifthOrderCalculateWeights() (note that the \f$\omega\f$ are different for each component of the vector \f$\hat{\bf f}\f$). The resulting tridiagonal system is solved using TridiagLU() (see also #TridiagLU, tridiagLU.h). \b Implementation \b Notes: + This method assumes a uniform grid in the spatial dimension corresponding to the interpolation. @@ -58,11 +58,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -82,33 +82,33 @@ int Interp1PrimFifthOrderCRWENO( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - CompactScheme *compact= (CompactScheme*) solver->compact; - WENOParameters *weno = (WENOParameters*) solver->interp; - TridiagLU *lu = (TridiagLU*) solver->lusolver; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact= (CompactScheme*) solver->m_compact; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + TridiagLU_Params *lu = (TridiagLU_Params *) solver->m_lusolver; int sys,Nsys,d; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double one_third = 1.0/3.0; - static const double one_sixth = 1.0/6.0; + static const double s_one_third = 1.0/3.0; + static const double s_one_sixth = 1.0/6.0; double *ww1, *ww2, *ww3; - ww1 = weno->w1 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww2 = weno->w2 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww3 = weno->w3 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; + ww1 = weno->m_w1 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww2 = weno->m_w2 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww3 = weno->m_w3 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -121,10 +121,10 @@ int Interp1PrimFifthOrderCRWENO( _ArrayProduct1D_(bounds_outer,ndims,Nsys); Nsys *= nvars; /* Allocate arrays for tridiagonal system */ - double *A = compact->A; - double *B = compact->B; - double *C = compact->C; - double *R = compact->R; + double *A = compact->m_A; + double *B = compact->m_B; + double *C = compact->m_C; + double *R = compact->m_R; #pragma omp parallel for schedule(auto) default(shared) private(sys,d,index_outer,indexC,indexI) for (sys=0; sys < N_outer; sys++) { @@ -158,17 +158,17 @@ int Interp1PrimFifthOrderCRWENO( /* Candidate stencils and their optimal weights*/ double f1[nvars], f2[nvars], f3[nvars]; - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - _ArrayAXBYCZ_(f1,(2*one_sixth),fm3,(-7*one_sixth) ,fm2,(11*one_sixth) ,fm1,nvars); - _ArrayAXBYCZ_(f2,(-one_sixth) ,fm2,(5*one_sixth) ,fm1,(2*one_sixth) ,fp1,nvars); - _ArrayAXBYCZ_(f3,(2*one_sixth),fm1,(5*one_sixth) ,fp1,(-one_sixth) ,fp2,nvars); + _ArrayAXBYCZ_(f1,(2*s_one_sixth),fm3,(-7*s_one_sixth) ,fm2,(11*s_one_sixth) ,fm1,nvars); + _ArrayAXBYCZ_(f2,(-s_one_sixth) ,fm2,(5*s_one_sixth) ,fm1,(2*s_one_sixth) ,fp1,nvars); + _ArrayAXBYCZ_(f3,(2*s_one_sixth),fm1,(5*s_one_sixth) ,fp1,(-s_one_sixth) ,fp2,nvars); } else { /* CRWENO5 at the interior points */ - _ArrayAXBY_(f1,(one_sixth) ,fm2,(5*one_sixth),fm1,nvars); - _ArrayAXBY_(f2,(5*one_sixth),fm1,(one_sixth) ,fp1,nvars); - _ArrayAXBY_(f3,(one_sixth) ,fm1,(5*one_sixth),fp1,nvars); + _ArrayAXBY_(f1,(s_one_sixth) ,fm2,(5*s_one_sixth),fm1,nvars); + _ArrayAXBY_(f2,(5*s_one_sixth),fm1,(s_one_sixth) ,fp1,nvars); + _ArrayAXBY_(f3,(s_one_sixth) ,fm1,(5*s_one_sixth),fp1,nvars); } /* retrieve the WENO weights */ @@ -177,20 +177,20 @@ int Interp1PrimFifthOrderCRWENO( w2 = (ww2+p*nvars); w3 = (ww3+p*nvars); - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { _ArraySetValue_ ((A+Nsys*indexI[dir]+sys*nvars),nvars,0.0) _ArraySetValue_ ((B+Nsys*indexI[dir]+sys*nvars),nvars,1.0) _ArraySetValue_ ((C+Nsys*indexI[dir]+sys*nvars),nvars,0.0) } else { if (upw > 0) { - _ArrayAXBY_ ((A+Nsys*indexI[dir]+sys*nvars),(2*one_third) ,w1,(one_third) ,w2,nvars); - _ArrayAXBYCZ_ ((B+Nsys*indexI[dir]+sys*nvars),(one_third) ,w1,(2*one_third),w2,(2*one_third),w3,nvars); - _ArrayScaleCopy1D_(w3,(one_third),(C+Nsys*indexI[dir]+sys*nvars),nvars); + _ArrayAXBY_ ((A+Nsys*indexI[dir]+sys*nvars),(2*s_one_third) ,w1,(s_one_third) ,w2,nvars); + _ArrayAXBYCZ_ ((B+Nsys*indexI[dir]+sys*nvars),(s_one_third) ,w1,(2*s_one_third),w2,(2*s_one_third),w3,nvars); + _ArrayScaleCopy1D_(w3,(s_one_third),(C+Nsys*indexI[dir]+sys*nvars),nvars); } else { - _ArrayAXBY_ ((C+Nsys*indexI[dir]+sys*nvars),(2*one_third) ,w1,(one_third) ,w2,nvars); - _ArrayAXBYCZ_ ((B+Nsys*indexI[dir]+sys*nvars),(one_third) ,w1,(2*one_third),w2,(2*one_third),w3,nvars); - _ArrayScaleCopy1D_(w3,(one_third),(A+Nsys*indexI[dir]+sys*nvars),nvars); + _ArrayAXBY_ ((C+Nsys*indexI[dir]+sys*nvars),(2*s_one_third) ,w1,(s_one_third) ,w2,nvars); + _ArrayAXBYCZ_ ((B+Nsys*indexI[dir]+sys*nvars),(s_one_third) ,w1,(2*s_one_third),w2,(2*s_one_third),w3,nvars); + _ArrayScaleCopy1D_(w3,(s_one_third),(A+Nsys*indexI[dir]+sys*nvars),nvars); } } _ArrayMultiply3Add1D_ ((R+Nsys*indexI[dir]+sys*nvars),w1,f1,w2,f2,w3,f3,nvars); @@ -200,25 +200,25 @@ int Interp1PrimFifthOrderCRWENO( #ifdef serial /* Solve the tridiagonal system */ - IERR tridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,NULL); CHECKERR(ierr); + IERR TridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,NULL); CHECKERR(ierr); #else /* Solve the tridiagonal system */ /* all processes except the last will solve without the last interface to avoid overlap */ - if (mpi->ip[dir] != mpi->iproc[dir]-1) { IERR tridiagLU(A,B,C,R,dim[dir] ,Nsys,lu,&mpi->comm[dir]); CHECKERR(ierr); } - else { IERR tridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,&mpi->comm[dir]); CHECKERR(ierr); } + if (mpi->m_ip[dir] != mpi->m_iproc[dir]-1) { IERR TridiagLU(A,B,C,R,dim[dir] ,Nsys,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } + else { IERR TridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } /* Now get the solution to the last interface from the next proc */ - double *sendbuf = compact->sendbuf; - double *recvbuf = compact->recvbuf; + double *sendbuf = compact->m_sendbuf; + double *recvbuf = compact->m_recvbuf; MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - if (mpi->ip[dir]) for (d=0; dip[dir] != mpi->iproc[dir]-1) MPI_Irecv(recvbuf,Nsys,MPI_DOUBLE,mpi->ip[dir]+1,214,mpi->comm[dir],&req[0]); - if (mpi->ip[dir]) MPI_Isend(sendbuf,Nsys,MPI_DOUBLE,mpi->ip[dir]-1,214,mpi->comm[dir],&req[1]); + if (mpi->m_ip[dir]) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) MPI_Irecv(recvbuf,Nsys,MPI_DOUBLE,mpi->m_ip[dir]+1,214,mpi->m_comm[dir],&req[0]); + if (mpi->m_ip[dir]) MPI_Isend(sendbuf,Nsys,MPI_DOUBLE,mpi->m_ip[dir]-1,214,mpi->m_comm[dir],&req[1]); MPI_Status status_arr[2]; MPI_Waitall(2,&req[0],status_arr); - if (mpi->ip[dir] != mpi->iproc[dir]-1) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) for (d=0; dcompact; - WENOParameters *weno = (WENOParameters*) solver->interp; - TridiagLU *lu = (TridiagLU*) solver->lusolver; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact= (CompactScheme*) solver->m_compact; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + TridiagLU_Params *lu = (TridiagLU_Params *) solver->m_lusolver; int sys,Nsys,d,v,k; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - static const double one_third = 1.0/3.0; - static const double one_sixth = 1.0/6.0; + static const double s_one_third = 1.0/3.0; + static const double s_one_sixth = 1.0/6.0; double *ww1, *ww2, *ww3; - ww1 = weno->w1 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww2 = weno->w2 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww3 = weno->w3 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; + ww1 = weno->m_w1 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww2 = weno->m_w2 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww3 = weno->m_w3 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -137,10 +137,10 @@ int Interp1PrimFifthOrderCRWENOChar( double R[nvars*nvars], L[nvars*nvars], uavg[nvars]; /* Allocate arrays for tridiagonal system */ - double *A = compact->A; - double *B = compact->B; - double *C = compact->C; - double *F = compact->R; + double *A = compact->m_A; + double *B = compact->m_B; + double *C = compact->m_C; + double *F = compact->m_R; #pragma omp parallel for schedule(auto) default(shared) private(sys,d,v,k,R,L,uavg,index_outer,indexC,indexI) for (sys=0; sysAveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); for (v=0; vip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - f1 = (2*one_sixth)*fm3 - (7.0*one_sixth)*fm2 + (11.0*one_sixth)*fm1; - f2 = (-one_sixth)*fm2 + (5.0*one_sixth)*fm1 + (2*one_sixth)*fp1; - f3 = (2*one_sixth)*fm1 + (5*one_sixth)*fp1 - (one_sixth)*fp2; + f1 = (2*s_one_sixth)*fm3 - (7.0*s_one_sixth)*fm2 + (11.0*s_one_sixth)*fm1; + f2 = (-s_one_sixth)*fm2 + (5.0*s_one_sixth)*fm1 + (2*s_one_sixth)*fp1; + f3 = (2*s_one_sixth)*fm1 + (5*s_one_sixth)*fp1 - (s_one_sixth)*fp2; } else { /* CRWENO5 at the interior points */ - f1 = (one_sixth) * (fm2 + 5*fm1); - f2 = (one_sixth) * (5*fm1 + fp1); - f3 = (one_sixth) * (fm1 + 5*fp1); + f1 = (s_one_sixth) * (fm2 + 5*fm1); + f2 = (s_one_sixth) * (5*fm1 + fp1); + f3 = (s_one_sixth) * (fm1 + 5*fp1); } /* calculate WENO weights */ @@ -207,8 +207,8 @@ int Interp1PrimFifthOrderCRWENOChar( w2 = *(ww2+p*nvars+v); w3 = *(ww3+p*nvars+v); - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { for (k=0; k 0) { for (k=0; kip[dir] != mpi->iproc[dir]-1) { - IERR blocktridiagLU(A,B,C,F,dim[dir] ,Nsys,nvars,lu,&mpi->comm[dir]); CHECKERR(ierr); + if (mpi->m_ip[dir] != mpi->m_iproc[dir]-1) { + IERR BlockTridiagLU(A,B,C,F,dim[dir] ,Nsys,nvars,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } else { - IERR blocktridiagLU(A,B,C,F,dim[dir]+1,Nsys,nvars,lu,&mpi->comm[dir]); CHECKERR(ierr); + IERR BlockTridiagLU(A,B,C,F,dim[dir]+1,Nsys,nvars,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } /* Now get the solution to the last interface from the next proc */ - double *sendbuf = compact->sendbuf; - double *recvbuf = compact->recvbuf; + double *sendbuf = compact->m_sendbuf; + double *recvbuf = compact->m_recvbuf; MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - if (mpi->ip[dir]) for (d=0; dip[dir] != mpi->iproc[dir]-1) MPI_Irecv(recvbuf,Nsys*nvars,MPI_DOUBLE,mpi->ip[dir]+1,214,mpi->comm[dir],&req[0]); - if (mpi->ip[dir]) MPI_Isend(sendbuf,Nsys*nvars,MPI_DOUBLE,mpi->ip[dir]-1,214,mpi->comm[dir],&req[1]); + if (mpi->m_ip[dir]) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) MPI_Irecv(recvbuf,Nsys*nvars,MPI_DOUBLE,mpi->m_ip[dir]+1,214,mpi->m_comm[dir],&req[0]); + if (mpi->m_ip[dir]) MPI_Isend(sendbuf,Nsys*nvars,MPI_DOUBLE,mpi->m_ip[dir]-1,214,mpi->m_comm[dir],&req[1]); MPI_Status status_arr[2]; MPI_Waitall(2,&req[0],status_arr); - if (mpi->ip[dir] != mpi->iproc[dir]-1) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) for (d=0; dcompact; - TridiagLU *lu = (TridiagLU*) solver->lusolver; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact= (CompactScheme*) solver->m_compact; + TridiagLU_Params *lu = (TridiagLU_Params *) solver->m_lusolver; int sys,Nsys,d,v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double one_third = 1.0/3.0, + static const double s_one_third = 1.0/3.0, thirteen_by_sixty = 13.0/60.0, fortyseven_by_sixty = 47.0/60.0, twentyseven_by_sixty = 27.0/60.0, one_by_twenty = 1.0/20.0, - one_by_thirty = 1.0/30.0, + s_one_by_thirty = 1.0/30.0, nineteen_by_thirty = 19.0/30.0, - three_by_ten = 3.0/10.0, + s_three_by_ten = 3.0/10.0, six_by_ten = 6.0/10.0, one_by_ten = 1.0/10.0; @@ -117,10 +117,10 @@ int Interp1PrimFifthOrderCompactUpwind( _ArrayProduct1D_(bounds_outer,ndims,Nsys); Nsys *= nvars; /* Allocate arrays for tridiagonal system */ - double *A = compact->A; - double *B = compact->B; - double *C = compact->C; - double *R = compact->R; + double *A = compact->m_A; + double *B = compact->m_B; + double *C = compact->m_C; + double *R = compact->m_R; #pragma omp parallel for schedule(auto) default(shared) private(sys,d,index_outer,indexC,indexI) for (sys=0; sys < N_outer; sys++) { @@ -152,15 +152,15 @@ int Interp1PrimFifthOrderCompactUpwind( fp1 = fC+qp1*nvars; fp2 = fC+qp2*nvars; - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use 5th order upwind at the physical boundaries */ _ArraySetValue_((A+Nsys*indexI[dir]+sys*nvars),nvars,0.0) _ArraySetValue_((B+Nsys*indexI[dir]+sys*nvars),nvars,1.0) _ArraySetValue_((C+Nsys*indexI[dir]+sys*nvars),nvars,0.0) for (v=0; v 0) { - _ArraySetValue_((A+Nsys*indexI[dir]+sys*nvars),nvars,three_by_ten); + _ArraySetValue_((A+Nsys*indexI[dir]+sys*nvars),nvars,s_three_by_ten); _ArraySetValue_((B+Nsys*indexI[dir]+sys*nvars),nvars,six_by_ten ); _ArraySetValue_((C+Nsys*indexI[dir]+sys*nvars),nvars,one_by_ten ); } else { - _ArraySetValue_((C+Nsys*indexI[dir]+sys*nvars),nvars,three_by_ten); + _ArraySetValue_((C+Nsys*indexI[dir]+sys*nvars),nvars,s_three_by_ten); _ArraySetValue_((B+Nsys*indexI[dir]+sys*nvars),nvars,six_by_ten ); _ArraySetValue_((A+Nsys*indexI[dir]+sys*nvars),nvars,one_by_ten ); } for (v=0; vip[dir] != mpi->iproc[dir]-1) { IERR tridiagLU(A,B,C,R,dim[dir] ,Nsys,lu,&mpi->comm[dir]); CHECKERR(ierr); } - else { IERR tridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,&mpi->comm[dir]); CHECKERR(ierr); } + if (mpi->m_ip[dir] != mpi->m_iproc[dir]-1) { IERR TridiagLU(A,B,C,R,dim[dir] ,Nsys,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } + else { IERR TridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } /* Now get the solution to the last interface from the next proc */ - double *sendbuf = compact->sendbuf; - double *recvbuf = compact->recvbuf; + double *sendbuf = compact->m_sendbuf; + double *recvbuf = compact->m_recvbuf; MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - if (mpi->ip[dir]) for (d=0; dip[dir] != mpi->iproc[dir]-1) MPI_Irecv(recvbuf,Nsys,MPI_DOUBLE,mpi->ip[dir]+1,214,mpi->comm[dir],&req[0]); - if (mpi->ip[dir]) MPI_Isend(sendbuf,Nsys,MPI_DOUBLE,mpi->ip[dir]-1,214,mpi->comm[dir],&req[1]); + if (mpi->m_ip[dir]) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) MPI_Irecv(recvbuf,Nsys,MPI_DOUBLE,mpi->m_ip[dir]+1,214,mpi->m_comm[dir],&req[0]); + if (mpi->m_ip[dir]) MPI_Isend(sendbuf,Nsys,MPI_DOUBLE,mpi->m_ip[dir]-1,214,mpi->m_comm[dir],&req[1]); MPI_Status status_arr[2]; MPI_Waitall(2,&req[0],status_arr); - if (mpi->ip[dir] != mpi->iproc[dir]-1) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) for (d=0; dcompact; - TridiagLU *lu = (TridiagLU*) solver->lusolver; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact= (CompactScheme*) solver->m_compact; + TridiagLU_Params *lu = (TridiagLU_Params *) solver->m_lusolver; int sys,Nsys,d,v,k; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - static const double three_by_ten = 3.0/10.0, + static const double s_three_by_ten = 3.0/10.0, six_by_ten = 6.0/10.0, one_by_ten = 1.0/10.0, - one_by_thirty = 1.0/30.0, + s_one_by_thirty = 1.0/30.0, nineteen_by_thirty = 19.0/30.0, - one_third = 1.0/3.0, + s_one_third = 1.0/3.0, thirteen_by_sixty = 13.0/60.0, fortyseven_by_sixty = 47.0/60.0, twentyseven_by_sixty = 27.0/60.0, @@ -136,10 +136,10 @@ int Interp1PrimFifthOrderCompactUpwindChar( double R[nvars*nvars], L[nvars*nvars], uavg[nvars]; /* Allocate arrays for tridiagonal system */ - double *A = compact->A; - double *B = compact->B; - double *C = compact->C; - double *F = compact->R; + double *A = compact->m_A; + double *B = compact->m_B; + double *C = compact->m_C; + double *F = compact->m_R; #pragma omp parallel for schedule(auto) default(shared) private(sys,d,v,k,R,L,uavg,index_outer,indexC,indexI) for (sys=0; sysAveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); for (v=0; vip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use 5th order upwind at the physical boundaries */ for (k=0; k 0) { for (k=0; kip[dir] != mpi->iproc[dir]-1) { - IERR blocktridiagLU(A,B,C,F,dim[dir] ,Nsys,nvars,lu,&mpi->comm[dir]); CHECKERR(ierr); + if (mpi->m_ip[dir] != mpi->m_iproc[dir]-1) { + IERR BlockTridiagLU(A,B,C,F,dim[dir] ,Nsys,nvars,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } else { - IERR blocktridiagLU(A,B,C,F,dim[dir]+1,Nsys,nvars,lu,&mpi->comm[dir]); CHECKERR(ierr); + IERR BlockTridiagLU(A,B,C,F,dim[dir]+1,Nsys,nvars,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } /* Now get the solution to the last interface from the next proc */ - double *sendbuf = compact->sendbuf; - double *recvbuf = compact->recvbuf; + double *sendbuf = compact->m_sendbuf; + double *recvbuf = compact->m_recvbuf; MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - if (mpi->ip[dir]) for (d=0; dip[dir] != mpi->iproc[dir]-1) MPI_Irecv(recvbuf,Nsys*nvars,MPI_DOUBLE,mpi->ip[dir]+1,214,mpi->comm[dir],&req[0]); - if (mpi->ip[dir]) MPI_Isend(sendbuf,Nsys*nvars,MPI_DOUBLE,mpi->ip[dir]-1,214,mpi->comm[dir],&req[1]); + if (mpi->m_ip[dir]) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) MPI_Irecv(recvbuf,Nsys*nvars,MPI_DOUBLE,mpi->m_ip[dir]+1,214,mpi->m_comm[dir],&req[0]); + if (mpi->m_ip[dir]) MPI_Isend(sendbuf,Nsys*nvars,MPI_DOUBLE,mpi->m_ip[dir]-1,214,mpi->m_comm[dir],&req[1]); MPI_Status status_arr[2]; MPI_Waitall(2,&req[0],status_arr); - if (mpi->ip[dir] != mpi->iproc[dir]-1) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) for (d=0; dcompact; - WENOParameters *weno = (WENOParameters*) solver->interp; - TridiagLU *lu = (TridiagLU*) solver->lusolver; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact= (CompactScheme*) solver->m_compact; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + TridiagLU_Params *lu = (TridiagLU_Params *) solver->m_lusolver; int sys,Nsys,d; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - static const double one_half = 1.0/2.0; - static const double one_third = 1.0/3.0; - static const double one_sixth = 1.0/6.0; + static const double s_one_half = 1.0/2.0; + static const double s_one_third = 1.0/3.0; + static const double s_one_sixth = 1.0/6.0; double *ww1, *ww2, *ww3; - ww1 = weno->w1 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww2 = weno->w2 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww3 = weno->w3 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; + ww1 = weno->m_w1 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww2 = weno->m_w2 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww3 = weno->m_w3 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -106,10 +106,10 @@ int Interp1PrimFifthOrderHCWENO( _ArrayProduct1D_(bounds_outer,ndims,Nsys); Nsys *= nvars; /* Allocate arrays for tridiagonal system */ - double *A = compact->A; - double *B = compact->B; - double *C = compact->C; - double *R = compact->R; + double *A = compact->m_A; + double *B = compact->m_B; + double *C = compact->m_C; + double *R = compact->m_R; #pragma omp parallel for schedule(auto) default(shared) private(sys,d,index_outer,indexC,indexI) for (sys=0; sys < N_outer; sys++) { @@ -144,9 +144,9 @@ int Interp1PrimFifthOrderHCWENO( /* Candidate stencils and their optimal weights*/ double f1, f2, f3; - f1 = (2*one_sixth)*fm3 - (7.0*one_sixth)*fm2 + (11.0*one_sixth)*fm1; - f2 = (-one_sixth)*fm2 + (5.0*one_sixth)*fm1 + (2*one_sixth)*fp1; - f3 = (2*one_sixth)*fm1 + (5*one_sixth)*fp1 - (one_sixth)*fp2; + f1 = (2*s_one_sixth)*fm3 - (7.0*s_one_sixth)*fm2 + (11.0*s_one_sixth)*fm1; + f2 = (-s_one_sixth)*fm2 + (5.0*s_one_sixth)*fm1 + (2*s_one_sixth)*fp1; + f3 = (2*s_one_sixth)*fm1 + (5*s_one_sixth)*fp1 - (s_one_sixth)*fp2; /* calculate WENO weights */ double w1,w2,w3; @@ -156,35 +156,35 @@ int Interp1PrimFifthOrderHCWENO( /* calculate the hybridization parameter */ double sigma; - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Standard WENO at physical boundaries */ sigma = 0.0; } else { double cuckoo, df_jm12, df_jp12, df_jp32, r_j, r_jp1, r_int; - cuckoo = (0.9*weno->rc / (1.0-0.9*weno->rc)) * weno->xi * weno->xi; + cuckoo = (0.9*weno->m_rc / (1.0-0.9*weno->m_rc)) * weno->m_xi * weno->m_xi; df_jm12 = fm1 - fm2; df_jp12 = fp1 - fm1; df_jp32 = fp2 - fp1; r_j = (absolute(2*df_jp12*df_jm12)+cuckoo)/(df_jp12*df_jp12+df_jm12*df_jm12+cuckoo); r_jp1 = (absolute(2*df_jp32*df_jp12)+cuckoo)/(df_jp32*df_jp32+df_jp12*df_jp12+cuckoo); r_int = min(r_j, r_jp1); - sigma = min((r_int/weno->rc), 1.0); + sigma = min((r_int/weno->m_rc), 1.0); } if (upw > 0) { - A[sys*nvars+v+Nsys*indexI[dir]] = one_half * sigma; + A[sys*nvars+v+Nsys*indexI[dir]] = s_one_half * sigma; B[sys*nvars+v+Nsys*indexI[dir]] = 1.0; - C[sys*nvars+v+Nsys*indexI[dir]] = one_sixth * sigma; + C[sys*nvars+v+Nsys*indexI[dir]] = s_one_sixth * sigma; } else { - C[sys*nvars+v+Nsys*indexI[dir]] = one_half * sigma; + C[sys*nvars+v+Nsys*indexI[dir]] = s_one_half * sigma; B[sys*nvars+v+Nsys*indexI[dir]] = 1.0; - A[sys*nvars+v+Nsys*indexI[dir]] = one_sixth * sigma; + A[sys*nvars+v+Nsys*indexI[dir]] = s_one_sixth * sigma; } double fWENO, fCompact; fWENO = w1*f1 + w2*f2 + w3*f3; - fCompact = one_sixth * (one_third*fm2 + 19.0*one_third*fm1 + 10.0*one_third*fp1); + fCompact = s_one_sixth * (s_one_third*fm2 + 19.0*s_one_third*fm1 + 10.0*s_one_third*fp1); R[sys*nvars+v+Nsys*indexI[dir]] = sigma*fCompact + (1.0-sigma)*fWENO; } } @@ -193,25 +193,25 @@ int Interp1PrimFifthOrderHCWENO( #ifdef serial /* Solve the tridiagonal system */ - IERR tridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,NULL); CHECKERR(ierr); + IERR TridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,NULL); CHECKERR(ierr); #else /* Solve the tridiagonal system */ /* all processes except the last will solve without the last interface to avoid overlap */ - if (mpi->ip[dir] != mpi->iproc[dir]-1) { IERR tridiagLU(A,B,C,R,dim[dir] ,Nsys,lu,&mpi->comm[dir]); CHECKERR(ierr); } - else { IERR tridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,&mpi->comm[dir]); CHECKERR(ierr); } + if (mpi->m_ip[dir] != mpi->m_iproc[dir]-1) { IERR TridiagLU(A,B,C,R,dim[dir] ,Nsys,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } + else { IERR TridiagLU(A,B,C,R,dim[dir]+1,Nsys,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } /* Now get the solution to the last interface from the next proc */ - double *sendbuf = compact->sendbuf; - double *recvbuf = compact->recvbuf; + double *sendbuf = compact->m_sendbuf; + double *recvbuf = compact->m_recvbuf; MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - if (mpi->ip[dir]) for (d=0; dip[dir] != mpi->iproc[dir]-1) MPI_Irecv(recvbuf,Nsys,MPI_DOUBLE,mpi->ip[dir]+1,214,mpi->comm[dir],&req[0]); - if (mpi->ip[dir]) MPI_Isend(sendbuf,Nsys,MPI_DOUBLE,mpi->ip[dir]-1,214,mpi->comm[dir],&req[1]); + if (mpi->m_ip[dir]) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) MPI_Irecv(recvbuf,Nsys,MPI_DOUBLE,mpi->m_ip[dir]+1,214,mpi->m_comm[dir],&req[0]); + if (mpi->m_ip[dir]) MPI_Isend(sendbuf,Nsys,MPI_DOUBLE,mpi->m_ip[dir]-1,214,mpi->m_comm[dir],&req[1]); MPI_Status status_arr[2]; MPI_Waitall(2,&req[0],status_arr); - if (mpi->ip[dir] != mpi->iproc[dir]-1) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) for (d=0; dcompact; - WENOParameters *weno = (WENOParameters*) solver->interp; - TridiagLU *lu = (TridiagLU*) solver->lusolver; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + CompactScheme *compact= (CompactScheme*) solver->m_compact; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + TridiagLU_Params *lu = (TridiagLU_Params *) solver->m_lusolver; int sys,Nsys,d,v,k; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - static const double one_half = 1.0/2.0; - static const double one_third = 1.0/3.0; - static const double one_sixth = 1.0/6.0; + static const double s_one_half = 1.0/2.0; + static const double s_one_third = 1.0/3.0; + static const double s_one_sixth = 1.0/6.0; double *ww1, *ww2, *ww3; - ww1 = weno->w1 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww2 = weno->w2 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww3 = weno->w3 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; + ww1 = weno->m_w1 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww2 = weno->m_w2 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww3 = weno->m_w3 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -124,10 +124,10 @@ int Interp1PrimFifthOrderHCWENOChar( double R[nvars*nvars], L[nvars*nvars], uavg[nvars]; /* Allocate arrays for tridiagonal system */ - double *A = compact->A; - double *B = compact->B; - double *C = compact->C; - double *F = compact->R; + double *A = compact->m_A; + double *B = compact->m_B; + double *C = compact->m_C; + double *F = compact->m_R; #pragma omp parallel for schedule(auto) default(shared) private(sys,d,v,k,R,L,uavg,index_outer,indexC,indexI) for (sys=0; sysAveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); for (v=0; vip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - f1 = (2*one_sixth)*fm3 - (7.0*one_sixth)*fm2 + (11.0*one_sixth)*fm1; - f2 = (-one_sixth)*fm2 + (5.0*one_sixth)*fm1 + (2*one_sixth)*fp1; - f3 = (2*one_sixth)*fm1 + (5*one_sixth)*fp1 - (one_sixth)*fp2; + f1 = (2*s_one_sixth)*fm3 - (7.0*s_one_sixth)*fm2 + (11.0*s_one_sixth)*fm1; + f2 = (-s_one_sixth)*fm2 + (5.0*s_one_sixth)*fm1 + (2*s_one_sixth)*fp1; + f3 = (2*s_one_sixth)*fm1 + (5*s_one_sixth)*fp1 - (s_one_sixth)*fp2; } else { /* HCWENO5 at the interior points */ - f1 = (one_sixth) * (fm2 + 5*fm1); - f2 = (one_sixth) * (5*fm1 + fp1); - f3 = (one_sixth) * (fm1 + 5*fp1); + f1 = (s_one_sixth) * (fm2 + 5*fm1); + f2 = (s_one_sixth) * (5*fm1 + fp1); + f3 = (s_one_sixth) * (fm1 + 5*fp1); } /* calculate WENO weights */ @@ -196,38 +196,38 @@ int Interp1PrimFifthOrderHCWENOChar( /* calculate the hybridization parameter */ double sigma; - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Standard WENO at physical boundaries */ sigma = 0.0; } else { double cuckoo, df_jm12, df_jp12, df_jp32, r_j, r_jp1, r_int; - cuckoo = (0.9*weno->rc / (1.0-0.9*weno->rc)) * weno->xi * weno->xi; + cuckoo = (0.9*weno->m_rc / (1.0-0.9*weno->m_rc)) * weno->m_xi * weno->m_xi; df_jm12 = fm1 - fm2; df_jp12 = fp1 - fm1; df_jp32 = fp2 - fp1; r_j = (absolute(2*df_jp12*df_jm12)+cuckoo)/(df_jp12*df_jp12+df_jm12*df_jm12+cuckoo); r_jp1 = (absolute(2*df_jp32*df_jp12)+cuckoo)/(df_jp32*df_jp32+df_jp12*df_jp12+cuckoo); r_int = min(r_j, r_jp1); - sigma = min((r_int/weno->rc), 1.0); + sigma = min((r_int/weno->m_rc), 1.0); } if (upw > 0) { for (k=0; kip[dir] != mpi->iproc[dir]-1) { - IERR blocktridiagLU(A,B,C,F,dim[dir] ,Nsys,nvars,lu,&mpi->comm[dir]); CHECKERR(ierr); + if (mpi->m_ip[dir] != mpi->m_iproc[dir]-1) { + IERR BlockTridiagLU(A,B,C,F,dim[dir] ,Nsys,nvars,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } else { - IERR blocktridiagLU(A,B,C,F,dim[dir]+1,Nsys,nvars,lu,&mpi->comm[dir]); CHECKERR(ierr); + IERR BlockTridiagLU(A,B,C,F,dim[dir]+1,Nsys,nvars,lu,&mpi->m_comm[dir]); CHECKERR(ierr); } /* Now get the solution to the last interface from the next proc */ - double *sendbuf = compact->sendbuf; - double *recvbuf = compact->recvbuf; + double *sendbuf = compact->m_sendbuf; + double *recvbuf = compact->m_recvbuf; MPI_Request req[2] = {MPI_REQUEST_NULL,MPI_REQUEST_NULL}; - if (mpi->ip[dir]) for (d=0; dip[dir] != mpi->iproc[dir]-1) MPI_Irecv(recvbuf,Nsys*nvars,MPI_DOUBLE,mpi->ip[dir]+1,214,mpi->comm[dir],&req[0]); - if (mpi->ip[dir]) MPI_Isend(sendbuf,Nsys*nvars,MPI_DOUBLE,mpi->ip[dir]-1,214,mpi->comm[dir],&req[1]); + if (mpi->m_ip[dir]) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) MPI_Irecv(recvbuf,Nsys*nvars,MPI_DOUBLE,mpi->m_ip[dir]+1,214,mpi->m_comm[dir],&req[0]); + if (mpi->m_ip[dir]) MPI_Isend(sendbuf,Nsys*nvars,MPI_DOUBLE,mpi->m_ip[dir]-1,214,mpi->m_comm[dir],&req[1]); MPI_Status status_arr[2]; MPI_Waitall(2,&req[0],status_arr); - if (mpi->ip[dir] != mpi->iproc[dir]-1) for (d=0; dm_ip[dir] != mpi->m_iproc[dir]-1) for (d=0; dghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double one_by_thirty = 1.0/30.0, + static const double s_one_by_thirty = 1.0/30.0, thirteen_by_sixty = 13.0/60.0, fortyseven_by_sixty = 47.0/60.0, twentyseven_by_sixty = 27.0/60.0, @@ -132,7 +132,7 @@ int Interp1PrimFifthOrderUpwind( int v; for (v=0; vghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - static const double one_by_thirty = 1.0/30.0, + static const double s_one_by_thirty = 1.0/30.0, thirteen_by_sixty = 13.0/60.0, fortyseven_by_sixty = 47.0/60.0, twentyseven_by_sixty = 27.0/60.0, @@ -147,11 +147,11 @@ int Interp1PrimFifthOrderUpwindChar( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { @@ -168,7 +168,7 @@ int Interp1PrimFifthOrderUpwindChar( } /* fifth order upwind approximation of the characteristic flux */ - fchar[v] = one_by_thirty * fm3 + fchar[v] = s_one_by_thirty * fm3 - thirteen_by_sixty * fm2 + fortyseven_by_sixty * fm1 + twentyseven_by_sixty * fp1 diff --git a/src/InterpolationFunctions/Interp1PrimFifthOrderWENO.c b/src/InterpolationFunctions/Interp1PrimFifthOrderWENO.c index a2b3d5e0..58bea49e 100644 --- a/src/InterpolationFunctions/Interp1PrimFifthOrderWENO.c +++ b/src/InterpolationFunctions/Interp1PrimFifthOrderWENO.c @@ -59,11 +59,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -78,27 +78,27 @@ int Interp1PrimFifthOrderWENO( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double one_sixth = 1.0/6.0; + static const double s_one_sixth = 1.0/6.0; double *ww1, *ww2, *ww3; - ww1 = weno->w1 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww2 = weno->w2 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww3 = weno->w3 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; + ww1 = weno->m_w1 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww2 = weno->m_w2 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww3 = weno->m_w3 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -145,9 +145,9 @@ int Interp1PrimFifthOrderWENO( /* Candidate stencils and their optimal weights*/ double f1[nvars], f2[nvars], f3[nvars]; - _ArrayAXBYCZ_(f1,(2*one_sixth),fm3,(-7*one_sixth) ,fm2,(11*one_sixth) ,fm1,nvars); - _ArrayAXBYCZ_(f2,(-one_sixth) ,fm2,(5*one_sixth) ,fm1,(2*one_sixth) ,fp1,nvars); - _ArrayAXBYCZ_(f3,(2*one_sixth),fm1,(5*one_sixth) ,fp1,(-one_sixth) ,fp2,nvars); + _ArrayAXBYCZ_(f1,(2*s_one_sixth),fm3,(-7*s_one_sixth) ,fm2,(11*s_one_sixth) ,fm1,nvars); + _ArrayAXBYCZ_(f2,(-s_one_sixth) ,fm2,(5*s_one_sixth) ,fm1,(2*s_one_sixth) ,fp1,nvars); + _ArrayAXBYCZ_(f3,(2*s_one_sixth),fm1,(5*s_one_sixth) ,fp1,(-s_one_sixth) ,fp2,nvars); /* calculate WENO weights */ double *w1,*w2,*w3; diff --git a/src/InterpolationFunctions/Interp1PrimFifthOrderWENOChar.c b/src/InterpolationFunctions/Interp1PrimFifthOrderWENOChar.c index 2058a682..be9a36e8 100644 --- a/src/InterpolationFunctions/Interp1PrimFifthOrderWENOChar.c +++ b/src/InterpolationFunctions/Interp1PrimFifthOrderWENOChar.c @@ -42,7 +42,7 @@ \f{equation}{ \alpha^k = {\bf l}_k \cdot {\bf f},\ k=1,\cdots,n \f} - is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::nvars. The nonlinear weights \f$\omega_k; k=1,2,3\f$ are the WENO weights computed in WENOFifthOrderCalculateWeightsChar(). The final interpolated function is computed from the interpolated characteristic quantities as: + is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::m_nvars. The nonlinear weights \f$\omega_k; k=1,2,3\f$ are the WENO weights computed in WENOFifthOrderCalculateWeightsChar(). The final interpolated function is computed from the interpolated characteristic quantities as: \f{equation}{ \hat{\bf f}_{j+1/2} = \sum_{k=1}^n \alpha^k_{j+1/2} {\bf r}_k \f} @@ -71,11 +71,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -90,28 +90,28 @@ int Interp1PrimFifthOrderWENOChar( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; int i, k, v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - static const double one_sixth = 1.0/6.0; + static const double s_one_sixth = 1.0/6.0; double *ww1, *ww2, *ww3; - ww1 = weno->w1 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww2 = weno->w2 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; - ww3 = weno->w3 + (upw < 0 ? 2*weno->size : 0) + (uflag ? weno->size : 0) + weno->offset[dir]; + ww1 = weno->m_w1 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww2 = weno->m_w2 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; + ww3 = weno->m_w3 + (upw < 0 ? 2*weno->m_size : 0) + (uflag ? weno->m_size : 0) + weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -151,11 +151,11 @@ int Interp1PrimFifthOrderWENOChar( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { @@ -173,9 +173,9 @@ int Interp1PrimFifthOrderWENOChar( /* Candidate stencils and their optimal weights*/ double f1, f2, f3; - f1 = (2*one_sixth)*fm3 - (7.0*one_sixth)*fm2 + (11.0*one_sixth)*fm1; - f2 = (-one_sixth)*fm2 + (5.0*one_sixth)*fm1 + (2*one_sixth)*fp1; - f3 = (2*one_sixth)*fm1 + (5*one_sixth)*fp1 - (one_sixth)*fp2; + f1 = (2*s_one_sixth)*fm3 - (7.0*s_one_sixth)*fm2 + (11.0*s_one_sixth)*fm1; + f2 = (-s_one_sixth)*fm2 + (5.0*s_one_sixth)*fm1 + (2*s_one_sixth)*fp1; + f3 = (2*s_one_sixth)*fm1 + (5*s_one_sixth)*fp1 - (s_one_sixth)*fp2; /* calculate WENO weights */ double w1,w2,w3; diff --git a/src/InterpolationFunctions/Interp1PrimFifthOrderWENO_GPU.cu b/src/InterpolationFunctions/Interp1PrimFifthOrderWENO_GPU.cu index 954edab4..ad4427a8 100644 --- a/src/InterpolationFunctions/Interp1PrimFifthOrderWENO_GPU.cu +++ b/src/InterpolationFunctions/Interp1PrimFifthOrderWENO_GPU.cu @@ -158,10 +158,10 @@ extern "C" int gpuInterp1PrimFifthOrderWENO( HyPar *solver = (HyPar*) s; WENOParameters *weno = (WENOParameters*) solver->interp; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; int *stride= solver->stride_with_ghosts; /* calculate dimension offset */ @@ -191,7 +191,7 @@ extern "C" int gpuInterp1PrimFifthOrderWENO( Interp1PrimFifthOrderWENO_kernel<<>>( npoints_grid, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], upw, uflag, - solver->gpu_dim_local, fC, weno->w1, weno->w2, weno->w3, fI + solver->m_gpu_dim_local, fC, weno->w1, weno->w2, weno->w3, fI ); cudaDeviceSynchronize(); @@ -364,10 +364,10 @@ extern "C" int gpuInterp1PrimFifthOrderWENO( HyPar *solver = (HyPar*) s; WENOParameters *weno = (WENOParameters*) solver->interp; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; int *stride= solver->stride_with_ghosts; /* calculate dimension offset */ @@ -397,8 +397,8 @@ extern "C" int gpuInterp1PrimFifthOrderWENO( #endif Interp1PrimFifthOrderWENO_kernel<<>>( - npoints_grid, solver->npoints_local_wghosts, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], upw, uflag, - solver->gpu_dim_local, fC, weno->w1, weno->w2, weno->w3, fI + npoints_grid, solver->m_npoints_local_wghosts, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], upw, uflag, + solver->m_gpu_dim_local, fC, weno->w1, weno->w2, weno->w3, fI ); #if defined(GPU_STAT) checkCuda( cudaEventRecord(stop) ); diff --git a/src/InterpolationFunctions/Interp1PrimFirstOrderUpwind.c b/src/InterpolationFunctions/Interp1PrimFirstOrderUpwind.c index ba54f606..d5afc4a7 100644 --- a/src/InterpolationFunctions/Interp1PrimFirstOrderUpwind.c +++ b/src/InterpolationFunctions/Interp1PrimFirstOrderUpwind.c @@ -50,11 +50,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). */ @@ -65,17 +65,17 @@ int Interp1PrimFirstOrderUpwind( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ diff --git a/src/InterpolationFunctions/Interp1PrimFirstOrderUpwindChar.c b/src/InterpolationFunctions/Interp1PrimFirstOrderUpwindChar.c index f69b6c5c..35c8670c 100644 --- a/src/InterpolationFunctions/Interp1PrimFirstOrderUpwindChar.c +++ b/src/InterpolationFunctions/Interp1PrimFirstOrderUpwindChar.c @@ -40,7 +40,7 @@ \f{equation}{ \alpha^k = {\bf l}_k \cdot {\bf f},\ k=1,\cdots,n \f} - is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::nvars. The final interpolated function is computed from the interpolated characteristic quantities as: + is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::m_nvars. The final interpolated function is computed from the interpolated characteristic quantities as: \f{equation}{ \hat{\bf f}_{j+1/2} = \sum_{k=1}^n \alpha^k_{j+1/2} {\bf r}_k \f} @@ -66,11 +66,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). */ @@ -81,19 +81,19 @@ int Interp1PrimFirstOrderUpwindChar( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int i, k, v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -120,11 +120,11 @@ int Interp1PrimFirstOrderUpwindChar( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*pL],&u[nvars*pR],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*pL],&u[nvars*pR],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { diff --git a/src/InterpolationFunctions/Interp1PrimFourthOrderCentral.c b/src/InterpolationFunctions/Interp1PrimFourthOrderCentral.c index 89ed05fd..574480b2 100644 --- a/src/InterpolationFunctions/Interp1PrimFourthOrderCentral.c +++ b/src/InterpolationFunctions/Interp1PrimFourthOrderCentral.c @@ -51,11 +51,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). */ @@ -66,17 +66,17 @@ int Interp1PrimFourthOrderCentral( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -93,8 +93,8 @@ int Interp1PrimFourthOrderCentral( _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); - static const double c1 = 7.0 / 12.0; - static const double c2 = -1.0 / 12.0; + static const double s_c1 = 7.0 / 12.0; + static const double s_c2 = -1.0 / 12.0; int i; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexL,indexR,indexI) @@ -118,10 +118,10 @@ int Interp1PrimFourthOrderCentral( int qRR; _ArrayIndex1D_(ndims,dim ,indexRR,ghosts,qRR); int v; for (v=0; vghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -107,8 +107,8 @@ int Interp1PrimFourthOrderCentralChar( /* allocate arrays for the averaged state, eigenvectors and characteristic interpolated f */ double R[nvars*nvars], L[nvars*nvars], uavg[nvars], fchar[nvars]; - static const double c1 = 7.0 / 12.0; - static const double c2 = -1.0 / 12.0; + static const double s_c1 = 7.0 / 12.0; + static const double s_c2 = -1.0 / 12.0; #pragma omp parallel for schedule(auto) default(shared) private(i,k,v,R,L,uavg,fchar,index_outer,indexC,indexI) for (i=0; iAveragingFunction(uavg,&u[nvars*pL],&u[nvars*pR],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*pL],&u[nvars*pR],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { @@ -146,7 +146,7 @@ int Interp1PrimFourthOrderCentralChar( } /* first order upwind approximation of the characteristic flux */ - fchar[v] = c2*fcLL + c1*fcL + c1*fcR + c2*fcRR; + fchar[v] = s_c2*fcLL + s_c1*fcL + s_c1*fcR + s_c2*fcRR; } diff --git a/src/InterpolationFunctions/Interp1PrimSecondOrderCentral.c b/src/InterpolationFunctions/Interp1PrimSecondOrderCentral.c index f215da89..bf2a5cbb 100644 --- a/src/InterpolationFunctions/Interp1PrimSecondOrderCentral.c +++ b/src/InterpolationFunctions/Interp1PrimSecondOrderCentral.c @@ -51,11 +51,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). */ @@ -66,17 +66,17 @@ int Interp1PrimSecondOrderCentral( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ diff --git a/src/InterpolationFunctions/Interp1PrimSecondOrderCentralChar.c b/src/InterpolationFunctions/Interp1PrimSecondOrderCentralChar.c index de7192d8..bf75b4a0 100644 --- a/src/InterpolationFunctions/Interp1PrimSecondOrderCentralChar.c +++ b/src/InterpolationFunctions/Interp1PrimSecondOrderCentralChar.c @@ -40,7 +40,7 @@ \f{equation}{ \alpha^k = {\bf l}_k \cdot {\bf f},\ k=1,\cdots,n \f} - is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::nvars. The final interpolated function is computed from the interpolated characteristic quantities as: + is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::m_nvars. The final interpolated function is computed from the interpolated characteristic quantities as: \f{equation}{ \hat{\bf f}_{j+1/2} = \sum_{k=1}^n \alpha^k_{j+1/2} {\bf r}_k \f} @@ -68,11 +68,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). */ @@ -83,19 +83,19 @@ int Interp1PrimSecondOrderCentralChar( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int i, k, v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -122,11 +122,11 @@ int Interp1PrimSecondOrderCentralChar( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*pL],&u[nvars*pR],solver->physics); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,&u[nvars*pL],&u[nvars*pR],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { diff --git a/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCL.c b/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCL.c index 796c76b6..98126a39 100644 --- a/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCL.c +++ b/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCL.c @@ -59,11 +59,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -80,18 +80,18 @@ int Interp1PrimSecondOrderMUSCL ( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - MUSCLParameters *muscl = (MUSCLParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + MUSCLParameters *muscl = (MUSCLParameters*) solver->m_interp; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ double half = 1.0/2.0; diff --git a/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCLChar.c b/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCLChar.c index 3cd276d7..ed259526 100644 --- a/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCLChar.c +++ b/src/InterpolationFunctions/Interp1PrimSecondOrderMUSCLChar.c @@ -46,7 +46,7 @@ \f{equation}{ \alpha^k = {\bf l}_k \cdot {\bf f},\ k=1,\cdots,n \f} - is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::nvars. The final interpolated function is computed from the interpolated characteristic quantities as: + is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::m_nvars. The final interpolated function is computed from the interpolated characteristic quantities as: \f{equation}{ \hat{\bf f}_{j+1/2} = \sum_{k=1}^n \alpha^k_{j+1/2} {\bf r}_k \f} @@ -75,11 +75,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -96,24 +96,24 @@ int Interp1PrimSecondOrderMUSCLChar ( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - MUSCLParameters *muscl = (MUSCLParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + MUSCLParameters *muscl = (MUSCLParameters*) solver->m_interp; int i, k, v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - double one_third = 1.0/3.0; - double one_sixth = 1.0/6.0; + double s_one_third = 1.0/3.0; + double s_one_sixth = 1.0/6.0; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -144,12 +144,12 @@ int Interp1PrimSecondOrderMUSCLChar ( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { @@ -190,12 +190,12 @@ int Interp1PrimSecondOrderMUSCLChar ( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { diff --git a/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCL.c b/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCL.c index 2bf3de18..86e4677f 100644 --- a/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCL.c +++ b/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCL.c @@ -59,11 +59,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -79,22 +79,22 @@ int Interp1PrimThirdOrderMUSCL( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - MUSCLParameters *muscl = (MUSCLParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + MUSCLParameters *muscl = (MUSCLParameters*) solver->m_interp; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - double one_third = 1.0/3.0; - double one_sixth = 1.0/6.0; + double s_one_third = 1.0/3.0; + double s_one_sixth = 1.0/6.0; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -125,10 +125,10 @@ int Interp1PrimThirdOrderMUSCL( double fdiff = p1 - m1; double bdiff = m1 - m2; - double limit = (3*fdiff*bdiff + muscl->eps) - / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->eps); + double limit = (3*fdiff*bdiff + muscl->m_eps) + / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->m_eps); - fI[p*nvars+v] = m1 + limit * (one_third*fdiff + one_sixth*bdiff); + fI[p*nvars+v] = m1 + limit * (s_one_third*fdiff + s_one_sixth*bdiff); } } } @@ -153,10 +153,10 @@ int Interp1PrimThirdOrderMUSCL( double fdiff = p2 - p1; double bdiff = p1 - m1; - double limit = (3*fdiff*bdiff + muscl->eps) - / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->eps); + double limit = (3*fdiff*bdiff + muscl->m_eps) + / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->m_eps); - fI[p*nvars+v] = p1 - limit * (one_third*fdiff + one_sixth*bdiff); + fI[p*nvars+v] = p1 - limit * (s_one_third*fdiff + s_one_sixth*bdiff); } } } diff --git a/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCLChar.c b/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCLChar.c index ff41279c..27a211ab 100644 --- a/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCLChar.c +++ b/src/InterpolationFunctions/Interp1PrimThirdOrderMUSCLChar.c @@ -46,7 +46,7 @@ \f{equation}{ \alpha^k = {\bf l}_k \cdot {\bf f},\ k=1,\cdots,n \f} - is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::nvars. The final interpolated function is computed from the interpolated characteristic quantities as: + is the \f$k\f$-th characteristic quantity, and \f${\bf l}_k\f$ is the \f$k\f$-th left eigenvector, \f${\bf r}_k\f$ is the \f$k\f$-th right eigenvector, and \f$n\f$ is #HyPar::m_nvars. The final interpolated function is computed from the interpolated characteristic quantities as: \f{equation}{ \hat{\bf f}_{j+1/2} = \sum_{k=1}^n \alpha^k_{j+1/2} {\bf r}_k \f} @@ -75,11 +75,11 @@ --------- | --------- | --------------------------------------------- fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. - u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::nvars), dim is the local size (#HyPar::dim_local), D is the number of spatial dimensions. + u | double* | The solution array \f${\bf u}\f$ (with ghost points). If the interpolation is characteristic based, this is needed to compute the eigendecomposition. For a multidimensional problem, the layout is as follows: u is a contiguous 1D array of size (nvars*dim[0]*dim[1]*...*dim[D-1]) corresponding to the multi-dimensional solution, with the following ordering - nvars, dim[0], dim[1], ..., dim[D-1], where nvars is the number of solution components (#HyPar::m_nvars), dim is the local size (#HyPar::m_dim_local), D is the number of spatial dimensions. x | double* | The grid array (with ghost points). This is used only by non-uniform-grid interpolation methods. For multidimensional problems, the layout is as follows: x is a contiguous 1D array of size (dim[0]+dim[1]+...+dim[D-1]), with the spatial coordinates along dim[0] stored from 0,...,dim[0]-1, the spatial coordinates along dim[1] stored along dim[0],...,dim[0]+dim[1]-1, and so forth. upw | int | Upwinding direction: if positive, a left-biased interpolant will be computed; if negative, a right-biased interpolant will be computed. If the interpolation method is central, then this has no effect. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. uflag | int | A flag indicating if the function being interpolated \f${\bf f}\f$ is the solution itself \f${\bf u}\f$ (if 1, \f${\bf f}\left({\bf u}\right) \equiv {\bf u}\f$). @@ -95,24 +95,24 @@ int Interp1PrimThirdOrderMUSCLChar( double *x, /*!< Grid coordinates */ int upw, /*!< Upwind direction (left or right biased) */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m, /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m, /*!< Object of type #MPIVariables containing MPI-related variables */ int uflag /*!< Flag to indicate if \f$f(u) \equiv u\f$, i.e, if the solution is being reconstructed */ ) { - HyPar *solver = (HyPar*) s; - MUSCLParameters *muscl = (MUSCLParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + MUSCLParameters *muscl = (MUSCLParameters*) solver->m_interp; int i, k, v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* define some constants */ - double one_third = 1.0/3.0; - double one_sixth = 1.0/6.0; + double s_one_third = 1.0/3.0; + double s_one_sixth = 1.0/6.0; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -143,12 +143,12 @@ int Interp1PrimThirdOrderMUSCLChar( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { @@ -162,9 +162,9 @@ int Interp1PrimThirdOrderMUSCLChar( } double fdiff = p1 - m1; double bdiff = m1 - m2; - double limit = (3*fdiff*bdiff + muscl->eps) - / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->eps); - fchar[v] = m1 + limit * (one_third*fdiff + one_sixth*bdiff); + double limit = (3*fdiff*bdiff + muscl->m_eps) + / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->m_eps); + fchar[v] = m1 + limit * (s_one_third*fdiff + s_one_sixth*bdiff); } /* calculate the interface u from the characteristic u */ @@ -190,12 +190,12 @@ int Interp1PrimThirdOrderMUSCLChar( _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); /* find averaged state at this interface */ - IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->physics); + IERR solver->AveragingFunction(uavg,&u[nvars*qm1],&u[nvars*qp1],solver->m_physics); CHECKERR(ierr); /* Get the left and right eigenvectors */ - IERR solver->GetLeftEigenvectors (uavg,L,solver->physics,dir); CHECKERR(ierr); - IERR solver->GetRightEigenvectors (uavg,R,solver->physics,dir); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors (uavg,L,solver->m_physics,dir); CHECKERR(ierr); + IERR solver->GetRightEigenvectors (uavg,R,solver->m_physics,dir); CHECKERR(ierr); /* For each characteristic field */ for (v = 0; v < nvars; v++) { @@ -209,9 +209,9 @@ int Interp1PrimThirdOrderMUSCLChar( } double fdiff = p2 - p1; double bdiff = p1 - m1; - double limit = (3*fdiff*bdiff + muscl->eps) - / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->eps); - fchar[v] = p1 - limit * (one_third*fdiff + one_sixth*bdiff); + double limit = (3*fdiff*bdiff + muscl->m_eps) + / (2*(fdiff-bdiff)*(fdiff-bdiff) + 3*fdiff*bdiff + muscl->m_eps); + fchar[v] = p1 - limit * (s_one_third*fdiff + s_one_sixth*bdiff); } /* calculate the interface u from the characteristic u */ diff --git a/src/InterpolationFunctions/Interp2PrimSecondOrder.c b/src/InterpolationFunctions/Interp2PrimSecondOrder.c index 23a3a516..8e572916 100644 --- a/src/InterpolationFunctions/Interp2PrimSecondOrder.c +++ b/src/InterpolationFunctions/Interp2PrimSecondOrder.c @@ -49,7 +49,7 @@ fI | double* | Array to hold the computed interpolant at the grid interfaces. This array must have the same layout as the solution, but with \b no \b ghost \b points. Its size should be the same as u in all dimensions, except dir (the dimension along which to interpolate) along which it should be larger by 1 (number of interfaces is 1 more than the number of interior cell centers). fC | double* | Array with the cell-centered values of the flux function \f${\bf f}\left({\bf u}\right)\f$. This array must have the same layout and size as the solution, \b with \b ghost \b points. dir | int | Spatial dimension along which to interpolate (eg: 0 for 1D; 0 or 1 for 2D; 0,1 or 2 for 3D) - s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::ghosts, #HyPar::ndims, #HyPar::nvars, #HyPar::dim_local. + s | void* | Solver object of type #HyPar: the following variables are needed - #HyPar::m_ghosts, #HyPar::m_ndims, #HyPar::m_nvars, #HyPar::m_dim_local. m | void* | MPI object of type #MPIVariables: this is needed only by compact interpolation method that need to solve a global implicit system across MPI ranks. */ @@ -57,16 +57,16 @@ int Interp2PrimSecondOrder( double *fI, /*!< Array of interpolated function values at the interfaces */ double *fC, /*!< Array of cell-centered values of the function \f${\bf f}\left({\bf u}\right)\f$ */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ diff --git a/src/InterpolationFunctions/MUSCLInitialize.c b/src/InterpolationFunctions/MUSCLInitialize.c index 62a3c343..604b173b 100644 --- a/src/InterpolationFunctions/MUSCLInitialize.c +++ b/src/InterpolationFunctions/MUSCLInitialize.c @@ -15,19 +15,19 @@ Initialize the 2nd or 3rd order MUSCL scheme. */ int MUSCLInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - MUSCLParameters *muscl = (MUSCLParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + MUSCLParameters *muscl = (MUSCLParameters*) solver->m_interp; /* default values */ - muscl->eps = 1e-3; - strcpy(muscl->limiter_type, _LIM_GM_); + muscl->m_eps = 1e-3; + strcpy(muscl->m_limiter_type, _LIM_GM_); - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; int ferr; in = fopen("muscl.inp","r"); @@ -39,8 +39,8 @@ int MUSCLInitialize( if (!strcmp(word, "begin")){ while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); - if (!strcmp(word,"epsilon")) { ferr = fscanf(in,"%lf",&muscl->eps); if (ferr != 1) return(1); } - else if (!strcmp(word,"limiter")) { ferr = fscanf(in,"%s" ,muscl->limiter_type); if (ferr != 1) return(1); } + if (!strcmp(word,"epsilon")) { ferr = fscanf(in,"%lf",&muscl->m_eps); if (ferr != 1) return(1); } + else if (!strcmp(word,"limiter")) { ferr = fscanf(in,"%s" ,muscl->m_limiter_type); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr); @@ -56,21 +56,21 @@ int MUSCLInitialize( } } - MPIBroadcast_double(&muscl->eps, 1, 0, &mpi->world); - MPIBroadcast_character(muscl->limiter_type, _MAX_STRING_SIZE_, 0, &mpi->world); + MPIBroadcast_double(&muscl->m_eps, 1, 0, &mpi->m_world); + MPIBroadcast_character(muscl->m_limiter_type, _MAX_STRING_SIZE_, 0, &mpi->m_world); - if (!strcmp(muscl->limiter_type, _LIM_GM_)) { + if (!strcmp(muscl->m_limiter_type, _LIM_GM_)) { muscl->LimiterFunction = LimiterGeneralizedMinMod; - } else if (!strcmp(muscl->limiter_type, _LIM_MM_)) { + } else if (!strcmp(muscl->m_limiter_type, _LIM_MM_)) { muscl->LimiterFunction = LimiterMinMod; - } else if (!strcmp(muscl->limiter_type, _LIM_VANLEER_)) { + } else if (!strcmp(muscl->m_limiter_type, _LIM_VANLEER_)) { muscl->LimiterFunction = LimiterVanLeer; - } else if (!strcmp(muscl->limiter_type, _LIM_SUPERBEE_)) { + } else if (!strcmp(muscl->m_limiter_type, _LIM_SUPERBEE_)) { muscl->LimiterFunction = LimiterSuperBee; } else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr, "Warning: %s is an invalid limiter type. Using default (Generalized MinMod).\n", - muscl->limiter_type); + muscl->m_limiter_type); } muscl->LimiterFunction = LimiterGeneralizedMinMod; } diff --git a/src/InterpolationFunctions/WENOCleanup.c b/src/InterpolationFunctions/WENOCleanup.c index b9e3cfab..295d605c 100644 --- a/src/InterpolationFunctions/WENOCleanup.c +++ b/src/InterpolationFunctions/WENOCleanup.c @@ -14,22 +14,22 @@ /*! Cleans up all allocations related to the WENO-type methods. */ -int WENOCleanup(void *s, /*!< WENO object of type #WENOParameters */ - int flag_gpu /*!< flag to indicate if on GPU */ ) +int WENOCleanup(void *a_s, /*!< WENO object of type #WENOParameters */ + int a_flag_gpu /*!< flag to indicate if on GPU */ ) { - WENOParameters *weno = (WENOParameters*) s; + WENOParameters *weno = (WENOParameters*) a_s; - if (weno->offset) free(weno->offset); + if (weno->m_offset) free(weno->m_offset); #if defined(HAVE_CUDA) - if (flag_gpu) { - if (weno->w1) gpuFree(weno->w1); - if (weno->w2) gpuFree(weno->w2); - if (weno->w3) gpuFree(weno->w3); + if (a_flag_gpu) { + if (weno->m_w1) gpuFree(weno->m_w1); + if (weno->m_w2) gpuFree(weno->m_w2); + if (weno->m_w3) gpuFree(weno->m_w3); } else { #endif - if (weno->w1) free(weno->w1); - if (weno->w2) free(weno->w2); - if (weno->w3) free(weno->w3); + if (weno->m_w1) free(weno->m_w1); + if (weno->m_w2) free(weno->m_w2); + if (weno->m_w3) free(weno->m_w3); #if defined(HAVE_CUDA) } #endif diff --git a/src/InterpolationFunctions/WENOFifthOrderCalculateWeights.c b/src/InterpolationFunctions/WENOFifthOrderCalculateWeights.c index 478e3961..72c4a28c 100644 --- a/src/InterpolationFunctions/WENOFifthOrderCalculateWeights.c +++ b/src/InterpolationFunctions/WENOFifthOrderCalculateWeights.c @@ -42,19 +42,19 @@ int WENOFifthOrderCalculateWeights( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int ret; - if (weno->yc) ret = WENOFifthOrderCalculateWeightsYC (fC,uC,x,dir,solver,mpi); - else if (weno->borges) ret = WENOFifthOrderCalculateWeightsZ (fC,uC,x,dir,solver,mpi); - else if (weno->mapped) ret = WENOFifthOrderCalculateWeightsM (fC,uC,x,dir,solver,mpi); + if (weno->m_yc) ret = WENOFifthOrderCalculateWeightsYC (fC,uC,x,dir,solver,mpi); + else if (weno->m_borges) ret = WENOFifthOrderCalculateWeightsZ (fC,uC,x,dir,solver,mpi); + else if (weno->m_mapped) ret = WENOFifthOrderCalculateWeightsM (fC,uC,x,dir,solver,mpi); else ret = WENOFifthOrderCalculateWeightsJS (fC,uC,x,dir,solver,mpi); return ret; @@ -68,17 +68,17 @@ int WENOFifthOrderCalculateWeightsChar( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; - if (weno->yc) return(WENOFifthOrderCalculateWeightsCharYC (fC,uC,x,dir,solver,mpi)); - else if (weno->borges) return(WENOFifthOrderCalculateWeightsCharZ (fC,uC,x,dir,solver,mpi)); - else if (weno->mapped) return(WENOFifthOrderCalculateWeightsCharM (fC,uC,x,dir,solver,mpi)); + if (weno->m_yc) return(WENOFifthOrderCalculateWeightsCharYC (fC,uC,x,dir,solver,mpi)); + else if (weno->m_borges) return(WENOFifthOrderCalculateWeightsCharZ (fC,uC,x,dir,solver,mpi)); + else if (weno->m_mapped) return(WENOFifthOrderCalculateWeightsCharM (fC,uC,x,dir,solver,mpi)); else return(WENOFifthOrderCalculateWeightsCharJS (fC,uC,x,dir,solver,mpi)); } @@ -113,29 +113,29 @@ int WENOFifthOrderCalculateWeightsJS( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -144,18 +144,18 @@ int WENOFifthOrderCalculateWeightsJS( _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI) for (i=0; ispatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_JS_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_JS_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_JS_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_JS_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_JS_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_JS_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_JS_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_JS_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -267,29 +267,29 @@ int WENOFifthOrderCalculateWeightsM( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -298,18 +298,18 @@ int WENOFifthOrderCalculateWeightsM( _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #if defined(CPU_STAT) clock_t startTime, endTime; @@ -364,32 +364,32 @@ int WENOFifthOrderCalculateWeightsM( p2RU = (uC+qp2R*nvars); /* optimal weights*/ - double c1, c2, c3; - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_M_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_M_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_M_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_M_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_M_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_M_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_M_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_M_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -436,29 +436,29 @@ int WENOFifthOrderCalculateWeightsZ( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -467,18 +467,18 @@ int WENOFifthOrderCalculateWeightsZ( _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI) for (i=0; ispatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_Z_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_Z_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_Z_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_Z_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_Z_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_Z_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_Z_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_Z_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -592,29 +592,29 @@ int WENOFifthOrderCalculateWeightsYC( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -623,18 +623,18 @@ int WENOFifthOrderCalculateWeightsYC( _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; int N_outer; _ArrayProduct1D_(bounds_outer,ndims,N_outer); - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #if defined(CPU_STAT) clock_t cpu_start, cpu_end; @@ -688,32 +688,32 @@ int WENOFifthOrderCalculateWeightsYC( p2RU = (uC+qp2R*nvars); /* optimal weights*/ - double c1, c2, c3; - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_YC_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_YC_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_YC_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_YC_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_YC_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_YC_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_YC_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_YC_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -762,29 +762,29 @@ int WENOFifthOrderCalculateWeightsCharJS( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -796,18 +796,18 @@ int WENOFifthOrderCalculateWeightsCharJS( /* allocate arrays for the averaged state, eigenvectors and characteristic interpolated f */ double L[nvars*nvars], uavg[nvars]; - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI) for (i=0; iAveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->physics); CHECKERR(ierr); - IERR solver->GetLeftEigenvectors(uavg,L,solver->physics,dir); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->m_physics); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors(uavg,L,solver->m_physics,dir); CHECKERR(ierr); /* Defining stencil points */ double m3LF[nvars], m2LF[nvars], m1LF[nvars], p1LF[nvars], p2LF[nvars]; @@ -863,32 +863,32 @@ int WENOFifthOrderCalculateWeightsCharJS( MatVecMult(nvars,p2RU,L,(uC+nvars*qp2R)); /* optimal weights*/ - double c1, c2, c3; - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_JS_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_JS_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_JS_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_JS_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_JS_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_JS_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_JS_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_JS_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -932,29 +932,29 @@ int WENOFifthOrderCalculateWeightsCharM( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -966,18 +966,18 @@ int WENOFifthOrderCalculateWeightsCharM( /* allocate arrays for the averaged state, eigenvectors and characteristic interpolated f */ double L[nvars*nvars], uavg[nvars]; - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI) for (i=0; iAveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->physics); CHECKERR(ierr); - IERR solver->GetLeftEigenvectors(uavg,L,solver->physics,dir); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->m_physics); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors(uavg,L,solver->m_physics,dir); CHECKERR(ierr); /* Defining stencil points */ double m3LF[nvars], m2LF[nvars], m1LF[nvars], p1LF[nvars], p2LF[nvars]; @@ -1033,32 +1033,32 @@ int WENOFifthOrderCalculateWeightsCharM( MatVecMult(nvars,p2RU,L,(uC+nvars*qp2R)); /* optimal weights*/ - double c1, c2, c3; - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_M_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_M_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_M_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_M_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_M_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_M_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_M_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_M_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -1103,29 +1103,29 @@ int WENOFifthOrderCalculateWeightsCharZ( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -1137,18 +1137,18 @@ int WENOFifthOrderCalculateWeightsCharZ( /* allocate arrays for the averaged state, eigenvectors and characteristic interpolated f */ double L[nvars*nvars], uavg[nvars]; - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI) for (i=0; iAveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->physics); CHECKERR(ierr); - IERR solver->GetLeftEigenvectors(uavg,L,solver->physics,dir); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->m_physics); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors(uavg,L,solver->m_physics,dir); CHECKERR(ierr); /* Defining stencil points */ double m3LF[nvars], m2LF[nvars], m1LF[nvars], p1LF[nvars], p2LF[nvars]; @@ -1204,32 +1204,32 @@ int WENOFifthOrderCalculateWeightsCharZ( MatVecMult(nvars,p2RU,L,(uC+nvars*qp2R)); /* optimal weights*/ - double c1, c2, c3; - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_Z_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_Z_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_Z_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_Z_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_Z_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_Z_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_Z_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_Z_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } @@ -1274,29 +1274,29 @@ int WENOFifthOrderCalculateWeightsCharYC( double *uC, /*!< Array of cell-centered values of the solution \f${\bf u}\f$ */ double *x, /*!< Grid coordinates */ int dir, /*!< Spatial dimension along which to interpolation */ - void *s, /*!< Object of type #HyPar containing solver-related variables */ - void *m /*!< Object of type #MPIVariables containing MPI-related variables */ + void *a_s, /*!< Object of type #HyPar containing solver-related variables */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related variables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int i; double *ww1LF, *ww2LF, *ww3LF, *ww1RF, *ww2RF, *ww3RF; double *ww1LU, *ww2LU, *ww3LU, *ww1RU, *ww2RU, *ww3RU; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int *stride= solver->stride_with_ghosts; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int *stride= solver->m_stride_with_ghosts; /* define some constants */ - static const double thirteen_by_twelve = 13.0/12.0; - static const double one_fourth = 1.0/4.0; + static const double s_thirteen_by_twelve = 13.0/12.0; + static const double s_one_fourth = 1.0/4.0; /* calculate dimension offset */ - int offset = weno->offset[dir]; + int offset = weno->m_offset[dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along dimension "dir" */ @@ -1308,18 +1308,18 @@ int WENOFifthOrderCalculateWeightsCharYC( /* allocate arrays for the averaged state, eigenvectors and characteristic interpolated f */ double L[nvars*nvars], uavg[nvars]; - ww1LF = weno->w1 + offset; - ww2LF = weno->w2 + offset; - ww3LF = weno->w3 + offset; - ww1RF = weno->w1 + 2*weno->size + offset; - ww2RF = weno->w2 + 2*weno->size + offset; - ww3RF = weno->w3 + 2*weno->size + offset; - ww1LU = weno->w1 + weno->size + offset; - ww2LU = weno->w2 + weno->size + offset; - ww3LU = weno->w3 + weno->size + offset; - ww1RU = weno->w1 + 2*weno->size + weno->size + offset; - ww2RU = weno->w2 + 2*weno->size + weno->size + offset; - ww3RU = weno->w3 + 2*weno->size + weno->size + offset; + ww1LF = weno->m_w1 + offset; + ww2LF = weno->m_w2 + offset; + ww3LF = weno->m_w3 + offset; + ww1RF = weno->m_w1 + 2*weno->m_size + offset; + ww2RF = weno->m_w2 + 2*weno->m_size + offset; + ww3RF = weno->m_w3 + 2*weno->m_size + offset; + ww1LU = weno->m_w1 + weno->m_size + offset; + ww2LU = weno->m_w2 + weno->m_size + offset; + ww3LU = weno->m_w3 + weno->m_size + offset; + ww1RU = weno->m_w1 + 2*weno->m_size + weno->m_size + offset; + ww2RU = weno->m_w2 + 2*weno->m_size + weno->m_size + offset; + ww3RU = weno->m_w3 + 2*weno->m_size + weno->m_size + offset; #pragma omp parallel for schedule(auto) default(shared) private(i,index_outer,indexC,indexI) for (i=0; iAveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->physics); CHECKERR(ierr); - IERR solver->GetLeftEigenvectors(uavg,L,solver->physics,dir); CHECKERR(ierr); + IERR solver->AveragingFunction(uavg,(uC+nvars*qm1L),(uC+nvars*qp1L),solver->m_physics); CHECKERR(ierr); + IERR solver->GetLeftEigenvectors(uavg,L,solver->m_physics,dir); CHECKERR(ierr); /* Defining stencil points */ double m3LF[nvars], m2LF[nvars], m1LF[nvars], p1LF[nvars], p2LF[nvars]; @@ -1375,32 +1375,32 @@ int WENOFifthOrderCalculateWeightsCharYC( MatVecMult(nvars,p2RU,L,(uC+nvars*qp2R)); /* optimal weights*/ - double c1, c2, c3; - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[dir] == 0 ) && (indexI[dir] == 0 )) + || ((mpi->m_ip[dir] == mpi->m_iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_YC_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->eps,nvars); - _WENOWeights_v_YC_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->eps,nvars); - _WENOWeights_v_YC_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->eps,nvars); - _WENOWeights_v_YC_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->eps,nvars); + _WENOWeights_v_YC_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno->m_eps,nvars); + _WENOWeights_v_YC_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno->m_eps,nvars); + _WENOWeights_v_YC_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno->m_eps,nvars); + _WENOWeights_v_YC_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno->m_eps,nvars); } } diff --git a/src/InterpolationFunctions/WENOFifthOrderCalculateWeights_GPU.cu b/src/InterpolationFunctions/WENOFifthOrderCalculateWeights_GPU.cu index 1777d190..e7d59781 100644 --- a/src/InterpolationFunctions/WENOFifthOrderCalculateWeights_GPU.cu +++ b/src/InterpolationFunctions/WENOFifthOrderCalculateWeights_GPU.cu @@ -76,8 +76,8 @@ void WENOFifthOrderCalculateWeightsM_kernel( int p = threadIdx.x + (blockDim.x * blockIdx.x); if (p < ngrid_points) { const int max_ndims = 3; - const double thirteen_by_twelve = 13.0 / 12.0; - const double one_fourth = 1.0 / 4.0; + const double s_thirteen_by_twelve = 13.0 / 12.0; + const double s_one_fourth = 1.0 / 4.0; int bounds_inter[max_ndims], indexC[max_ndims], indexI[max_ndims]; int qm1L, qm2L, qm3L, qp1L, qp2L, qm1R, qm2R, qm3R, qp1R, qp2R; @@ -139,32 +139,32 @@ void WENOFifthOrderCalculateWeightsM_kernel( p1RU = (uC+qp1R*nvars); p2RU = (uC+qp2R*nvars); - double c1, c2, c3; + double s_c1, s_c2, c3; if (is_crweno) { if ( (is_mpi_ip_zero && (indexI[dir] == 0 )) || (is_mpi_ip_proc && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_M_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,nvars); - _WENOWeights_v_M_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,nvars); - _WENOWeights_v_M_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,nvars); - _WENOWeights_v_M_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,nvars); + _WENOWeights_v_M_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,nvars); + _WENOWeights_v_M_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,nvars); + _WENOWeights_v_M_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,nvars); + _WENOWeights_v_M_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,nvars); } return; @@ -210,10 +210,10 @@ int gpuWENOFifthOrderCalculateWeightsM( WENOParameters *weno = (WENOParameters*) solver->interp; MPIVariables *mpi = (MPIVariables*) m; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; int *stride= solver->stride_with_ghosts; /* calculate dimension offset */ @@ -224,8 +224,8 @@ int gpuWENOFifthOrderCalculateWeightsM( int nblocks = (npoints_grid-1) / GPU_THREADS_PER_BLOCK + 1; int is_crweno = (strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_) == 0) ? 1 : 0; - int is_mpi_ip_zero = (mpi->ip[dir] == 0) ? 1 : 0; - int is_mpi_ip_proc = (mpi->ip[dir] == mpi->iproc[dir]-1) ? 1 : 0; + int is_mpi_ip_zero = (mpi->m_ip[dir] == 0) ? 1 : 0; + int is_mpi_ip_proc = (mpi->m_ip[dir] == mpi->m_iproc[dir]-1) ? 1 : 0; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; @@ -248,7 +248,7 @@ int gpuWENOFifthOrderCalculateWeightsM( WENOFifthOrderCalculateWeightsM_kernel<<>>( npoints_grid, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], is_crweno, is_mpi_ip_zero, is_mpi_ip_proc, weno->eps, - solver->gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 + solver->m_gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 ); cudaDeviceSynchronize(); @@ -294,8 +294,8 @@ void WENOFifthOrderCalculateWeightsYC_kernel( int p = threadIdx.x + (blockDim.x * blockIdx.x); if (p < ngrid_points) { const int max_ndims = 3; - const double thirteen_by_twelve = 13.0 / 12.0; - const double one_fourth = 1.0 / 4.0; + const double s_thirteen_by_twelve = 13.0 / 12.0; + const double s_one_fourth = 1.0 / 4.0; int bounds_inter[max_ndims], indexC[max_ndims], indexI[max_ndims]; int qm1L, qm2L, qm3L, qp1L, qp2L, qm1R, qm2R, qm3R, qp1R, qp2R; @@ -357,32 +357,32 @@ void WENOFifthOrderCalculateWeightsYC_kernel( p1RU = (uC+qp1R*nvars); p2RU = (uC+qp2R*nvars); - double c1, c2, c3; + double s_c1, s_c2, c3; if (is_crweno) { if ( (is_mpi_ip_zero && (indexI[dir] == 0 )) || (is_mpi_ip_proc && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_YC_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,nvars); - _WENOWeights_v_YC_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,nvars); - _WENOWeights_v_YC_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,nvars); - _WENOWeights_v_YC_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,nvars); + _WENOWeights_v_YC_((ww1LF+p*nvars),(ww2LF+p*nvars),(ww3LF+p*nvars),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,nvars); + _WENOWeights_v_YC_((ww1RF+p*nvars),(ww2RF+p*nvars),(ww3RF+p*nvars),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,nvars); + _WENOWeights_v_YC_((ww1LU+p*nvars),(ww2LU+p*nvars),(ww3LU+p*nvars),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,nvars); + _WENOWeights_v_YC_((ww1RU+p*nvars),(ww2RU+p*nvars),(ww3RU+p*nvars),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,nvars); } return; @@ -430,10 +430,10 @@ int gpuWENOFifthOrderCalculateWeightsYC( WENOParameters *weno = (WENOParameters*) solver->interp; MPIVariables *mpi = (MPIVariables*) m; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; int *stride= solver->stride_with_ghosts; /* calculate dimension offset */ @@ -445,8 +445,8 @@ int gpuWENOFifthOrderCalculateWeightsYC( int nblocks = (ngrid_points - 1) / 256 + 1; int is_crweno = (strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_) == 0) ? 1 : 0; - int is_mpi_ip_zero = (mpi->ip[dir] == 0) ? 1 : 0; - int is_mpi_ip_proc = (mpi->ip[dir] == mpi->iproc[dir]-1) ? 1 : 0; + int is_mpi_ip_zero = (mpi->m_ip[dir] == 0) ? 1 : 0; + int is_mpi_ip_proc = (mpi->m_ip[dir] == mpi->m_iproc[dir]-1) ? 1 : 0; cudaEvent_t startEvent, stopEvent; float milliseconds = 0; @@ -459,7 +459,7 @@ int gpuWENOFifthOrderCalculateWeightsYC( WENOFifthOrderCalculateWeightsYC_kernel<<>>( ngrid_points, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], is_crweno, is_mpi_ip_zero, is_mpi_ip_proc, weno->eps, - solver->gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 + solver->m_gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 ); checkCuda( cudaEventRecord(stopEvent, 0) ); checkCuda( cudaEventSynchronize(stopEvent) ); @@ -507,8 +507,8 @@ void WENOFifthOrderCalculateWeightsM_kernel( int p = threadIdx.x + (blockDim.x * blockIdx.x); if (p < npoints_grid) { const int max_ndims = 3; - const double thirteen_by_twelve = 13.0 / 12.0; - const double one_fourth = 1.0 / 4.0; + const double s_thirteen_by_twelve = 13.0 / 12.0; + const double s_one_fourth = 1.0 / 4.0; int bounds_inter[max_ndims], indexC[max_ndims], indexI[max_ndims]; int qm1L, qm2L, qm3L, qp1L, qp2L, qm1R, qm2R, qm3R, qp1R, qp2R; @@ -583,32 +583,32 @@ void WENOFifthOrderCalculateWeightsM_kernel( qp1R += npoints_local_wghosts; qp2R += npoints_local_wghosts; - double c1, c2, c3; + double s_c1, s_c2, c3; if (is_crweno) { if ( (is_mpi_ip_zero && (indexI[dir] == 0 )) || (is_mpi_ip_proc && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_M_Scalar_((ww1LF+p),(ww2LF+p),(ww3LF+p),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,0); - _WENOWeights_v_M_Scalar_((ww1RF+p),(ww2RF+p),(ww3RF+p),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,0); - _WENOWeights_v_M_Scalar_((ww1LU+p),(ww2LU+p),(ww3LU+p),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,0); - _WENOWeights_v_M_Scalar_((ww1RU+p),(ww2RU+p),(ww3RU+p),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,0); + _WENOWeights_v_M_Scalar_((ww1LF+p),(ww2LF+p),(ww3LF+p),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,0); + _WENOWeights_v_M_Scalar_((ww1RF+p),(ww2RF+p),(ww3RF+p),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,0); + _WENOWeights_v_M_Scalar_((ww1LU+p),(ww2LU+p),(ww3LU+p),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,0); + _WENOWeights_v_M_Scalar_((ww1RU+p),(ww2RU+p),(ww3RU+p),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,0); p += npoints_grid; } } @@ -657,10 +657,10 @@ int gpuWENOFifthOrderCalculateWeightsM( WENOParameters *weno = (WENOParameters*) solver->interp; MPIVariables *mpi = (MPIVariables*) m; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; int *stride= solver->stride_with_ghosts; /* calculate dimension offset */ @@ -671,8 +671,8 @@ int gpuWENOFifthOrderCalculateWeightsM( int nblocks = (npoints_grid-1) / GPU_THREADS_PER_BLOCK + 1; int is_crweno = (strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_) == 0) ? 1 : 0; - int is_mpi_ip_zero = (mpi->ip[dir] == 0) ? 1 : 0; - int is_mpi_ip_proc = (mpi->ip[dir] == mpi->iproc[dir]-1) ? 1 : 0; + int is_mpi_ip_zero = (mpi->m_ip[dir] == 0) ? 1 : 0; + int is_mpi_ip_proc = (mpi->m_ip[dir] == mpi->m_iproc[dir]-1) ? 1 : 0; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; @@ -693,9 +693,9 @@ int gpuWENOFifthOrderCalculateWeightsM( #endif WENOFifthOrderCalculateWeightsM_kernel<<>>( - npoints_grid, solver->npoints_local_wghosts, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], + npoints_grid, solver->m_npoints_local_wghosts, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], is_crweno, is_mpi_ip_zero, is_mpi_ip_proc, weno->eps, - solver->gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 + solver->m_gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 ); cudaDeviceSynchronize(); @@ -743,8 +743,8 @@ void WENOFifthOrderCalculateWeightsYC_kernel( int p = threadIdx.x + (blockDim.x * blockIdx.x); if (p < npoints_grid) { const int max_ndims = 3; - const double thirteen_by_twelve = 13.0 / 12.0; - const double one_fourth = 1.0 / 4.0; + const double s_thirteen_by_twelve = 13.0 / 12.0; + const double s_one_fourth = 1.0 / 4.0; int bounds_inter[max_ndims], indexC[max_ndims], indexI[max_ndims]; int qm1L, qm2L, qm3L, qp1L, qp2L, qm1R, qm2R, qm3R, qp1R, qp2R; @@ -819,32 +819,32 @@ void WENOFifthOrderCalculateWeightsYC_kernel( qp1R += npoints_local_wghosts; qp2R += npoints_local_wghosts; - double c1, c2, c3; + double s_c1, s_c2, c3; if (is_crweno) { if ( (is_mpi_ip_zero && (indexI[dir] == 0 )) || (is_mpi_ip_proc && (indexI[dir] == dim[dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* calculate WENO weights */ - _WENOWeights_v_YC_Scalar_((ww1LF+p),(ww2LF+p),(ww3LF+p),c1,c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,0); - _WENOWeights_v_YC_Scalar_((ww1RF+p),(ww2RF+p),(ww3RF+p),c1,c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,0); - _WENOWeights_v_YC_Scalar_((ww1LU+p),(ww2LU+p),(ww3LU+p),c1,c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,0); - _WENOWeights_v_YC_Scalar_((ww1RU+p),(ww2RU+p),(ww3RU+p),c1,c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,0); + _WENOWeights_v_YC_Scalar_((ww1LF+p),(ww2LF+p),(ww3LF+p),s_c1,s_c2,c3,m3LF,m2LF,m1LF,p1LF,p2LF,weno_eps,0); + _WENOWeights_v_YC_Scalar_((ww1RF+p),(ww2RF+p),(ww3RF+p),s_c1,s_c2,c3,m3RF,m2RF,m1RF,p1RF,p2RF,weno_eps,0); + _WENOWeights_v_YC_Scalar_((ww1LU+p),(ww2LU+p),(ww3LU+p),s_c1,s_c2,c3,m3LU,m2LU,m1LU,p1LU,p2LU,weno_eps,0); + _WENOWeights_v_YC_Scalar_((ww1RU+p),(ww2RU+p),(ww3RU+p),s_c1,s_c2,c3,m3RU,m2RU,m1RU,p1RU,p2RU,weno_eps,0); p += npoints_grid; } } @@ -894,10 +894,10 @@ int gpuWENOFifthOrderCalculateWeightsYC( WENOParameters *weno = (WENOParameters*) solver->interp; MPIVariables *mpi = (MPIVariables*) m; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; int *stride= solver->stride_with_ghosts; /* calculate dimension offset */ @@ -908,8 +908,8 @@ int gpuWENOFifthOrderCalculateWeightsYC( int nblocks = (npoints_grid-1) / GPU_THREADS_PER_BLOCK + 1; int is_crweno = (strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_) == 0) ? 1 : 0; - int is_mpi_ip_zero = (mpi->ip[dir] == 0) ? 1 : 0; - int is_mpi_ip_proc = (mpi->ip[dir] == mpi->iproc[dir]-1) ? 1 : 0; + int is_mpi_ip_zero = (mpi->m_ip[dir] == 0) ? 1 : 0; + int is_mpi_ip_proc = (mpi->m_ip[dir] == mpi->m_iproc[dir]-1) ? 1 : 0; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; @@ -930,9 +930,9 @@ int gpuWENOFifthOrderCalculateWeightsYC( #endif WENOFifthOrderCalculateWeightsYC_kernel<<>>( - npoints_grid, solver->npoints_local_wghosts, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], + npoints_grid, solver->m_npoints_local_wghosts, ndims, dir, ghosts, nvars, weno->size, offset, stride[dir], is_crweno, is_mpi_ip_zero, is_mpi_ip_proc, weno->eps, - solver->gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 + solver->m_gpu_dim_local, fC, uC, weno->w1, weno->w2, weno->w3 ); cudaDeviceSynchronize(); diff --git a/src/InterpolationFunctions/WENOFifthOrderInitializeWeights.c b/src/InterpolationFunctions/WENOFifthOrderInitializeWeights.c index b40b6d63..e72a5fc4 100644 --- a/src/InterpolationFunctions/WENOFifthOrderInitializeWeights.c +++ b/src/InterpolationFunctions/WENOFifthOrderInitializeWeights.c @@ -24,7 +24,7 @@ + \a offset indicates the location in #WENOParameters::w1,#WENOParameters::w2, and #WENOParameters::w3 from where the chunk of memory with the weights for the spatial dimension \a dir starts. + This chunk of memory (1D array) represents a multidimensional array of the following size: - 4 X (number of interfaces) X (number of solution components #HyPar::nvars). The factor 4 comes from the + 4 X (number of interfaces) X (number of solution components #HyPar::m_nvars). The factor 4 comes from the fact that the array stores weights for the interpolation of left-biased flux function, left-biased solution, right-biased flux function, and right-biased solution, one after the other, in this order. + The weights are initialized to their optimal values so that, if no limiting is specified @@ -34,30 +34,30 @@ int WENOFifthOrderInitializeWeights( double* const a_w1, /*!< Weight array */ double* const a_w2, /*!< Weight array */ double* const a_w3, /*!< Weight array */ const int* const a_offset, /*!< Offset array */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - WENOParameters *weno = (WENOParameters*) solver->interp; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + WENOParameters *weno = (WENOParameters*) solver->m_interp; + MPIVariables *mpi = (MPIVariables*) a_m; int done; double *ww1, *ww2, *ww3; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; /* calculate dimension offset */ - int offset = a_offset[dir]; + int offset = a_offset[a_dir]; /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along - dimension "dir" */ + dimension "a_dir" */ int indexI[ndims], index_outer[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; /* calculate weights for a left-biased interpolation */ ww1 = a_w1 + offset; @@ -66,77 +66,77 @@ int WENOFifthOrderInitializeWeights( double* const a_w1, /*!< Weight array */ done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,indexI,ndims); - for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) { + for (indexI[a_dir] = 0; indexI[a_dir] < dim[a_dir]+1; indexI[a_dir]++) { int p, v; _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); for (v=0; vspatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[a_dir] == 0 ) && (indexI[a_dir] == 0 )) + || ((mpi->m_ip[a_dir] == mpi->m_iproc[a_dir]-1) && (indexI[a_dir] == dim[a_dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* save the weights */ - *(ww1+p*nvars+v) = c1; - *(ww2+p*nvars+v) = c2; + *(ww1+p*nvars+v) = s_c1; + *(ww2+p*nvars+v) = s_c2; *(ww3+p*nvars+v) = c3; } } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } - ww1 = a_w1 + weno->size + offset; - ww2 = a_w2 + weno->size + offset; - ww3 = a_w3 + weno->size + offset; + ww1 = a_w1 + weno->m_size + offset; + ww2 = a_w2 + weno->m_size + offset; + ww3 = a_w3 + weno->m_size + offset; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,indexI,ndims); - for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) { + for (indexI[a_dir] = 0; indexI[a_dir] < dim[a_dir]+1; indexI[a_dir]++) { int p, v; _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); for (v=0; vspatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[a_dir] == 0 ) && (indexI[a_dir] == 0 )) + || ((mpi->m_ip[a_dir] == mpi->m_iproc[a_dir]-1) && (indexI[a_dir] == dim[a_dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* save the weights */ - *(ww1+p*nvars+v) = c1; - *(ww2+p*nvars+v) = c2; + *(ww1+p*nvars+v) = s_c1; + *(ww2+p*nvars+v) = s_c2; *(ww3+p*nvars+v) = c3; } } @@ -144,84 +144,84 @@ int WENOFifthOrderInitializeWeights( double* const a_w1, /*!< Weight array */ } /* calculate weights for a right-biased interpolation */ - ww1 = a_w1 + 2*weno->size + offset; - ww2 = a_w2 + 2*weno->size + offset; - ww3 = a_w3 + 2*weno->size + offset; + ww1 = a_w1 + 2*weno->m_size + offset; + ww2 = a_w2 + 2*weno->m_size + offset; + ww3 = a_w3 + 2*weno->m_size + offset; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,indexI,ndims); - for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) { + for (indexI[a_dir] = 0; indexI[a_dir] < dim[a_dir]+1; indexI[a_dir]++) { int p, v; _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); for (v=0; vspatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[a_dir] == 0 ) && (indexI[a_dir] == 0 )) + || ((mpi->m_ip[a_dir] == mpi->m_iproc[a_dir]-1) && (indexI[a_dir] == dim[a_dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* save the weights */ - *(ww1+p*nvars+v) = c1; - *(ww2+p*nvars+v) = c2; + *(ww1+p*nvars+v) = s_c1; + *(ww2+p*nvars+v) = s_c2; *(ww3+p*nvars+v) = c3; } } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } - ww1 = a_w1 + 2*weno->size + weno->size + offset; - ww2 = a_w2 + 2*weno->size + weno->size + offset; - ww3 = a_w3 + 2*weno->size + weno->size + offset; + ww1 = a_w1 + 2*weno->m_size + weno->m_size + offset; + ww2 = a_w2 + 2*weno->m_size + weno->m_size + offset; + ww3 = a_w3 + 2*weno->m_size + weno->m_size + offset; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,indexI,ndims); - for (indexI[dir] = 0; indexI[dir] < dim[dir]+1; indexI[dir]++) { + for (indexI[a_dir] = 0; indexI[a_dir] < dim[a_dir]+1; indexI[a_dir]++) { int p, v; _ArrayIndex1D_(ndims,bounds_inter,indexI,0,p); for (v=0; vspatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { - if ( ((mpi->ip[dir] == 0 ) && (indexI[dir] == 0 )) - || ((mpi->ip[dir] == mpi->iproc[dir]-1) && (indexI[dir] == dim[dir])) ) { + double s_c1, s_c2, c3; + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + if ( ((mpi->m_ip[a_dir] == 0 ) && (indexI[a_dir] == 0 )) + || ((mpi->m_ip[a_dir] == mpi->m_iproc[a_dir]-1) && (indexI[a_dir] == dim[a_dir])) ) { /* Use WENO5 at the physical boundaries */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } else { /* CRWENO5 at the interior points */ - c1 = _CRWENO_OPTIMAL_WEIGHT_1_; - c2 = _CRWENO_OPTIMAL_WEIGHT_2_; + s_c1 = _CRWENO_OPTIMAL_WEIGHT_1_; + s_c2 = _CRWENO_OPTIMAL_WEIGHT_2_; c3 = _CRWENO_OPTIMAL_WEIGHT_3_; } } else { /* WENO5 and HCWENO5 */ - c1 = _WENO_OPTIMAL_WEIGHT_1_; - c2 = _WENO_OPTIMAL_WEIGHT_2_; + s_c1 = _WENO_OPTIMAL_WEIGHT_1_; + s_c2 = _WENO_OPTIMAL_WEIGHT_2_; c3 = _WENO_OPTIMAL_WEIGHT_3_; } /* save the weights */ - *(ww1+p*nvars+v) = c1; - *(ww2+p*nvars+v) = c2; + *(ww1+p*nvars+v) = s_c1; + *(ww2+p*nvars+v) = s_c2; *(ww3+p*nvars+v) = c3; } } diff --git a/src/InterpolationFunctions/WENOInitialize.c b/src/InterpolationFunctions/WENOInitialize.c index 38d5d43b..bc302b3d 100644 --- a/src/InterpolationFunctions/WENOInitialize.c +++ b/src/InterpolationFunctions/WENOInitialize.c @@ -32,54 +32,54 @@ int gpuWENOFifthOrderCalculateWeights (double*,double*,double*,int,void*,void* schemes. */ int WENOInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - char *scheme, /*!< Name of scheme */ - char *type /*!< Type of interpolation */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + char *a_scheme, /*!< Name of scheme */ + char *a_type /*!< Type of interpolation */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - WENOParameters *weno = (WENOParameters*) solver->interp; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + WENOParameters *weno = (WENOParameters*) solver->m_interp; - static int count = 0; + static int s_count = 0; - int nvars = solver->nvars; - int ndims = solver->ndims; + int nvars = solver->m_nvars; + int ndims = solver->m_ndims; /* default parameters */ - weno->mapped = 0; - weno->borges = 0; - weno->yc = 0; - weno->no_limiting = 0; - weno->eps = 1e-6; - weno->p = 2.0; - - weno->rc = 0.3; - weno->xi = 0.001; - weno->tol = 1e-16; - - if (!mpi->rank) { + weno->m_mapped = 0; + weno->m_borges = 0; + weno->m_yc = 0; + weno->m_no_limiting = 0; + weno->m_eps = 1e-6; + weno->m_p = 2.0; + + weno->m_rc = 0.3; + weno->m_xi = 0.001; + weno->m_tol = 1e-16; + + if (!mpi->m_rank) { FILE *in; int ferr; in = fopen("weno.inp","r"); - if (!in) printf("Warning: File weno.inp not found. Using default parameters for WENO5/CRWENO5/HCWENO5 scheme.\n"); + if (!in) printf("Warning: File weno.inp not found. Using default parameters for WENO5/CRWENO5/HCWENO5 a_scheme.\n"); else { - if (!count) printf("Reading WENO parameters from weno.inp.\n"); + if (!s_count) printf("Reading WENO parameters from weno.inp.\n"); char word[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "begin")){ while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); - if (!strcmp(word,"mapped" )) { ferr = fscanf(in,"%d" ,&weno->mapped ); if (ferr != 1) return(1); } - else if (!strcmp(word,"borges" )) { ferr = fscanf(in,"%d" ,&weno->borges ); if (ferr != 1) return(1); } - else if (!strcmp(word,"yc" )) { ferr = fscanf(in,"%d" ,&weno->yc ); if (ferr != 1) return(1); } - else if (!strcmp(word,"no_limiting")) { ferr = fscanf(in,"%d" ,&weno->no_limiting); if (ferr != 1) return(1); } - else if (!strcmp(word,"epsilon" )) { ferr = fscanf(in,"%lf",&weno->eps ); if (ferr != 1) return(1); } - else if (!strcmp(word,"p" )) { ferr = fscanf(in,"%lf",&weno->p ); if (ferr != 1) return(1); } - else if (!strcmp(word,"rc" )) { ferr = fscanf(in,"%lf",&weno->rc ); if (ferr != 1) return(1); } - else if (!strcmp(word,"xi" )) { ferr = fscanf(in,"%lf",&weno->xi ); if (ferr != 1) return(1); } - else if (!strcmp(word,"tol" )) { ferr = fscanf(in,"%lf",&weno->tol ); if (ferr != 1) return(1); } + if (!strcmp(word,"mapped" )) { ferr = fscanf(in,"%d" ,&weno->m_mapped ); if (ferr != 1) return(1); } + else if (!strcmp(word,"borges" )) { ferr = fscanf(in,"%d" ,&weno->m_borges ); if (ferr != 1) return(1); } + else if (!strcmp(word,"yc" )) { ferr = fscanf(in,"%d" ,&weno->m_yc ); if (ferr != 1) return(1); } + else if (!strcmp(word,"no_limiting")) { ferr = fscanf(in,"%d" ,&weno->m_no_limiting); if (ferr != 1) return(1); } + else if (!strcmp(word,"epsilon" )) { ferr = fscanf(in,"%lf",&weno->m_eps ); if (ferr != 1) return(1); } + else if (!strcmp(word,"p" )) { ferr = fscanf(in,"%lf",&weno->m_p ); if (ferr != 1) return(1); } + else if (!strcmp(word,"rc" )) { ferr = fscanf(in,"%lf",&weno->m_rc ); if (ferr != 1) return(1); } + else if (!strcmp(word,"xi" )) { ferr = fscanf(in,"%lf",&weno->m_xi ); if (ferr != 1) return(1); } + else if (!strcmp(word,"tol" )) { ferr = fscanf(in,"%lf",&weno->m_tol ); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr); @@ -97,50 +97,50 @@ int WENOInitialize( int integer_data[4]; double real_data[5]; - if (!mpi->rank) { - integer_data[0] = weno->mapped; - integer_data[1] = weno->borges; - integer_data[2] = weno->yc; - integer_data[3] = weno->no_limiting; - real_data[0] = weno->eps; - real_data[1] = weno->p; - real_data[2] = weno->rc; - real_data[3] = weno->xi; - real_data[4] = weno->tol; + if (!mpi->m_rank) { + integer_data[0] = weno->m_mapped; + integer_data[1] = weno->m_borges; + integer_data[2] = weno->m_yc; + integer_data[3] = weno->m_no_limiting; + real_data[0] = weno->m_eps; + real_data[1] = weno->m_p; + real_data[2] = weno->m_rc; + real_data[3] = weno->m_xi; + real_data[4] = weno->m_tol; } - MPIBroadcast_integer(integer_data,4,0,&mpi->world); - MPIBroadcast_double (real_data ,5,0,&mpi->world); - - weno->mapped = integer_data[0]; - weno->borges = integer_data[1]; - weno->yc = integer_data[2]; - weno->no_limiting = integer_data[3]; - weno->eps = real_data [0]; - weno->p = real_data [1]; - weno->rc = real_data [2]; - weno->xi = real_data [3]; - weno->tol = real_data [4]; + MPIBroadcast_integer(integer_data,4,0,&mpi->m_world); + MPIBroadcast_double (real_data ,5,0,&mpi->m_world); + + weno->m_mapped = integer_data[0]; + weno->m_borges = integer_data[1]; + weno->m_yc = integer_data[2]; + weno->m_no_limiting = integer_data[3]; + weno->m_eps = real_data [0]; + weno->m_p = real_data [1]; + weno->m_rc = real_data [2]; + weno->m_xi = real_data [3]; + weno->m_tol = real_data [4]; /* WENO weight calculation is hard-coded for p=2, so return error if p != 2 in - * user input file, so that there's no confusion */ - if (weno->p != 2.0) { - if (!mpi->rank && !count) printf("Warning from WENOInitialize(): \"p\" parameter is 2.0. Any other value will be ignored!\n"); + * user input file, so that there'a_s no confusion */ + if (weno->m_p != 2.0) { + if (!mpi->m_rank && !s_count) printf("Warning from WENOInitialize(): \"p\" parameter is 2.0. Any other value will be ignored!\n"); } - weno->offset = NULL; - weno->w1 = NULL; - weno->w2 = NULL; - weno->w3 = NULL; + weno->m_offset = NULL; + weno->m_w1 = NULL; + weno->m_w2 = NULL; + weno->m_w3 = NULL; - weno->offset = (int*) calloc (ndims,sizeof(int)); + weno->m_offset = (int*) calloc (ndims,sizeof(int)); int dir,d; for (dir=0; diroffset[dir] = 0; + weno->m_offset[dir] = 0; for (d=0; ddim_local[i]+1 : solver->dim_local[i] ); - weno->offset[dir] += size; + size *= ( i==d ? solver->m_dim_local[i]+1 : solver->m_dim_local[i] ); + weno->m_offset[dir] += size; } } @@ -148,16 +148,16 @@ int WENOInitialize( for (d=0; ddim_local[i]+1 : solver->dim_local[i] ); + size *= ( i==d ? solver->m_dim_local[i]+1 : solver->m_dim_local[i] ); total_size += size; } - weno->size = total_size; + weno->m_size = total_size; - if ((!strcmp(type,_CHARACTERISTIC_)) && (nvars > 1)) + if ((!strcmp(a_type,_CHARACTERISTIC_)) && (nvars > 1)) solver->SetInterpLimiterVar = WENOFifthOrderCalculateWeightsChar; else { #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { solver->SetInterpLimiterVar = gpuWENOFifthOrderCalculateWeights; } else { #endif @@ -174,32 +174,32 @@ int WENOInitialize( for (d=0; doffset, + weno->m_offset, d, solver, mpi); - count++; + s_count++; #if defined(HAVE_CUDA) - if (solver->use_gpu) { - //gpuMalloc((void**)&weno->gpu_offset, solver->ndims*sizeof(int)); - gpuMalloc((void**)&weno->w1, 4*total_size*sizeof(double)); - gpuMalloc((void**)&weno->w2, 4*total_size*sizeof(double)); - gpuMalloc((void**)&weno->w3, 4*total_size*sizeof(double)); - - //gpuMemcpy(weno->gpu_offset, weno->offset, solver->ndims*sizeof(int), gpuMemcpyHostToDevice); - gpuMemcpy(weno->w1, tmp_w1, 4*total_size*sizeof(double), gpuMemcpyHostToDevice); - gpuMemcpy(weno->w2, tmp_w2, 4*total_size*sizeof(double), gpuMemcpyHostToDevice); - gpuMemcpy(weno->w3, tmp_w3, 4*total_size*sizeof(double), gpuMemcpyHostToDevice); + if (solver->m_use_gpu) { + //gpuMalloc((void**)&weno->gpu_offset, solver->m_ndims*sizeof(int)); + gpuMalloc((void**)&weno->m_w1, 4*total_size*sizeof(double)); + gpuMalloc((void**)&weno->m_w2, 4*total_size*sizeof(double)); + gpuMalloc((void**)&weno->m_w3, 4*total_size*sizeof(double)); + + //gpuMemcpy(weno->gpu_offset, weno->m_offset, solver->m_ndims*sizeof(int), gpuMemcpyHostToDevice); + gpuMemcpy(weno->m_w1, tmp_w1, 4*total_size*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(weno->m_w2, tmp_w2, 4*total_size*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(weno->m_w3, tmp_w3, 4*total_size*sizeof(double), gpuMemcpyHostToDevice); } else { #endif - weno->w1 = (double*) calloc (4*total_size,sizeof(double)); - weno->w2 = (double*) calloc (4*total_size,sizeof(double)); - weno->w3 = (double*) calloc (4*total_size,sizeof(double)); + weno->m_w1 = (double*) calloc (4*total_size,sizeof(double)); + weno->m_w2 = (double*) calloc (4*total_size,sizeof(double)); + weno->m_w3 = (double*) calloc (4*total_size,sizeof(double)); - _ArrayCopy1D_(tmp_w1, weno->w1, 4*total_size); - _ArrayCopy1D_(tmp_w2, weno->w2, 4*total_size); - _ArrayCopy1D_(tmp_w3, weno->w3, 4*total_size); + _ArrayCopy1D_(tmp_w1, weno->m_w1, 4*total_size); + _ArrayCopy1D_(tmp_w2, weno->m_w2, 4*total_size); + _ArrayCopy1D_(tmp_w3, weno->m_w3, 4*total_size); #if defined(HAVE_CUDA) } #endif diff --git a/src/LimiterFunctions/LimiterGeneralizedMinMod.c b/src/LimiterFunctions/LimiterGeneralizedMinMod.c index 65481a34..a41981ff 100644 --- a/src/LimiterFunctions/LimiterGeneralizedMinMod.c +++ b/src/LimiterFunctions/LimiterGeneralizedMinMod.c @@ -14,10 +14,10 @@ doi:10.1016/0021-9991(79)90145-1 */ double LimiterGeneralizedMinMod ( - double r /*!< Input slope ratio */ + double a_r /*!< Input slope ratio */ ) { double theta = 1.0; - double retval = max(0.0,min3(theta*r,0.5*(1.0+r),theta)); + double retval = max(0.0,min3(theta*a_r,0.5*(1.0+a_r),theta)); return retval; } diff --git a/src/LimiterFunctions/LimiterMinMod.c b/src/LimiterFunctions/LimiterMinMod.c index 020936b7..9ffc4b0b 100644 --- a/src/LimiterFunctions/LimiterMinMod.c +++ b/src/LimiterFunctions/LimiterMinMod.c @@ -14,9 +14,9 @@ doi:10.1146/annurev.fl.18.010186.002005 */ double LimiterMinMod( - double r /*!< Input slope ratio */ + double a_r /*!< Input slope ratio */ ) { - double retval = max(0.0,min(1.0,r)); + double retval = max(0.0,min(1.0,a_r)); return retval; } diff --git a/src/LimiterFunctions/LimiterSuperBee.c b/src/LimiterFunctions/LimiterSuperBee.c index 08ac355b..f0285eab 100644 --- a/src/LimiterFunctions/LimiterSuperBee.c +++ b/src/LimiterFunctions/LimiterSuperBee.c @@ -14,9 +14,9 @@ doi:10.1146/annurev.fl.18.010186.002005 */ double LimiterSuperBee( - double r /*!< Input slope ratio */ + double a_r /*!< Input slope ratio */ ) { - double retval = max3(0, min(2*r,1), min(r,2)); + double retval = max3(0, min(2*a_r,1), min(a_r,2)); return retval; } diff --git a/src/LimiterFunctions/LimiterVanLeer.c b/src/LimiterFunctions/LimiterVanLeer.c index b2778337..8ff2ad59 100644 --- a/src/LimiterFunctions/LimiterVanLeer.c +++ b/src/LimiterFunctions/LimiterVanLeer.c @@ -15,9 +15,9 @@ doi:10.1016/0021-9991(74)90019-9 */ double LimiterVanLeer ( - double r /*!< Input slope ratio */ + double a_r /*!< Input slope ratio */ ) { - double retval = (r+absolute(r)) / (1.0+absolute(r)); + double retval = (a_r+absolute(a_r)) / (1.0+absolute(a_r)); return retval; } diff --git a/src/MPIFunctions/MPIBroadcast.c b/src/MPIFunctions/MPIBroadcast.c index 7e1f7430..04d179a2 100644 --- a/src/MPIFunctions/MPIBroadcast.c +++ b/src/MPIFunctions/MPIBroadcast.c @@ -7,42 +7,42 @@ /*! Broadcast an array of type \a double to all MPI ranks */ int MPIBroadcast_double( - double *x, /*!< array to broadcast to all ranks */ - int size, /*!< size of array to broadcast */ - int root, /*!< rank from which to broadcast */ - void *comm /*!< MPI communicator within which to broadcast */ + double *a_x, /*!< array to broadcast to all ranks */ + int a_size, /*!< size of array to broadcast */ + int a_root, /*!< rank from which to broadcast */ + void *a_comm /*!< MPI communicator within which to broadcast */ ) { #ifndef serial - MPI_Bcast(x,size,MPI_DOUBLE,root,*((MPI_Comm*)comm)); + MPI_Bcast(a_x,a_size,MPI_DOUBLE,a_root,*((MPI_Comm*)a_comm)); #endif return(0); } /*! Broadcast an array of type \a int to all MPI ranks */ int MPIBroadcast_integer( - int *x, /*!< array to broadcast to all ranks */ - int size, /*!< size of array to broadcast */ - int root, /*!< rank from which to broadcast */ - void *comm /*!< MPI communicator within which to broadcast */ + int *a_x, /*!< array to broadcast to all ranks */ + int a_size, /*!< size of array to broadcast */ + int a_root, /*!< rank from which to broadcast */ + void *a_comm /*!< MPI communicator within which to broadcast */ ) { #ifndef serial - MPI_Bcast(x,size,MPI_INT,root,*((MPI_Comm*)comm)); + MPI_Bcast(a_x,a_size,MPI_INT,a_root,*((MPI_Comm*)a_comm)); #endif return(0); } /*! Broadcast an array of type \a char to all MPI ranks */ int MPIBroadcast_character( - char *x, /*!< array to broadcast to all ranks */ - int size, /*!< size of array to broadcast */ - int root, /*!< rank from which to broadcast */ - void *comm /*!< MPI communicator within which to broadcast */ + char *a_x, /*!< array to broadcast to all ranks */ + int a_size, /*!< size of array to broadcast */ + int a_root, /*!< rank from which to broadcast */ + void *a_comm /*!< MPI communicator within which to broadcast */ ) { #ifndef serial - MPI_Bcast(x,size,MPI_CHAR,root,*((MPI_Comm*)comm)); + MPI_Bcast(a_x,a_size,MPI_CHAR,a_root,*((MPI_Comm*)a_comm)); #endif return(0); } diff --git a/src/MPIFunctions/MPICommunicators.c b/src/MPIFunctions/MPICommunicators.c index 341a9298..2a1a6e11 100644 --- a/src/MPIFunctions/MPICommunicators.c +++ b/src/MPIFunctions/MPICommunicators.c @@ -33,34 +33,34 @@ instead of MPI_WORLD. */ int MPICreateCommunicators( - int ndims, /*!< Number of spatial dimensions */ - void *m /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; #ifdef serial - mpi->comm = NULL; + mpi->m_comm = NULL; #else int i,n,color,key; int *ip,*iproc; - mpi->comm = (MPI_Comm*) calloc (ndims, sizeof(MPI_Comm)); - if (ndims == 1) MPI_Comm_dup(mpi->world,mpi->comm); + mpi->m_comm = (MPI_Comm*) calloc (a_ndims, sizeof(MPI_Comm)); + if (a_ndims == 1) MPI_Comm_dup(mpi->m_world,mpi->m_comm); else { - ip = (int*) calloc (ndims-1,sizeof(int)); - iproc = (int*) calloc (ndims-1,sizeof(int)); - for (n=0; nip[i]; - iproc[tick] = mpi->iproc[i]; + ip[tick] = mpi->m_ip[i]; + iproc[tick] = mpi->m_iproc[i]; tick++; } } - _ArrayIndex1D_(ndims-1,iproc,ip,0,color); - key = mpi->ip[n]; - MPI_Comm_split(mpi->world,color,key,&mpi->comm[n]); + _ArrayIndex1D_(a_ndims-1,iproc,ip,0,color); + key = mpi->m_ip[n]; + MPI_Comm_split(mpi->m_world,color,key,&mpi->m_comm[n]); } free(ip); free(iproc); @@ -73,17 +73,17 @@ int MPICreateCommunicators( Free the subcommunicators created in MPICreateCommunicators(). */ int MPIFreeCommunicators( - int ndims, /*!< Number of spatial dimensions */ - void *m /*!< MPI object of type #MPIVariables */ + int a_ndims, /*!< Number of spatial dimensions */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { #ifndef serial - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int n; - for (n=0; ncomm[n]); - free(mpi->comm); - if (mpi->IOParticipant) MPI_Comm_free(&mpi->IOWorld); - MPI_Comm_free(&mpi->world); + for (n=0; nm_comm[n]); + free(mpi->m_comm); + if (mpi->m_IOParticipant) MPI_Comm_free(&mpi->m_IOWorld); + MPI_Comm_free(&mpi->m_world); #endif return(0); } diff --git a/src/MPIFunctions/MPIExchangeBoundaries1D.c b/src/MPIFunctions/MPIExchangeBoundaries1D.c index 6404ae9e..0490ae05 100644 --- a/src/MPIFunctions/MPIExchangeBoundaries1D.c +++ b/src/MPIFunctions/MPIExchangeBoundaries1D.c @@ -30,46 +30,46 @@ + Rank 9 will exchange data with ranks 2 and 16, and fill in its ghost points. */ int MPIExchangeBoundaries1D( - void *m, /*!< MPI object of type MPIVariables */ - double *x, /*!< The 1D array for which to exchange data */ - int N, /*!< Size of the array */ - int ghosts, /*!< Number of ghost points */ - int dir, /*!< Spatial dimension corresponding to the 1D array */ - int ndims /*!< Number of spatial dimensions in the simulation */ + void *a_m, /*!< MPI object of type MPIVariables */ + double *a_x, /*!< The 1D array for which to exchange data */ + int a_N, /*!< Size of the array */ + int a_ghosts, /*!< Number of ghost points */ + int a_dir, /*!< Spatial dimension corresponding to the 1D array */ + int a_ndims /*!< Number of spatial dimensions in the simulation */ ) { #ifndef serial - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int i; - int *ip = mpi->ip; - int *iproc = mpi->iproc; + int *ip = mpi->m_ip; + int *iproc = mpi->m_iproc; int non = 0; /* number of neighbours */ int neighbor_rank[2] = {-1,-1}; - int nip[ndims]; + int nip[a_ndims]; /* each process has 2 neighbors (except at physical boundaries) */ /* calculate the rank of these neighbors (-1 -> none) */ - _ArrayCopy1D_(ip,nip,ndims); nip[dir]--; - if (ip[dir] == 0) neighbor_rank[0] = -1; - else neighbor_rank[0] = MPIRank1D(ndims,iproc,nip); - _ArrayCopy1D_(ip,nip,ndims); nip[dir]++; - if (ip[dir] == (iproc[dir]-1))neighbor_rank[1] = -1; - else neighbor_rank[1] = MPIRank1D(ndims,iproc,nip); + _ArrayCopy1D_(ip,nip,a_ndims); nip[a_dir]--; + if (ip[a_dir] == 0) neighbor_rank[0] = -1; + else neighbor_rank[0] = MPIRank1D(a_ndims,iproc,nip); + _ArrayCopy1D_(ip,nip,a_ndims); nip[a_dir]++; + if (ip[a_dir] == (iproc[a_dir]-1))neighbor_rank[1] = -1; + else neighbor_rank[1] = MPIRank1D(a_ndims,iproc,nip); /* Allocate send and receive buffers */ - double sendbuf[2][ghosts], recvbuf[2][ghosts]; + double sendbuf[2][a_ghosts], recvbuf[2][a_ghosts]; /* count number of neighbors and copy data to send buffers */ non = 0; if (neighbor_rank[0] != -1) { non++; - for (i = 0; i < ghosts; i++) sendbuf[0][i] = x[i+ghosts]; + for (i = 0; i < a_ghosts; i++) sendbuf[0][i] = a_x[i+a_ghosts]; } if (neighbor_rank[1] != -1) { non++; - for (i = 0; i < ghosts; i++) sendbuf[1][i] = x[i+N]; + for (i = 0; i < a_ghosts; i++) sendbuf[1][i] = a_x[i+a_N]; } MPI_Request requests[2*non]; MPI_Status statuses[2*non]; @@ -77,13 +77,13 @@ int MPIExchangeBoundaries1D( /* exchange the data */ int tick = 0; if (neighbor_rank[0]!= -1) { - MPI_Irecv(recvbuf[0],ghosts,MPI_DOUBLE,neighbor_rank[0],1631,mpi->world,&requests[tick]); - MPI_Isend(sendbuf[0],ghosts,MPI_DOUBLE,neighbor_rank[0],1631,mpi->world,&requests[tick+non]); + MPI_Irecv(recvbuf[0],a_ghosts,MPI_DOUBLE,neighbor_rank[0],1631,mpi->m_world,&requests[tick]); + MPI_Isend(sendbuf[0],a_ghosts,MPI_DOUBLE,neighbor_rank[0],1631,mpi->m_world,&requests[tick+non]); tick++; } if (neighbor_rank[1] != -1) { - MPI_Irecv(recvbuf[1],ghosts,MPI_DOUBLE,neighbor_rank[1],1631,mpi->world,&requests[tick]); - MPI_Isend(sendbuf[1],ghosts,MPI_DOUBLE,neighbor_rank[1],1631,mpi->world,&requests[tick+non]); + MPI_Irecv(recvbuf[1],a_ghosts,MPI_DOUBLE,neighbor_rank[1],1631,mpi->m_world,&requests[tick]); + MPI_Isend(sendbuf[1],a_ghosts,MPI_DOUBLE,neighbor_rank[1],1631,mpi->m_world,&requests[tick+non]); tick++; } @@ -91,8 +91,8 @@ int MPIExchangeBoundaries1D( MPI_Waitall(2*non,requests,statuses); /* copy received data to ghost points */ - if (neighbor_rank[0] != -1) for (i = 0; i < ghosts; i++) x[i] = recvbuf[0][i]; - if (neighbor_rank[1] != -1) for (i = 0; i < ghosts; i++) x[i+N+ghosts] = recvbuf[1][i]; + if (neighbor_rank[0] != -1) for (i = 0; i < a_ghosts; i++) a_x[i] = recvbuf[0][i]; + if (neighbor_rank[1] != -1) for (i = 0; i < a_ghosts; i++) a_x[i+a_N+a_ghosts] = recvbuf[1][i]; #endif return(0); diff --git a/src/MPIFunctions/MPIExchangeBoundariesnD.c b/src/MPIFunctions/MPIExchangeBoundariesnD.c index 8d470c34..962d172f 100644 --- a/src/MPIFunctions/MPIExchangeBoundariesnD.c +++ b/src/MPIFunctions/MPIExchangeBoundariesnD.c @@ -40,133 +40,133 @@ so \a var [4*10+2] = \a var [42]. */ int MPIExchangeBoundariesnD( - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables (vector components) at each grid location */ - int *dim, /*!< Integer array whose elements are the local size along each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - void *m, /*!< MPI object of type #MPIVariables */ - double *var /*!< The array for which to exchange data and fill in ghost points */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables (vector components) at each grid location */ + int *a_dim, /*!< Integer array whose elements are the local size along each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_var /*!< The array for which to exchange data and fill in ghost points */ ) { #ifndef serial - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int d; - int *ip = mpi->ip; - int *iproc = mpi->iproc; - int *bcflag = mpi->bcperiodic; + int *ip = mpi->m_ip; + int *iproc = mpi->m_iproc; + int *bcflag = mpi->m_bcperiodic; - int neighbor_rank[2*ndims], nip[ndims], index[ndims], bounds[ndims], offset[ndims]; - MPI_Request rcvreq[2*ndims], sndreq[2*ndims]; - for (d=0; d<2*ndims; d++) rcvreq[d] = sndreq[d] = MPI_REQUEST_NULL; + int neighbor_rank[2*a_ndims], nip[a_ndims], index[a_ndims], bounds[a_ndims], offset[a_ndims]; + MPI_Request rcvreq[2*a_ndims], sndreq[2*a_ndims]; + for (d=0; d<2*a_ndims; d++) rcvreq[d] = sndreq[d] = MPI_REQUEST_NULL; - /* each process has 2*ndims neighbors (except at non-periodic physical boundaries) */ + /* each process has 2*a_ndims neighbors (except at non-periodic physical boundaries) */ /* calculate the rank of these neighbors (-1 -> none) */ - for (d = 0; d < ndims; d++) { - _ArrayCopy1D_(ip,nip,ndims); + for (d = 0; d < a_ndims; d++) { + _ArrayCopy1D_(ip,nip,a_ndims); if (ip[d] == 0) nip[d] = iproc[d]-1; else nip[d]--; if ((ip[d] == 0) && (!bcflag[d])) neighbor_rank[2*d] = -1; - else neighbor_rank[2*d] = MPIRank1D(ndims,iproc,nip); - _ArrayCopy1D_(ip,nip,ndims); + else neighbor_rank[2*d] = MPIRank1D(a_ndims,iproc,nip); + _ArrayCopy1D_(ip,nip,a_ndims); if (ip[d] == (iproc[d]-1)) nip[d] = 0; else nip[d]++; if ((ip[d] == (iproc[d]-1)) && (!bcflag[d])) neighbor_rank[2*d+1] = -1; - else neighbor_rank[2*d+1] = MPIRank1D(ndims,iproc,nip); + else neighbor_rank[2*d+1] = MPIRank1D(a_ndims,iproc,nip); } /* calculate dimensions of each of the send-receive regions */ - double *sendbuf = mpi->sendbuf; - double *recvbuf = mpi->recvbuf; - int stride = mpi->maxbuf; - int bufdim[ndims]; - for (d = 0; d < ndims; d++) { + double *sendbuf = mpi->m_sendbuf; + double *recvbuf = mpi->m_recvbuf; + int stride = mpi->m_maxbuf; + int bufdim[a_ndims]; + for (d = 0; d < a_ndims; d++) { bufdim[d] = 1; int i; - for (i = 0; i < ndims; i++) { - if (i == d) bufdim[d] *= ghosts; - else bufdim[d] *= dim[i]; + for (i = 0; i < a_ndims; i++) { + if (i == d) bufdim[d] *= a_ghosts; + else bufdim[d] *= a_dim[i]; } } /* post the receive requests */ - for (d = 0; d < ndims; d++) { + for (d = 0; d < a_ndims; d++) { if (neighbor_rank[2*d ] != -1) { - MPI_Irecv(&recvbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1630, - mpi->world,&rcvreq[2*d]); + MPI_Irecv(&recvbuf[2*d*stride],bufdim[d]*a_nvars,MPI_DOUBLE,neighbor_rank[2*d ],1630, + mpi->m_world,&rcvreq[2*d]); } if (neighbor_rank[2*d+1] != -1) { - MPI_Irecv(&recvbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1631, - mpi->world,&rcvreq[2*d+1]); + MPI_Irecv(&recvbuf[(2*d+1)*stride],bufdim[d]*a_nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1631, + mpi->m_world,&rcvreq[2*d+1]); } } /* count number of neighbors and copy data to send buffers */ - for (d = 0; d < ndims; d++) { - _ArrayCopy1D_(dim,bounds,ndims); bounds[d] = ghosts; + for (d = 0; d < a_ndims; d++) { + _ArrayCopy1D_(a_dim,bounds,a_ndims); bounds[d] = a_ghosts; if (neighbor_rank[2*d] != -1) { - _ArraySetValue_(offset,ndims,0); - int done = 0; _ArraySetValue_(index,ndims,0); + _ArraySetValue_(offset,a_ndims,0); + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p1); - int p2; _ArrayIndex1D_(ndims,bounds,index,0,p2); - _ArrayCopy1D_((var+nvars*p1),(sendbuf+2*d*stride+nvars*p2),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1DWO_(a_ndims,a_dim,index,offset,a_ghosts,p1); + int p2; _ArrayIndex1D_(a_ndims,bounds,index,0,p2); + _ArrayCopy1D_((a_var+a_nvars*p1),(sendbuf+2*d*stride+a_nvars*p2),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } } if (neighbor_rank[2*d+1] != -1) { - _ArraySetValue_(offset,ndims,0);offset[d] = dim[d]-ghosts; - int done = 0; _ArraySetValue_(index,ndims,0); + _ArraySetValue_(offset,a_ndims,0);offset[d] = a_dim[d]-a_ghosts; + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p1); - int p2; _ArrayIndex1D_(ndims,bounds,index,0,p2); - _ArrayCopy1D_((var+nvars*p1),(sendbuf+(2*d+1)*stride+nvars*p2),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1DWO_(a_ndims,a_dim,index,offset,a_ghosts,p1); + int p2; _ArrayIndex1D_(a_ndims,bounds,index,0,p2); + _ArrayCopy1D_((a_var+a_nvars*p1),(sendbuf+(2*d+1)*stride+a_nvars*p2),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } } } /* send the data */ - for (d = 0; d < ndims; d++) { + for (d = 0; d < a_ndims; d++) { if (neighbor_rank[2*d ] != -1) { - MPI_Isend(&sendbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1631, - mpi->world,&sndreq[2*d]); + MPI_Isend(&sendbuf[2*d*stride],bufdim[d]*a_nvars,MPI_DOUBLE,neighbor_rank[2*d ],1631, + mpi->m_world,&sndreq[2*d]); } if (neighbor_rank[2*d+1] != -1) { - MPI_Isend(&sendbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1630, - mpi->world,&sndreq[2*d+1]); + MPI_Isend(&sendbuf[(2*d+1)*stride],bufdim[d]*a_nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1630, + mpi->m_world,&sndreq[2*d+1]); } } /* Wait till data is done received */ - MPI_Status status_arr[2*ndims]; - MPI_Waitall(2*ndims,rcvreq,status_arr); + MPI_Status status_arr[2*a_ndims]; + MPI_Waitall(2*a_ndims,rcvreq,status_arr); /* copy received data to ghost points */ - for (d = 0; d < ndims; d++) { - _ArrayCopy1D_(dim,bounds,ndims); bounds[d] = ghosts; + for (d = 0; d < a_ndims; d++) { + _ArrayCopy1D_(a_dim,bounds,a_ndims); bounds[d] = a_ghosts; if (neighbor_rank[2*d] != -1) { - _ArraySetValue_(offset,ndims,0); offset[d] = -ghosts; - int done = 0; _ArraySetValue_(index,ndims,0); + _ArraySetValue_(offset,a_ndims,0); offset[d] = -a_ghosts; + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p1); - int p2; _ArrayIndex1D_(ndims,bounds,index,0,p2); - _ArrayCopy1D_((recvbuf+2*d*stride+nvars*p2),(var+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1DWO_(a_ndims,a_dim,index,offset,a_ghosts,p1); + int p2; _ArrayIndex1D_(a_ndims,bounds,index,0,p2); + _ArrayCopy1D_((recvbuf+2*d*stride+a_nvars*p2),(a_var+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } } if (neighbor_rank[2*d+1] != -1) { - _ArraySetValue_(offset,ndims,0); offset[d] = dim[d]; - int done = 0; _ArraySetValue_(index,ndims,0); + _ArraySetValue_(offset,a_ndims,0); offset[d] = a_dim[d]; + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p1); - int p2; _ArrayIndex1D_(ndims,bounds,index,0,p2); - _ArrayCopy1D_((recvbuf+(2*d+1)*stride+nvars*p2),(var+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1DWO_(a_ndims,a_dim,index,offset,a_ghosts,p1); + int p2; _ArrayIndex1D_(a_ndims,bounds,index,0,p2); + _ArrayCopy1D_((recvbuf+(2*d+1)*stride+a_nvars*p2),(a_var+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } } } /* Wait till send requests are complete before freeing memory */ - MPI_Waitall(2*ndims,sndreq,status_arr); + MPI_Waitall(2*a_ndims,sndreq,status_arr); #endif return(0); diff --git a/src/MPIFunctions/MPIExchangeBoundariesnD_GPU.cu b/src/MPIFunctions/MPIExchangeBoundariesnD_GPU.cu index d3eca823..6275eece 100644 --- a/src/MPIFunctions/MPIExchangeBoundariesnD_GPU.cu +++ b/src/MPIFunctions/MPIExchangeBoundariesnD_GPU.cu @@ -167,10 +167,10 @@ extern "C" int gpuMPIExchangeBoundariesnD( MPIVariables *mpi = (MPIVariables*) m; int d; - int *ip = mpi->ip; - int *iproc = mpi->iproc; - int *bcflag = mpi->bcperiodic; - int *cpu_dim = mpi->cpu_dim; + int *ip = mpi->m_ip; + int *iproc = mpi->m_iproc; + int *bcflag = mpi->m_bcperiodic; + int *cpu_dim = mpi->m_cpu_dim; int neighbor_rank[2*ndims], nip[ndims], bounds[ndims]; MPI_Request rcvreq[2*ndims], sndreq[2*ndims]; @@ -192,9 +192,9 @@ extern "C" int gpuMPIExchangeBoundariesnD( } /* calculate dimensions of each of the send-receive regions */ - double *sendbuf = mpi->gpu_sendbuf; - double *recvbuf = mpi->gpu_recvbuf; - int stride = mpi->maxbuf; + double *sendbuf = mpi->m_gpu_sendbuf; + double *recvbuf = mpi->m_gpu_recvbuf; + int stride = mpi->m_maxbuf; int bufdim[ndims]; for (d = 0; d < ndims; d++) { bufdim[d] = 1; @@ -209,11 +209,11 @@ extern "C" int gpuMPIExchangeBoundariesnD( for (d = 0; d < ndims; d++) { if (neighbor_rank[2*d ] != -1) { MPI_Irecv(&recvbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1630, - mpi->world,&rcvreq[2*d]); + mpi->m_world,&rcvreq[2*d]); } if (neighbor_rank[2*d+1] != -1) { MPI_Irecv(&recvbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1631, - mpi->world,&rcvreq[2*d+1]); + mpi->m_world,&rcvreq[2*d+1]); } } @@ -237,11 +237,11 @@ extern "C" int gpuMPIExchangeBoundariesnD( for (d = 0; d < ndims; d++) { if (neighbor_rank[2*d ] != -1) { MPI_Isend(&sendbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1631, - mpi->world,&sndreq[2*d]); + mpi->m_world,&sndreq[2*d]); } if (neighbor_rank[2*d+1] != -1) { MPI_Isend(&sendbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1630, - mpi->world,&sndreq[2*d+1]); + mpi->m_world,&sndreq[2*d+1]); } } @@ -446,10 +446,10 @@ extern "C" int gpuMPIExchangeBoundariesnD( MPIVariables *mpi = (MPIVariables*) m; int d; - int *ip = mpi->ip; - int *iproc = mpi->iproc; - int *bcflag = mpi->bcperiodic; - int *cpu_dim = mpi->cpu_dim; + int *ip = mpi->m_ip; + int *iproc = mpi->m_iproc; + int *bcflag = mpi->m_bcperiodic; + int *cpu_dim = mpi->m_cpu_dim; int size = 1; for (d=0; dgpu_sendbuf; - double *recvbuf = mpi->gpu_recvbuf; - int stride = mpi->maxbuf; + double *sendbuf = mpi->m_gpu_sendbuf; + double *recvbuf = mpi->m_gpu_recvbuf; + int stride = mpi->m_maxbuf; int bufdim[ndims]; for (d = 0; d < ndims; d++) { bufdim[d] = 1; @@ -489,11 +489,11 @@ extern "C" int gpuMPIExchangeBoundariesnD( for (d = 0; d < ndims; d++) { if (neighbor_rank[2*d ] != -1) { MPI_Irecv(&recvbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1630, - mpi->world,&rcvreq[2*d]); + mpi->m_world,&rcvreq[2*d]); } if (neighbor_rank[2*d+1] != -1) { MPI_Irecv(&recvbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1631, - mpi->world,&rcvreq[2*d+1]); + mpi->m_world,&rcvreq[2*d+1]); } } @@ -519,11 +519,11 @@ extern "C" int gpuMPIExchangeBoundariesnD( for (d = 0; d < ndims; d++) { if (neighbor_rank[2*d ] != -1) { MPI_Isend(&sendbuf[2*d*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d ],1631, - mpi->world,&sndreq[2*d]); + mpi->m_world,&sndreq[2*d]); } if (neighbor_rank[2*d+1] != -1) { MPI_Isend(&sendbuf[(2*d+1)*stride],bufdim[d]*nvars,MPI_DOUBLE,neighbor_rank[2*d+1],1630, - mpi->world,&sndreq[2*d+1]); + mpi->m_world,&sndreq[2*d+1]); } } diff --git a/src/MPIFunctions/MPIGatherArray1D.c b/src/MPIFunctions/MPIGatherArray1D.c index 8fab24df..d6521d82 100644 --- a/src/MPIFunctions/MPIGatherArray1D.c +++ b/src/MPIFunctions/MPIGatherArray1D.c @@ -24,64 +24,64 @@ and overwrites that portion with the latest data sent. */ int MPIGatherArray1D( - void *m, /*!< MPI object of type #MPIVariables */ - double *xg, /*!< Global 1D array (must be preallocated) without ghost points */ - double *x, /*!< Local 1D array to be gathered */ - int istart, /*!< Starting index (global) of this rank's portion of the array */ - int iend, /*!< Ending index (global) of this rank's portion of the array + 1 */ - int N_local, /*!< Local size of the array */ - int ghosts /*!< Number of ghost points */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_xg, /*!< Global 1D array (must be preallocated) without ghost points */ + double *a_x, /*!< Local 1D array to be gathered */ + int a_istart, /*!< Starting index (global) of this rank's portion of the array */ + int a_iend, /*!< Ending index (global) of this rank's portion of the array + 1 */ + int a_N_local, /*!< Local size of the array */ + int a_ghosts /*!< Number of ghost points */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int ierr = 0; - /* xg should be non-null only on root */ - if (mpi->rank && xg) { + /* a_xg should be non-null only on root */ + if (mpi->m_rank && a_xg) { fprintf(stderr,"Error in MPIGatherArray1D(): global array exists on non-root processors (rank %d).\n", - mpi->rank); + mpi->m_rank); ierr = 1; } - if ((!mpi->rank) && (!xg)) { + if ((!mpi->m_rank) && (!a_xg)) { fprintf(stderr,"Error in MPIGatherArray1D(): global array is not allocated on root processor.\n"); ierr = 1; } /* create and copy data to a buffer to send to the root process */ - double *buffer = (double*) calloc (N_local,sizeof(double)); - _ArrayCopy1D_((x+ghosts),(buffer),N_local); + double *buffer = (double*) calloc (a_N_local,sizeof(double)); + _ArrayCopy1D_((a_x+a_ghosts),(buffer),a_N_local); - if (!mpi->rank) { + if (!mpi->m_rank) { #ifndef serial MPI_Status status; #endif int proc; - for (proc = 0; proc < mpi->nproc; proc++) { + for (proc = 0; proc < mpi->m_nproc; proc++) { /* Find out the domain limits for each process */ int is,ie; if (proc) { #ifndef serial - MPI_Recv(&is,1,MPI_INT,proc,1442,mpi->world,&status); - MPI_Recv(&ie,1,MPI_INT,proc,1443,mpi->world,&status); + MPI_Recv(&is,1,MPI_INT,proc,1442,mpi->m_world,&status); + MPI_Recv(&ie,1,MPI_INT,proc,1443,mpi->m_world,&status); #endif - } else { is = istart; ie = iend; } + } else { is = a_istart; ie = a_iend; } int size = ie - is; if (proc) { #ifndef serial double *recvbuf = (double*) calloc (size,sizeof(double)); - MPI_Recv(recvbuf,size,MPI_DOUBLE,proc,1916,mpi->world,&status); - _ArrayCopy1D_((recvbuf),(xg+is),size); + MPI_Recv(recvbuf,size,MPI_DOUBLE,proc,1916,mpi->m_world,&status); + _ArrayCopy1D_((recvbuf),(a_xg+is),size); free(recvbuf); #endif - } else _ArrayCopy1D_(buffer,(xg+is),size); + } else _ArrayCopy1D_(buffer,(a_xg+is),size); } } else { #ifndef serial /* Meanwhile, on other processes - send stuff to root */ - MPI_Send(&istart,1 ,MPI_INT ,0,1442,mpi->world); - MPI_Send(&iend ,1 ,MPI_INT ,0,1443,mpi->world); - MPI_Send(buffer ,N_local,MPI_DOUBLE,0,1916,mpi->world); + MPI_Send(&a_istart,1 ,MPI_INT ,0,1442,mpi->m_world); + MPI_Send(&a_iend ,1 ,MPI_INT ,0,1443,mpi->m_world); + MPI_Send(buffer ,a_N_local,MPI_DOUBLE,0,1916,mpi->m_world); #endif } diff --git a/src/MPIFunctions/MPIGatherArraynD.c b/src/MPIFunctions/MPIGatherArraynD.c index 6f76abf0..c0673920 100644 --- a/src/MPIFunctions/MPIGatherArraynD.c +++ b/src/MPIFunctions/MPIGatherArraynD.c @@ -19,73 +19,73 @@ + The global array must be allocated only on rank 0. On other ranks, it must be NULL. */ int MPIGatherArraynD( - int ndims, /*!< Number of spatial dimensions */ - void *m, /*!< MPI object of type #MPIVariables */ - double *xg, /*!< Global array (preallocated) without ghost points */ - double *x, /*!< Local array */ - int *dim_global, /*!< Integer array with elements as global size along each spatial dimension */ - int *dim_local, /*!< Integer array with elements as local size along each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - int nvars /*!< Number of variables (vector components) */ + int a_ndims, /*!< Number of spatial dimensions */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_xg, /*!< Global array (preallocated) without ghost points */ + double *a_x, /*!< Local array */ + int *a_dim_global, /*!< Integer array with elements as global size along each spatial dimension */ + int *a_dim_local, /*!< Integer array with elements as local size along each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + int a_nvars /*!< Number of variables (vector components) */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int d, size; _DECLARE_IERR_; - int is[ndims], ie[ndims], index[ndims], bounds[ndims]; + int is[a_ndims], ie[a_ndims], index[a_ndims], bounds[a_ndims]; - /* xg should be non-null only on root */ - if (mpi->rank && xg) { + /* a_xg should be non-null only on root */ + if (mpi->m_rank && a_xg) { fprintf(stderr,"Error in MPIGatherArraynD(): global array exists on non-root processors (rank %d).\n", - mpi->rank); + mpi->m_rank); return(1); } - if ((!mpi->rank) && (!xg)) { + if ((!mpi->m_rank) && (!a_xg)) { fprintf(stderr,"Error in MPIGatherArraynD(): global array is not allocated on root processor.\n"); return(1); } - /* calculate total size of local domain (w/o ghosts) */ + /* calculate total size of local domain (w/o a_ghosts) */ size = 1; - for (d = 0; d < ndims; d++) size *= dim_local[d]; + for (d = 0; d < a_ndims; d++) size *= a_dim_local[d]; /* create and copy data to send to root process */ - double *buffer = (double*) calloc (size*nvars, sizeof(double)); - IERR ArrayCopynD(ndims,x,buffer,dim_local,ghosts,0,index,nvars); CHECKERR(ierr); + double *buffer = (double*) calloc (size*a_nvars, sizeof(double)); + IERR ArrayCopynD(a_ndims,a_x,buffer,a_dim_local,a_ghosts,0,index,a_nvars); CHECKERR(ierr); - if (!mpi->rank) { + if (!mpi->m_rank) { int proc; - for (proc = 0; proc < mpi->nproc; proc++) { + for (proc = 0; proc < mpi->m_nproc; proc++) { int d,done,size; /* Find out the domain limits for each process */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); CHECKERR(ierr); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); CHECKERR(ierr); size = 1; - for (d=0; dworld,&status); - int done = 0; _ArraySetValue_(index,ndims,0); + double *recvbuf = (double*) calloc (size*a_nvars, sizeof(double)); + MPI_Recv(recvbuf,size*a_nvars,MPI_DOUBLE,proc,1902,mpi->m_world,&status); + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,bounds,index,0,p1); - int p2; _ArrayIndex1DWO_(ndims,dim_global,index,is,0,p2); - _ArrayCopy1D_((recvbuf+nvars*p1),(xg+nvars*p2),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1D_(a_ndims,bounds,index,0,p1); + int p2; _ArrayIndex1DWO_(a_ndims,a_dim_global,index,is,0,p2); + _ArrayCopy1D_((recvbuf+a_nvars*p1),(a_xg+a_nvars*p2),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } free(recvbuf); #endif } else { - done = 0; _ArraySetValue_(index,ndims,0); + done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,bounds,index,0,p1); - int p2; _ArrayIndex1DWO_(ndims,dim_global,index,is,0,p2); - _ArrayCopy1D_((buffer+nvars*p1),(xg+nvars*p2),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1D_(a_ndims,bounds,index,0,p1); + int p2; _ArrayIndex1DWO_(a_ndims,a_dim_global,index,is,0,p2); + _ArrayCopy1D_((buffer+a_nvars*p1),(a_xg+a_nvars*p2),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } } } @@ -93,7 +93,7 @@ int MPIGatherArraynD( } else { #ifndef serial /* Meanwhile, on other processes */ - MPI_Send(buffer,size*nvars,MPI_DOUBLE,0,1902,mpi->world); + MPI_Send(buffer,size*a_nvars,MPI_DOUBLE,0,1902,mpi->m_world); #endif } @@ -113,81 +113,81 @@ int MPIGatherArraynD( */ int MPIGatherArraynDwGhosts( - int ndims, /*!< Number of spatial dimensions */ - void *m, /*!< MPI object of type #MPIVariables */ - double *xg, /*!< Global array (preallocated) with ghost points */ - double *x, /*!< Local array */ - int *dim_global, /*!< Integer array with elements as global size along each spatial dimension */ - int *dim_local, /*!< Integer array with elements as local size along each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - int nvars /*!< Number of variables (vector components) */ + int a_ndims, /*!< Number of spatial dimensions */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_xg, /*!< Global array (preallocated) with ghost points */ + double *a_x, /*!< Local array */ + int *a_dim_global, /*!< Integer array with elements as global size along each spatial dimension */ + int *a_dim_local, /*!< Integer array with elements as local size along each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + int a_nvars /*!< Number of variables (vector components) */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int d, size; _DECLARE_IERR_; /* do an exchange to make sure interior/periodic ghost points are filled with consistent values */ - IERR MPIExchangeBoundariesnD(ndims, nvars, dim_local, ghosts, mpi, x); + IERR MPIExchangeBoundariesnD(a_ndims, a_nvars, a_dim_local, a_ghosts, mpi, a_x); - int is[ndims], ie[ndims], index[ndims], bounds[ndims]; - int dim_global_wghosts[ndims]; - for (d = 0; d < ndims; d++) dim_global_wghosts[d] = dim_global[d] + 2*ghosts; + int is[a_ndims], ie[a_ndims], index[a_ndims], bounds[a_ndims]; + int dim_global_wghosts[a_ndims]; + for (d = 0; d < a_ndims; d++) dim_global_wghosts[d] = a_dim_global[d] + 2*a_ghosts; - /* xg should be non-null only on root */ - if (mpi->rank && xg) { + /* a_xg should be non-null only on root */ + if (mpi->m_rank && a_xg) { fprintf(stderr,"Error in MPIGatherArraynD(): global array exists on non-root processors (rank %d).\n", - mpi->rank); + mpi->m_rank); return(1); } - if ((!mpi->rank) && (!xg)) { + if ((!mpi->m_rank) && (!a_xg)) { fprintf(stderr,"Error in MPIGatherArraynD(): global array is not allocated on root processor.\n"); return(1); } - /* calculate total size of local domain (w/ ghosts) */ + /* calculate total size of local domain (w/ a_ghosts) */ size = 1; - for (d = 0; d < ndims; d++) size *= (dim_local[d]+2*ghosts); + for (d = 0; d < a_ndims; d++) size *= (a_dim_local[d]+2*a_ghosts); /* create and copy data (incl. ghost points) to send to root process */ - double *buffer = (double*) calloc (size*nvars, sizeof(double)); - _ArrayCopy1D_(x, buffer, size*nvars); + double *buffer = (double*) calloc (size*a_nvars, sizeof(double)); + _ArrayCopy1D_(a_x, buffer, size*a_nvars); - if (!mpi->rank) { + if (!mpi->m_rank) { int proc; - for (proc = 0; proc < mpi->nproc; proc++) { + for (proc = 0; proc < mpi->m_nproc; proc++) { int d,done; /* Find out the domain limits for each process */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); CHECKERR(ierr); - for (d=0; dworld,&status); - int done = 0; _ArraySetValue_(index,ndims,0); + double *recvbuf = (double*) calloc (size*a_nvars, sizeof(double)); + MPI_Recv(recvbuf,size*a_nvars,MPI_DOUBLE,proc,1902,mpi->m_world,&status); + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,bounds,index,ghosts,p1); - int p2; _ArrayIndex1DWO_(ndims,dim_global,index,is,ghosts,p2); - _ArrayCopy1D_((recvbuf+nvars*p1),(xg+nvars*p2),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1D_(a_ndims,bounds,index,a_ghosts,p1); + int p2; _ArrayIndex1DWO_(a_ndims,a_dim_global,index,is,a_ghosts,p2); + _ArrayCopy1D_((recvbuf+a_nvars*p1),(a_xg+a_nvars*p2),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } free(recvbuf); #endif } else { - done = 0; _ArraySetValue_(index,ndims,0); + done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,bounds,index,ghosts,p1); - int p2; _ArrayIndex1DWO_(ndims,dim_global,index,is,ghosts,p2); - _ArrayCopy1D_((buffer+nvars*p1),(xg+nvars*p2),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1D_(a_ndims,bounds,index,a_ghosts,p1); + int p2; _ArrayIndex1DWO_(a_ndims,a_dim_global,index,is,a_ghosts,p2); + _ArrayCopy1D_((buffer+a_nvars*p1),(a_xg+a_nvars*p2),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } } } @@ -195,7 +195,7 @@ int MPIGatherArraynDwGhosts( } else { #ifndef serial /* Meanwhile, on other processes */ - MPI_Send(buffer,size*nvars,MPI_DOUBLE,0,1902,mpi->world); + MPI_Send(buffer,size*a_nvars,MPI_DOUBLE,0,1902,mpi->m_world); #endif } diff --git a/src/MPIFunctions/MPIGetArrayDatanD.c b/src/MPIFunctions/MPIGetArrayDatanD.c index 200cc4a7..d6b88f32 100644 --- a/src/MPIFunctions/MPIGetArrayDatanD.c +++ b/src/MPIFunctions/MPIGetArrayDatanD.c @@ -19,42 +19,42 @@ spatial dimension n, and ie[n] is the end index (+1) along spatial dimension n. */ int MPIGetArrayDatanD( - double *xbuf, /*!< preallocated memory on destination rank to hold the received data */ - double *x, /*!< local array of which a part is needed */ - int *source, /*!< MPI rank of the source */ - int *dest, /*!< MPI rank of the destination */ - int *limits, /*!< Integer array (of size 2*ndims) with the start and end indices + double *a_xbuf, /*!< preallocated memory on destination rank to hold the received data */ + double *a_x, /*!< local array of which a part is needed */ + int *a_source, /*!< MPI rank of the source */ + int *a_dest, /*!< MPI rank of the destination */ + int *a_limits, /*!< Integer array (of size 2*a_ndims) with the start and end indices along each spatial dimension of the desired portion of the array */ - int *dim, /*!< Integer array whose elements are the local size of x in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - int ndims, /*!< Number of spatial dimensions */ - int nvars, /*!< Number of variables (vector components) */ - void *m /*!< MPI object of type #MPIVariables */ + int *a_dim, /*!< Integer array whose elements are the local size of x in each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_nvars, /*!< Number of variables (vector components) */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int d; - int source_rank = MPIRank1D(ndims,mpi->iproc,source); - int dest_rank = MPIRank1D(ndims,mpi->iproc,dest ); + int source_rank = MPIRank1D(a_ndims,mpi->m_iproc,a_source); + int dest_rank = MPIRank1D(a_ndims,mpi->m_iproc,a_dest ); - int is[ndims], ie[ndims], index[ndims], bounds[ndims], size; + int is[a_ndims], ie[a_ndims], index[a_ndims], bounds[a_ndims], size; size = 1; - for (d=0; drank == source_rank) { - double *buf = (double*) calloc (size*nvars, sizeof(double)); - int done = 0; _ArraySetValue_(index,ndims,0); + if (mpi->m_rank == source_rank) { + double *buf = (double*) calloc (size*a_nvars, sizeof(double)); + int done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,bounds,index,0,p1); - int p2; _ArrayIndex1DWO_(ndims,dim,index,is,ghosts,p2); - _ArrayCopy1D_((x+nvars*p2),(buf+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,bounds,index,done); + int p1; _ArrayIndex1D_(a_ndims,bounds,index,0,p1); + int p2; _ArrayIndex1DWO_(a_ndims,a_dim,index,is,a_ghosts,p2); + _ArrayCopy1D_((a_x+a_nvars*p2),(buf+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,bounds,index,done); } - MPI_Send(buf,size*nvars,MPI_DOUBLE,dest_rank,2211,mpi->world); + MPI_Send(buf,size*a_nvars,MPI_DOUBLE,dest_rank,2211,mpi->m_world); free(buf); - } else if (mpi->rank == dest_rank) { + } else if (mpi->m_rank == dest_rank) { MPI_Status status; - MPI_Recv(xbuf,size*nvars,MPI_DOUBLE,source_rank,2211,mpi->world,&status); + MPI_Recv(a_xbuf,size*a_nvars,MPI_DOUBLE,source_rank,2211,mpi->m_world,&status); } else { fprintf(stderr,"Error in MPIGetArrayData3D(): Process %d shouldn't have entered this function.\n", - mpi->rank); + mpi->m_rank); return(1); } #endif diff --git a/src/MPIFunctions/MPIGetFilename.c b/src/MPIFunctions/MPIGetFilename.c index 25fd5fda..21efed9b 100644 --- a/src/MPIFunctions/MPIGetFilename.c +++ b/src/MPIFunctions/MPIGetFilename.c @@ -17,26 +17,26 @@ corresponding to the MPI rank. */ void MPIGetFilename( - char *root, /*!< filename root */ - void *c, /*!< MPI communicator */ - char *filename /*!< filename */ + char *a_root, /*!< filename root */ + void *a_c, /*!< MPI communicator */ + char *a_filename /*!< filename */ ) { char tail[_MAX_STRING_SIZE_]=""; int rank; #ifndef serial - MPI_Comm comm = *((MPI_Comm*)c); + MPI_Comm comm = *((MPI_Comm*)a_c); MPI_Comm_rank(comm,&rank); #else rank = 0; #endif GetStringFromInteger(rank,tail,4); - strcpy(filename,""); - strcat(filename,root); - strcat(filename,"." ); - strcat(filename,tail); + strcpy(a_filename,""); + strcat(a_filename,a_root); + strcat(a_filename,"." ); + strcat(a_filename,tail); return; } diff --git a/src/MPIFunctions/MPIIOGroups.c b/src/MPIFunctions/MPIIOGroups.c index 72ce2ec3..1ccc0b2b 100644 --- a/src/MPIFunctions/MPIIOGroups.c +++ b/src/MPIFunctions/MPIIOGroups.c @@ -34,15 +34,15 @@ multiple of the specified number of I/O groups (#MPIVariables::N_IORanks), then only 1 rank is used. */ -int MPICreateIOGroups(void *m /*!< MPI object of type #MPIVariables*/) +int MPICreateIOGroups(void *a_m /*!< MPI object of type #MPIVariables*/) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; #ifndef serial - int nproc = mpi->nproc; - int rank = mpi->rank; - int N_IORanks = mpi->N_IORanks; + int nproc = mpi->m_nproc; + int rank = mpi->m_rank; + int N_IORanks = mpi->m_N_IORanks; int GroupSize; if (nproc%N_IORanks==0) GroupSize = nproc/N_IORanks; @@ -60,25 +60,25 @@ int MPICreateIOGroups(void *m /*!< MPI object of type #MPIVariables*/) GroupSize = nproc; } - mpi->CommGroup = rank/GroupSize; - mpi->IORank = mpi->CommGroup * GroupSize; + mpi->m_CommGroup = rank/GroupSize; + mpi->m_IORank = mpi->m_CommGroup * GroupSize; /* set flag for whether this rank does file I/O */ - if (rank == mpi->IORank) mpi->IOParticipant = 1; - else mpi->IOParticipant = 0; + if (rank == mpi->m_IORank) mpi->m_IOParticipant = 1; + else mpi->m_IOParticipant = 0; /* save the first and last process of this group */ - mpi->GroupStartRank = mpi->IORank; - mpi->GroupEndRank = (mpi->CommGroup+1)*GroupSize; + mpi->m_GroupStartRank = mpi->m_IORank; + mpi->m_GroupEndRank = (mpi->m_CommGroup+1)*GroupSize; /* create a new communicator with the IO participants */ int i,*FileIORanks; MPI_Group WorldGroup, IOGroup; FileIORanks = (int*) calloc (N_IORanks,sizeof(int)); for (i=0; iworld,&WorldGroup); + MPI_Comm_group(mpi->m_world,&WorldGroup); MPI_Group_incl(WorldGroup,N_IORanks,FileIORanks,&IOGroup); - MPI_Comm_create(mpi->world,IOGroup,&mpi->IOWorld); + MPI_Comm_create(mpi->m_world,IOGroup,&mpi->m_IOWorld); MPI_Group_free(&IOGroup); MPI_Group_free(&WorldGroup); free(FileIORanks); diff --git a/src/MPIFunctions/MPILocalDomainLimits.c b/src/MPIFunctions/MPILocalDomainLimits.c index 1990c838..b2376b77 100644 --- a/src/MPIFunctions/MPILocalDomainLimits.c +++ b/src/MPIFunctions/MPILocalDomainLimits.c @@ -16,27 +16,27 @@ (i=start; i<=end; i++). */ int MPILocalDomainLimits( - int ndims, /*!< Number of spatial dimensions */ - int p, /*!< MPI rank */ - void *m, /*!< MPI object of type #MPIVariables */ - int *dim_global, /*!< Integer array with elements as global size in each spatial dimension */ - int *is, /*!< Integer array whose elements will contain the starting index of the local domain on rank \a p */ - int *ie /*!< Integer array whose elements will contain the ending index of the local domain on rank \a p */ + int a_ndims, /*!< Number of spatial dimensions */ + int a_p, /*!< MPI rank */ + void *a_m, /*!< MPI object of type #MPIVariables */ + int *a_dim_global, /*!< Integer array with elements as global size in each spatial dimension */ + int *a_is, /*!< Integer array whose elements will contain the starting index of the local domain on rank \a p */ + int *a_ie /*!< Integer array whose elements will contain the ending index of the local domain on rank \a p */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int i; _DECLARE_IERR_; - int ip[ndims]; - IERR MPIRanknD(ndims,p,mpi->iproc,ip); CHECKERR(ierr); + int ip[a_ndims]; + IERR MPIRanknD(a_ndims,a_p,mpi->m_iproc,ip); CHECKERR(ierr); - for (i=0; iiproc[i],root ); - isize = MPIPartition1D(dim_global[i],mpi->iproc[i],ip[i]); - if (is) is[i] = ip[i]*imax_local; - if (ie) ie[i] = ip[i]*imax_local + isize; + imax_local = MPIPartition1D(a_dim_global[i],mpi->m_iproc[i],root ); + isize = MPIPartition1D(a_dim_global[i],mpi->m_iproc[i],ip[i]); + if (a_is) a_is[i] = ip[i]*imax_local; + if (a_ie) a_ie[i] = ip[i]*imax_local + isize; } return(0); } diff --git a/src/MPIFunctions/MPIMax.c b/src/MPIFunctions/MPIMax.c index ce95335b..b674b905 100644 --- a/src/MPIFunctions/MPIMax.c +++ b/src/MPIFunctions/MPIMax.c @@ -13,17 +13,17 @@ in \a var on all the MPI ranks in the given communicator. */ int MPIMax_integer( - int *global, /*!< array to contain the global maximums */ - int *var, /*!< the local array */ - int size, /*!< size of the local array */ - void *comm /*!< MPI communicator */ + int *a_global, /*!< array to contain the global maximums */ + int *a_var, /*!< the local array */ + int a_size, /*!< size of the local array */ + void *a_comm /*!< MPI communicator */ ) { #ifdef serial int i; - for (i = 0; i < size; i++) global[i] = var[i]; + for (i = 0; i < a_size; i++) a_global[i] = a_var[i]; #else - MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_INT,MPI_MAX,*((MPI_Comm*)comm)); + MPI_Allreduce((a_var==a_global?MPI_IN_PLACE:a_var),a_global,a_size,MPI_INT,MPI_MAX,*((MPI_Comm*)a_comm)); #endif return(0); } @@ -36,17 +36,17 @@ int MPIMax_integer( in \a var on all the MPI ranks in the given communicator. */ int MPIMax_double( - double *global, /*!< array to contain the global maximums */ - double *var, /*!< the local array */ - int size, /*!< size of the local array */ - void *comm /*!< MPI communicator */ + double *a_global, /*!< array to contain the global maximums */ + double *a_var, /*!< the local array */ + int a_size, /*!< size of the local array */ + void *a_comm /*!< MPI communicator */ ) { #ifdef serial int i; - for (i = 0; i < size; i++) global[i] = var[i]; + for (i = 0; i < a_size; i++) a_global[i] = a_var[i]; #else - MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_DOUBLE,MPI_MAX,*((MPI_Comm*)comm)); + MPI_Allreduce((a_var==a_global?MPI_IN_PLACE:a_var),a_global,a_size,MPI_DOUBLE,MPI_MAX,*((MPI_Comm*)a_comm)); #endif return(0); } diff --git a/src/MPIFunctions/MPIMin.c b/src/MPIFunctions/MPIMin.c index 26129da6..fbe2a5ef 100644 --- a/src/MPIFunctions/MPIMin.c +++ b/src/MPIFunctions/MPIMin.c @@ -13,17 +13,17 @@ in \a var on all the MPI ranks in the given communicator. */ int MPIMin_integer( - int *global, /*!< array to contain the global minimums */ - int *var, /*!< the local array */ - int size, /*!< size of the local array */ - void *comm /*!< MPI communicator */ + int *a_global, /*!< array to contain the global minimums */ + int *a_var, /*!< the local array */ + int a_size, /*!< size of the local array */ + void *a_comm /*!< MPI communicator */ ) { #ifdef serial int i; - for (i = 0; i < size; i++) global[i] = var[i]; + for (i = 0; i < a_size; i++) a_global[i] = a_var[i]; #else - MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_INT,MPI_MIN,*((MPI_Comm*)comm)); + MPI_Allreduce((a_var==a_global?MPI_IN_PLACE:a_var),a_global,a_size,MPI_INT,MPI_MIN,*((MPI_Comm*)a_comm)); #endif return(0); } @@ -36,17 +36,17 @@ int MPIMin_integer( in \a var on all the MPI ranks in the given communicator. */ int MPIMin_double( - double *global, /*!< array to contain the global minimums */ - double *var, /*!< the local array */ - int size, /*!< size of the local array */ - void *comm /*!< MPI communicator */ + double *a_global, /*!< array to contain the global minimums */ + double *a_var, /*!< the local array */ + int a_size, /*!< size of the local array */ + void *a_comm /*!< MPI communicator */ ) { #ifdef serial int i; - for (i = 0; i < size; i++) global[i] = var[i]; + for (i = 0; i < a_size; i++) a_global[i] = a_var[i]; #else - MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_DOUBLE,MPI_MIN,*((MPI_Comm*)comm)); + MPI_Allreduce((a_var==a_global?MPI_IN_PLACE:a_var),a_global,a_size,MPI_DOUBLE,MPI_MIN,*((MPI_Comm*)a_comm)); #endif return(0); } diff --git a/src/MPIFunctions/MPIPartition1D.c b/src/MPIFunctions/MPIPartition1D.c index 337564be..cd8c0e01 100644 --- a/src/MPIFunctions/MPIPartition1D.c +++ b/src/MPIFunctions/MPIPartition1D.c @@ -12,16 +12,16 @@ computes the size of the local part of the 1D array on \a rank. */ int MPIPartition1D( - int nglobal, /*!< Global size */ - int nproc, /*!< Total number of ranks */ - int rank /*!< Rank */ + int a_nglobal, /*!< Global size */ + int a_nproc, /*!< Total number of ranks */ + int a_rank /*!< Rank */ ) { int nlocal; - if (nglobal%nproc == 0) nlocal = nglobal/nproc; + if (a_nglobal%a_nproc == 0) nlocal = a_nglobal/a_nproc; else { - if (rank == nproc-1) nlocal = nglobal/nproc + nglobal%nproc; - else nlocal = nglobal/nproc; + if (a_rank == a_nproc-1) nlocal = a_nglobal/a_nproc + a_nglobal%a_nproc; + else nlocal = a_nglobal/a_nproc; } return(nlocal); } diff --git a/src/MPIFunctions/MPIPartitionArray1D.c b/src/MPIFunctions/MPIPartitionArray1D.c index 5bf0f562..e7c3b22f 100644 --- a/src/MPIFunctions/MPIPartitionArray1D.c +++ b/src/MPIFunctions/MPIPartitionArray1D.c @@ -23,54 +23,54 @@ normal to one corresponding to \a x ). */ int MPIPartitionArray1D( - void *m, /*!< MPI object of type #MPIVariables */ - double *xg, /*!< Global 1D array (must be preallocated) without ghost points */ - double *x, /*!< Local 1D array to be gathered */ - int istart, /*!< Starting index (global) of this rank's portion of the array */ - int iend, /*!< Ending index (global) of this rank's portion of the array + 1 */ - int N_local, /*!< Local size of the array */ - int ghosts /*!< Number of ghost points */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_xg, /*!< Global 1D array (must be preallocated) without ghost points */ + double *a_x, /*!< Local 1D array to be gathered */ + int a_istart, /*!< Starting index (global) of this rank's portion of the array */ + int a_iend, /*!< Ending index (global) of this rank's portion of the array + 1 */ + int a_N_local, /*!< Local size of the array */ + int a_ghosts /*!< Number of ghost points */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int ierr = 0; #ifndef serial MPI_Status status; #endif - /* xg should be non-null only on root */ - if (mpi->rank && xg) { + /* a_xg should be non-null only on root */ + if (mpi->m_rank && a_xg) { fprintf(stderr,"Error in MPIPartitionArray1D(): global array exists on non-root processors (rank %d).\n", - mpi->rank); + mpi->m_rank); ierr = 1; } - if ((!mpi->rank) && (!xg)) { + if ((!mpi->m_rank) && (!a_xg)) { fprintf(stderr,"Error in MPIPartitionArray1D(): global array is not allocated on root processor.\n"); ierr = 1; } - if (!mpi->rank) { + if (!mpi->m_rank) { int proc; - for (proc = 0; proc < mpi->nproc; proc++) { + for (proc = 0; proc < mpi->m_nproc; proc++) { /* Find out the domain limits for each process */ int is,ie; if (proc) { #ifndef serial - MPI_Recv(&is,1,MPI_INT,proc,1442,mpi->world,&status); - MPI_Recv(&ie,1,MPI_INT,proc,1443,mpi->world,&status); + MPI_Recv(&is,1,MPI_INT,proc,1442,mpi->m_world,&status); + MPI_Recv(&ie,1,MPI_INT,proc,1443,mpi->m_world,&status); #endif } else { - is = istart; - ie = iend; + is = a_istart; + ie = a_iend; } int size = ie - is; double *buffer = (double*) calloc (size, sizeof(double)); - _ArrayCopy1D_((xg+is),buffer,size); + _ArrayCopy1D_((a_xg+is),buffer,size); if (proc) { #ifndef serial - MPI_Send(buffer,size,MPI_DOUBLE,proc,1539,mpi->world); + MPI_Send(buffer,size,MPI_DOUBLE,proc,1539,mpi->m_world); #endif - } else _ArrayCopy1D_(buffer,x,N_local); + } else _ArrayCopy1D_(buffer,a_x,a_N_local); free(buffer); } @@ -78,11 +78,11 @@ int MPIPartitionArray1D( #ifndef serial /* Meanwhile, on other processes */ /* send local start and end indices to root */ - MPI_Send(&istart,1,MPI_INT,0,1442,mpi->world); - MPI_Send(&iend ,1,MPI_INT,0,1443,mpi->world); - double *buffer = (double*) calloc (N_local, sizeof(buffer)); - MPI_Recv(buffer,N_local,MPI_DOUBLE,0,1539,mpi->world,&status); - _ArrayCopy1D_(buffer,x,N_local); + MPI_Send(&a_istart,1,MPI_INT,0,1442,mpi->m_world); + MPI_Send(&a_iend ,1,MPI_INT,0,1443,mpi->m_world); + double *buffer = (double*) calloc (a_N_local, sizeof(buffer)); + MPI_Recv(buffer,a_N_local,MPI_DOUBLE,0,1539,mpi->m_world,&status); + _ArrayCopy1D_(buffer,a_x,a_N_local); free(buffer); #endif } diff --git a/src/MPIFunctions/MPIPartitionArraynD.c b/src/MPIFunctions/MPIPartitionArraynD.c index bc8d7481..b0bcab8e 100644 --- a/src/MPIFunctions/MPIPartitionArraynD.c +++ b/src/MPIFunctions/MPIPartitionArraynD.c @@ -19,62 +19,62 @@ + The global array must be allocated only on rank 0. On other ranks, it must be NULL. */ int MPIPartitionArraynD( - int ndims, /*!< Number of spatial dimensions */ - void *m, /*!< MPI object of type #MPIVariables */ - double *xg, /*!< Global array (preallocated) without ghost points */ - double *x, /*!< Local array */ - int *dim_global, /*!< Integer array with elements as global size along each spatial dimension */ - int *dim_local, /*!< Integer array with elements as local size along each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - int nvars /*!< Number of variables (vector components) */ + int a_ndims, /*!< Number of spatial dimensions */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_xg, /*!< Global array (preallocated) without ghost points */ + double *a_x, /*!< Local array */ + int *a_dim_global, /*!< Integer array with elements as global size along each spatial dimension */ + int *a_dim_local, /*!< Integer array with elements as local size along each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + int a_nvars /*!< Number of variables (vector components) */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; _DECLARE_IERR_; - int is[ndims], ie[ndims], index[ndims], bounds[ndims]; + int is[a_ndims], ie[a_ndims], index[a_ndims], bounds[a_ndims]; - /* xg should be non-null only on root */ - if (mpi->rank && xg) { + /* a_xg should be non-null only on root */ + if (mpi->m_rank && a_xg) { fprintf(stderr,"Error in MPIPartitionArraynD(): global array exists on non-root processors (rank %d).\n", - mpi->rank); + mpi->m_rank); return(1); } - if ((!mpi->rank) && (!xg)) { + if ((!mpi->m_rank) && (!a_xg)) { fprintf(stderr,"Error in MPIPartitionArraynD(): global array is not allocated on root processor.\n"); return(1); } - if (!mpi->rank) { + if (!mpi->m_rank) { int proc; - for (proc = 0; proc < mpi->nproc; proc++) { + for (proc = 0; proc < mpi->m_nproc; proc++) { int d,done,size; /* Find out the domain limits for each process */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); CHECKERR(ierr); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); CHECKERR(ierr); size = 1; - for (d=0; dworld); + MPI_Send(buffer,size*a_nvars,MPI_DOUBLE,proc,1538,mpi->m_world); #endif } else { - done = 0; _ArraySetValue_(index,ndims,0); + done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,dim_local,index,ghosts,p1); - int p2; _ArrayIndex1D_(ndims,dim_local,index,0,p2); - _ArrayCopy1D_((buffer+nvars*p2),(x+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,dim_local,index,done); + int p1; _ArrayIndex1D_(a_ndims,a_dim_local,index,a_ghosts,p1); + int p2; _ArrayIndex1D_(a_ndims,a_dim_local,index,0,p2); + _ArrayCopy1D_((buffer+a_nvars*p2),(a_x+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,a_dim_local,index,done); } } free(buffer); @@ -85,15 +85,15 @@ int MPIPartitionArraynD( /* Meanwhile, on other processes */ MPI_Status status; int d, done, size; - size = 1; for (d=0; dworld,&status); - done = 0; _ArraySetValue_(index,ndims,0); + size = 1; for (d=0; dm_world,&status); + done = 0; _ArraySetValue_(index,a_ndims,0); while (!done) { - int p1; _ArrayIndex1D_(ndims,dim_local,index,ghosts,p1); - int p2; _ArrayIndex1D_(ndims,dim_local,index,0,p2); - _ArrayCopy1D_((buffer+nvars*p2),(x+nvars*p1),nvars); - _ArrayIncrementIndex_(ndims,dim_local,index,done); + int p1; _ArrayIndex1D_(a_ndims,a_dim_local,index,a_ghosts,p1); + int p2; _ArrayIndex1D_(a_ndims,a_dim_local,index,0,p2); + _ArrayCopy1D_((buffer+a_nvars*p2),(a_x+a_nvars*p1),a_nvars); + _ArrayIncrementIndex_(a_ndims,a_dim_local,index,done); } free(buffer); #endif @@ -112,61 +112,61 @@ int MPIPartitionArraynD( + The global array must be allocated only on rank 0. On other ranks, it must be NULL. */ int MPIPartitionArraynDwGhosts( - int ndims, /*!< Number of spatial dimensions */ - void *m, /*!< MPI object of type #MPIVariables */ - double *xg, /*!< Global array (preallocated) without ghost points */ - double *x, /*!< Local array */ - int *dim_global, /*!< Integer array with elements as global size along each spatial dimension */ - int *dim_local, /*!< Integer array with elements as local size along each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - int nvars /*!< Number of variables (vector components) */ + int a_ndims, /*!< Number of spatial dimensions */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_xg, /*!< Global array (preallocated) without ghost points */ + double *a_x, /*!< Local array */ + int *a_dim_global, /*!< Integer array with elements as global size along each spatial dimension */ + int *a_dim_local, /*!< Integer array with elements as local size along each spatial dimension */ + int a_ghosts, /*!< Number of ghost points */ + int a_nvars /*!< Number of variables (vector components) */ ) { - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int d; _DECLARE_IERR_; - int is[ndims], ie[ndims], index[ndims], bounds[ndims]; - int dim_global_wghosts[ndims]; - for (d = 0; d < ndims; d++) dim_global_wghosts[d] = dim_global[d] + 2*ghosts; + int is[a_ndims], ie[a_ndims], index[a_ndims], bounds[a_ndims]; + int dim_global_wghosts[a_ndims]; + for (d = 0; d < a_ndims; d++) dim_global_wghosts[d] = a_dim_global[d] + 2*a_ghosts; - /* xg should be non-null only on root */ - if (mpi->rank && xg) { + /* a_xg should be non-null only on root */ + if (mpi->m_rank && a_xg) { fprintf(stderr,"Error in MPIPartitionArraynD(): global array exists on non-root processors (rank %d).\n", - mpi->rank); + mpi->m_rank); return(1); } - if ((!mpi->rank) && (!xg)) { + if ((!mpi->m_rank) && (!a_xg)) { fprintf(stderr,"Error in MPIPartitionArraynD(): global array is not allocated on root processor.\n"); return(1); } - if (!mpi->rank) { + if (!mpi->m_rank) { int proc; - for (proc = 0; proc < mpi->nproc; proc++) { + for (proc = 0; proc < mpi->m_nproc; proc++) { int done,size; /* Find out the domain limits for each process */ - IERR MPILocalDomainLimits(ndims,proc,mpi,dim_global,is,ie); CHECKERR(ierr); + IERR MPILocalDomainLimits(a_ndims,proc,mpi,a_dim_global,is,ie); CHECKERR(ierr); size = 1; - for (d=0; dworld); + MPI_Send(buffer,size*a_nvars,MPI_DOUBLE,proc,1538,mpi->m_world); #endif } else { - done = 0; _ArraySetValue_(index,ndims,0); - _ArrayCopy1D_(buffer, x, size*nvars); + done = 0; _ArraySetValue_(index,a_ndims,0); + _ArrayCopy1D_(buffer, a_x, size*a_nvars); } free(buffer); } @@ -176,10 +176,10 @@ int MPIPartitionArraynDwGhosts( /* Meanwhile, on other processes */ MPI_Status status; int done, size; - size = 1; for (d=0; dworld,&status); - _ArrayCopy1D_(buffer, x, size*nvars); + size = 1; for (d=0; dm_world,&status); + _ArrayCopy1D_(buffer, a_x, size*a_nvars); free(buffer); #endif } diff --git a/src/MPIFunctions/MPIRank1D.c b/src/MPIFunctions/MPIRank1D.c index 792e9d91..f2f97924 100644 --- a/src/MPIFunctions/MPIRank1D.c +++ b/src/MPIFunctions/MPIRank1D.c @@ -24,15 +24,15 @@ */ int MPIRank1D( - int ndims, /*!< Number of spatial dimensions */ - int *iproc, /*!< Integer array whose elements are the number of MPI ranks along each dimension */ - int *ip /*!< Integer array whose elements are the rank of this process along each dimension */ + int a_ndims, /*!< Number of spatial dimensions */ + int *a_iproc, /*!< Integer array whose elements are the number of MPI ranks along each dimension */ + int *a_ip /*!< Integer array whose elements are the rank of this process along each dimension */ ) { int i,rank = 0, term = 1; - for (i=0; i=0; i--) { - term /= iproc[i]; - ip[i] = rank/term; - rank -= ip[i]*term; + for (i=0; i=0; i--) { + term /= a_iproc[i]; + a_ip[i] = a_rank/term; + a_rank -= a_ip[i]*term; } return(0); } diff --git a/src/MPIFunctions/MPISum.c b/src/MPIFunctions/MPISum.c index 830bbf9f..d01c64e1 100644 --- a/src/MPIFunctions/MPISum.c +++ b/src/MPIFunctions/MPISum.c @@ -14,17 +14,17 @@ in \a var on all the MPI ranks in the given communicator. */ int MPISum_integer( - int *global, /*!< array to contain the global sums */ - int *var, /*!< the local array */ - int size, /*!< size of the local array */ - void *comm /*!< MPI communicator */ + int *a_global, /*!< array to contain the global sums */ + int *a_var, /*!< the local array */ + int a_size, /*!< size of the local array */ + void *a_comm /*!< MPI communicator */ ) { #ifdef serial int i; - for (i = 0; i < size; i++) global[i] = var[i]; + for (i = 0; i < a_size; i++) a_global[i] = a_var[i]; #else - MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_INT,MPI_SUM,*((MPI_Comm*)comm)); + MPI_Allreduce((a_var==a_global?MPI_IN_PLACE:a_var),a_global,a_size,MPI_INT,MPI_SUM,*((MPI_Comm*)a_comm)); #endif return(0); } @@ -37,17 +37,17 @@ int MPISum_integer( in \a var on all the MPI ranks in the given communicator. */ int MPISum_double( - double *global, /*!< array to contain the global sums */ - double *var, /*!< the local array */ - int size, /*!< size of the local array */ - void *comm /*!< MPI communicator */ + double *a_global, /*!< array to contain the global sums */ + double *a_var, /*!< the local array */ + int a_size, /*!< size of the local array */ + void *a_comm /*!< MPI communicator */ ) { #ifdef serial int i; - for (i = 0; i < size; i++) global[i] = var[i]; + for (i = 0; i < a_size; i++) a_global[i] = a_var[i]; #else - MPI_Allreduce((var==global?MPI_IN_PLACE:var),global,size,MPI_DOUBLE,MPI_SUM,*((MPI_Comm*)comm)); + MPI_Allreduce((a_var==a_global?MPI_IN_PLACE:a_var),a_global,a_size,MPI_DOUBLE,MPI_SUM,*((MPI_Comm*)a_comm)); #endif return(0); } diff --git a/src/MathFunctions/FillGhostCells.c b/src/MathFunctions/FillGhostCells.c index 6cfee196..c01bbc60 100644 --- a/src/MathFunctions/FillGhostCells.c +++ b/src/MathFunctions/FillGhostCells.c @@ -14,7 +14,7 @@ from the other side of the domain. Otherwise, the interior data is extrapolated by a 4th order polynomial (assuming uniform grid spacing). */ -void fillGhostCells( const int* const a_dim, /*!< grid dimensions of solution */ +void FillGhostCells( const int* const a_dim, /*!< grid dimensions of solution */ const int a_ngpt, /*!< number of ghost cells */ double* const a_u, /*!< solution array */ const int a_nvars, /*!< number of vector components of the solution */ @@ -114,15 +114,15 @@ void fillGhostCells( const int* const a_dim, /*!< grid dimensions of soluti double alpha = - (double) (a_ngpt - index[d]); double c0 = -((-2.0 + alpha)*(-1.0 + alpha)*alpha)/6.0; - double c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; - double c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; + double s_c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; + double s_c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; double c3 = (alpha*(-1.0 + alpha*alpha))/6.0; for (int v = 0; v < a_nvars; v++) { a_u[p_gpt*a_nvars+v] = c0 * a_u[p_int_0*a_nvars+v] - + c1 * a_u[p_int_1*a_nvars+v] - + c2 * a_u[p_int_2*a_nvars+v] + + s_c1 * a_u[p_int_1*a_nvars+v] + + s_c2 * a_u[p_int_2*a_nvars+v] + c3 * a_u[p_int_3*a_nvars+v]; } @@ -157,15 +157,15 @@ void fillGhostCells( const int* const a_dim, /*!< grid dimensions of soluti double alpha = - (double) (index[d]+1); double c0 = -((-2.0 + alpha)*(-1.0 + alpha)*alpha)/6.0; - double c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; - double c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; + double s_c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; + double s_c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; double c3 = (alpha*(-1.0 + alpha*alpha))/6.0; for (int v = 0; v < a_nvars; v++) { a_u[p_gpt*a_nvars+v] = c0 * a_u[p_int_0*a_nvars+v] - + c1 * a_u[p_int_1*a_nvars+v] - + c2 * a_u[p_int_2*a_nvars+v] + + s_c1 * a_u[p_int_1*a_nvars+v] + + s_c2 * a_u[p_int_2*a_nvars+v] + c3 * a_u[p_int_3*a_nvars+v]; } diff --git a/src/MathFunctions/FindInterval.c b/src/MathFunctions/FindInterval.c index 0047805a..326b5a8e 100644 --- a/src/MathFunctions/FindInterval.c +++ b/src/MathFunctions/FindInterval.c @@ -17,30 +17,30 @@ Note: This function handles 1-dimensional intervals and grids only. */ void FindInterval( - double a, /*!< Lower bound of interval */ - double b, /*!< Upper bound of interval */ - double *x, /*!< Array of spatial coordinates representing a grid */ - int N, /*!< Number of grid points / size of x */ - int *imin, /*!< Lowest grid index within [a,b] */ - int *imax /*!< Highest grid index within [a,b] */ + double a_a, /*!< Lower bound of interval */ + double a_b, /*!< Upper bound of interval */ + double *a_x, /*!< Array of spatial coordinates representing a grid */ + int a_N, /*!< Number of grid points / size of x */ + int *a_imin, /*!< Lowest grid index within [a_a,b] */ + int *a_imax /*!< Highest grid index within [a_a,b] */ ) { int i; - *imax = -1; - *imin = N; + *a_imax = -1; + *a_imin = a_N; - double min_dx = x[1] - x[0]; - for (i = 2; i < N; i++) { - double dx = x[i] - x[i-1]; + double min_dx = a_x[1] - a_x[0]; + for (i = 2; i < a_N; i++) { + double dx = a_x[i] - a_x[i-1]; if (dx < min_dx) min_dx = dx; } double tol = 1e-10 * min_dx; - for (i = 0; i < N; i++) { - if (x[i] <= (b+tol)) *imax = i+1; + for (i = 0; i < a_N; i++) { + if (a_x[i] <= (a_b+tol)) *a_imax = i+1; } - for (i = N-1; i > -1; i--) { - if (x[i] >= (a-tol)) *imin = i; + for (i = a_N-1; i > -1; i--) { + if (a_x[i] >= (a_a-tol)) *a_imin = i; } return; diff --git a/src/MathFunctions/InterpolateGlobalnDVar.c b/src/MathFunctions/InterpolateGlobalnDVar.c index 29779d7b..e5ec7b80 100644 --- a/src/MathFunctions/InterpolateGlobalnDVar.c +++ b/src/MathFunctions/InterpolateGlobalnDVar.c @@ -10,13 +10,13 @@ #include /*! Is the input number an integer power of 2? */ -static int isPowerOfTwo(int x) +static int isPowerOfTwo(int a_x) { - if (x == 0) return 0; + if (a_x == 0) return 0; - while (x > 1) { - if (x%2 != 0) return 0; - x /= 2; + while (a_x > 1) { + if (a_x%2 != 0) return 0; + a_x /= 2; } return 1; } @@ -64,19 +64,19 @@ static int coarsen1D( const int* const a_dim_src, /*!< Grid size of source da } /* set interpolation coefficients depending on desired order */ - double c0, c1, c2, c3, c4, c5; + double c0, s_c1, s_c2, c3, c4, c5; // if (a_interp_order == 2) { // c0 = c5 = 0.0; -// c1 = c4 = 0.0; -// c2 = c3 = 0.5; +// s_c1 = c4 = 0.0; +// s_c2 = c3 = 0.5; // } else if (a_interp_order == 4) { // c0 = c5 = 0.0; -// c1 = c4 = -1.0/16.0; -// c2 = c3 = 9.0/16.0; +// s_c1 = c4 = -1.0/16.0; +// s_c2 = c3 = 9.0/16.0; // } else if (a_interp_order == 6) { c0 = c5 = 3.0/256.0; - c1 = c4 = -25.0/256.0; - c2 = c3 = 150.0/256.0; + s_c1 = c4 = -25.0/256.0; + s_c2 = c3 = 150.0/256.0; // } else { // fprintf(stderr,"Invalid value of interpolation order!\n"); // return 1; @@ -135,8 +135,8 @@ static int coarsen1D( const int* const a_dim_src, /*!< Grid size of source da for (int v = 0; v < a_nvars; v++) { double val = c0 * a_u_src[p_m3*a_nvars+v] - + c1 * a_u_src[p_m2*a_nvars+v] - + c2 * a_u_src[p_m1*a_nvars+v] + + s_c1 * a_u_src[p_m2*a_nvars+v] + + s_c2 * a_u_src[p_m1*a_nvars+v] + c3 * a_u_src[p_p1*a_nvars+v] + c4 * a_u_src[p_p2*a_nvars+v] + c5 * a_u_src[p_p3*a_nvars+v]; @@ -254,25 +254,25 @@ static int refine1D(const int* const a_dim_src, /*!< Grid size of source dat int q5; _ArrayIndex1D_(a_ndims, a_dim_src, index_src5, a_ngpt, q5); /* set interpolation coefficients depending on desired order */ - double c0, c1, c2, c3, c4, c5; + double c0, s_c1, s_c2, c3, c4, c5; // if (a_interp_order == 2) { // c0 = 0.0; -// c1 = 0.0; -// c2 = (1.0-alpha); +// s_c1 = 0.0; +// s_c2 = (1.0-alpha); // c3 = alpha; // c4 = 0.0; // c5 = 0.0; // } else if (a_interp_order == 4) { // c0 = 0.0; -// c1 = -((-2.0 + alpha)*(-1.0 + alpha)*alpha)/6.0; -// c2 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; +// s_c1 = -((-2.0 + alpha)*(-1.0 + alpha)*alpha)/6.0; +// s_c2 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; // c3 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; // c4 = (alpha*(-1.0 + alpha*alpha))/6.0; // c5 = 0.0; // } else if (a_interp_order == 6) { c0 = -((-3.0 + alpha)*(-2.0 + alpha)*(-1.0 + alpha)*alpha*(1.0 + alpha))/120.0; - c1 = ((-3.0 + alpha)*(-2.0 + alpha)*(-1.0 + alpha)*alpha*(2.0 + alpha))/24.0; - c2 = -((-3.0 + alpha)*(-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha)*(2.0 + alpha))/12.0; + s_c1 = ((-3.0 + alpha)*(-2.0 + alpha)*(-1.0 + alpha)*alpha*(2.0 + alpha))/24.0; + s_c2 = -((-3.0 + alpha)*(-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha)*(2.0 + alpha))/12.0; c3 = ((-3.0 + alpha)*(-2.0 + alpha)*alpha*(1.0 + alpha)*(2.0 + alpha))/12.0; c4 = -((-3.0 + alpha)*(-1.0 + alpha)*alpha*(1.0 + alpha)*(2.0 + alpha))/24.0; c5 = (alpha*(4.0 - 5.0*alpha*alpha + alpha*alpha*alpha*alpha))/120.0; @@ -284,8 +284,8 @@ static int refine1D(const int* const a_dim_src, /*!< Grid size of source dat for (int v = 0; v < a_nvars; v++) { a_u_dst[p*a_nvars+v] = c0 * a_u_src[q0*a_nvars+v] - + c1 * a_u_src[q1*a_nvars+v] - + c2 * a_u_src[q2*a_nvars+v] + + s_c1 * a_u_src[q1*a_nvars+v] + + s_c2 * a_u_src[q2*a_nvars+v] + c3 * a_u_src[q3*a_nvars+v] + c4 * a_u_src[q4*a_nvars+v] + c5 * a_u_src[q5*a_nvars+v]; @@ -374,7 +374,7 @@ int InterpolateGlobalnDVar( const int* const a_dim_dst, /*!< grid dimensions to u_to = (double*) calloc (size, sizeof(double)); } - fillGhostCells( dim_from, + FillGhostCells( dim_from, a_ghosts, u_from, a_nvars, diff --git a/src/MathFunctions/TrilinearInterpolation.c b/src/MathFunctions/TrilinearInterpolation.c index af402c4b..6cd88920 100644 --- a/src/MathFunctions/TrilinearInterpolation.c +++ b/src/MathFunctions/TrilinearInterpolation.c @@ -20,34 +20,34 @@ coeffs[7] => xmax,ymax,zmax */ void TrilinearInterpCoeffs( - double xmin, /*!< x-coordinate of the lower-end */ - double xmax, /*!< x-coordinate of the higher-end */ - double ymin, /*!< y-coordinate of the lower-end */ - double ymax, /*!< y-coordinate of the higher-end */ - double zmin, /*!< z-coordinate of the lower-end */ - double zmax, /*!< z-coordinate of the higher-end */ - double x, /*!< x-coordinate of the point to interpolate at */ - double y, /*!< y-coordinate of the point to interpolate at */ - double z, /*!< z-coordinate of the point to interpolate at */ - double *coeffs/*!< array of size 8 (pre-allocated) to store the coefficients in */ + double a_xmin, /*!< x-coordinate of the lower-end */ + double a_xmax, /*!< x-coordinate of the higher-end */ + double a_ymin, /*!< y-coordinate of the lower-end */ + double a_ymax, /*!< y-coordinate of the higher-end */ + double a_zmin, /*!< z-coordinate of the lower-end */ + double a_zmax, /*!< z-coordinate of the higher-end */ + double a_x, /*!< x-coordinate of the point to interpolate at */ + double a_y, /*!< y-coordinate of the point to interpolate at */ + double a_z, /*!< z-coordinate of the point to interpolate at */ + double *a_coeffs/*!< array of size 8 (pre-allocated) to store the coefficients in */ ) { - double vol_inv = 1 / ((xmax-xmin)*(ymax-ymin)*(zmax-zmin)); - double tldx1 = x - xmin; - double tldx2 = xmax - x; - double tldy1 = y - ymin; - double tldy2 = ymax - y; - double tldz1 = z - zmin; - double tldz2 = zmax - z; + double vol_inv = 1 / ((a_xmax-a_xmin)*(a_ymax-a_ymin)*(a_zmax-a_zmin)); + double tldx1 = a_x - a_xmin; + double tldx2 = a_xmax - a_x; + double tldy1 = a_y - a_ymin; + double tldy2 = a_ymax - a_y; + double tldz1 = a_z - a_zmin; + double tldz2 = a_zmax - a_z; - coeffs[0] = tldz2 * tldy2 * tldx2 * vol_inv; - coeffs[1] = tldz2 * tldy2 * tldx1 * vol_inv; - coeffs[2] = tldz2 * tldy1 * tldx2 * vol_inv; - coeffs[3] = tldz2 * tldy1 * tldx1 * vol_inv; - coeffs[4] = tldz1 * tldy2 * tldx2 * vol_inv; - coeffs[5] = tldz1 * tldy2 * tldx1 * vol_inv; - coeffs[6] = tldz1 * tldy1 * tldx2 * vol_inv; - coeffs[7] = tldz1 * tldy1 * tldx1 * vol_inv; + a_coeffs[0] = tldz2 * tldy2 * tldx2 * vol_inv; + a_coeffs[1] = tldz2 * tldy2 * tldx1 * vol_inv; + a_coeffs[2] = tldz2 * tldy1 * tldx2 * vol_inv; + a_coeffs[3] = tldz2 * tldy1 * tldx1 * vol_inv; + a_coeffs[4] = tldz1 * tldy2 * tldx2 * vol_inv; + a_coeffs[5] = tldz1 * tldy2 * tldx1 * vol_inv; + a_coeffs[6] = tldz1 * tldy1 * tldx2 * vol_inv; + a_coeffs[7] = tldz1 * tldy1 * tldx1 * vol_inv; return; } diff --git a/src/PETScFunctions/PetscCleanup.cpp b/src/PETScFunctions/PetscCleanup.cpp index f3574a67..c96d660b 100644 --- a/src/PETScFunctions/PetscCleanup.cpp +++ b/src/PETScFunctions/PetscCleanup.cpp @@ -9,18 +9,18 @@ #include /*! Clean up allocations in the PETSc interface */ -int PetscCleanup(void *obj /*!< Object of type #PETScContext */) +int PetscCleanup(void *a_obj /*!< Object of type #PETScContext */) { - PETScContext *ctxt = (PETScContext*) obj; - for (int i = 0; i < ctxt->globalDOF.size(); i++) { - free(ctxt->globalDOF[i]); + PETScContext *ctxt = (PETScContext*) a_obj; + for (int i = 0; i < ctxt->m_globalDOF.size(); i++) { + free(ctxt->m_globalDOF[i]); } - ctxt->globalDOF.clear(); - for (int i = 0; i < ctxt->points.size(); i++) { - free(ctxt->points[i]); + ctxt->m_globalDOF.clear(); + for (int i = 0; i < ctxt->m_points.size(); i++) { + free(ctxt->m_points[i]); } - ctxt->points.clear(); - if (ctxt->offsets) free(ctxt->offsets); + ctxt->m_points.clear(); + if (ctxt->m_offsets) free(ctxt->m_offsets); return(0); } diff --git a/src/PETScFunctions/PetscComputePreconMatIMEX.cpp b/src/PETScFunctions/PetscComputePreconMatIMEX.cpp index ee0c7953..a62ca9cb 100644 --- a/src/PETScFunctions/PetscComputePreconMatIMEX.cpp +++ b/src/PETScFunctions/PetscComputePreconMatIMEX.cpp @@ -14,12 +14,12 @@ /*! Compute and assemble the preconditioning matrix for the implicit-explicit (IMEX) time integration of the governing equations: Right now, it just calls PetscComputePreconMatImpl() */ -int PetscComputePreconMatIMEX(Mat Pmat, /*!< Preconditioning matrix to construct */ - Vec Y, /*!< Solution vector */ - void *ctxt /*!< Application context */ ) +int PetscComputePreconMatIMEX(Mat a_Pmat, /*!< Preconditioning matrix to construct */ + Vec a_Y, /*!< Solution vector */ + void *a_ctxt /*!< Application context */ ) { /* Same implementation as PetscComputePreconMatImpl() */ - return(PetscComputePreconMatImpl(Pmat,Y,ctxt)); + return(PetscComputePreconMatImpl(a_Pmat,a_Y,a_ctxt)); } #endif diff --git a/src/PETScFunctions/PetscComputePreconMatImpl.cpp b/src/PETScFunctions/PetscComputePreconMatImpl.cpp index 8c88a1e5..4c44c4f3 100644 --- a/src/PETScFunctions/PetscComputePreconMatImpl.cpp +++ b/src/PETScFunctions/PetscComputePreconMatImpl.cpp @@ -56,47 +56,47 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -int PetscComputePreconMatImpl( Mat Pmat, /*!< Preconditioning matrix to construct */ - Vec Y, /*!< Solution vector */ - void *ctxt /*!< Application context */ ) +int PetscComputePreconMatImpl( Mat a_Pmat, /*!< Preconditioning matrix to construct */ + Vec a_Y, /*!< Solution vector */ + void *a_ctxt /*!< Application context */ ) { PetscErrorCode ierr; - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; PetscFunctionBegin; /* initialize preconditioning matrix to zero */ - MatZeroEntries(Pmat); + MatZeroEntries(a_Pmat); /* copy solution from PETSc vector */ for (int ns = 0; ns < nsims; ns++) { - TransferVecFromPETSc( sim[ns].solver.u, - Y, + TransferVecFromPETSc( sim[ns].solver.m_u, + a_Y, context, ns, - context->offsets[ns]); + context->m_offsets[ns]); HyPar* solver( &(sim[ns].solver) ); MPIVariables* mpi( &(sim[ns].mpi) ); - int ndims = solver->ndims, - nvars = solver->nvars, - npoints = solver->npoints_local, - ghosts = solver->ghosts, - *dim = solver->dim_local, - *isPeriodic = solver->isPeriodic, - *points = context->points[ns], + int ndims = solver->m_ndims, + nvars = solver->m_nvars, + npoints = solver->m_npoints_local, + ghosts = solver->m_ghosts, + *dim = solver->m_dim_local, + *isPeriodic = solver->m_is_periodic, + *points = context->m_points[ns], index[ndims],indexL[ndims],indexR[ndims], rows[nvars],cols[nvars]; - double *u = solver->u, - *iblank = solver->iblank, + double *u = solver->m_u, + *iblank = solver->m_iblank, dxinv, values[nvars*nvars]; /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,u,NULL,context->waqt); + solver->ApplyBoundaryConditions(solver,mpi,u,NULL,context->m_waqt); MPIExchangeBoundariesnD(ndims,nvars,dim,ghosts,mpi,u); /* loop through all computational points */ @@ -105,7 +105,7 @@ int PetscComputePreconMatImpl( Mat Pmat, /*!< Preconditioning matrix to const int p = this_point[ndims]; int index[ndims]; _ArrayCopy1D_(this_point,index,ndims); - double iblank = solver->iblank[p]; + double iblank = solver->m_iblank[p]; /* compute the contributions from the hyperbolic flux derivatives along each dimension */ if (solver->JFunction) { @@ -119,33 +119,33 @@ int PetscComputePreconMatImpl( Mat Pmat, /*!< Preconditioning matrix to const int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); int pg, pgL, pgR; - pg = (int) context->globalDOF[ns][p]; - pgL = (int) context->globalDOF[ns][pL]; - pgR = (int) context->globalDOF[ns][pR]; + pg = (int) context->m_globalDOF[ns][p]; + pgL = (int) context->m_globalDOF[ns][pL]; + pgR = (int) context->m_globalDOF[ns][pR]; /* Retrieve 1/delta-x at this grid point */ - _GetCoordinate_(dir,index[dir],dim,ghosts,solver->dxinv,dxinv); + _GetCoordinate_(dir,index[dir],dim,ghosts,solver->m_dxinv,dxinv); /* diagonal element */ for (int v=0; vJFunction(values,(u+nvars*p),solver->physics,dir,nvars,0); + solver->JFunction(values,(u+nvars*p),solver->m_physics,dir,nvars,0); _ArrayScale1D_(values,(dxinv*iblank),(nvars*nvars)); - MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); + MatSetValues(a_Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); /* left neighbor */ if (pgL >= 0) { for (int v=0; vJFunction(values,(u+nvars*pL),solver->physics,dir,nvars,1); + solver->JFunction(values,(u+nvars*pL),solver->m_physics,dir,nvars,1); _ArrayScale1D_(values,(-dxinv*iblank),(nvars*nvars)); - MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); + MatSetValues(a_Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); } /* right neighbor */ if (pgR >= 0) { for (int v=0; vJFunction(values,(u+nvars*pR),solver->physics,dir,nvars,-1); + solver->JFunction(values,(u+nvars*pR),solver->m_physics,dir,nvars,-1); _ArrayScale1D_(values,(-dxinv*iblank),(nvars*nvars)); - MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); + MatSetValues(a_Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); } } } @@ -162,43 +162,43 @@ int PetscComputePreconMatImpl( Mat Pmat, /*!< Preconditioning matrix to const int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); int pg, pgL, pgR; - pg = (int) context->globalDOF[ns][p]; - pgL = (int) context->globalDOF[ns][pL]; - pgR = (int) context->globalDOF[ns][pR]; + pg = (int) context->m_globalDOF[ns][p]; + pgL = (int) context->m_globalDOF[ns][pL]; + pgR = (int) context->m_globalDOF[ns][pR]; /* Retrieve 1/delta-x at this grid point */ - _GetCoordinate_(dir,index[dir],dim,ghosts,solver->dxinv,dxinv); + _GetCoordinate_(dir,index[dir],dim,ghosts,solver->m_dxinv,dxinv); /* diagonal element */ for (int v=0; vKFunction(values,(u+nvars*p),solver->physics,dir,nvars); + solver->KFunction(values,(u+nvars*p),solver->m_physics,dir,nvars); _ArrayScale1D_(values,(-2*dxinv*dxinv*iblank),(nvars*nvars)); - MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); + MatSetValues(a_Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); /* left neighbor */ if (pgL >= 0) { for (int v=0; vKFunction(values,(u+nvars*pL),solver->physics,dir,nvars); + solver->KFunction(values,(u+nvars*pL),solver->m_physics,dir,nvars); _ArrayScale1D_(values,(dxinv*dxinv*iblank),(nvars*nvars)); - MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); + MatSetValues(a_Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); } /* right neighbor */ if (pgR >= 0) { for (int v=0; vKFunction(values,(u+nvars*pR),solver->physics,dir,nvars); + solver->KFunction(values,(u+nvars*pR),solver->m_physics,dir,nvars); _ArrayScale1D_(values,(dxinv*dxinv*iblank),(nvars*nvars)); - MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); + MatSetValues(a_Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); } } } } } - MatAssemblyBegin(Pmat,MAT_FINAL_ASSEMBLY); - MatAssemblyEnd (Pmat,MAT_FINAL_ASSEMBLY); + MatAssemblyBegin(a_Pmat,MAT_FINAL_ASSEMBLY); + MatAssemblyEnd (a_Pmat,MAT_FINAL_ASSEMBLY); - MatShift(Pmat,context->shift); + MatShift(a_Pmat,context->m_shift); PetscFunctionReturn(0); } diff --git a/src/PETScFunctions/PetscCreatePointList.cpp b/src/PETScFunctions/PetscCreatePointList.cpp index 149aa035..1eba630d 100644 --- a/src/PETScFunctions/PetscCreatePointList.cpp +++ b/src/PETScFunctions/PetscCreatePointList.cpp @@ -22,47 +22,47 @@ Note: this list is local, not global. */ -int PetscCreatePointList(void *obj /*!< Object of type #PETScContext */) +int PetscCreatePointList(void *a_obj /*!< Object of type #PETScContext */) { - PETScContext* ctxt = (PETScContext*) obj; - SimulationObject* sim = (SimulationObject*) ctxt->simobj; + PETScContext* ctxt = (PETScContext*) a_obj; + SimulationObject* sim = (SimulationObject*) ctxt->m_simobj; - int nsims = ctxt->nsims; - int ndims = sim[0].solver.ndims; + int nsims = ctxt->m_nsims; + int ndims = sim[0].solver.m_ndims; /* count the number of computational points */ - ctxt->npoints = 0; - ctxt->ndofs = 0; - ctxt->offsets = (int*) calloc(nsims, sizeof(int)); + ctxt->m_npoints = 0; + ctxt->m_ndofs = 0; + ctxt->m_offsets = (int*) calloc(nsims, sizeof(int)); for (int ns = 0; ns < nsims; ns++) { - ctxt->npoints += sim[ns].solver.npoints_local; - ctxt->offsets[ns] = ctxt->ndofs; - ctxt->ndofs += (sim[ns].solver.npoints_local*sim[ns].solver.nvars); + ctxt->m_npoints += sim[ns].solver.m_npoints_local; + ctxt->m_offsets[ns] = ctxt->m_ndofs; + ctxt->m_ndofs += (sim[ns].solver.m_npoints_local*sim[ns].solver.m_nvars); } int nv = ndims+1; - ctxt->points.resize(nsims, nullptr); + ctxt->m_points.resize(nsims, nullptr); for (int ns = 0; ns < nsims; ns++) { - int npoints = sim[ns].solver.npoints_local; - ctxt->points[ns] = (int*) calloc (npoints*nv,sizeof(int)); + int npoints = sim[ns].solver.m_npoints_local; + ctxt->m_points[ns] = (int*) calloc (npoints*nv,sizeof(int)); - const int* const dim( sim[ns].solver.dim_local ); - const int ghosts( sim[ns].solver.ghosts ); + const int* const dim( sim[ns].solver.m_dim_local ); + const int ghosts( sim[ns].solver.m_ghosts ); int done = 0, i = 0; std::vector index(ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims, dim, index.data(), ghosts, p); - _ArrayCopy1D_(index.data(), (ctxt->points[ns]+i*nv), ndims); - (ctxt->points[ns]+i*nv)[ndims] = p; + _ArrayCopy1D_(index.data(), (ctxt->m_points[ns]+i*nv), ndims); + (ctxt->m_points[ns]+i*nv)[ndims] = p; _ArrayIncrementIndex_(ndims,dim,index,done); i++; } if (i != npoints) { - fprintf(stderr,"Error in PetscCreatePointList() on rank %d:\n", sim[ns].mpi.rank); + fprintf(stderr,"Error in PetscCreatePointList() on rank %d:\n", sim[ns].mpi.m_rank); fprintf(stderr,"Inconsistency in point count - %d, %d.\n", i, npoints); return 1; @@ -71,9 +71,9 @@ int PetscCreatePointList(void *obj /*!< Object of type #PETScContext */) int global_npoints; int global_ndofs; - MPISum_integer(&global_npoints,&(ctxt->npoints),1,&sim[0].mpi.world); - MPISum_integer(&global_ndofs,&(ctxt->ndofs),1,&sim[0].mpi.world); - if (!ctxt->rank) { + MPISum_integer(&global_npoints,&(ctxt->m_npoints),1,&sim[0].mpi.m_world); + MPISum_integer(&global_ndofs,&(ctxt->m_ndofs),1,&sim[0].mpi.m_world); + if (!ctxt->m_rank) { printf("PETSc: total number of computational points is %d.\n",global_npoints); printf("PETSc: total number of computational DOFs is %d.\n",global_ndofs); } diff --git a/src/PETScFunctions/PetscError.cpp b/src/PETScFunctions/PetscError.cpp index a60de46b..57e5fc48 100644 --- a/src/PETScFunctions/PetscError.cpp +++ b/src/PETScFunctions/PetscError.cpp @@ -17,46 +17,46 @@ /*! Compute the norms of the error estimate, if the PETSc time integrator has it (for example TSGLEE) */ -int PetscTimeError(TS ts /*!< Time integrator object of PETSc type TS */) +int PetscTimeError(TS a_ts /*!< Time integrator object of PETSc type TS */) { PetscErrorCode ierr; PETScContext* context(nullptr); - ierr = TSGetApplicationContext(ts,&context); CHKERRQ(ierr); + ierr = TSGetApplicationContext(a_ts,&context); CHKERRQ(ierr); if (!context) { fprintf(stderr,"Error in PetscError: Null context!\n"); return(1); } - SimulationObject* sim( (SimulationObject*)context->simobj ); - int nsims( context->nsims ); + SimulationObject* sim( (SimulationObject*)context->m_simobj ); + int nsims( context->m_nsims ); double dt; - ierr = TSGetTimeStep(ts,&dt); CHKERRQ(ierr); + ierr = TSGetTimeStep(a_ts,&dt); CHKERRQ(ierr); TSType time_scheme; - ierr = TSGetType(ts,&time_scheme); CHKERRQ(ierr); + ierr = TSGetType(a_ts,&time_scheme); CHKERRQ(ierr); Vec Y; - ierr = TSGetSolution(ts,&Y); CHKERRQ(ierr); + ierr = TSGetSolution(a_ts,&Y); CHKERRQ(ierr); for (int ns = 0; ns < nsims; ns++) { - TransferVecFromPETSc( sim[ns].solver.u, + TransferVecFromPETSc( sim[ns].solver.m_u, Y, context, ns, - context->offsets[ns] ); + context->m_offsets[ns] ); } if (std::string(time_scheme) == std::string(TSGLEE)) { Vec Z; ierr = VecDuplicate(Y,&Z); CHKERRQ(ierr); - ierr = TSGetTimeError(ts,0,&Z);CHKERRQ(ierr); + ierr = TSGetTimeError(a_ts,0,&Z);CHKERRQ(ierr); for (int ns = 0; ns < nsims; ns++) { - TransferVecFromPETSc( sim[ns].solver.uref, + TransferVecFromPETSc( sim[ns].solver.m_uref, Z, context, ns, - context->offsets[ns] ); + context->m_offsets[ns] ); } ierr = VecDestroy(&Z); CHKERRQ(ierr); @@ -65,44 +65,44 @@ int PetscTimeError(TS ts /*!< Time integrator object of PETSc type TS */) HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - int size = solver->npoints_local_wghosts * solver->nvars; + int size = solver->m_npoints_local_wghosts * solver->m_nvars; double sum = 0.0, global_sum = 0.0, - *Uerr = solver->uref, + *Uerr = solver->m_uref, error[3] = {0,0,0}; /* calculate solution norm for relative errors */ double sol_norm[3] = {0.0,0.0,0.0}; /* L1 */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - sol_norm[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + sol_norm[0] = global_sum/((double)solver->m_npoints_global); /* L2 */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - sol_norm[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + sol_norm[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* Linf */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); sol_norm[2] = global_sum; /* calculate L1 norm of error */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,Uerr); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - error[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,Uerr); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + error[0] = global_sum/((double)solver->m_npoints_global); /* calculate L2 norm of error */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,Uerr); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - error[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,Uerr); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + error[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* calculate Linf norm of error */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,Uerr); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,Uerr); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); error[2] = global_sum; if ( (sol_norm[0] > _MACHINE_ZERO_) @@ -114,7 +114,7 @@ int PetscTimeError(TS ts /*!< Time integrator object of PETSc type TS */) } /* write to file */ - if (!mpi->rank) { + if (!mpi->m_rank) { std::string fname = "glm_err"; if (nsims > 1) { char idx_string[16]; diff --git a/src/PETScFunctions/PetscGlobalDOF.cpp b/src/PETScFunctions/PetscGlobalDOF.cpp index 2bc8df60..1667f18d 100644 --- a/src/PETScFunctions/PetscGlobalDOF.cpp +++ b/src/PETScFunctions/PetscGlobalDOF.cpp @@ -13,50 +13,50 @@ #include #include -static int ApplyPeriodicity( int dir, /*!< Spatial dimension along which to apply periodicity */ - int ndims, /*!< Number of spatial dimensions */ - int *size, /*!< Integer array with the number of grid points in +static int ApplyPeriodicity( int a_dir, /*!< Spatial dimension along which to apply periodicity */ + int a_ndims, /*!< Number of spatial dimensions */ + int *a_size, /*!< Integer array with the number of grid points in each spatial dimension */ - int ghosts, /*!< Number of ghost points */ - double *phi /*!< The array on which to apply the boundary condition */ ) + int a_ghosts, /*!< Number of ghost points */ + double *a_phi /*!< The array on which to apply the boundary condition */ ) { - int bounds[ndims], index1[ndims], index2[ndims], offset[ndims], + int bounds[a_ndims], index1[a_ndims], index2[a_ndims], offset[a_ndims], done, p1 = 0, p2 = 0; - _ArrayCopy1D_(size,bounds,ndims); bounds[dir] = ghosts; + _ArrayCopy1D_(a_size,bounds,a_ndims); bounds[a_dir] = a_ghosts; - done = 0; _ArraySetValue_(index1,ndims,0); + done = 0; _ArraySetValue_(index1,a_ndims,0); while (!done) { - _ArraySetValue_(offset,ndims,0); offset[dir] = -ghosts; - _ArrayIndex1DWO_(ndims,size,index1,offset,ghosts,p1); - _ArrayCopy1D_(index1,index2,ndims); - index2[dir] = index1[dir] + size[dir]-ghosts; - _ArrayIndex1D_(ndims,size,index2,ghosts,p2); - - phi[p1] = phi[p2]; - _ArrayIncrementIndex_(ndims,bounds,index1,done); + _ArraySetValue_(offset,a_ndims,0); offset[a_dir] = -a_ghosts; + _ArrayIndex1DWO_(a_ndims,a_size,index1,offset,a_ghosts,p1); + _ArrayCopy1D_(index1,index2,a_ndims); + index2[a_dir] = index1[a_dir] + a_size[a_dir]-a_ghosts; + _ArrayIndex1D_(a_ndims,a_size,index2,a_ghosts,p2); + + a_phi[p1] = a_phi[p2]; + _ArrayIncrementIndex_(a_ndims,bounds,index1,done); } - done = 0; _ArraySetValue_(index1,ndims,0); + done = 0; _ArraySetValue_(index1,a_ndims,0); while (!done) { - _ArraySetValue_(offset,ndims,0); offset[dir] = size[dir]; - _ArrayIndex1DWO_(ndims,size,index1,offset,ghosts,p1); - _ArrayIndex1D_(ndims,size,index1,ghosts,p2); + _ArraySetValue_(offset,a_ndims,0); offset[a_dir] = a_size[a_dir]; + _ArrayIndex1DWO_(a_ndims,a_size,index1,offset,a_ghosts,p1); + _ArrayIndex1D_(a_ndims,a_size,index1,a_ghosts,p2); - phi[p1] = phi[p2]; - _ArrayIncrementIndex_(ndims,bounds,index1,done); + a_phi[p1] = a_phi[p2]; + _ArrayIncrementIndex_(a_ndims,bounds,index1,done); } return(0); } /*! Compute the global DOF index for all the grid points: The "global DOF index" - is the component number (or block component number for #HyPar::nvars > 1) of + is the component number (or block component number for #HyPar::m_nvars > 1) of a grid point in the global solution vector. It is also the row number (or block row number) of the grid point in the global matrix representing, for example, the Jacobian of the right-hand-side. #PETScContext::globalDOF is an integer array with the same layout as the solution - array #HyPar::u (but with one component) containing the global DOF index for the - corresponding grid points. It has the same number of ghost points as #HyPar::u. + array #HyPar::m_u (but with one component) containing the global DOF index for the + corresponding grid points. It has the same number of ghost points as #HyPar::m_u. + This array is initialized to -1. + The global DOF indices are computed for all non-ghost grid points. + If any boundaries are periodic, periodic boundary conditions are applied to fill @@ -66,21 +66,21 @@ static int ApplyPeriodicity( int dir, /*!< Spatial dimension along which + Thus, ghost points corresponding to physical, non-periodic boundaries retain the initial value of -1. */ -int PetscGlobalDOF(void* c /*!< Object of type #PETScContext*/) +int PetscGlobalDOF(void* a_c /*!< Object of type #PETScContext*/) { - PETScContext* ctxt = (PETScContext*) c; - SimulationObject* sim = (SimulationObject*) ctxt->simobj; - int nsims = ctxt->nsims; + PETScContext* ctxt = (PETScContext*) a_c; + SimulationObject* sim = (SimulationObject*) ctxt->m_simobj; + int nsims = ctxt->m_nsims; - ctxt->globalDOF.resize(nsims, nullptr); + ctxt->m_globalDOF.resize(nsims, nullptr); /* compute MPI offset */ - std::vector local_sizes(ctxt->nproc ,0); - local_sizes[ctxt->rank] = ctxt->npoints; - MPIMax_integer(local_sizes.data(),local_sizes.data(),ctxt->nproc,&sim[0].mpi.world); + std::vector local_sizes(ctxt->m_nproc ,0); + local_sizes[ctxt->m_rank] = ctxt->m_npoints; + MPIMax_integer(local_sizes.data(),local_sizes.data(),ctxt->m_nproc,&sim[0].mpi.m_world); int MPIOffset = 0; - for (int i=0; irank; i++) MPIOffset += local_sizes[i]; + for (int i=0; im_rank; i++) MPIOffset += local_sizes[i]; int simOffset = 0; for (int ns = 0; ns < nsims; ns++) { @@ -88,27 +88,27 @@ int PetscGlobalDOF(void* c /*!< Object of type #PETScContext*/) HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - int *dim = solver->dim_local, - ndims = solver->ndims, - ghosts = solver->ghosts, - npoints = solver->npoints_local, - npoints_wg = solver->npoints_local_wghosts, + int *dim = solver->m_dim_local, + ndims = solver->m_ndims, + ghosts = solver->m_ghosts, + npoints = solver->m_npoints_local, + npoints_wg = solver->m_npoints_local_wghosts, nv = ndims + 1, i; - ctxt->globalDOF[ns] = (double*) calloc( npoints_wg, sizeof(double) ); - _ArraySetValue_(ctxt->globalDOF[ns], npoints_wg, -1.0); + ctxt->m_globalDOF[ns] = (double*) calloc( npoints_wg, sizeof(double) ); + _ArraySetValue_(ctxt->m_globalDOF[ns], npoints_wg, -1.0); for (int i = 0; i < npoints; i++) { - int p = (ctxt->points[ns]+i*nv)[ndims]; - ctxt->globalDOF[ns][p] = (double) (i + simOffset + MPIOffset); + int p = (ctxt->m_points[ns]+i*nv)[ndims]; + ctxt->m_globalDOF[ns][p] = (double) (i + simOffset + MPIOffset); } for (int i=0; iisPeriodic[i]) { - ApplyPeriodicity(i,ndims,dim,ghosts,ctxt->globalDOF[ns]); + if (solver->m_is_periodic[i]) { + ApplyPeriodicity(i,ndims,dim,ghosts,ctxt->m_globalDOF[ns]); } } - MPIExchangeBoundariesnD(ndims,1,dim,ghosts,mpi,ctxt->globalDOF[ns]); + MPIExchangeBoundariesnD(ndims,1,dim,ghosts,mpi,ctxt->m_globalDOF[ns]); simOffset += npoints; } diff --git a/src/PETScFunctions/PetscIFunctionIMEX.cpp b/src/PETScFunctions/PetscIFunctionIMEX.cpp index 1e6ce55d..8dd42d00 100644 --- a/src/PETScFunctions/PetscIFunctionIMEX.cpp +++ b/src/PETScFunctions/PetscIFunctionIMEX.cpp @@ -50,93 +50,93 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscIFunctionIMEX( TS ts, /*!< The time integration object */ - PetscReal t, /*!< Current solution time */ - Vec Y, /*!< State vector (input) */ - Vec Ydot, /*!< Time derivative of the state vector (input) */ - Vec F, /*!< The computed function vector */ - void *ctxt /*!< Object of type PETScContext */ ) +PetscErrorCode PetscIFunctionIMEX( TS a_ts, /*!< The time integration object */ + PetscReal a_t, /*!< Current solution time */ + Vec a_Y, /*!< State vector (input) */ + Vec a_Ydot, /*!< Time derivative of the state vector (input) */ + Vec a_F, /*!< The computed function vector */ + void *a_ctxt /*!< Object of type PETScContext */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; PetscFunctionBegin; - context->waqt = t; + context->m_waqt = a_t; for (int ns = 0; ns < nsims; ns++) { HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_IFunction++; + solver->m_count_i_function++; - int size = solver->npoints_local_wghosts; - double *u = solver->u; - double *rhs = solver->rhs; + int size = solver->m_npoints_local_wghosts; + double *u = solver->m_u; + double *rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t); + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* initialize right-hand side to zero */ - _ArraySetValue_(rhs,size*solver->nvars,0.0); + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); /* Evaluate hyperbolic, parabolic and source terms and the RHS */ - if ((!strcmp(solver->SplitHyperbolicFlux,"yes")) && solver->flag_fdf_specified) { - if (context->flag_hyperbolic_f == _IMPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->FdFFunction,solver->UpwindFdF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if ((!strcmp(solver->m_split_hyperbolic_flux,"yes")) && solver->m_flag_fdf_specified) { + if (context->m_flag_hyperbolic_f == _IMPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->FdFFunction,solver->UpwindFdF); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _IMPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if (context->m_flag_hyperbolic_df == _IMPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->dFFunction,solver->UpwinddF); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - } else if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (context->flag_hyperbolic_f == _IMPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp, 1.0,rhs,size*solver->nvars); + } else if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (context->m_flag_hyperbolic_f == _IMPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->FFunction,solver->Upwind); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->dFFunction,solver->UpwinddF); + _ArrayAXPY_(solver->m_hyp, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _IMPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if (context->m_flag_hyperbolic_df == _IMPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->dFFunction,solver->UpwinddF); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } else { - if (context->flag_hyperbolic == _IMPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if (context->m_flag_hyperbolic == _IMPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->FFunction,solver->Upwind); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } - if (context->flag_parabolic == _IMPLICIT_) { - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - _ArrayAXPY_(solver->par, 1.0,rhs,size*solver->nvars); + if (context->m_flag_parabolic == _IMPLICIT_) { + solver->ParabolicFunction (solver->m_par,u,solver,mpi,a_t); + _ArrayAXPY_(solver->m_par, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_source == _IMPLICIT_) { - solver->SourceFunction (solver->source,u,solver,mpi,t); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + if (context->m_flag_source == _IMPLICIT_) { + solver->SourceFunction (solver->m_source,u,solver,mpi,a_t); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); } /* save a copy of the solution and RHS for use in IJacobian */ - _ArrayCopy1D_(u ,solver->uref ,(size*solver->nvars)); - _ArrayCopy1D_(rhs,solver->rhsref,(size*solver->nvars)); + _ArrayCopy1D_(u ,solver->m_uref ,(size*solver->m_nvars)); + _ArrayCopy1D_(rhs,solver->m_rhsref,(size*solver->m_nvars)); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } - /* LHS = Ydot - F(u) */ - VecAYPX(F,-1.0,Ydot); + /* LHS = a_Ydot - a_F(u) */ + VecAYPX(a_F,-1.0,a_Ydot); PetscFunctionReturn(0); } diff --git a/src/PETScFunctions/PetscIFunctionImpl.cpp b/src/PETScFunctions/PetscIFunctionImpl.cpp index d7e07b12..0924f337 100644 --- a/src/PETScFunctions/PetscIFunctionImpl.cpp +++ b/src/PETScFunctions/PetscIFunctionImpl.cpp @@ -34,16 +34,16 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscIFunctionImpl( TS ts, /*!< Time integration object */ - PetscReal t, /*!< Current simulation time */ - Vec Y, /*!< State vector (input) */ - Vec Ydot, /*!< Time derivative of the state vector (input) */ - Vec F, /*!< The computed right-hand-side vector */ - void *ctxt /*!< Object of type #PETScContext */ ) +PetscErrorCode PetscIFunctionImpl( TS a_ts, /*!< Time integration object */ + PetscReal a_t, /*!< Current simulation time */ + Vec a_Y, /*!< State vector (input) */ + Vec a_Ydot, /*!< Time derivative of the state vector (input) */ + Vec a_F, /*!< The computed right-hand-side vector */ + void *a_ctxt /*!< Object of type #PETScContext */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; PetscFunctionBegin; for (int ns = 0; ns < nsims; ns++) { @@ -51,44 +51,44 @@ PetscErrorCode PetscIFunctionImpl( TS ts, /*!< Time integration object HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_RHSFunction++; + solver->m_count_rhs_function++; - int size = solver->npoints_local_wghosts; - double* u = solver->u; - double* rhs = solver->rhs; + int size = solver->m_npoints_local_wghosts; + double* u = solver->m_u; + double* rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t); + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* Evaluate hyperbolic, parabolic and source terms and the RHS */ - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,1,solver->FFunction,solver->Upwind); - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - solver->SourceFunction (solver->source,u,solver,mpi,t); + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,1,solver->FFunction,solver->Upwind); + solver->ParabolicFunction (solver->m_par,u,solver,mpi,a_t); + solver->SourceFunction (solver->m_source,u,solver,mpi,a_t); - _ArraySetValue_(rhs,size*solver->nvars,0.0); - _ArrayAXPY_(solver->hyp ,-1.0,rhs,size*solver->nvars); - _ArrayAXPY_(solver->par , 1.0,rhs,size*solver->nvars); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); + _ArrayAXPY_(solver->m_hyp ,-1.0,rhs,size*solver->m_nvars); + _ArrayAXPY_(solver->m_par , 1.0,rhs,size*solver->m_nvars); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); /* save a copy of the solution and RHS for use in IJacobian */ - _ArrayCopy1D_(u ,solver->uref ,(size*solver->nvars)); - _ArrayCopy1D_(rhs,solver->rhsref,(size*solver->nvars)); + _ArrayCopy1D_(u ,solver->m_uref ,(size*solver->m_nvars)); + _ArrayCopy1D_(rhs,solver->m_rhsref,(size*solver->m_nvars)); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } - /* LHS = Ydot - F(u) */ - VecAYPX(F,-1.0,Ydot); + /* LHS = a_Ydot - a_F(u) */ + VecAYPX(a_F,-1.0,a_Ydot); PetscFunctionReturn(0); } diff --git a/src/PETScFunctions/PetscIJacobian.cpp b/src/PETScFunctions/PetscIJacobian.cpp index fd6b517f..b2e960a1 100644 --- a/src/PETScFunctions/PetscIJacobian.cpp +++ b/src/PETScFunctions/PetscIJacobian.cpp @@ -49,25 +49,25 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscIJacobian( TS ts, /*!< Time stepping object (see PETSc TS)*/ - PetscReal t, /*!< Current time */ - Vec Y, /*!< Solution vector */ - Vec Ydot, /*!< Time-derivative of solution vector */ - PetscReal a, /*!< Shift */ - Mat A, /*!< Jacobian matrix */ - Mat B, /*!< Preconditioning matrix */ - void *ctxt /*!< Application context */ ) +PetscErrorCode PetscIJacobian( TS a_ts, /*!< Time stepping object (see PETSc TS)*/ + PetscReal a_t, /*!< Current time */ + Vec a_Y, /*!< Solution vector */ + Vec a_Ydot, /*!< Time-derivative of solution vector */ + PetscReal a_a, /*!< Shift */ + Mat a_A, /*!< Jacobian matrix */ + Mat a_B, /*!< Preconditioning matrix */ + void *a_ctxt /*!< Application context */ ) { - PETScContext* context = (PETScContext*) ctxt; + PETScContext* context = (PETScContext*) a_ctxt; PetscFunctionBegin; - for (int ns = 0; ns < context->nsims; ns++) { - ((SimulationObject*)context->simobj)[ns].solver.count_IJacobian++; + for (int ns = 0; ns < context->m_nsims; ns++) { + ((SimulationObject*)context->m_simobj)[ns].solver.m_count_i_jacobian++; } - context->shift = a; - context->waqt = t; + context->m_shift = a_a; + context->m_waqt = a_t; /* Construct preconditioning matrix */ - if (context->flag_use_precon) PetscComputePreconMatImpl(B,Y,context); + if (context->m_flag_use_precon) PetscComputePreconMatImpl(a_B,a_Y,context); PetscFunctionReturn(0); } @@ -95,7 +95,7 @@ PetscErrorCode PetscIJacobian( TS ts, /*!< Time stepping object (see PETS \f{equation}{ {\bf f} = \alpha {\bf y} - \frac{1}{\epsilon} \left[ {\bf F}\left({\bf U}_0+\epsilon{\bf y}\right)-{\bf F}\left({\bf U}_0\right) \right] \f} - In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::uref (the reference solution at which the + In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::m_uref (the reference solution at which the nonlinear Jacobian is computed). See papers on Jacobian-free Newton-Krylov (JFNK) methods to understand how \f$\epsilon\f$ is computed. \b Notes: @@ -108,76 +108,76 @@ PetscErrorCode PetscIJacobian( TS ts, /*!< Time stepping object (see PETS the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscJacobianFunction_JFNK( Mat Jacobian, /*!< Jacobian matrix */ - Vec Y, /*!< Input vector */ - Vec F /*!< Output vector +PetscErrorCode PetscJacobianFunction_JFNK( Mat a_Jacobian, /*!< Jacobian matrix */ + Vec a_Y, /*!< Input vector */ + Vec a_F /*!< Output vector (Jacobian times input vector) */ ) { PETScContext* context(nullptr); PetscFunctionBegin; - MatShellGetContext(Jacobian,&context); - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + MatShellGetContext(a_Jacobian,&context); + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; double normY; - VecNorm(Y,NORM_2,&normY); + VecNorm(a_Y,NORM_2,&normY); if (normY < 1e-16) { - /* F = 0 */ - VecZeroEntries(F); - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,0,Y); + /* a_F = 0 */ + VecZeroEntries(a_F); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,0,a_Y); } else { - double epsilon = context->jfnk_eps / normY; - double t = context->waqt; /* current stage/step time */ + double epsilon = context->m_jfnk_eps / normY; + double t = context->m_waqt; /* current stage/step time */ for (int ns = 0; ns < nsims; ns++) { HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_IJacFunction++; + solver->m_count_i_jac_function++; - int size = solver->npoints_local_wghosts; + int size = solver->m_npoints_local_wghosts; - double *u = solver->u; - double *uref = solver->uref; - double *rhsref = solver->rhsref; - double *rhs = solver->rhs; + double *u = solver->m_u; + double *uref = solver->m_uref; + double *rhsref = solver->m_rhsref; + double *rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); - _ArrayAYPX_(uref,epsilon,u,size*solver->nvars); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); + _ArrayAYPX_(uref,epsilon,u,size*solver->m_nvars); /* apply boundary conditions and exchange data over MPI interfaces */ solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* Evaluate hyperbolic, parabolic and source terms and the RHS for U+dU */ - _ArraySetValue_(rhs,size*solver->nvars,0.0); - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - _ArrayAXPY_(solver->par, 1.0,rhs,size*solver->nvars); - solver->SourceFunction (solver->source,u,solver,mpi,t); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); + solver->ParabolicFunction (solver->m_par,u,solver,mpi,t); + _ArrayAXPY_(solver->m_par, 1.0,rhs,size*solver->m_nvars); + solver->SourceFunction (solver->m_source,u,solver,mpi,t); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); - _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->m_nvars); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,(-1.0/epsilon),Y); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,(-1.0/epsilon),a_Y); } @@ -209,7 +209,7 @@ PetscErrorCode PetscJacobianFunction_JFNK( Mat Jacobian, /*!< Jacobian matrix */ \f{equation}{ {\bf f} = \alpha {\bf y} - \left[ {\bf F}\left({\bf U}_0+{\bf y}\right)-{\bf F}\left({\bf U}_0\right) \right] \f} - In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::uref (the reference solution at which the + In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::m_uref (the reference solution at which the nonlinear Jacobian is computed). Since \f$\mathcal{F}\f$ is linear, @@ -233,75 +233,75 @@ PetscErrorCode PetscJacobianFunction_JFNK( Mat Jacobian, /*!< Jacobian matrix */ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscJacobianFunction_Linear( Mat Jacobian, /*!< Jacobian matrix */ - Vec Y, /*!< Input vector */ - Vec F /*!< Output vector +PetscErrorCode PetscJacobianFunction_Linear( Mat a_Jacobian, /*!< Jacobian matrix */ + Vec a_Y, /*!< Input vector */ + Vec a_F /*!< Output vector (Jacobian times input vector */) { PETScContext* context(nullptr); PetscFunctionBegin; - MatShellGetContext(Jacobian,&context); - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + MatShellGetContext(a_Jacobian,&context); + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; double normY; - VecNorm(Y,NORM_2,&normY); + VecNorm(a_Y,NORM_2,&normY); if (normY < 1e-16) { - /* F = 0 */ - VecZeroEntries(F); - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,0,Y); + /* a_F = 0 */ + VecZeroEntries(a_F); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,0,a_Y); } else { - double t = context->waqt; /* current stage/step time */ + double t = context->m_waqt; /* current stage/step time */ for (int ns = 0; ns < nsims; ns++) { HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_IJacFunction++; + solver->m_count_i_jac_function++; - int size = solver->npoints_local_wghosts; + int size = solver->m_npoints_local_wghosts; - double *u = solver->u; - double *uref = solver->uref; - double *rhsref = solver->rhsref; - double *rhs = solver->rhs; + double *u = solver->m_u; + double *uref = solver->m_uref; + double *rhsref = solver->m_rhsref; + double *rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); - _ArrayAYPX_(uref,1.0,u,size*solver->nvars); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); + _ArrayAYPX_(uref,1.0,u,size*solver->m_nvars); /* apply boundary conditions and exchange data over MPI interfaces */ solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* Evaluate hyperbolic, parabolic and source terms and the RHS for U+dU */ - _ArraySetValue_(rhs,size*solver->nvars,0.0); - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - _ArrayAXPY_(solver->par, 1.0,rhs,size*solver->nvars); - solver->SourceFunction (solver->source,u,solver,mpi,t); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); + solver->ParabolicFunction (solver->m_par,u,solver,mpi,t); + _ArrayAXPY_(solver->m_par, 1.0,rhs,size*solver->m_nvars); + solver->SourceFunction (solver->m_source,u,solver,mpi,t); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); - _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->m_nvars); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,-1.0,Y); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,-1.0,a_Y); } diff --git a/src/PETScFunctions/PetscIJacobianIMEX.cpp b/src/PETScFunctions/PetscIJacobianIMEX.cpp index a48394fb..f9522b23 100644 --- a/src/PETScFunctions/PetscIJacobianIMEX.cpp +++ b/src/PETScFunctions/PetscIJacobianIMEX.cpp @@ -58,25 +58,25 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscIJacobianIMEX(TS ts, /*!< Time stepping object (see PETSc TS)*/ - PetscReal t, /*!< Current time */ - Vec Y, /*!< Solution vector */ - Vec Ydot, /*!< Time-derivative of solution vector */ - PetscReal a, /*!< Shift */ - Mat A, /*!< Jacobian matrix */ - Mat B, /*!< Preconditioning matrix */ - void *ctxt /*!< Application context */ ) +PetscErrorCode PetscIJacobianIMEX(TS a_ts, /*!< Time stepping object (see PETSc TS)*/ + PetscReal a_t, /*!< Current time */ + Vec a_Y, /*!< Solution vector */ + Vec a_Ydot, /*!< Time-derivative of solution vector */ + PetscReal a_a, /*!< Shift */ + Mat a_A, /*!< Jacobian matrix */ + Mat a_B, /*!< Preconditioning matrix */ + void *a_ctxt /*!< Application context */ ) { - PETScContext* context = (PETScContext*) ctxt; + PETScContext* context = (PETScContext*) a_ctxt; PetscFunctionBegin; - for (int ns = 0; ns < context->nsims; ns++) { - ((SimulationObject*)context->simobj)[ns].solver.count_IJacobian++; + for (int ns = 0; ns < context->m_nsims; ns++) { + ((SimulationObject*)context->m_simobj)[ns].solver.m_count_i_jacobian++; } - context->shift = a; - context->waqt = t; + context->m_shift = a_a; + context->m_waqt = a_t; /* Construct preconditioning matrix */ - if (context->flag_use_precon) PetscComputePreconMatIMEX(B,Y,context); + if (context->m_flag_use_precon) PetscComputePreconMatIMEX(a_B,a_Y,context); PetscFunctionReturn(0); } @@ -106,7 +106,7 @@ PetscErrorCode PetscIJacobianIMEX(TS ts, /*!< Time stepping object (see P \f{equation}{ {\bf f} = \alpha {\bf y} - \frac{1}{\epsilon} \left[ {\bf G}\left({\bf U}_0+\epsilon{\bf y}\right)-{\bf G}\left({\bf U}_0\right) \right] \f} - In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::uref (the reference solution at which the + In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::m_uref (the reference solution at which the nonlinear Jacobian is computed). See papers on Jacobian-free Newton-Krylov (JFNK) methods to understand how \f$\epsilon\f$ is computed. Note that \f${\bf G}\left({\bf U}\right)\f$ represents all terms that the user has indicated to be @@ -125,108 +125,108 @@ PetscErrorCode PetscIJacobianIMEX(TS ts, /*!< Time stepping object (see P the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscJacobianFunctionIMEX_JFNK(Mat Jacobian, /*!< Jacobian matrix */ - Vec Y,/*!< Input vector */ - Vec F /*!< Output vector (Jacobian times input vector */ ) +PetscErrorCode PetscJacobianFunctionIMEX_JFNK(Mat a_Jacobian, /*!< Jacobian matrix */ + Vec a_Y,/*!< Input vector */ + Vec a_F /*!< Output vector (Jacobian times input vector */ ) { PETScContext* context(nullptr); PetscFunctionBegin; - MatShellGetContext(Jacobian,&context); - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + MatShellGetContext(a_Jacobian,&context); + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; double normY; - VecNorm(Y,NORM_2,&normY); + VecNorm(a_Y,NORM_2,&normY); if (normY < 1e-16) { - /* F = 0 */ - VecZeroEntries(F); - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,0,Y); + /* a_F = 0 */ + VecZeroEntries(a_F); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,0,a_Y); } else { - double epsilon = context->jfnk_eps / normY; - double t = context->waqt; /* current stage/step time */ + double epsilon = context->m_jfnk_eps / normY; + double t = context->m_waqt; /* current stage/step time */ for (int ns = 0; ns < nsims; ns++) { HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_IJacFunction++; + solver->m_count_i_jac_function++; - int size = solver->npoints_local_wghosts; + int size = solver->m_npoints_local_wghosts; - double *u = solver->u; - double *uref = solver->uref; - double *rhsref = solver->rhsref; - double *rhs = solver->rhs; + double *u = solver->m_u; + double *uref = solver->m_uref; + double *rhsref = solver->m_rhsref; + double *rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); - _ArrayAYPX_(uref,epsilon,u,size*solver->nvars); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); + _ArrayAYPX_(uref,epsilon,u,size*solver->m_nvars); /* apply boundary conditions and exchange data over MPI interfaces */ solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* Evaluate hyperbolic, parabolic and source terms and the RHS for U+dU */ - _ArraySetValue_(rhs,size*solver->nvars,0.0); - if ((!strcmp(solver->SplitHyperbolicFlux,"yes")) && solver->flag_fdf_specified) { - if (context->flag_hyperbolic_f == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); + if ((!strcmp(solver->m_split_hyperbolic_flux,"yes")) && solver->m_flag_fdf_specified) { + if (context->m_flag_hyperbolic_f == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FdFFunction,solver->UpwindFdF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + if (context->m_flag_hyperbolic_df == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - } else if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (context->flag_hyperbolic_f == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + } else if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (context->m_flag_hyperbolic_f == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp, 1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + if (context->m_flag_hyperbolic_df == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } else { - if (context->flag_hyperbolic == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + if (context->m_flag_hyperbolic == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } - if (context->flag_parabolic == _IMPLICIT_) { - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - _ArrayAXPY_(solver->par, 1.0,rhs,size*solver->nvars); + if (context->m_flag_parabolic == _IMPLICIT_) { + solver->ParabolicFunction (solver->m_par,u,solver,mpi,t); + _ArrayAXPY_(solver->m_par, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_source == _IMPLICIT_) { - solver->SourceFunction (solver->source,u,solver,mpi,t); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + if (context->m_flag_source == _IMPLICIT_) { + solver->SourceFunction (solver->m_source,u,solver,mpi,t); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); } - _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->m_nvars); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,(-1.0/epsilon),Y); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,(-1.0/epsilon),a_Y); } @@ -259,7 +259,7 @@ PetscErrorCode PetscJacobianFunctionIMEX_JFNK(Mat Jacobian, /*!< Jacobian matrix \f{equation}{ {\bf f} = \alpha {\bf y} - \left[ {\bf G}\left({\bf U}_0+{\bf y}\right)-{\bf G}\left({\bf U}_0\right) \right] \f} - In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::uref (the reference solution at which the + In the code, \f${\bf y}\f$ is \a Y, \f$\bf f\f$ is \a F, and \f${\bf U}_0\f$ is \a #HyPar::m_uref (the reference solution at which the nonlinear Jacobian is computed). Since \f$\mathcal{F}\f$ is linear, @@ -287,108 +287,108 @@ PetscErrorCode PetscJacobianFunctionIMEX_JFNK(Mat Jacobian, /*!< Jacobian matrix the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscJacobianFunctionIMEX_Linear(Mat Jacobian, /*!< Jacobian matrix */ - Vec Y,/*!< Input vector */ - Vec F /*!< Output vector +PetscErrorCode PetscJacobianFunctionIMEX_Linear(Mat a_Jacobian, /*!< Jacobian matrix */ + Vec a_Y,/*!< Input vector */ + Vec a_F /*!< Output vector (Jacobian times input vector */) { PETScContext* context(nullptr); PetscFunctionBegin; - MatShellGetContext(Jacobian,&context); - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + MatShellGetContext(a_Jacobian,&context); + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; double normY; - VecNorm(Y,NORM_2,&normY); + VecNorm(a_Y,NORM_2,&normY); if (normY < 1e-16) { - /* F = 0 */ - VecZeroEntries(F); - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,0,Y); + /* a_F = 0 */ + VecZeroEntries(a_F); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,0,a_Y); } else { - double t = context->waqt; /* current stage/step time */ + double t = context->m_waqt; /* current stage/step time */ for (int ns = 0; ns < nsims; ns++) { HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_IJacFunction++; + solver->m_count_i_jac_function++; - int size = solver->npoints_local_wghosts; + int size = solver->m_npoints_local_wghosts; - double *u = solver->u; - double *uref = solver->uref; - double *rhsref = solver->rhsref; - double *rhs = solver->rhs; + double *u = solver->m_u; + double *uref = solver->m_uref; + double *rhsref = solver->m_rhsref; + double *rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); - _ArrayAYPX_(uref,1.0,u,size*solver->nvars); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); + _ArrayAYPX_(uref,1.0,u,size*solver->m_nvars); /* apply boundary conditions and exchange data over MPI interfaces */ solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* Evaluate hyperbolic, parabolic and source terms and the RHS for U+dU */ - _ArraySetValue_(rhs,size*solver->nvars,0.0); - if ((!strcmp(solver->SplitHyperbolicFlux,"yes")) && solver->flag_fdf_specified) { - if (context->flag_hyperbolic_f == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); + if ((!strcmp(solver->m_split_hyperbolic_flux,"yes")) && solver->m_flag_fdf_specified) { + if (context->m_flag_hyperbolic_f == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FdFFunction,solver->UpwindFdF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + if (context->m_flag_hyperbolic_df == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - } else if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (context->flag_hyperbolic_f == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + } else if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (context->m_flag_hyperbolic_f == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp, 1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + if (context->m_flag_hyperbolic_df == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } else { - if (context->flag_hyperbolic == _IMPLICIT_) { - solver->HyperbolicFunction( solver->hyp,u,solver,mpi,t,0, + if (context->m_flag_hyperbolic == _IMPLICIT_) { + solver->HyperbolicFunction( solver->m_hyp,u,solver,mpi,t,0, solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } - if (context->flag_parabolic == _IMPLICIT_) { - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - _ArrayAXPY_(solver->par, 1.0,rhs,size*solver->nvars); + if (context->m_flag_parabolic == _IMPLICIT_) { + solver->ParabolicFunction (solver->m_par,u,solver,mpi,t); + _ArrayAXPY_(solver->m_par, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_source == _IMPLICIT_) { - solver->SourceFunction (solver->source,u,solver,mpi,t); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + if (context->m_flag_source == _IMPLICIT_) { + solver->SourceFunction (solver->m_source,u,solver,mpi,t); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); } - _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->nvars); + _ArrayAXPY_(rhsref,-1.0,rhs,size*solver->m_nvars); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } - /* [J]Y = aY - F(Y) */ - VecAXPBY(F,context->shift,-1.0,Y); + /* [J]a_Y = aY - a_F(a_Y) */ + VecAXPBY(a_F,context->m_shift,-1.0,a_Y); } diff --git a/src/PETScFunctions/PetscJacobianMatNonzeroEntriesImpl.cpp b/src/PETScFunctions/PetscJacobianMatNonzeroEntriesImpl.cpp index 0afa7ec8..413daec1 100644 --- a/src/PETScFunctions/PetscJacobianMatNonzeroEntriesImpl.cpp +++ b/src/PETScFunctions/PetscJacobianMatNonzeroEntriesImpl.cpp @@ -35,29 +35,29 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -int PetscJacobianMatNonzeroEntriesImpl( Mat Amat, /*!< Matrix */ - int width, /*!< Stencil width */ - void *ctxt /*!< Application context */ ) +int PetscJacobianMatNonzeroEntriesImpl( Mat a_Amat, /*!< Matrix */ + int a_width, /*!< Stencil width */ + void *a_ctxt /*!< Application context */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; PetscFunctionBegin; - int nsims = context->nsims; + int nsims = context->m_nsims; /* initialize matrix to zero */ - MatZeroEntries(Amat); + MatZeroEntries(a_Amat); for (int ns = 0; ns < nsims; ns++) { HyPar* solver( &(sim[ns].solver) ); MPIVariables* mpi( &(sim[ns].mpi) ); - int ndims = solver->ndims, - nvars = solver->nvars, - npoints = solver->npoints_local, - ghosts = solver->ghosts, - *dim = solver->dim_local, - *points = context->points[ns], + int ndims = solver->m_ndims, + nvars = solver->m_nvars, + npoints = solver->m_npoints_local, + ghosts = solver->m_ghosts, + *dim = solver->m_dim_local, + *points = context->m_points[ns], index[ndims],indexL[ndims],indexR[ndims], rows[nvars],cols[nvars]; @@ -72,31 +72,31 @@ int PetscJacobianMatNonzeroEntriesImpl( Mat Amat, /*!< Matrix */ for (int dir = 0; dir < ndims; dir++) { - int pg = (int) context->globalDOF[ns][p]; + int pg = (int) context->m_globalDOF[ns][p]; /* diagonal element */ for (int v=0; vglobalDOF[ns][pL]; + int pgL = (int) context->m_globalDOF[ns][pL]; if (pgL >= 0) { for (int v=0; vglobalDOF[ns][pR]; + int pgR = (int) context->m_globalDOF[ns][pR]; /* right neighbor */ if (pgR >= 0) { for (int v=0; vsimobj; - int nsims = context->nsims; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; TSType time_scheme; - TSGetType(ts,&time_scheme); + TSGetType(a_ts,&time_scheme); - TSGetTimeStep(ts,&(context->dt)); - context->stage_index = stageindex; - if (context->stage_times.size() == stageindex) { - context->stage_times.push_back(stagetime/context->dt); + TSGetTimeStep(a_ts,&(context->m_dt)); + context->m_stage_index = a_stageindex; + if (context->m_stage_times.size() == a_stageindex) { + context->m_stage_times.push_back(a_stagetime/context->m_dt); } for (int ns = 0; ns < nsims; ns++) { @@ -46,27 +46,27 @@ PetscErrorCode PetscPostStage( TS ts, /*!< Time integrator of PE MPIVariables* mpi = &(sim[ns].mpi); /* get solution */ - TransferVecFromPETSc(solver->u,Y[stageindex],context,ns,context->offsets[ns]); + TransferVecFromPETSc(solver->m_u,a_Y[a_stageindex],context,ns,context->m_offsets[ns]); /* apply immersed boundaries */ - solver->ApplyIBConditions(solver,mpi,solver->u,stagetime); + solver->ApplyIBConditions(solver,mpi,solver->m_u,a_stagetime); /* If using a non-linear scheme with ARKIMEX methods, compute the non-linear finite-difference operator */ if (!strcmp(time_scheme,TSARKIMEX)) { - solver->NonlinearInterp( solver->u, + solver->NonlinearInterp( solver->m_u, solver, mpi, - (double)stagetime, + (double)a_stagetime, solver->FFunction ); } /* Call any physics-specific post-stage function, if available */ if (solver->PostStage) { - solver->PostStage(solver->u,solver,mpi,stagetime); + solver->PostStage(solver->m_u,solver,mpi,a_stagetime); } - TransferVecToPETSc(solver->u,Y[stageindex],context,ns,context->offsets[ns]); + TransferVecToPETSc(solver->m_u,a_Y[a_stageindex],context,ns,context->m_offsets[ns]); } diff --git a/src/PETScFunctions/PetscPostTimeStep.cpp b/src/PETScFunctions/PetscPostTimeStep.cpp index e41c33c1..bc0298f5 100644 --- a/src/PETScFunctions/PetscPostTimeStep.cpp +++ b/src/PETScFunctions/PetscPostTimeStep.cpp @@ -18,31 +18,31 @@ int OutputSolution (void*,int,double); /*!< Write solutions to file */ #define __FUNCT__ "PetscPostTimeStep" /*! Function called after every time step */ -PetscErrorCode PetscPostTimeStep(TS ts /*!< Time integrator object */) +PetscErrorCode PetscPostTimeStep(TS a_ts /*!< Time integrator object */) { PETScContext* context(nullptr); PetscFunctionBegin; - TSGetApplicationContext(ts,&context); + TSGetApplicationContext(a_ts,&context); if (!context) { fprintf(stderr,"Error in PetscPreTimeStep: Null context!\n"); return(1); } - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; Vec Y; - TSGetSolution(ts,&Y); + TSGetSolution(a_ts,&Y); double waqt; - TSGetTime(ts,&waqt); + TSGetTime(a_ts,&waqt); int iter; - TSGetStepNumber(ts,&iter); + TSGetStepNumber(a_ts,&iter); double dt; - TSGetTimeStep(ts,&dt); + TSGetTimeStep(a_ts,&dt); - context->tic++; + context->m_tic++; double max_cfl = 0.0; double total_norm = 0.0; @@ -52,28 +52,28 @@ PetscErrorCode PetscPostTimeStep(TS ts /*!< Time integrator object */) MPIVariables* mpi = &(sim[ns].mpi); /* get solution */ - TransferVecFromPETSc(solver->u,Y,context,ns,context->offsets[ns]); + TransferVecFromPETSc(solver->m_u,Y,context,ns,context->m_offsets[ns]); /* Call any physics-specific post-step function */ - if (solver->PostStep) solver->PostStep(solver->u,solver,mpi,waqt,iter); + if (solver->PostStep) solver->PostStep(solver->m_u,solver,mpi,waqt,iter); /* Calculate CFL and diffusion number */ double local_max_cfl = -1.0, global_max_cfl = -1.0; if (solver->ComputeCFL) local_max_cfl = solver->ComputeCFL(solver,mpi,dt,waqt); - MPIMax_double(&global_max_cfl ,&local_max_cfl ,1,&mpi->world); + MPIMax_double(&global_max_cfl ,&local_max_cfl ,1,&mpi->m_world); if (global_max_cfl > max_cfl) max_cfl = global_max_cfl; /* Calculate norm of the change in the solution for this time step */ - _ArrayAXPY_(solver->u,-1.0,solver->u0,(solver->npoints_local_wghosts*solver->nvars)); - double sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u0); - double global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - double norm = sqrt((global_sum/(double)solver->npoints_global)); + _ArrayAXPY_(solver->m_u,-1.0,solver->m_u0,(solver->m_npoints_local_wghosts*solver->m_nvars)); + double sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u0); + double global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + double norm = sqrt((global_sum/(double)solver->m_npoints_global)); total_norm += norm; - if (!strcmp(solver->ConservationCheck,"yes")) { + if (!strcmp(solver->m_conservation_check,"yes")) { /* calculate volume integral of the solution at this time step */ - solver->VolumeIntegralFunction(solver->VolumeIntegral,solver->u,solver,mpi); + solver->VolumeIntegralFunction(solver->m_volume_integral,solver->m_u,solver,mpi); /* calculate surface integral of the flux at this time step */ solver->BoundaryIntegralFunction(solver,mpi); /* calculate the conservation error at this time step */ @@ -82,14 +82,14 @@ PetscErrorCode PetscPostTimeStep(TS ts /*!< Time integrator object */) } - gettimeofday(&context->iter_end_time,NULL); + gettimeofday(&context->m_iter_end_time,NULL); long long walltime; - walltime = ( (context->iter_end_time.tv_sec * 1000000 + context->iter_end_time.tv_usec) - - (context->iter_start_time.tv_sec * 1000000 + context->iter_start_time.tv_usec)); - context->iter_wctime = (double) walltime / 1000000.0; - context->ti_runtime += context->iter_wctime; + walltime = ( (context->m_iter_end_time.tv_sec * 1000000 + context->m_iter_end_time.tv_usec) + - (context->m_iter_start_time.tv_sec * 1000000 + context->m_iter_start_time.tv_usec)); + context->m_iter_wctime = (double) walltime / 1000000.0; + context->m_ti_runtime += context->m_iter_wctime; - if ((!context->rank) && (iter%sim[0].solver.screen_op_iter == 0)) { + if ((!context->m_rank) && (iter%sim[0].solver.m_screen_op_iter == 0)) { if (nsims > 1) { printf("--\n"); @@ -97,23 +97,23 @@ PetscErrorCode PetscPostTimeStep(TS ts /*!< Time integrator object */) printf(" dt=%1.3E ", dt); printf(" CFL=%1.3E, ", max_cfl); printf(" norm=%1.4E\n", total_norm); - printf(" wctime=%1.1E (s)\n",context->iter_wctime); + printf(" wctime=%1.1E (s)\n",context->m_iter_wctime); } else { printf("iter=%7d ", iter); printf("dt=%1.3E ", dt); printf("t=%1.3E ", waqt); printf("CFL=%1.3E ", max_cfl ); printf("norm=%1.4E ", total_norm); - printf("wctime: %1.1E (s) ",context->iter_wctime); + printf("wctime: %1.1E (s) ",context->m_iter_wctime); } /* calculate and print conservation error */ - if (!strcmp(sim[0].solver.ConservationCheck,"yes")) { + if (!strcmp(sim[0].solver.m_conservation_check,"yes")) { double error = 0; for (int ns = 0; ns < nsims; ns++) { - for (int v=0; vop_times_arr.push_back(waqt); + context->m_op_times_arr.push_back(waqt); #endif - context->tic=0; + context->m_tic=0; } PetscFunctionReturn(0); diff --git a/src/PETScFunctions/PetscPreStage.cpp b/src/PETScFunctions/PetscPreStage.cpp index f8003425..872aac4a 100644 --- a/src/PETScFunctions/PetscPreStage.cpp +++ b/src/PETScFunctions/PetscPreStage.cpp @@ -11,7 +11,7 @@ #define __FUNCT__ "PetscPreStage" /*! Function called before a stage in multi-stage time-integration methods */ -PetscErrorCode PetscPreStage( TS ts, /*!< Time integration object */ +PetscErrorCode PetscPreStage( TS a_ts, /*!< Time integration object */ PetscReal waqt /*!< Current simulation time */ ) { PetscFunctionBegin; diff --git a/src/PETScFunctions/PetscPreTimeStep.cpp b/src/PETScFunctions/PetscPreTimeStep.cpp index 950e5902..1c867c51 100644 --- a/src/PETScFunctions/PetscPreTimeStep.cpp +++ b/src/PETScFunctions/PetscPreTimeStep.cpp @@ -21,37 +21,37 @@ int OutputSolution (void*,int,double); /*!< Write solutions to file */ #define __FUNCT__ "PetscPreTimeStep" /*! Function called before a time step */ -PetscErrorCode PetscPreTimeStep(TS ts /*!< Time integration object */) +PetscErrorCode PetscPreTimeStep(TS a_ts /*!< Time integration object */) { PETScContext* context(nullptr); PetscFunctionBegin; - TSGetApplicationContext(ts,&context); + TSGetApplicationContext(a_ts,&context); if (!context) { fprintf(stderr,"Error in PetscPreTimeStep: Null context!\n"); return(1); } - gettimeofday(&(context->iter_start_time),NULL); - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + gettimeofday(&(context->m_iter_start_time),NULL); + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; Vec Y; - TSGetSolution(ts,&Y); + TSGetSolution(a_ts,&Y); double waqt; - TSGetTime(ts,&waqt); + TSGetTime(a_ts,&waqt); double dt; - TSGetTimeStep(ts,&dt); + TSGetTimeStep(a_ts,&dt); int iter; - TSGetStepNumber(ts,&iter); + TSGetStepNumber(a_ts,&iter); - context->dt = dt; - context->waqt = waqt; - context->t_start = waqt; + context->m_dt = dt; + context->m_waqt = waqt; + context->m_t_start = waqt; TSType time_scheme; - TSGetType(ts,&time_scheme); + TSGetType(a_ts,&time_scheme); for (int ns = 0; ns < nsims; ns++) { @@ -59,34 +59,34 @@ PetscErrorCode PetscPreTimeStep(TS ts /*!< Time integration object */) MPIVariables* mpi = &(sim[ns].mpi); /* get solution */ - TransferVecFromPETSc(solver->u,Y,context,ns,context->offsets[ns]); + TransferVecFromPETSc(solver->m_u,Y,context,ns,context->m_offsets[ns]); /* save a copy of the solution to compute norm at end of time step */ - _ArrayCopy1D_(solver->u,solver->u0,(solver->npoints_local_wghosts*solver->nvars)); + _ArrayCopy1D_(solver->m_u,solver->m_u0,(solver->m_npoints_local_wghosts*solver->m_nvars)); /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,solver->u,NULL,waqt); - solver->ApplyIBConditions(solver,mpi,solver->u,waqt); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + solver->ApplyBoundaryConditions(solver,mpi,solver->m_u,NULL,waqt); + solver->ApplyIBConditions(solver,mpi,solver->m_u,waqt); + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, - solver->u ); + solver->m_u ); /* Call any physics-specific pre-step function */ - if (solver->PreStep) solver->PreStep(solver->u,solver,mpi,waqt); + if (solver->PreStep) solver->PreStep(solver->m_u,solver,mpi,waqt); /* If using a non-linear scheme with ARKIMEX methods, compute the non-linear finite-difference operator */ if (!strcmp(time_scheme,TSARKIMEX)) { - solver->NonlinearInterp(solver->u,solver,mpi,waqt,solver->FFunction); + solver->NonlinearInterp(solver->m_u,solver,mpi,waqt,solver->FFunction); } /* set the step boundary flux integral value to zero */ - _ArraySetValue_(solver->StepBoundaryIntegral,2*solver->ndims*solver->nvars,0.0); + _ArraySetValue_(solver->m_step_boundary_integral,2*solver->m_ndims*solver->m_nvars,0.0); - TransferVecToPETSc(solver->u,Y,context,ns,context->offsets[ns]); + TransferVecToPETSc(solver->m_u,Y,context,ns,context->m_offsets[ns]); } @@ -99,14 +99,14 @@ PetscErrorCode PetscPreTimeStep(TS ts /*!< Time integration object */) } OutputSolution(sim, nsims,waqt); #ifdef with_librom - context->op_times_arr.push_back(waqt); + context->m_op_times_arr.push_back(waqt); #endif } #ifdef with_librom - if ( (context->rom_mode == _ROM_MODE_TRAIN_) - && (iter%((libROMInterface*)context->rom_interface)->samplingFrequency() == 0) ) { - ((libROMInterface*)context->rom_interface)->takeSample( sim, waqt ); + if ( (context->m_rom_mode == _ROM_MODE_TRAIN_) + && (iter%((libROMInterface*)context->m_rom_interface)->samplingFrequency() == 0) ) { + ((libROMInterface*)context->m_rom_interface)->takeSample( sim, waqt ); } #endif diff --git a/src/PETScFunctions/PetscRHSFunctionExpl.cpp b/src/PETScFunctions/PetscRHSFunctionExpl.cpp index 0c46c0d7..07dae24e 100644 --- a/src/PETScFunctions/PetscRHSFunctionExpl.cpp +++ b/src/PETScFunctions/PetscRHSFunctionExpl.cpp @@ -33,15 +33,15 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscRHSFunctionExpl( TS ts, /*!< Time integration object */ - PetscReal t, /*!< Current simulation time */ - Vec Y, /*!< State vector (input) */ - Vec F, /*!< The computed right-hand-side vector */ - void *ctxt /*!< Object of type #PETScContext */ ) +PetscErrorCode PetscRHSFunctionExpl( TS a_ts, /*!< Time integration object */ + PetscReal a_t, /*!< Current simulation time */ + Vec a_Y, /*!< State vector (input) */ + Vec a_F, /*!< The computed right-hand-side vector */ + void *a_ctxt /*!< Object of type #PETScContext */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; PetscFunctionBegin; @@ -50,36 +50,36 @@ PetscErrorCode PetscRHSFunctionExpl( TS ts, /*!< Time integration obje HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_RHSFunction++; + solver->m_count_rhs_function++; - int size = solver->npoints_local_wghosts; - double* u = solver->u; - double* rhs = solver->rhs; + int size = solver->m_npoints_local_wghosts; + double* u = solver->m_u; + double* rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t); + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); /* Evaluate hyperbolic, parabolic and source terms and the RHS */ - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,1,solver->FFunction,solver->Upwind); + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,1,solver->FFunction,solver->Upwind); - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - solver->SourceFunction (solver->source,u,solver,mpi,t); + solver->ParabolicFunction (solver->m_par,u,solver,mpi,a_t); + solver->SourceFunction (solver->m_source,u,solver,mpi,a_t); - _ArraySetValue_(rhs,size*solver->nvars,0.0); - _ArrayAXPY_(solver->hyp ,-1.0,rhs,size*solver->nvars); - _ArrayAXPY_(solver->par , 1.0,rhs,size*solver->nvars); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); + _ArrayAXPY_(solver->m_hyp ,-1.0,rhs,size*solver->m_nvars); + _ArrayAXPY_(solver->m_par , 1.0,rhs,size*solver->m_nvars); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } diff --git a/src/PETScFunctions/PetscRHSFunctionIMEX.cpp b/src/PETScFunctions/PetscRHSFunctionIMEX.cpp index c3098c8f..bf4f9a61 100644 --- a/src/PETScFunctions/PetscRHSFunctionIMEX.cpp +++ b/src/PETScFunctions/PetscRHSFunctionIMEX.cpp @@ -46,17 +46,17 @@ the PETSc documentation (https://petsc.org/release/docs/). Usually, googling with the function or variable name yields the specific doc page dealing with that function/variable. */ -PetscErrorCode PetscRHSFunctionIMEX( TS ts, /*!< Time integration object */ - PetscReal t, /*!< Current simulation time */ - Vec Y, /*!< State vector (input) */ - Vec F, /*!< The computed right-hand-side vector */ - void *ctxt /*!< Object of type #PETScContext */ ) +PetscErrorCode PetscRHSFunctionIMEX( TS a_ts, /*!< Time integration object */ + PetscReal a_t, /*!< Current simulation time */ + Vec a_Y, /*!< State vector (input) */ + Vec a_F, /*!< The computed right-hand-side vector */ + void *a_ctxt /*!< Object of type #PETScContext */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; - context->waqt = t; + context->m_waqt = a_t; PetscFunctionBegin; for (int ns = 0; ns < nsims; ns++) { @@ -64,60 +64,60 @@ PetscErrorCode PetscRHSFunctionIMEX( TS ts, /*!< Time integration obje HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - solver->count_RHSFunction++; + solver->m_count_rhs_function++; - int size = solver->npoints_local_wghosts; - double *u = solver->u; - double *rhs = solver->rhs; + int size = solver->m_npoints_local_wghosts; + double *u = solver->m_u; + double *rhs = solver->m_rhs; /* copy solution from PETSc vector */ - TransferVecFromPETSc(u,Y,context,ns,context->offsets[ns]); + TransferVecFromPETSc(u,a_Y,context,ns,context->m_offsets[ns]); /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - MPIExchangeBoundariesnD(solver->ndims,solver->nvars,solver->dim_local, - solver->ghosts,mpi,u); + solver->ApplyBoundaryConditions(solver,mpi,u,NULL,a_t); + MPIExchangeBoundariesnD(solver->m_ndims,solver->m_nvars,solver->m_dim_local, + solver->m_ghosts,mpi,u); /* initialize right-hand side to zero */ - _ArraySetValue_(rhs,size*solver->nvars,0.0); + _ArraySetValue_(rhs,size*solver->m_nvars,0.0); /* Evaluate hyperbolic, parabolic and source terms and the RHS */ - if ((!strcmp(solver->SplitHyperbolicFlux,"yes")) && solver->flag_fdf_specified) { - if (context->flag_hyperbolic_f == _EXPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->FdFFunction,solver->UpwindFdF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if ((!strcmp(solver->m_split_hyperbolic_flux,"yes")) && solver->m_flag_fdf_specified) { + if (context->m_flag_hyperbolic_f == _EXPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->FdFFunction,solver->UpwindFdF); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _EXPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if (context->m_flag_hyperbolic_df == _EXPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->dFFunction,solver->UpwinddF); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } - } else if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (context->flag_hyperbolic_f == _EXPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp, 1.0,rhs,size*solver->nvars); + } else if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (context->m_flag_hyperbolic_f == _EXPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->FFunction,solver->Upwind); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->dFFunction,solver->UpwinddF); + _ArrayAXPY_(solver->m_hyp, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_hyperbolic_df == _EXPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->dFFunction,solver->UpwinddF); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if (context->m_flag_hyperbolic_df == _EXPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->dFFunction,solver->UpwinddF); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } else { - if (context->flag_hyperbolic == _EXPLICIT_) { - solver->HyperbolicFunction(solver->hyp,u,solver,mpi,t,0,solver->FFunction,solver->Upwind); - _ArrayAXPY_(solver->hyp,-1.0,rhs,size*solver->nvars); + if (context->m_flag_hyperbolic == _EXPLICIT_) { + solver->HyperbolicFunction(solver->m_hyp,u,solver,mpi,a_t,0,solver->FFunction,solver->Upwind); + _ArrayAXPY_(solver->m_hyp,-1.0,rhs,size*solver->m_nvars); } } - if (context->flag_parabolic == _EXPLICIT_) { - solver->ParabolicFunction (solver->par,u,solver,mpi,t); - _ArrayAXPY_(solver->par, 1.0,rhs,size*solver->nvars); + if (context->m_flag_parabolic == _EXPLICIT_) { + solver->ParabolicFunction (solver->m_par,u,solver,mpi,a_t); + _ArrayAXPY_(solver->m_par, 1.0,rhs,size*solver->m_nvars); } - if (context->flag_source == _EXPLICIT_) { - solver->SourceFunction (solver->source,u,solver,mpi,t); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + if (context->m_flag_source == _EXPLICIT_) { + solver->SourceFunction (solver->m_source,u,solver,mpi,a_t); + _ArrayAXPY_(solver->m_source, 1.0,rhs,size*solver->m_nvars); } /* Transfer RHS to PETSc vector */ - TransferVecToPETSc(rhs,F,context,ns,context->offsets[ns]); + TransferVecToPETSc(rhs,a_F,context,ns,context->m_offsets[ns]); } PetscFunctionReturn(0); diff --git a/src/PETScFunctions/PetscRegisterTIMethods.cpp b/src/PETScFunctions/PetscRegisterTIMethods.cpp index 6f6c0206..4ddaadfb 100644 --- a/src/PETScFunctions/PetscRegisterTIMethods.cpp +++ b/src/PETScFunctions/PetscRegisterTIMethods.cpp @@ -43,7 +43,7 @@ To do: + Add support for TSGLEE when it gets merged to PETSc's master. */ -int PetscRegisterTIMethods(int rank /*!< MPI rank */) +int PetscRegisterTIMethods(int a_rank /*!< MPI rank */) { PetscErrorCode ierr; int ierr2; @@ -88,8 +88,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) else if (!strcmp(word,"pinterp")) { ierr2 = fscanf(in,"%d",&pinterp);if (ierr2 != 1) return(1); } else if (!strcmp(word,"At")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { At = (PetscReal*) calloc (s*s, sizeof(PetscReal)); @@ -102,8 +102,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"A")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { A = (PetscReal*) calloc (s*s, sizeof(PetscReal)); @@ -116,8 +116,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"bt")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { bt = (PetscReal*) calloc (s, sizeof(PetscReal)); @@ -126,8 +126,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"b")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { b = (PetscReal*) calloc (s, sizeof(PetscReal)); @@ -136,8 +136,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"ct")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { ct = (PetscReal*) calloc (s, sizeof(PetscReal)); @@ -146,8 +146,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"c")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { c = (PetscReal*) calloc (s, sizeof(PetscReal)); @@ -156,8 +156,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"bembt")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { bembt = (PetscReal*) calloc (s, sizeof(PetscReal)); @@ -166,8 +166,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"bemb")) { if (s == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); - if (!rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages must be defined "); + if (!a_rank) fprintf(stderr,"before specifying the Butcher tableaux entries.\n" ); return(1); } else { bemb = (PetscReal*) calloc (s, sizeof(PetscReal)); @@ -176,8 +176,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"bintt")) { if (s == 0 || pinterp == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages and pinterp must be " ); - if (!rank) fprintf(stderr,"defined as positive values before specifying interpolation coeffs.\n"); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages and pinterp must be " ); + if (!a_rank) fprintf(stderr,"defined as positive values before specifying interpolation coeffs.\n"); return(1); } else { bintt = (PetscReal*) calloc (s*pinterp, sizeof(PetscReal)); @@ -190,8 +190,8 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } else if (!strcmp(word,"bint")) { if (s == 0 || pinterp == 0) { - if (!rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages and pinterp must be " ); - if (!rank) fprintf(stderr,"defined as positive values before specifying interpolation coeffs.\n"); + if (!a_rank) fprintf(stderr,"Error in PetscRegisterTIMethods(): nstages and pinterp must be " ); + if (!a_rank) fprintf(stderr,"defined as positive values before specifying interpolation coeffs.\n"); return(1); } else { bint = (PetscReal*) calloc (s*pinterp, sizeof(PetscReal)); @@ -205,7 +205,7 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } } } else { - if (!rank) fprintf(stderr,"Error: Illegal format in file \"time_method.inp\" (expected keyword \"begin\").\n"); + if (!a_rank) fprintf(stderr,"Error: Illegal format in file \"time_method.inp\" (expected keyword \"begin\").\n"); return(1); } @@ -213,7 +213,7 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) if (!strcmp(type,"arkimex")) { if (A && At) { ierr = TSARKIMEXRegister(name,order,s,At,bt,ct,A,b,c,bembt,bemb,pinterp,bintt,bint); CHKERRQ(ierr); - if (!rank) { + if (!a_rank) { printf("\nRegistered custom ARKIMEX scheme \"%s\" with the following Butcher tableaux:-\n",name); int i,j; for (i = 0; i < s; i++) { @@ -242,7 +242,7 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) printf("\n\n"); } } else { - if (!rank) { + if (!a_rank) { fprintf(stderr,"Warning in PetscRegisterTIMethods(): Failed to register method "); fprintf(stderr,"(A or At not defined).\n"); } @@ -250,7 +250,7 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) } else if (!strcmp(type,"rk")) { if (A) { ierr = TSRKRegister(name,order,s,A,b,c,bemb,pinterp,bint); CHKERRQ(ierr); - if (!rank) { + if (!a_rank) { printf("\nRegistered custom RK scheme \"%s\" with the following Butcher tableaux:-\n",name); int i,j; for (i = 0; i < s; i++) { @@ -268,13 +268,13 @@ int PetscRegisterTIMethods(int rank /*!< MPI rank */) printf("\n\n"); } } else { - if (!rank) { + if (!a_rank) { fprintf(stderr,"Warning in PetscRegisterTIMethods(): Failed to register method "); fprintf(stderr,"(A not defined).\n"); } } } else { - if (!rank){ + if (!a_rank){ fprintf(stderr,"Error in PetscRegisterTIMethods(): %s class of time-integration schemes ",type); fprintf(stderr,"does not support custom method registration and usage.\n"); } diff --git a/src/PETScFunctions/PetscSetInitialGuessROM.cpp b/src/PETScFunctions/PetscSetInitialGuessROM.cpp index ecd190f3..60abd2da 100644 --- a/src/PETScFunctions/PetscSetInitialGuessROM.cpp +++ b/src/PETScFunctions/PetscSetInitialGuessROM.cpp @@ -15,31 +15,31 @@ /*! Compute the initial guess for a nonlinear solve * using a trained libROM reduced-order model. */ -PetscErrorCode PetscSetInitialGuessROM( SNES snes, /*!< Nonlinear solver object (see PETSc SNES) */ - Vec X, /*!< Initial guess vector */ +PetscErrorCode PetscSetInitialGuessROM( SNES a_snes, /*!< Nonlinear solver object (see PETSc SNES) */ + Vec a_X, /*!< Initial guess vector */ void* ctxt /*!< Application context */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; - int nsims = context->nsims; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; + int nsims = context->m_nsims; PetscFunctionBegin; - double stage_time = context->t_start; - if (context->stage_times.size() > (context->stage_index+1)) { - stage_time += context->stage_times[context->stage_index+1] * context->dt; + double stage_time = context->m_t_start; + if (context->m_stage_times.size() > (context->m_stage_index+1)) { + stage_time += context->m_stage_times[context->m_stage_index+1] * context->m_dt; } else { - stage_time += context->dt; + stage_time += context->m_dt; } - ((libROMInterface*)context->rom_interface)->predict(sim, stage_time); - if (!context->rank) { + ((libROMInterface*)context->m_rom_interface)->predict(sim, stage_time); + if (!context->m_rank) { printf( "libROM: Predicted ROM intial guess (time %1.4e), wallclock time: %f.\n", - stage_time, ((libROMInterface*)context->rom_interface)->predictWallclockTime() ); + stage_time, ((libROMInterface*)context->m_rom_interface)->predictWallclockTime() ); } for (int ns = 0; ns < nsims; ns++) { - TransferVecToPETSc(sim[ns].solver.u,X,context,ns,context->offsets[ns]); + TransferVecToPETSc(sim[ns].solver.m_u,a_X,context,ns,context->m_offsets[ns]); } diff --git a/src/PETScFunctions/TransferFromPETSc.cpp b/src/PETScFunctions/TransferFromPETSc.cpp index b8b6b657..27c4b503 100644 --- a/src/PETScFunctions/TransferFromPETSc.cpp +++ b/src/PETScFunctions/TransferFromPETSc.cpp @@ -20,28 +20,28 @@ \sa TransferVecToPETSc() */ -int TransferVecFromPETSc( double* const u, /*!< HyPar::u type array (with ghost points) */ - const Vec Y, /*!< PETSc vector */ - void* ctxt, /*!< Object of type #PETScContext */ - const int sim_idx,/*!< Simulation object index */ - const int offset /*!< Offset */ ) +int TransferVecFromPETSc( double* const a_u, /*!< HyPar::u type array (with ghost points) */ + const Vec a_Y, /*!< PETSc vector */ + void* a_ctxt, /*!< Object of type #PETScContext */ + const int a_sim_idx,/*!< Simulation object index */ + const int a_offset /*!< Offset */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; const double* Yarr; PetscFunctionBegin; - VecGetArrayRead(Y,&Yarr); - std::vector index(sim[sim_idx].solver.ndims,0); - ArrayCopynD( sim[sim_idx].solver.ndims, - (Yarr+offset), - u, - sim[sim_idx].solver.dim_local, + VecGetArrayRead(a_Y,&Yarr); + std::vector index(sim[a_sim_idx].solver.m_ndims,0); + ArrayCopynD( sim[a_sim_idx].solver.m_ndims, + (Yarr+a_offset), + a_u, + sim[a_sim_idx].solver.m_dim_local, 0, - sim[sim_idx].solver.ghosts, + sim[a_sim_idx].solver.m_ghosts, index.data(), - sim[sim_idx].solver.nvars ); - VecRestoreArrayRead(Y,&Yarr); + sim[a_sim_idx].solver.m_nvars ); + VecRestoreArrayRead(a_Y,&Yarr); PetscFunctionReturn(0); } diff --git a/src/PETScFunctions/TransferToPETSc.cpp b/src/PETScFunctions/TransferToPETSc.cpp index 86aef697..a885f9eb 100644 --- a/src/PETScFunctions/TransferToPETSc.cpp +++ b/src/PETScFunctions/TransferToPETSc.cpp @@ -21,28 +21,28 @@ \sa TransferVecFromPETSc() */ -int TransferVecToPETSc( const double* const u, /*!< HyPar::u type array (with ghost points) */ - Vec Y, /*!< PETSc vector */ - void* ctxt, /*!< Object of type #PETScContext */ - const int sim_idx,/*!< Simulation object index */ - const int offset /*!< Offset */ ) +int TransferVecToPETSc( const double* const a_u, /*!< HyPar::u type array (with ghost points) */ + Vec a_Y, /*!< PETSc vector */ + void* a_ctxt, /*!< Object of type #PETScContext */ + const int a_sim_idx,/*!< Simulation object index */ + const int a_offset /*!< Offset */ ) { - PETScContext* context = (PETScContext*) ctxt; - SimulationObject* sim = (SimulationObject*) context->simobj; + PETScContext* context = (PETScContext*) a_ctxt; + SimulationObject* sim = (SimulationObject*) context->m_simobj; double* Yarr; PetscFunctionBegin; - VecGetArray(Y,&Yarr); - std::vector index(sim[sim_idx].solver.ndims,0); - ArrayCopynD( sim[sim_idx].solver.ndims, - u, - (Yarr+offset), - sim[sim_idx].solver.dim_local, - sim[sim_idx].solver.ghosts, + VecGetArray(a_Y,&Yarr); + std::vector index(sim[a_sim_idx].solver.m_ndims,0); + ArrayCopynD( sim[a_sim_idx].solver.m_ndims, + a_u, + (Yarr+a_offset), + sim[a_sim_idx].solver.m_dim_local, + sim[a_sim_idx].solver.m_ghosts, 0, index.data(), - sim[sim_idx].solver.nvars ); - VecRestoreArray(Y,&Yarr); + sim[a_sim_idx].solver.m_nvars ); + VecRestoreArray(a_Y,&Yarr); PetscFunctionReturn(0); } @@ -50,30 +50,30 @@ int TransferVecToPETSc( const double* const u, /*!< HyPar::u type array (with gh /*! Copy a matrix of type #BandedMatrix to a PETSc matrix. */ -int TransferMatToPETSc( void *J, /*!< Matrix of type #BandedMatrix */ - Mat A, /*!< PETSc matrix */ - void *ctxt /*!< Object of type #PETScContext */ ) +int TransferMatToPETSc( void *a_J, /*!< Matrix of type #BandedMatrix */ + Mat a_A, /*!< PETSc matrix */ + void *a_ctxt /*!< Object of type #PETScContext */ ) { - BandedMatrix *M = (BandedMatrix*) J; + BandedMatrix *M = (BandedMatrix*) a_J; PetscErrorCode ierr = 0; - int bs = M->BlockSize, nbands = M->nbands, bs2 = bs*bs; + int bs = M->m_BlockSize, nbands = M->m_nbands, bs2 = bs*bs; - for (int i=0; inrows_local; i++) { + for (int i=0; im_nrows_local; i++) { int colind[nbands]; double val[bs][bs*nbands]; for (int n=0; nncol[nbands*i+n]; + colind[n] = M->m_ncol[nbands*i+n]; for (int p=0; pdata[i*nbands*bs2+n*bs2+p*bs+q]; + val[p][n*bs+q] = M->m_data[i*nbands*bs2+n*bs2+p*bs+q]; } } } - MatSetValuesBlocked(A,1,&M->nrow[i],M->nbands,&colind[0],&val[0][0],INSERT_VALUES); + MatSetValuesBlocked(a_A,1,&M->m_nrow[i],M->m_nbands,&colind[0],&val[0][0],INSERT_VALUES); } - MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY); - MatAssemblyEnd (A,MAT_FINAL_ASSEMBLY); + MatAssemblyBegin(a_A,MAT_FINAL_ASSEMBLY); + MatAssemblyEnd (a_A,MAT_FINAL_ASSEMBLY); return(0); } diff --git a/src/PhysicalModels/Burgers/BurgersAdvection.c b/src/PhysicalModels/Burgers/BurgersAdvection.c index 689eecb2..41f49fbe 100644 --- a/src/PhysicalModels/Burgers/BurgersAdvection.c +++ b/src/PhysicalModels/Burgers/BurgersAdvection.c @@ -14,21 +14,21 @@ {\bf F}\left({\bf u}\right) = 0.5 {\bf u}^2 \f} */ -int BurgersAdvection( double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the conserved solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ +int BurgersAdvection( double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the conserved solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Burgers *param = (Burgers*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Burgers *param = (Burgers*) solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -41,7 +41,7 @@ int BurgersAdvection( double *f, /*!< Array to hold the computed flux (same s int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - for (v = 0; v < nvars; v++) f[nvars*p+v] = 0.5 * u[nvars*p+v] * u[nvars*p+v]; + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = 0.5 * a_u[nvars*p+v] * a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Burgers/BurgersCleanup.c b/src/PhysicalModels/Burgers/BurgersCleanup.c index 23f9f205..d6636008 100644 --- a/src/PhysicalModels/Burgers/BurgersCleanup.c +++ b/src/PhysicalModels/Burgers/BurgersCleanup.c @@ -7,9 +7,9 @@ #include /*! Function to clean up all physics-related allocations for the Burgers equations */ -int BurgersCleanup(void *s /*!< Solver object of type #HyPar */) +int BurgersCleanup(void *a_s /*!< Solver object of type #HyPar */) { - Burgers *physics = (Burgers*) s; + Burgers *physics = (Burgers*) a_s; return(0); } diff --git a/src/PhysicalModels/Burgers/BurgersComputeCFL.c b/src/PhysicalModels/Burgers/BurgersComputeCFL.c index af90295e..8da23d60 100644 --- a/src/PhysicalModels/Burgers/BurgersComputeCFL.c +++ b/src/PhysicalModels/Burgers/BurgersComputeCFL.c @@ -12,20 +12,20 @@ /*! Computes the maximum CFL number over the domain. Note that the CFL is computed over the local domain on this processor only. */ -double BurgersComputeCFL( void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ +double BurgersComputeCFL( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - Burgers *params = (Burgers*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Burgers *params = (Burgers*) solver->m_physics; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *u = solver->u; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *u = solver->m_u; int index[ndims], dir, v; @@ -36,8 +36,8 @@ double BurgersComputeCFL( void *s, /*!< Solver object of type #HyPar */ for (v=0; vdxinv,dxinv); /* 1/dx */ - double local_cfl = u[nvars*p+v]*dt*dxinv; + _GetCoordinate_(dir,index[dir],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + double local_cfl = u[nvars*p+v]*a_dt*dxinv; if (local_cfl > max_cfl) max_cfl = local_cfl; } } diff --git a/src/PhysicalModels/Burgers/BurgersInitialize.c b/src/PhysicalModels/Burgers/BurgersInitialize.c index 4f5cd0c4..694f9519 100644 --- a/src/PhysicalModels/Burgers/BurgersInitialize.c +++ b/src/PhysicalModels/Burgers/BurgersInitialize.c @@ -22,23 +22,23 @@ int BurgersUpwind (double*,double*,double*,double*, allocate and set physics-related parameters, read physics-related inputs from file, and set the physics-related function pointers in #HyPar */ -int BurgersInitialize(void *s, /*!< Solver object of type #HyPar */ - void *m /*!< Object of type #MPIVariables containing MPI-related info */ +int BurgersInitialize(void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related info */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Burgers *physics = (Burgers*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Burgers *physics = (Burgers*) solver->m_physics; int i, ferr; - static int count = 0; + static int s_count = 0; /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; in = fopen("physics.inp","r"); if (in) { - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); char word[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "begin")){ @@ -60,8 +60,8 @@ int BurgersInitialize(void *s, /*!< Solver object of type #HyPar */ fclose(in); } - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in BurgersInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -76,6 +76,6 @@ int BurgersInitialize(void *s, /*!< Solver object of type #HyPar */ solver->FFunction = BurgersAdvection; solver->Upwind = BurgersUpwind; - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/Burgers/BurgersUpwind.c b/src/PhysicalModels/Burgers/BurgersUpwind.c index f40defe6..f60b583d 100644 --- a/src/PhysicalModels/Burgers/BurgersUpwind.c +++ b/src/PhysicalModels/Burgers/BurgersUpwind.c @@ -12,52 +12,52 @@ #include /*! Upwinding scheme for the Burgers equations */ -int BurgersUpwind( double* fI, /*!< Computed upwind interface flux */ - double* fL, /*!< Left-biased reconstructed interface flux */ - double* fR, /*!< Right-biased reconstructed interface flux */ - double* uL, /*!< Left-biased reconstructed interface solution */ - double* uR, /*!< Right-biased reconstructed interface solution */ - double* u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void* s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ +int BurgersUpwind( double* a_fI, /*!< Computed upwind interface flux */ + double* a_fL, /*!< Left-biased reconstructed interface flux */ + double* a_fR, /*!< Right-biased reconstructed interface flux */ + double* a_uL, /*!< Left-biased reconstructed interface solution */ + double* a_uR, /*!< Right-biased reconstructed interface solution */ + double* a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void* a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Burgers *param = (Burgers*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Burgers *param = (Burgers*) solver->m_physics; int done,v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); for (v = 0; v < nvars; v++) { - double eigL = u[nvars*pL+v], - eigR = u[nvars*pR+v]; + double eigL = a_u[nvars*pL+v], + eigR = a_u[nvars*pR+v]; if ((eigL > 0) && (eigR > 0)) { - fI[nvars*p+v] = fL[nvars*p+v]; + a_fI[nvars*p+v] = a_fL[nvars*p+v]; } else if ((eigL < 0) && (eigR < 0)) { - fI[nvars*p+v] = fR[nvars*p+v]; + a_fI[nvars*p+v] = a_fR[nvars*p+v]; } else { double alpha = max(absolute(eigL), absolute(eigR)); - fI[nvars*p+v] = 0.5 * (fL[nvars*p+v] + fR[nvars*p+v] - alpha * (uR[nvars*p+v] - uL[nvars*p+v])); + a_fI[nvars*p+v] = 0.5 * (a_fL[nvars*p+v] + a_fR[nvars*p+v] - alpha * (a_uR[nvars*p+v] - a_uL[nvars*p+v])); } } diff --git a/src/PhysicalModels/Euler1D/Euler1DCleanup.c b/src/PhysicalModels/Euler1D/Euler1DCleanup.c index 12605afd..99be1f50 100644 --- a/src/PhysicalModels/Euler1D/Euler1DCleanup.c +++ b/src/PhysicalModels/Euler1D/Euler1DCleanup.c @@ -8,12 +8,12 @@ /*! Function to clean up all physics-related allocations for the 1D Euler equations */ int Euler1DCleanup( - void *s /*!< Solver object of type #HyPar */ + void *a_s /*!< Solver object of type #HyPar */ ) { - Euler1D *param = (Euler1D*) s; - free(param->grav_field); - free(param->fast_jac); - free(param->solution); + Euler1D *param = (Euler1D*) a_s; + free(param->m_grav_field); + free(param->m_fast_jac); + free(param->m_solution); return(0); } diff --git a/src/PhysicalModels/Euler1D/Euler1DComputeCFL.c b/src/PhysicalModels/Euler1D/Euler1DComputeCFL.c index 7170d66b..085d06b5 100644 --- a/src/PhysicalModels/Euler1D/Euler1DComputeCFL.c +++ b/src/PhysicalModels/Euler1D/Euler1DComputeCFL.c @@ -15,20 +15,20 @@ is computed over the local domain on this processor only. */ double Euler1DComputeCFL( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; - double *u = solver->u; + double *u = solver->m_u; double max_cfl = 0; int done = 0; _ArraySetValue_(index,ndims,0); @@ -36,9 +36,9 @@ double Euler1DComputeCFL( int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double rho, v, e, P, c, dxinv, local_cfl; _Euler1DGetFlowVar_((u+_MODEL_NVARS_*p),rho,v,e,P,param); - _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - c = sqrt(param->gamma*P/rho); /* speed of sound */ - local_cfl = (absolute(v)+c)*dt*dxinv; /* local cfl for this grid point */ + _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + c = sqrt(param->m_gamma*P/rho); /* speed of sound */ + local_cfl = (absolute(v)+c)*a_dt*dxinv; /* local cfl for this grid point */ if (local_cfl > max_cfl) max_cfl = local_cfl; _ArrayIncrementIndex_(ndims,dim,index,done); } diff --git a/src/PhysicalModels/Euler1D/Euler1DEigen.c b/src/PhysicalModels/Euler1D/Euler1DEigen.c index 1b0b9134..b0e56f40 100644 --- a/src/PhysicalModels/Euler1D/Euler1DEigen.c +++ b/src/PhysicalModels/Euler1D/Euler1DEigen.c @@ -17,15 +17,15 @@ to interpolation functions for a characteristic-based reconstruction. */ int Euler1DLeftEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *L, /*!< Array of size nvar^2 = 3^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_L, /*!< Array of size nvar^2 = 3^2 to save the matrix of left eigenvectors in (row-major format). */ - void *p, /*!< Object of type #Euler1D with physics-related variables */ - int dir /*!< Spatial dimension (not used, since this is a 1D system) */ + void *a_p, /*!< Object of type #Euler1D with physics-related variables */ + int a_dir /*!< Spatial dimension (not used, since this is a 1D system) */ ) { - Euler1D *param = (Euler1D*) p; - _Euler1DLeftEigenvectors_(u,L,param,dir); + Euler1D *param = (Euler1D*) a_p; + _Euler1DLeftEigenvectors_(a_u,a_L,param,a_dir); return(0); } @@ -36,14 +36,14 @@ int Euler1DLeftEigenvectors( to interpolation functions for a characteristic-based reconstruction. */ int Euler1DRightEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *R, /*!< Array of size nvar^2 = 3^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_R, /*!< Array of size nvar^2 = 3^2 to save the matrix of right eigenvectors in (row-major format). */ - void *p, /*!< Object of type #Euler1D with physics-related variables */ - int dir /*!< Spatial dimension (not used, since this is a 1D system) */ + void *a_p, /*!< Object of type #Euler1D with physics-related variables */ + int a_dir /*!< Spatial dimension (not used, since this is a 1D system) */ ) { - Euler1D *param = (Euler1D*) p; - _Euler1DRightEigenvectors_(u,R,param,dir); + Euler1D *param = (Euler1D*) a_p; + _Euler1DRightEigenvectors_(a_u,a_R,param,a_dir); return(0); } diff --git a/src/PhysicalModels/Euler1D/Euler1DFlux.c b/src/PhysicalModels/Euler1D/Euler1DFlux.c index 9b3549c6..00e0b44a 100644 --- a/src/PhysicalModels/Euler1D/Euler1DFlux.c +++ b/src/PhysicalModels/Euler1D/Euler1DFlux.c @@ -14,17 +14,17 @@ \f} */ int Euler1DFlux( - double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the conserved solution */ - int dir,/*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ + double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the conserved solution */ + int a_dir,/*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int ndims = _MODEL_NDIMS_; static const int nvars = _MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -38,8 +38,8 @@ int Euler1DFlux( while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double rho, v, e, P; - _Euler1DGetFlowVar_((u+nvars*p),rho,v,e,P,param); - _Euler1DSetFlux_((f+nvars*p),rho,v,e,P); + _Euler1DGetFlowVar_((a_u+nvars*p),rho,v,e,P,param); + _Euler1DSetFlux_((a_f+nvars*p),rho,v,e,P); _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -62,17 +62,17 @@ int Euler1DFlux( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369 */ int Euler1DStiffFlux( - double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the conserved solution */ - int dir,/*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ + double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the conserved solution */ + int a_dir,/*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int ndims = _MODEL_NDIMS_; static const int nvars = _MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -85,7 +85,7 @@ int Euler1DStiffFlux( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - _Euler1DSetLinearizedStiffFlux_((f+nvars*p),(u+nvars*p),(param->fast_jac+nvars*nvars*p)); + _Euler1DSetLinearizedStiffFlux_((a_f+nvars*p),(a_u+nvars*p),(param->m_fast_jac+nvars*nvars*p)); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Euler1D/Euler1DFunctions.c b/src/PhysicalModels/Euler1D/Euler1DFunctions.c index b84aa252..a1c956f9 100644 --- a/src/PhysicalModels/Euler1D/Euler1DFunctions.c +++ b/src/PhysicalModels/Euler1D/Euler1DFunctions.c @@ -14,13 +14,13 @@ to interpolation functions for a characteristic-based reconstruction. */ int Euler1DRoeAverage( - double *uavg, /*!< The computed Roe-averaged state */ - double *uL, /*!< Left state (conserved variables)*/ - double *uR, /*!< Right state (conserved variables)*/ - void *p /*!< Object of type #Euler1D with physics-related variables */ + double *a_uavg, /*!< The computed Roe-averaged state */ + double *a_uL, /*!< Left state (conserved variables)*/ + double *a_uR, /*!< Right state (conserved variables)*/ + void *a_p /*!< Object of type #Euler1D with physics-related variables */ ) { - Euler1D *param = (Euler1D*) p; - _Euler1DRoeAverage_(uavg,uL,uR,param); + Euler1D *param = (Euler1D*) a_p; + _Euler1DRoeAverage_(a_uavg,a_uL,a_uR,param); return(0); } diff --git a/src/PhysicalModels/Euler1D/Euler1DGravityField.c b/src/PhysicalModels/Euler1D/Euler1DGravityField.c index 8c7a854c..0aff4c8c 100644 --- a/src/PhysicalModels/Euler1D/Euler1DGravityField.c +++ b/src/PhysicalModels/Euler1D/Euler1DGravityField.c @@ -21,17 +21,17 @@ the domain. */ int Euler1DGravityField( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Euler1D *param = (Euler1D*) solver->m_physics; - double *S = param->grav_field; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + double *S = param->m_grav_field; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_], d, done; @@ -45,10 +45,10 @@ int Euler1DGravityField( done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord); - if (param->grav_type == 0) { - S[p] = exp(-param->grav*xcoord); - } else if (param->grav_type == 1) { + double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->m_x,xcoord); + if (param->m_grav_type == 0) { + S[p] = exp(-param->m_grav*xcoord); + } else if (param->m_grav_type == 1) { double pi = 4.0 * atan(1.0); double phi = -sin(2*pi*xcoord)/(2*pi); S[p] = exp(-phi); @@ -56,14 +56,14 @@ int Euler1DGravityField( _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } - if (param->grav_type != 1) { + if (param->m_grav_type != 1) { /* a sensible simulation will not specify peridic boundary conditions * along a direction in which gravity acts (unless the gravitational field * itself is sinusoidal), so extrapolate the gravity field at the boundaries */ int indexb[_MODEL_NDIMS_], indexi[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { /* left boundary */ - if (!mpi->ip[d]) { + if (!mpi->m_ip[d]) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = -ghosts; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -76,7 +76,7 @@ int Euler1DGravityField( } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = dim[d]; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); diff --git a/src/PhysicalModels/Euler1D/Euler1DInitialize.c b/src/PhysicalModels/Euler1D/Euler1DInitialize.c index bea184e2..79555966 100644 --- a/src/PhysicalModels/Euler1D/Euler1DInitialize.c +++ b/src/PhysicalModels/Euler1D/Euler1DInitialize.c @@ -69,36 +69,36 @@ int Euler1DPreStep (double*,void*,void*,double); \b Note: "physics.inp" is \b optional; if absent, default values will be used. */ int Euler1DInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< Object of type #MPIVariables containing MPI-related info */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related info */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Euler1D *physics = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Euler1D *physics = (Euler1D*) solver->m_physics; int ferr, d; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in Euler1DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in Euler1DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->gamma = 1.4; - physics->grav = 0.0; - physics->grav_type = 0; - strcpy(physics->upw_choice,"roe"); + physics->m_gamma = 1.4; + physics->m_grav = 0.0; + physics->m_grav_type = 0; + strcpy(physics->m_upw_choice,"roe"); /* reading physical model specific inputs */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -108,16 +108,16 @@ int Euler1DInitialize( while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gamma")) { - ferr = fscanf(in,"%lf",&physics->gamma); + ferr = fscanf(in,"%lf",&physics->m_gamma); if (ferr != 1) return(1); } else if (!strcmp(word, "gravity")) { - ferr = fscanf(in,"%lf",&physics->grav); + ferr = fscanf(in,"%lf",&physics->m_grav); if (ferr != 1) return(1); } else if (!strcmp(word, "gravity_type")) { - ferr = fscanf(in,"%d",&physics->grav_type); + ferr = fscanf(in,"%d",&physics->m_grav_type); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upw_choice); + ferr = fscanf(in,"%s",physics->m_upw_choice); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; @@ -135,14 +135,14 @@ int Euler1DInitialize( } #ifndef serial - IERR MPIBroadcast_double (&physics->gamma ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->grav ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->grav_type,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->upw_choice,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_gamma ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_grav ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->m_grav_type,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_upw_choice,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); #endif - if ((physics->grav != 0.0) && (strcmp(physics->upw_choice,_LLF_)) && (strcmp(physics->upw_choice,_ROE_))) { - if (!mpi->rank) { + if ((physics->m_grav != 0.0) && (strcmp(physics->m_upw_choice,_LLF_)) && (strcmp(physics->m_upw_choice,_ROE_))) { + if (!mpi->m_rank) { fprintf(stderr,"Error in Euler1DInitialize: %s or %s upwinding is needed for flows ",_LLF_,_ROE_); fprintf(stderr,"with gravitational forces.\n"); } @@ -155,26 +155,26 @@ int Euler1DInitialize( solver->FFunction = Euler1DFlux; solver->SFunction = Euler1DSource; solver->UFunction = Euler1DModifiedSolution; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = Euler1DUpwindRoe; - else if (!strcmp(physics->upw_choice,_RF_ )) solver->Upwind = Euler1DUpwindRF; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = Euler1DUpwindLLF; - else if (!strcmp(physics->upw_choice,_SWFS_ )) solver->Upwind = Euler1DUpwindSWFS; - else if (!strcmp(physics->upw_choice,_RUSANOV_)) solver->Upwind = Euler1DUpwindRusanov; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->Upwind = Euler1DUpwindRoe; + else if (!strcmp(physics->m_upw_choice,_RF_ )) solver->Upwind = Euler1DUpwindRF; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->Upwind = Euler1DUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_SWFS_ )) solver->Upwind = Euler1DUpwindSWFS; + else if (!strcmp(physics->m_upw_choice,_RUSANOV_)) solver->Upwind = Euler1DUpwindRusanov; else { - if (!mpi->rank) fprintf(stderr,"Error in Euler1DInitialize(): %s is not a valid upwinding scheme.\n", - physics->upw_choice); + if (!mpi->m_rank) fprintf(stderr,"Error in Euler1DInitialize(): %s is not a valid upwinding scheme.\n", + physics->m_upw_choice); return(1); } - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { solver->dFFunction = Euler1DStiffFlux; solver->JFunction = Euler1DStiffJacobian; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->UpwinddF = Euler1DUpwinddFRoe; - else if (!strcmp(physics->upw_choice,_RF_ )) solver->UpwinddF = Euler1DUpwinddFRF; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->UpwinddF = Euler1DUpwinddFLLF; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->UpwinddF = Euler1DUpwinddFRoe; + else if (!strcmp(physics->m_upw_choice,_RF_ )) solver->UpwinddF = Euler1DUpwinddFRF; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->UpwinddF = Euler1DUpwinddFLLF; else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in Euler1DInitialize(): %s is not a valid upwinding scheme ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"when split form of the hyperbolic flux is used. Use %s, %s or %s.\n", _ROE_,_RF_,_LLF_); } @@ -189,18 +189,18 @@ int Euler1DInitialize( solver->GetLeftEigenvectors = Euler1DLeftEigenvectors; solver->GetRightEigenvectors = Euler1DRightEigenvectors; - if (!strcmp(physics->upw_choice,_LLF_ )) physics->SourceUpwind = Euler1DSourceUpwindLLF; - else if (!strcmp(physics->upw_choice,_ROE_ )) physics->SourceUpwind = Euler1DSourceUpwindRoe; + if (!strcmp(physics->m_upw_choice,_LLF_ )) physics->SourceUpwind = Euler1DSourceUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_ROE_ )) physics->SourceUpwind = Euler1DSourceUpwindRoe; /* allocate array to hold the gravity field */ - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int size = 1; for (d=0; d<_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts); - physics->grav_field = (double*) calloc (size, sizeof(double)); - physics->fast_jac = (double*) calloc (size*_MODEL_NVARS_*_MODEL_NVARS_, sizeof(double)); - physics->solution = (double*) calloc (size*_MODEL_NVARS_, sizeof(double)); + physics->m_grav_field = (double*) calloc (size, sizeof(double)); + physics->m_fast_jac = (double*) calloc (size*_MODEL_NVARS_*_MODEL_NVARS_, sizeof(double)); + physics->m_solution = (double*) calloc (size*_MODEL_NVARS_, sizeof(double)); IERR Euler1DGravityField(solver,mpi); CHECKERR(ierr); - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/Euler1D/Euler1DJacobian.c b/src/PhysicalModels/Euler1D/Euler1DJacobian.c index d4a00074..741d2ef9 100644 --- a/src/PhysicalModels/Euler1D/Euler1DJacobian.c +++ b/src/PhysicalModels/Euler1D/Euler1DJacobian.c @@ -11,31 +11,31 @@ solution at a grid point. The Jacobian is square matrix of size nvar=3, and is returned as a 1D array (double) of 9 elements in row-major format. */ -int Euler1DJacobian(double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 9 */ - double *u, /*!< solution at a grid point (array of size nvar = 3) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (x/y/z) (not used, since this is 1D system) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, +int Euler1DJacobian(double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 9 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 3) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (x/y/z) (not used, since this is 1D system) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - Euler1D *param = (Euler1D*) p; + Euler1D *param = (Euler1D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _Euler1DEigenvalues_ (u,D,param,0); - _Euler1DLeftEigenvectors_ (u,L,param,0); - _Euler1DRightEigenvectors_(u,R,param,0); + _Euler1DEigenvalues_ (a_u,D,param,0); + _Euler1DLeftEigenvectors_ (a_u,L,param,0); + _Euler1DRightEigenvectors_(a_u,R,param,0); - int aupw = absolute(upw), k; - k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 4; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 8; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + int aupw = absolute(a_upw), k; + k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 4; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 8; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); MatMult3(3,DL,D,L); - MatMult3(3,Jac,R,DL); + MatMult3(3,a_Jac,R,DL); return(0); } @@ -45,31 +45,31 @@ int Euler1DJacobian(double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 #_Euler1DSetStiffJac_). The Jacobian is square matrix of size nvar=3, and is returned as a 1D array (double) of 9 elements in row-major format. */ -int Euler1DStiffJacobian( double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 9 */ - double *u, /*!< solution at a grid point (array of size nvar = 3) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (x/y/z) (not used, since this is 1D system) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, +int Euler1DStiffJacobian( double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 9 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 3) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (x/y/z) (not used, since this is 1D system) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - Euler1D *param = (Euler1D*) p; + Euler1D *param = (Euler1D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _Euler1DEigenvalues_ (u,D,param,0); - _Euler1DLeftEigenvectors_ (u,L,param,0); - _Euler1DRightEigenvectors_(u,R,param,0); + _Euler1DEigenvalues_ (a_u,D,param,0); + _Euler1DLeftEigenvectors_ (a_u,L,param,0); + _Euler1DRightEigenvectors_(a_u,R,param,0); - int aupw = absolute(upw), k; + int aupw = absolute(a_upw), k; k = 0; D[k] = 0.0; /* remove the entropy eigenmode */ - k = 4; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 8; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + k = 4; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 8; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); MatMult3(3,DL,D,L); - MatMult3(3,Jac,R,DL); + MatMult3(3,a_Jac,R,DL); return(0); } diff --git a/src/PhysicalModels/Euler1D/Euler1DModifiedSolution.c b/src/PhysicalModels/Euler1D/Euler1DModifiedSolution.c index be0d1eae..8bcea979 100644 --- a/src/PhysicalModels/Euler1D/Euler1DModifiedSolution.c +++ b/src/PhysicalModels/Euler1D/Euler1DModifiedSolution.c @@ -21,20 +21,20 @@ Page 651 on why this modification is needed. */ int Euler1DModifiedSolution( - double *uC, /*!< The modified solution (same array size and layout as u) */ - double *u, /*!< The solution (conserved variables) */ - int d, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + double *a_uC, /*!< The modified solution (same array size and layout as a_u) */ + double *a_u, /*!< The solution (conserved variables) */ + int a_d, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double waqt /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -47,7 +47,7 @@ int Euler1DModifiedSolution( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); p *= _MODEL_NVARS_; - _ArrayScaleCopy1D_((u+p),(1.0/param->grav_field[p/_MODEL_NVARS_]),(uC+p),_MODEL_NVARS_); + _ArrayScaleCopy1D_((a_u+p),(1.0/param->m_grav_field[p/_MODEL_NVARS_]),(a_uC+p),_MODEL_NVARS_); _ArrayIncrementIndex_(ndims,bounds,index,done); } return(0); diff --git a/src/PhysicalModels/Euler1D/Euler1DPreStep.c b/src/PhysicalModels/Euler1D/Euler1DPreStep.c index 49eac0cd..54702c0f 100644 --- a/src/PhysicalModels/Euler1D/Euler1DPreStep.c +++ b/src/PhysicalModels/Euler1D/Euler1DPreStep.c @@ -14,16 +14,16 @@ \sa #_Euler1DSetLinearizedStiffFlux_, #_Euler1DSetStiffJac_, #Euler1DStiffFlux */ int Euler1DPreStep( - double *u, /*!< Solution (conserved variables) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + double *a_u, /*!< Solution (conserved variables) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double waqt /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int ndims = _MODEL_NDIMS_; static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -33,14 +33,14 @@ int Euler1DPreStep( /* set offset such that index is compatible with ghost point arrangement */ _ArraySetValue_(offset,ndims,-ghosts); /* copy the solution to act as a reference for linearization */ - _ArrayCopy1D_(u,param->solution,(solver->npoints_local_wghosts*_MODEL_NVARS_)); + _ArrayCopy1D_(a_u,param->m_solution,(solver->m_npoints_local_wghosts*_MODEL_NVARS_)); int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double rho, v, e, P; - _Euler1DGetFlowVar_((u+_MODEL_NVARS_*p),rho,v,e,P,param); - _Euler1DSetStiffJac_((param->fast_jac+JacSize*p),rho,v,e,P,param->gamma); + _Euler1DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,v,e,P,param); + _Euler1DSetStiffJac_((param->m_fast_jac+JacSize*p),rho,v,e,P,param->m_gamma); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Euler1D/Euler1DSource.c b/src/PhysicalModels/Euler1D/Euler1DSource.c index 470a48f5..f783fee9 100644 --- a/src/PhysicalModels/Euler1D/Euler1DSource.c +++ b/src/PhysicalModels/Euler1D/Euler1DSource.c @@ -21,42 +21,42 @@ static int Euler1DSourceFunction(double*,double*,double*,void*,void*,double); http://dx.doi.org/10.1007/s10915-012-9585-8. */ int Euler1DSource( - double *source, /*!< Computed source terms (array size & layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current solution time */ + double *a_source, /*!< Computed source terms (array size & layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar* ) s; - MPIVariables *mpi = (MPIVariables*) m; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Euler1D *param = (Euler1D*) solver->m_physics; - if (param->grav == 0.0) return(0); /* no gravitational forces */ + if (param->m_grav == 0.0) return(0); /* no gravitational forces */ int v, done, p, p1, p2; - double *SourceI = solver->fluxI; /* interace source term */ - double *SourceC = solver->fluxC; /* cell-centered source term */ - double *SourceL = solver->fL; - double *SourceR = solver->fR; + double *SourceI = solver->m_flux_i; /* interace a_source term */ + double *SourceC = solver->m_flux_c; /* cell-centered a_source term */ + double *SourceL = solver->m_f_l; + double *SourceR = solver->m_f_r; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *x = solver->x; - double *dxinv = solver->dxinv; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *x = solver->m_x; + double *dxinv = solver->m_dxinv; int index[ndims],index1[ndims],index2[ndims],dim_interface[ndims]; /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_XDIR_]++; - /* calculate the split source function exp(-phi/RT) */ - IERR Euler1DSourceFunction(SourceC,u,x,solver,mpi,t); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the split a_source function exp(-phi/RT) */ + IERR Euler1DSourceFunction(SourceC,a_u,x,solver,mpi,a_t); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_XDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -65,10 +65,10 @@ int Euler1DSource( _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1); _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse); - double rho, vel, e, P; _Euler1DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vel,e,P,param); + double rho, vel, e, P; _Euler1DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,vel,e,P,param); double term[_MODEL_NVARS_] = {0.0, rho, rho*vel}; for (v=0; v<_MODEL_NVARS_; v++) { - source[_MODEL_NVARS_*p+v] += ( (term[v]*(1.0/param->grav_field[p])) + a_source[_MODEL_NVARS_*p+v] += ( (term[v]*(1.0/param->m_grav_field[p])) * (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse ); } vel = P; /* useless statement to avoid compiler warning */ @@ -87,20 +87,20 @@ int Euler1DSource( http://dx.doi.org/10.1007/s10915-012-9585-8. */ int Euler1DSourceFunction( - double *f, /*!< Computed source function (array size and layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - double *x, /*!< Spatial coordinates */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current solution time */ + double *a_f, /*!< Computed source function (array size and layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + double *a_x, /*!< Spatial coordinates */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar* ) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -113,9 +113,9 @@ int Euler1DSourceFunction( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = param->grav_field[p]; - (f+_MODEL_NVARS_*p)[2] = param->grav_field[p]; + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = param->m_grav_field[p]; + (a_f+_MODEL_NVARS_*p)[2] = param->m_grav_field[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Euler1D/Euler1DSourceUpwind.c b/src/PhysicalModels/Euler1D/Euler1DSourceUpwind.c index ffd60619..fcc95a15 100644 --- a/src/PhysicalModels/Euler1D/Euler1DSourceUpwind.c +++ b/src/PhysicalModels/Euler1D/Euler1DSourceUpwind.c @@ -19,34 +19,34 @@ http://dx.doi.org/10.1007/s10915-012-9585-8. */ int Euler1DSourceUpwindLLF( - double *fI, /*!< Computed interface source term ("upwinded") */ - double *fL, /*!< Left-biased interface source term */ - double *fR, /*!< Right-biased interface source term */ - double *u, /*!< Solution (conserved variables) */ - int dir, /*!< Spatial dimension (unused since this is a 1D case) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed interface source term ("upwinded") */ + double *a_fL, /*!< Left-biased interface source term */ + double *a_fR, /*!< Right-biased interface source term */ + double *a_u, /*!< Solution (conserved variables) */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D case) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); /* Local Lax-Friedrich upwinding scheme */ for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -62,34 +62,34 @@ int Euler1DSourceUpwindLLF( http://dx.doi.org/10.1007/s10915-012-9585-8. */ int Euler1DSourceUpwindRoe( - double *fI, /*!< Computed interface source term ("upwinded") */ - double *fL, /*!< Left-biased interface source term */ - double *fR, /*!< Right-biased interface source term */ - double *u, /*!< Solution (conserved variables) */ - int dir, /*!< Spatial dimension (unused since this is a 1D case) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed interface source term ("upwinded") */ + double *a_fL, /*!< Left-biased interface source term */ + double *a_fR, /*!< Right-biased interface source term */ + double *a_u, /*!< Solution (conserved variables) */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D case) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); /* Local Lax-Friedrich upwinding scheme */ for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/Euler1D/Euler1DUpwind.c b/src/PhysicalModels/Euler1D/Euler1DUpwind.c index 5459665f..be5061b3 100644 --- a/src/PhysicalModels/Euler1D/Euler1DUpwind.c +++ b/src/PhysicalModels/Euler1D/Euler1DUpwind.c @@ -28,55 +28,55 @@ */ int Euler1DUpwindRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts= solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); - _Euler1DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); + _Euler1DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); _Euler1DEigenvalues_ (uavg,D,param,0); _Euler1DLeftEigenvectors_ (uavg,L,param,0); _Euler1DRightEigenvectors_ (uavg,R,param,0); - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); k = 0; D[k] = kappa*absolute(D[k]); k = 4; D[k] = kappa*absolute(D[k]); k = 8; D[k] = kappa*absolute(D[k]); @@ -88,9 +88,9 @@ int Euler1DUpwindRoe( udiss[1] = modA[1*_MODEL_NVARS_+0]*udiff[0] + modA[1*_MODEL_NVARS_+1]*udiff[1] + modA[1*_MODEL_NVARS_+2]*udiff[2]; udiss[2] = modA[2*_MODEL_NVARS_+0]*udiff[0] + modA[2*_MODEL_NVARS_+1]*udiff[1] + modA[2*_MODEL_NVARS_+2]*udiff[2]; - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -113,62 +113,62 @@ int Euler1DUpwindRoe( Note that this upwinding scheme cannot be used for solving flows with non-zero gravitational forces. */ int Euler1DUpwindRF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); /* Roe-Fixed upwinding scheme */ - _Euler1DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); + _Euler1DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); _Euler1DEigenvalues_ (uavg,D,param,0); _Euler1DLeftEigenvectors_ (uavg,L,param,0); _Euler1DRightEigenvectors_(uavg,R,param,0); /* calculate characteristic fluxes and variables */ - MatVecMult3(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); for (k = 0; k < _MODEL_NVARS_; k++) { double eigL,eigC,eigR; - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pL),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param,0); eigL = D[k*_MODEL_NVARS_+k]; - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pR),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param,0); eigR = D[k*_MODEL_NVARS_+k]; _Euler1DEigenvalues_(uavg,D,param,0); eigC = D[k*_MODEL_NVARS_+k]; @@ -183,7 +183,7 @@ int Euler1DUpwindRF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult3(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult3(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -210,62 +210,62 @@ int Euler1DUpwindRF( */ int Euler1DUpwindLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); /* Local Lax-Friedrich upwinding scheme */ - _Euler1DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); + _Euler1DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); _Euler1DEigenvalues_ (uavg,D,param,0); _Euler1DLeftEigenvectors_ (uavg,L,param,0); _Euler1DRightEigenvectors_(uavg,R,param,0); /* calculate characteristic fluxes and variables */ - MatVecMult3(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); for (k = 0; k < _MODEL_NVARS_; k++) { double eigL,eigC,eigR; - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pL),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param,0); eigL = D[k*_MODEL_NVARS_+k]; - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pR),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param,0); eigR = D[k*_MODEL_NVARS_+k]; _Euler1DEigenvalues_(uavg,D,param,0); eigC = D[k*_MODEL_NVARS_+k]; @@ -275,7 +275,7 @@ int Euler1DUpwindLLF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult3(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult3(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -291,49 +291,49 @@ int Euler1DUpwindLLF( Note that this method cannot be used for flows with non-zero gravitational forces. */ int Euler1DUpwindSWFS( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double fp[_MODEL_NVARS_], fm[_MODEL_NVARS_],uavg[_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - double rho,v,e,P,c,gamma=param->gamma,term,Mach; + double rho,v,e,P,c,gamma=param->m_gamma,term,Mach; /* Steger Warming flux splitting */ - _Euler1DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param); + _Euler1DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param); _Euler1DGetFlowVar_(uavg,rho,v,e,P,param); Mach = v/sqrt(gamma*P/rho); if (Mach < -1.0) { - _ArrayCopy1D3_((fR+_MODEL_NVARS_*p),(fI+_MODEL_NVARS_*p),_MODEL_NVARS_); + _ArrayCopy1D3_((a_fR+_MODEL_NVARS_*p),(a_fI+_MODEL_NVARS_*p),_MODEL_NVARS_); } else if (Mach < 1.0) { - _Euler1DGetFlowVar_((uL+_MODEL_NVARS_*p),rho,v,e,P,param); + _Euler1DGetFlowVar_((a_uL+_MODEL_NVARS_*p),rho,v,e,P,param); c = sqrt(gamma*P/rho); term = rho/(2.0*gamma); @@ -341,7 +341,7 @@ int Euler1DUpwindSWFS( fp[1] = term * (2*(gamma-1.0)*v*v + (v+c)*(v+c)); fp[2] = term * ((gamma-1.0)*v*v*v + 0.5*(v+c)*(v+c)*(v+c) + ((3.0-gamma)*(v+c)*c*c)/(2.0*(gamma-1.0))); - _Euler1DGetFlowVar_((uR+_MODEL_NVARS_*p),rho,v,e,P,param); + _Euler1DGetFlowVar_((a_uR+_MODEL_NVARS_*p),rho,v,e,P,param); c = sqrt(gamma*P/rho); term = rho/(2.0*gamma); @@ -349,11 +349,11 @@ int Euler1DUpwindSWFS( fm[1] = term * (v-c) * (v-c); fm[2] = term * (0.5*(v-c)*(v-c)*(v-c) + ((3.0-gamma)*(v-c)*c*c)/(2.0*(gamma-1.0))); - _ArrayAdd1D_((fI+_MODEL_NVARS_*p),fp,fm,_MODEL_NVARS_); + _ArrayAdd1D_((a_fI+_MODEL_NVARS_*p),fp,fm,_MODEL_NVARS_); } else { - _ArrayCopy1D3_((fL+_MODEL_NVARS_*p),(fI+_MODEL_NVARS_*p),_MODEL_NVARS_); + _ArrayCopy1D3_((a_fL+_MODEL_NVARS_*p),(a_fI+_MODEL_NVARS_*p),_MODEL_NVARS_); } @@ -374,29 +374,29 @@ int Euler1DUpwindSWFS( Computational Mathematics and Mathematical Physics, Vol. 1, No. 2, 1962, pp. 304–320 */ int Euler1DUpwindRusanov( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts= solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_]; @@ -405,36 +405,36 @@ int Euler1DUpwindRusanov( _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); - _Euler1DRoeAverage_(uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); - for (k = 0; k < _MODEL_NVARS_; k++) udiff[k] = 0.5 * (uR[_MODEL_NVARS_*p+k] - uL[_MODEL_NVARS_*p+k]); + _Euler1DRoeAverage_(uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); + for (k = 0; k < _MODEL_NVARS_; k++) udiff[k] = 0.5 * (a_uR[_MODEL_NVARS_*p+k] - a_uL[_MODEL_NVARS_*p+k]); double rho, uvel, E, P, c; - _Euler1DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,uvel,E,P,param); - c = param->gamma*P/rho; + _Euler1DGetFlowVar_((a_u+_MODEL_NVARS_*pL),rho,uvel,E,P,param); + c = param->m_gamma*P/rho; double alphaL = c + absolute(uvel); - _Euler1DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,uvel,E,P,param); - c = param->gamma*P/rho; + _Euler1DGetFlowVar_((a_u+_MODEL_NVARS_*pR),rho,uvel,E,P,param); + c = param->m_gamma*P/rho; double alphaR = c + absolute(uvel); _Euler1DGetFlowVar_(uavg,rho,uvel,E,P,param); - c = param->gamma*P/rho; + c = param->m_gamma*P/rho; double alphaavg = c + absolute(uvel); - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); for (k = 0; k < _MODEL_NVARS_; k++) { - fI[_MODEL_NVARS_*p+k] = 0.5 * (fL[_MODEL_NVARS_*p+k]+fR[_MODEL_NVARS_*p+k]) - alpha*udiff[k]; + a_fI[_MODEL_NVARS_*p+k] = 0.5 * (a_fL[_MODEL_NVARS_*p+k]+a_fR[_MODEL_NVARS_*p+k]) - alpha*udiff[k]; } } @@ -451,56 +451,56 @@ int Euler1DUpwindRusanov( characteristic fields / eigen-modes corresponding to \f$ u\pm a\f$ are used. */ int Euler1DUpwinddFRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; - double *uref = param->solution; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *uref = param->m_solution; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); _Euler1DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param); _Euler1DEigenvalues_ (uavg,D,param,0); _Euler1DLeftEigenvectors_ (uavg,L,param,0); _Euler1DRightEigenvectors_ (uavg,R,param,0); - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); k = 0; D[k] = 0.0; k = 4; D[k] = kappa*absolute(D[k]); k = 8; D[k] = kappa*absolute(D[k]); @@ -512,9 +512,9 @@ int Euler1DUpwinddFRoe( udiss[1] = modA[1*_MODEL_NVARS_+0]*udiff[0] + modA[1*_MODEL_NVARS_+1]*udiff[1] + modA[1*_MODEL_NVARS_+2]*udiff[2]; udiss[2] = modA[2*_MODEL_NVARS_+0]*udiff[0] + modA[2*_MODEL_NVARS_+1]*udiff[1] + modA[2*_MODEL_NVARS_+2]*udiff[2]; - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -532,44 +532,44 @@ int Euler1DUpwinddFRoe( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369 */ int Euler1DUpwinddFRF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - double *uref = param->solution; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + double *uref = param->m_solution; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); /* Roe-Fixed upwinding scheme */ @@ -579,16 +579,16 @@ int Euler1DUpwinddFRF( _Euler1DRightEigenvectors_(uavg,R,param,0); /* calculate characteristic fluxes and variables */ - MatVecMult3(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); for (k = 0; k < _MODEL_NVARS_; k++) { double eigL,eigC,eigR; - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pL),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param,0); eigL = (k == 0? 0.0 : D[k*_MODEL_NVARS_+k]); - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pR),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param,0); eigR = (k == 0? 0.0 : D[k*_MODEL_NVARS_+k]); _Euler1DEigenvalues_(uavg,D,param,0); eigC = (k == 0? 0.0 : D[k*_MODEL_NVARS_+k]); @@ -603,7 +603,7 @@ int Euler1DUpwinddFRF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult3(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult3(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -621,44 +621,44 @@ int Euler1DUpwinddFRF( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369 */ int Euler1DUpwinddFLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Euler1D *param = (Euler1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler1D *param = (Euler1D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - double *uref = param->solution; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + double *uref = param->m_solution; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field[pL],param->grav_field[pR]); + double kappa = max(param->m_grav_field[pL],param->m_grav_field[pR]); /* Local Lax-Friedrich upwinding scheme */ @@ -668,16 +668,16 @@ int Euler1DUpwinddFLLF( _Euler1DRightEigenvectors_(uavg,R,param,0); /* calculate characteristic fluxes and variables */ - MatVecMult3(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); for (k = 0; k < _MODEL_NVARS_; k++) { double eigL,eigC,eigR; - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pL),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param,0); eigL = (k == 0? 0.0 : D[k*_MODEL_NVARS_+k]); - _Euler1DEigenvalues_((u+_MODEL_NVARS_*pR),D,param,0); + _Euler1DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param,0); eigR = (k == 0? 0.0 : D[k*_MODEL_NVARS_+k]); _Euler1DEigenvalues_(uavg,D,param,0); eigC = (k == 0? 0.0 : D[k*_MODEL_NVARS_+k]); @@ -687,7 +687,7 @@ int Euler1DUpwinddFLLF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult3(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult3(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/Euler2D/Euler2DCleanup.c b/src/PhysicalModels/Euler2D/Euler2DCleanup.c index 38effa1e..2784062f 100644 --- a/src/PhysicalModels/Euler2D/Euler2DCleanup.c +++ b/src/PhysicalModels/Euler2D/Euler2DCleanup.c @@ -1,7 +1,7 @@ #include #include -int Euler2DCleanup(void *s) +int Euler2DCleanup(void *a_s) { return(0); } diff --git a/src/PhysicalModels/Euler2D/Euler2DComputeCFL.c b/src/PhysicalModels/Euler2D/Euler2DComputeCFL.c index 1a36dee9..f725d393 100644 --- a/src/PhysicalModels/Euler2D/Euler2DComputeCFL.c +++ b/src/PhysicalModels/Euler2D/Euler2DComputeCFL.c @@ -6,17 +6,17 @@ #include #include -double Euler2DComputeCFL(void *s,void *m,double dt,double t) +double Euler2DComputeCFL(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - Euler2D *param = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler2D *param = (Euler2D*) solver->m_physics; _DECLARE_IERR_; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; - double *u = solver->u; + double *u = solver->m_u; double max_cfl = 0; int done = 0; _ArraySetValue_(index,ndims,0); @@ -25,12 +25,12 @@ double Euler2DComputeCFL(void *s,void *m,double dt,double t) double rho,vx,vy,e,P,c,dxinv,dyinv,local_cfl[2]; _Euler2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); - c = sqrt(param->gamma*P/rho); /* speed of sound */ - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */ + c = sqrt(param->m_gamma*P/rho); /* speed of sound */ + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); /* 1/dy */ - local_cfl[_XDIR_] = (absolute(vx)+c)*dt*dxinv; /* local cfl for this grid point (x) */ - local_cfl[_YDIR_] = (absolute(vy)+c)*dt*dyinv; /* local cfl for this grid point (y) */ + local_cfl[_XDIR_] = (absolute(vx)+c)*a_dt*dxinv; /* local cfl for this grid point (x) */ + local_cfl[_YDIR_] = (absolute(vy)+c)*a_dt*dyinv; /* local cfl for this grid point (y) */ if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_]; if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_]; diff --git a/src/PhysicalModels/Euler2D/Euler2DEigen.c b/src/PhysicalModels/Euler2D/Euler2DEigen.c index 3852b8be..ce629f6f 100644 --- a/src/PhysicalModels/Euler2D/Euler2DEigen.c +++ b/src/PhysicalModels/Euler2D/Euler2DEigen.c @@ -13,16 +13,16 @@ */ -int Euler2DLeftEigenvectors(double *u,double *L,void *p,int dir) +int Euler2DLeftEigenvectors(double *a_u,double *a_L,void *a_p,int a_dir) { - Euler2D *param = (Euler2D*) p; - _Euler2DLeftEigenvectors_(u,L,param,dir); + Euler2D *param = (Euler2D*) a_p; + _Euler2DLeftEigenvectors_(a_u,a_L,param,a_dir); return(0); } -int Euler2DRightEigenvectors(double *u,double *R,void *p,int dir) +int Euler2DRightEigenvectors(double *a_u,double *a_R,void *a_p,int a_dir) { - Euler2D *param = (Euler2D*) p; - _Euler2DRightEigenvectors_(u,R,param,dir); + Euler2D *param = (Euler2D*) a_p; + _Euler2DRightEigenvectors_(a_u,a_R,param,a_dir); return(0); } diff --git a/src/PhysicalModels/Euler2D/Euler2DFlux.c b/src/PhysicalModels/Euler2D/Euler2DFlux.c index 4d4f3f33..4d43234d 100644 --- a/src/PhysicalModels/Euler2D/Euler2DFlux.c +++ b/src/PhysicalModels/Euler2D/Euler2DFlux.c @@ -4,15 +4,15 @@ #include #include -int Euler2DFlux(double *f,double *u,int dir,void *s,double t) +int Euler2DFlux(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Euler2D *param = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler2D *param = (Euler2D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; @@ -27,8 +27,8 @@ int Euler2DFlux(double *f,double *u,int dir,void *s,double t) while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double rho, vx, vy, e, P; - _Euler2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); - _Euler2DSetFlux_((f+_MODEL_NVARS_*p),rho,vx,vy,e,P,param,dir); + _Euler2DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); + _Euler2DSetFlux_((a_f+_MODEL_NVARS_*p),rho,vx,vy,e,P,param,a_dir); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Euler2D/Euler2DFunctions.c b/src/PhysicalModels/Euler2D/Euler2DFunctions.c index 50b61c31..4f16bc41 100644 --- a/src/PhysicalModels/Euler2D/Euler2DFunctions.c +++ b/src/PhysicalModels/Euler2D/Euler2DFunctions.c @@ -2,9 +2,9 @@ #include #include -int Euler2DRoeAverage(double *uavg,double *uL,double *uR,void *p) +int Euler2DRoeAverage(double *a_uavg,double *a_uL,double *a_uR,void *a_p) { - Euler2D *param = (Euler2D*) p; - _Euler2DRoeAverage_(uavg,uL,uR,param); + Euler2D *param = (Euler2D*) a_p; + _Euler2DRoeAverage_(a_uavg,a_uL,a_uR,param); return(0); } diff --git a/src/PhysicalModels/Euler2D/Euler2DInitialize.c b/src/PhysicalModels/Euler2D/Euler2DInitialize.c index f12daa95..b9fb2966 100644 --- a/src/PhysicalModels/Euler2D/Euler2DInitialize.c +++ b/src/PhysicalModels/Euler2D/Euler2DInitialize.c @@ -18,32 +18,32 @@ int Euler2DRoeAverage (double*,double*,double*,void*); int Euler2DLeftEigenvectors (double*,double*,void*,int); int Euler2DRightEigenvectors (double*,double*,void*,int); -int Euler2DInitialize(void *s,void *m) +int Euler2DInitialize(void *a_s,void *a_m) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Euler2D *physics = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Euler2D *physics = (Euler2D*) solver->m_physics; int ferr = 0; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in Euler2DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in Euler2DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->gamma = 1.4; - strcpy(physics->upw_choice,"roe"); + physics->m_gamma = 1.4; + strcpy(physics->m_upw_choice,"roe"); /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -53,9 +53,9 @@ int Euler2DInitialize(void *s,void *m) while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gamma")) { - ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_gamma); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upw_choice); if (ferr != 1) return(1); + ferr = fscanf(in,"%s",physics->m_upw_choice); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr); @@ -72,12 +72,12 @@ int Euler2DInitialize(void *s,void *m) } #ifndef serial - IERR MPIBroadcast_double (&physics->gamma,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->upw_choice,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_gamma,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_upw_choice,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); #endif - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in Euler2DInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -87,13 +87,13 @@ int Euler2DInitialize(void *s,void *m) /* initializing physical model-specific functions */ solver->ComputeCFL = Euler2DComputeCFL; solver->FFunction = Euler2DFlux; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = Euler2DUpwindRoe; - else if (!strcmp(physics->upw_choice,_RF_ )) solver->Upwind = Euler2DUpwindRF; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = Euler2DUpwindLLF; - else if (!strcmp(physics->upw_choice,_SWFS_)) solver->Upwind = Euler2DUpwindSWFS; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->Upwind = Euler2DUpwindRoe; + else if (!strcmp(physics->m_upw_choice,_RF_ )) solver->Upwind = Euler2DUpwindRF; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->Upwind = Euler2DUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_SWFS_)) solver->Upwind = Euler2DUpwindSWFS; else { fprintf(stderr,"Error in Euler2DInitialize(): %s is not a valid upwinding scheme.\n", - physics->upw_choice); + physics->m_upw_choice); return(1); } solver->AveragingFunction = Euler2DRoeAverage; @@ -102,9 +102,9 @@ int Euler2DInitialize(void *s,void *m) /* set the value of gamma in all the boundary objects */ int n; - DomainBoundary *boundary = (DomainBoundary*) solver->boundary; - for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma; + DomainBoundary *boundary = (DomainBoundary*) solver->m_boundary; + for (n = 0; n < solver->m_n_boundary_zones; n++) boundary[n].m_gamma = physics->m_gamma; - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/Euler2D/Euler2DUpwind.c b/src/PhysicalModels/Euler2D/Euler2DUpwind.c index aa1ee1f9..ac399bf0 100644 --- a/src/PhysicalModels/Euler2D/Euler2DUpwind.c +++ b/src/PhysicalModels/Euler2D/Euler2DUpwind.c @@ -7,17 +7,17 @@ #include #include -int Euler2DUpwindRoe(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Euler2DUpwindRoe(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Euler2D *param = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler2D *param = (Euler2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -25,24 +25,24 @@ int Euler2DUpwindRoe(double *fI,double *fL,double *fR,double *uL,double *uR,doub done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); - _Euler2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param); + _Euler2DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param); - _Euler2DEigenvalues_(uavg,D,param,dir); - _Euler2DLeftEigenvectors_(uavg,L,param,dir); - _Euler2DRightEigenvectors_(uavg,R,param,dir); + _Euler2DEigenvalues_(uavg,D,param,a_dir); + _Euler2DLeftEigenvectors_(uavg,L,param,a_dir); + _Euler2DRightEigenvectors_(uavg,R,param,a_dir); - /* Harten's Entropy Fix - Page 362 of Leveque */ + /* Harten'a_s Entropy Fix - Page 362 of Leveque */ int k; double delta = 0.000001, delta2 = delta*delta; k=0; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); @@ -54,10 +54,10 @@ int Euler2DUpwindRoe(double *fI,double *fL,double *fR,double *uL,double *uR,doub MatMult4(_MODEL_NVARS_,modA,R,DL); MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -65,54 +65,54 @@ int Euler2DUpwindRoe(double *fI,double *fL,double *fR,double *uL,double *uR,doub return(0); } -int Euler2DUpwindRF(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Euler2DUpwindRF(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Euler2D *param = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler2D *param = (Euler2D*) solver->m_physics; int done,k; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Roe-Fixed upwinding scheme */ - _Euler2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param); + _Euler2DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param); - _Euler2DEigenvalues_(uavg,D,param,dir); - _Euler2DLeftEigenvectors_ (uavg,L,param,dir); - _Euler2DRightEigenvectors_(uavg,R,param,dir); + _Euler2DEigenvalues_(uavg,D,param,a_dir); + _Euler2DLeftEigenvectors_ (uavg,L,param,a_dir); + _Euler2DRightEigenvectors_(uavg,R,param,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _Euler2DEigenvalues_((uL+_MODEL_NVARS_*p),D,param,dir); + _Euler2DEigenvalues_((a_uL+_MODEL_NVARS_*p),D,param,a_dir); eigL[0] = D[0]; eigL[1] = D[5]; eigL[2] = D[10]; eigL[3] = D[15]; - _Euler2DEigenvalues_((uR+_MODEL_NVARS_*p),D,param,dir); + _Euler2DEigenvalues_((a_uR+_MODEL_NVARS_*p),D,param,a_dir); eigR[0] = D[0]; eigR[1] = D[5]; eigR[2] = D[10]; eigR[3] = D[15]; - _Euler2DEigenvalues_(uavg,D,param,dir); + _Euler2DEigenvalues_(uavg,D,param,a_dir); eigC[0] = D[0]; eigC[1] = D[5]; eigC[2] = D[10]; @@ -128,7 +128,7 @@ int Euler2DUpwindRF(double *fI,double *fL,double *fR,double *uL,double *uR,doubl } /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -136,54 +136,54 @@ int Euler2DUpwindRF(double *fI,double *fL,double *fR,double *uL,double *uR,doubl return(0); } -int Euler2DUpwindLLF(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Euler2DUpwindLLF(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Euler2D *param = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler2D *param = (Euler2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Local Lax-Friedrich upwinding scheme */ - _Euler2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param); + _Euler2DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param); - _Euler2DEigenvalues_(uavg,D,param,dir); - _Euler2DLeftEigenvectors_ (uavg,L,param,dir); - _Euler2DRightEigenvectors_(uavg,R,param,dir); + _Euler2DEigenvalues_(uavg,D,param,a_dir); + _Euler2DLeftEigenvectors_ (uavg,L,param,a_dir); + _Euler2DRightEigenvectors_(uavg,R,param,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _Euler2DEigenvalues_((uL+_MODEL_NVARS_*p),D,param,dir); + _Euler2DEigenvalues_((a_uL+_MODEL_NVARS_*p),D,param,a_dir); eigL[0] = D[0]; eigL[1] = D[5]; eigL[2] = D[10]; eigL[3] = D[15]; - _Euler2DEigenvalues_((uR+_MODEL_NVARS_*p),D,param,dir); + _Euler2DEigenvalues_((a_uR+_MODEL_NVARS_*p),D,param,a_dir); eigR[0] = D[0]; eigR[1] = D[5]; eigR[2] = D[10]; eigR[3] = D[15]; - _Euler2DEigenvalues_(uavg,D,param,dir); + _Euler2DEigenvalues_(uavg,D,param,a_dir); eigC[0] = D[0]; eigC[1] = D[5]; eigC[2] = D[10]; @@ -200,7 +200,7 @@ int Euler2DUpwindLLF(double *fI,double *fL,double *fR,double *uL,double *uR,doub fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3])); /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -208,44 +208,44 @@ int Euler2DUpwindLLF(double *fI,double *fL,double *fR,double *uL,double *uR,doub return(0); } -int Euler2DUpwindSWFS(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Euler2DUpwindSWFS(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Euler2D *param = (Euler2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Euler2D *param = (Euler2D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double fp[_MODEL_NVARS_], fm[_MODEL_NVARS_],uavg[_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - double rho,vx,vy,e,P,c,gamma=param->gamma,term,Mach,lp[_MODEL_NVARS_],lm[_MODEL_NVARS_]; + double rho,vx,vy,e,P,c,gamma=param->m_gamma,term,Mach,lp[_MODEL_NVARS_],lm[_MODEL_NVARS_]; /* Steger Warming flux splitting */ - _Euler2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param); + _Euler2DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param); _Euler2DGetFlowVar_(uavg,rho,vx,vy,e,P,param); - Mach = (dir==_XDIR_ ? vx : vy) / sqrt(gamma*P/rho); + Mach = (a_dir==_XDIR_ ? vx : vy) / sqrt(gamma*P/rho); if (Mach < -1.0) { - _ArrayCopy1D_((fR+_MODEL_NVARS_*p),(fI+_MODEL_NVARS_*p),_MODEL_NVARS_); + _ArrayCopy1D_((a_fR+_MODEL_NVARS_*p),(a_fI+_MODEL_NVARS_*p),_MODEL_NVARS_); } else if (Mach < 1.0) { double kx = 0, ky = 0; - kx = (dir==_XDIR_ ? 1.0 : 0.0); - ky = (dir==_YDIR_ ? 1.0 : 0.0); + kx = (a_dir==_XDIR_ ? 1.0 : 0.0); + ky = (a_dir==_YDIR_ ? 1.0 : 0.0); - _Euler2DGetFlowVar_((uL+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); + _Euler2DGetFlowVar_((a_uL+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); c = sqrt(gamma*P/rho); term = rho/(2.0*gamma); lp[0] = lp[1] = kx*vx + ky*vy; @@ -260,7 +260,7 @@ int Euler2DUpwindSWFS(double *fI,double *fL,double *fR,double *uL,double *uR,dou + 0.5*lp[3]*((vx-c*kx)*(vx-c*kx) + (vy-c*ky)*(vy-c*ky)) + ((3.0-gamma)*(lp[2]+lp[3])*c*c)/(2.0*(gamma-1.0)) ); - _Euler2DGetFlowVar_((uR+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); + _Euler2DGetFlowVar_((a_uR+_MODEL_NVARS_*p),rho,vx,vy,e,P,param); c = sqrt(gamma*P/rho); term = rho/(2.0*gamma); lm[0] = lm[1] = kx*vx + ky*vy; @@ -275,11 +275,11 @@ int Euler2DUpwindSWFS(double *fI,double *fL,double *fR,double *uL,double *uR,dou + 0.5*lm[3]*((vx-c*kx)*(vx-c*kx) + (vy-c*ky)*(vy-c*ky)) + ((3.0-gamma)*(lm[2]+lm[3])*c*c)/(2.0*(gamma-1.0)) ); - _ArrayAdd1D_((fI+_MODEL_NVARS_*p),fp,fm,_MODEL_NVARS_); + _ArrayAdd1D_((a_fI+_MODEL_NVARS_*p),fp,fm,_MODEL_NVARS_); } else { - _ArrayCopy1D_((fL+_MODEL_NVARS_*p),(fI+_MODEL_NVARS_*p),_MODEL_NVARS_); + _ArrayCopy1D_((a_fL+_MODEL_NVARS_*p),(a_fI+_MODEL_NVARS_*p),_MODEL_NVARS_); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellAdvection.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellAdvection.c index 306e590a..ba335a2a 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellAdvection.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellAdvection.c @@ -4,15 +4,15 @@ #include #include -int FPDoubleWellAdvection(double *f,double *u,int dir,void *s,double t) +int FPDoubleWellAdvection(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -25,8 +25,8 @@ int FPDoubleWellAdvection(double *f,double *u,int dir,void *s,double t) int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - double x; _GetCoordinate_(0,index[0]-ghosts,dim,ghosts,solver->x,x); - for (v = 0; v < nvars; v++) f[nvars*p+v] = drift(x) * u[nvars*p+v]; + double x; _GetCoordinate_(0,index[0]-ghosts,dim,ghosts,solver->m_x,x); + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = drift(x) * a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellCleanup.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellCleanup.c index 7eddf4c3..27f4823f 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellCleanup.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellCleanup.c @@ -1,7 +1,7 @@ #include #include -int FPDoubleWellCleanup(void *s) +int FPDoubleWellCleanup(void *a_s) { return(0); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeCFL.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeCFL.c index 373c5a43..45a61be4 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeCFL.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeCFL.c @@ -4,24 +4,24 @@ #include #include -double FPDoubleWellComputeCFL(void *s,void *m,double dt,double t) +double FPDoubleWellComputeCFL(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int d, i, v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *dxinv = solver->dxinv; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *dxinv = solver->m_dxinv; int offset = 0; double max_cfl = 0; for (d = 0; d < ndims; d++) { for (i = 0; i < dim[d]; i++) { for (v = 0; v < nvars; v++) { - double x; _GetCoordinate_(0,i,dim,ghosts,solver->x,x); - double local_cfl = absolute(drift(x)) * dt + double x; _GetCoordinate_(0,i,dim,ghosts,solver->m_x,x); + double local_cfl = absolute(drift(x)) * a_dt * dxinv[offset+ghosts+i]; if (local_cfl > max_cfl) max_cfl = local_cfl; } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeDiffNumber.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeDiffNumber.c index e7311f66..d3c63a1b 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeDiffNumber.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellComputeDiffNumber.c @@ -2,24 +2,24 @@ #include #include -double FPDoubleWellComputeDiffNumber(void *s,void *m,double dt,double t) +double FPDoubleWellComputeDiffNumber(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - FPDoubleWell *params = (FPDoubleWell*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPDoubleWell *params = (FPDoubleWell*) solver->m_physics; int d, i, v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *dxinv = solver->dxinv; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *dxinv = solver->m_dxinv; int offset = 0; double max_diffno = 0; for (d = 0; d < ndims; d++) { for (i = 0; i < dim[d]; i++) { for (v = 0; v < nvars; v++) { - double local_diffno = 0.5 * params->q * dt + double local_diffno = 0.5 * params->m_q * a_dt * dxinv[offset+ghosts+i] * dxinv[offset+ghosts+i]; if (local_diffno > max_diffno) max_diffno = local_diffno; diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellDiffusion.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellDiffusion.c index 23170fd7..19495ef5 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellDiffusion.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellDiffusion.c @@ -4,16 +4,16 @@ #include #include -int FPDoubleWellDiffusion(double *f,double *u,int dir,void *s,double t) +int FPDoubleWellDiffusion(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - FPDoubleWell *param = (FPDoubleWell*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPDoubleWell *param = (FPDoubleWell*) solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -26,7 +26,7 @@ int FPDoubleWellDiffusion(double *f,double *u,int dir,void *s,double t) int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - for (v = 0; v < nvars; v++) f[nvars*p+v] = 0.5*param->q * u[nvars*p+v]; + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = 0.5*param->m_q * a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellInitialize.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellInitialize.c index 74527fd2..a6127c47 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellInitialize.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellInitialize.c @@ -16,29 +16,29 @@ int FPDoubleWellUpwind (double*,double*,double*,double*, int FPDoubleWellPostStep (double*,void*,void*,double,int); int FPDoubleWellPrintStep (void*,void*,double); -int FPDoubleWellInitialize(void *s,void *m) +int FPDoubleWellInitialize(void *a_s,void *a_m) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPDoubleWell *physics = (FPDoubleWell*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPDoubleWell *physics = (FPDoubleWell*) solver->m_physics; int ferr = 0; _DECLARE_IERR_; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in FPDoubleWellInitializeO(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in FPDoubleWellInitializeO(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) { fprintf(stderr,"Error: File \"physics.inp\" not found.\n"); @@ -51,7 +51,7 @@ int FPDoubleWellInitialize(void *s,void *m) ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "q")) { /* read diffusion coefficient */ - ferr = fscanf(in,"%lf",&physics->q); + ferr = fscanf(in,"%lf",&physics->m_q); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; @@ -69,11 +69,11 @@ int FPDoubleWellInitialize(void *s,void *m) } #ifndef serial - IERR MPIBroadcast_double(&physics->q,1,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->m_q,1,0,&mpi->m_world); CHECKERR(ierr); #endif - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in FPDoubleWellInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -90,9 +90,9 @@ int FPDoubleWellInitialize(void *s,void *m) solver->PrintStep = FPDoubleWellPrintStep; /* Calculate and print the PDF integral of the initial solution */ - IERR FPDoubleWellPostStep(solver->u,solver,mpi,0.0,0);CHECKERR(ierr); + IERR FPDoubleWellPostStep(solver->m_u,solver,mpi,0.0,0);CHECKERR(ierr); IERR FPDoubleWellPrintStep(solver,mpi,0.0); CHECKERR(ierr); - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellPostStep.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellPostStep.c index 67e34d38..e93c57a0 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellPostStep.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellPostStep.c @@ -5,30 +5,30 @@ #include #include -int FPDoubleWellPostStep(double *u,void* s,void *m,double t,int iter) +int FPDoubleWellPostStep(double *a_u,void* a_s,void *a_m,double a_t,int a_iter) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPDoubleWell *params = (FPDoubleWell*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPDoubleWell *params = (FPDoubleWell*) solver->m_physics; _DECLARE_IERR_; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; double local_sum = 0; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); - double dx = 1.0 / solver->dxinv[index[0]+ghosts]; - local_sum += (u[p] * dx); + double dx = 1.0 / solver->m_dxinv[index[0]+ghosts]; + local_sum += (a_u[p] * dx); _ArrayIncrementIndex_(ndims,dim,index,done); } double local_integral = local_sum; double global_integral = 0; - IERR MPISum_double(&global_integral,&local_integral,1,&mpi->world); CHECKERR(ierr); - params->pdf_integral = global_integral; + IERR MPISum_double(&global_integral,&local_integral,1,&mpi->m_world); CHECKERR(ierr); + params->m_pdf_integral = global_integral; return(0); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellPrintStep.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellPrintStep.c index 15ee8aff..a07e1dfa 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellPrintStep.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellPrintStep.c @@ -2,10 +2,10 @@ #include #include -int FPDoubleWellPrintStep(void* s,void *m,double t) +int FPDoubleWellPrintStep(void* a_s,void *a_m,double a_t) { - HyPar *solver = (HyPar*) s; - FPDoubleWell *params = (FPDoubleWell*) solver->physics; - printf("Domain integral of the probability density function: %1.16E\n",params->pdf_integral); + HyPar *solver = (HyPar*) a_s; + FPDoubleWell *params = (FPDoubleWell*) solver->m_physics; + printf("Domain integral of the probability density function: %1.16E\n",params->m_pdf_integral); return(0); } diff --git a/src/PhysicalModels/FPDoubleWell/FPDoubleWellUpwind.c b/src/PhysicalModels/FPDoubleWell/FPDoubleWellUpwind.c index f9129e07..c679303b 100644 --- a/src/PhysicalModels/FPDoubleWell/FPDoubleWellUpwind.c +++ b/src/PhysicalModels/FPDoubleWell/FPDoubleWellUpwind.c @@ -4,31 +4,31 @@ #include #include -int FPDoubleWellUpwind(double *fI,double *fL,double *fR,double *uL,double *uR, - double *u,int dir,void *s,double t) +int FPDoubleWellUpwind(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR, + double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - double x1; _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->x,x1); - double x2; _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->x,x2); + double x1; _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->m_x,x1); + double x2; _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->m_x,x2); double x = 0.5 * ( x1 + x2 ); for (v = 0; v < nvars; v++) - fI[nvars*p+v] = (drift(x) > 0 ? fL[nvars*p+v] : fR[nvars*p+v] ); + a_fI[nvars*p+v] = (drift(x) > 0 ? a_fL[nvars*p+v] : a_fR[nvars*p+v] ); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemAdvection.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemAdvection.c index b8d9e92b..e5d56d83 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemAdvection.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemAdvection.c @@ -4,16 +4,16 @@ #include #include -int FPPowerSystemAdvection(double *f,double *u,int dir,void *s,double t) +int FPPowerSystemAdvection(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; -// FPPowerSystem *params = (FPPowerSystem*)solver->physics; + HyPar *solver = (HyPar*) a_s; +// FPPowerSystem *params = (FPPowerSystem*)solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -26,7 +26,7 @@ int FPPowerSystemAdvection(double *f,double *u,int dir,void *s,double t) int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - for (v = 0; v < nvars; v++) f[nvars*p+v] = u[nvars*p+v]; + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemCleanup.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemCleanup.c index 31ae3c57..89b3ee27 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemCleanup.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemCleanup.c @@ -1,7 +1,7 @@ #include #include -int FPPowerSystemCleanup(void *s) +int FPPowerSystemCleanup(void *a_s) { return(0); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeCFL.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeCFL.c index 0fa51d63..d88e7e43 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeCFL.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeCFL.c @@ -8,28 +8,28 @@ double FPPowerSystemDriftFunction(int,void*,double,double,double); -double FPPowerSystemComputeCFL(void *s,void *m,double dt,double t) +double FPPowerSystemComputeCFL(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem *params = (FPPowerSystem*)solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem *params = (FPPowerSystem*)solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_cfl = 0; int index[ndims]; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { - double x; _GetCoordinate_(0,index[0],dim,ghosts,solver->x,x); - double y; _GetCoordinate_(1,index[1],dim,ghosts,solver->x,y); - double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); - double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dyinv); - double drift_x= FPPowerSystemDriftFunction(0,params,x,y,t); - double drift_y= FPPowerSystemDriftFunction(1,params,x,y,t); - - double local_cfl_x = absolute(drift_x) * dt * dxinv; - double local_cfl_y = absolute(drift_y) * dt * dyinv; + double x; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_x,x); + double y; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_x,y); + double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); + double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dyinv); + double drift_x= FPPowerSystemDriftFunction(0,params,x,y,a_t); + double drift_y= FPPowerSystemDriftFunction(1,params,x,y,a_t); + + double local_cfl_x = absolute(drift_x) * a_dt * dxinv; + double local_cfl_y = absolute(drift_y) * a_dt * dyinv; if (local_cfl_x > max_cfl) max_cfl = local_cfl_x; if (local_cfl_y > max_cfl) max_cfl = local_cfl_y; diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeDiffNumber.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeDiffNumber.c index c25f6776..34c03fb2 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeDiffNumber.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemComputeDiffNumber.c @@ -8,26 +8,26 @@ double FPPowerSystemDissipationFunction(int,void*,double); -double FPPowerSystemComputeDiffNumber(void *s,void *m,double dt,double t) +double FPPowerSystemComputeDiffNumber(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem *params = (FPPowerSystem*)solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem *params = (FPPowerSystem*)solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_diff = 0; int index[ndims]; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { - double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); - double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dyinv); - double dissp_x= FPPowerSystemDissipationFunction(0,params,t); - double dissp_y= FPPowerSystemDissipationFunction(1,params,t); + double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); + double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dyinv); + double dissp_x= FPPowerSystemDissipationFunction(0,params,a_t); + double dissp_y= FPPowerSystemDissipationFunction(1,params,a_t); - double local_diff_x = absolute(dissp_x) * dt * dxinv * dxinv; - double local_diff_y = absolute(dissp_y) * dt * dyinv * dyinv; + double local_diff_x = absolute(dissp_x) * a_dt * dxinv * dxinv; + double local_diff_y = absolute(dissp_y) * a_dt * dyinv * dyinv; if (local_diff_x > max_diff) max_diff = local_diff_x; if (local_diff_y > max_diff) max_diff = local_diff_y; diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemDiffusion.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemDiffusion.c index f7046305..fe4c8b98 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemDiffusion.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemDiffusion.c @@ -6,16 +6,16 @@ double FPPowerSystemDissipationFunction(int,void*,double); -int FPPowerSystemDiffusion(double *f,double *u,int dir,void *s,double t) +int FPPowerSystemDiffusion(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem *params = (FPPowerSystem*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem *params = (FPPowerSystem*) solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -28,8 +28,8 @@ int FPPowerSystemDiffusion(double *f,double *u,int dir,void *s,double t) int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - double dissipation = FPPowerSystemDissipationFunction(dir,params,t); - for (v = 0; v < nvars; v++) f[nvars*p+v] = dissipation * u[nvars*p+v]; + double dissipation = FPPowerSystemDissipationFunction(a_dir,params,a_t); + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = dissipation * a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemFunctions.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemFunctions.c index aacef799..88936242 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemFunctions.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemFunctions.c @@ -1,32 +1,32 @@ #include #include -double FPPowerSystemDriftFunction(int dir,void *p,double x,double y, double t) +double FPPowerSystemDriftFunction(int a_dir,void *a_p,double a_x,double a_y, double a_t) { - FPPowerSystem *params = (FPPowerSystem*) p; + FPPowerSystem *params = (FPPowerSystem*) a_p; double drift = 0; - if (dir == 0) drift = params->O_s * (y - 1.0); - else if (dir == 1) { - if (t < params->tf) params->Pmax = params->E*params->V/params->g1; - else if (t < params->tcl) params->Pmax = 0.0; - else params->Pmax = params->E*params->V/params->g2; - drift = (1.0/(2.0*params->H)) * (params->Pm - params->Pmax*sin(x) - params->D*(y-1.0)); + if (a_dir == 0) drift = params->m_O_s * (a_y - 1.0); + else if (a_dir == 1) { + if (a_t < params->m_tf) params->Pmax = params->m_E*params->m_V/params->m_g1; + else if (a_t < params->tcl) params->Pmax = 0.0; + else params->Pmax = params->m_E*params->m_V/params->m_g2; + drift = (1.0/(2.0*params->H)) * (params->Pm - params->Pmax*sin(a_x) - params->D*(a_y-1.0)); } return drift; } -double FPPowerSystemDissipationFunction(int dir,void *p,double t) +double FPPowerSystemDissipationFunction(int a_dir,void *a_p,double a_t) { - FPPowerSystem *params = (FPPowerSystem*) p; + FPPowerSystem *params = (FPPowerSystem*) a_p; double dissp = 0; - if (dir == 1) { + if (a_dir == 1) { double gamma = params->D / (2.0*params->H); dissp = (1.0/(2.0*params->H)) * (1.0/(2.0*params->H)) - * ((params->l*params->q*params->q)/(params->l*gamma+1.0)) - * (1.0 - exp(-(gamma+1.0/params->l)*t)); + * ((params->m_l*params->m_q*params->m_q)/(params->m_l*gamma+1.0)) + * (1.0 - exp(-(gamma+1.0/params->m_l)*a_t)); } return(dissp); diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemInitialize.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemInitialize.c index 3d41200e..f467788a 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemInitialize.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemInitialize.c @@ -17,21 +17,21 @@ int FPPowerSystemUpwind (double*,double*,double*,double*, int FPPowerSystemPostStep (double*,void*,void*,double,int); int FPPowerSystemPrintStep (void*,void*,double); -int FPPowerSystemInitialize(void *s,void *m) +int FPPowerSystemInitialize(void *a_s,void *a_m) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPPowerSystem *physics = (FPPowerSystem*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPPowerSystem *physics = (FPPowerSystem*) solver->m_physics; int ferr; _DECLARE_IERR_; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in FPPowerSystemInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in FPPowerSystemInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } @@ -39,20 +39,20 @@ int FPPowerSystemInitialize(void *s,void *m) /* default values of model parameters */ physics->H = 5.0; physics->D = 5.0; - physics->E = 1.1358; - physics->V = 1.0; - physics->g1 = 0.545; - physics->g2 = 0.745; + physics->m_E = 1.1358; + physics->m_V = 1.0; + physics->m_g1 = 0.545; + physics->m_g2 = 0.745; physics->Pm = 0.9; - physics->l = 0.1; - physics->q = 1.0; - physics->O_s = 120*(4.0*atan(1.0)); - physics->tf = 0.1; + physics->m_l = 0.1; + physics->m_q = 1.0; + physics->m_O_s = 120*(4.0*atan(1.0)); + physics->m_tf = 0.1; physics->tcl = 0.2; /* reading physical model specific inputs - all processes */ FILE *in; - if ((!mpi->rank) && (!count)) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if ((!mpi->m_rank) && (!s_count)) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) { fprintf(stderr,"Error: File \"physics.inp\" not found.\n"); @@ -64,16 +64,16 @@ int FPPowerSystemInitialize(void *s,void *m) while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "inertia")) {ferr=fscanf(in,"%lf",&physics->H );if(ferr!=1)return(1);} - else if (!strcmp(word, "omega_s")) {ferr=fscanf(in,"%lf",&physics->O_s);if(ferr!=1)return(1);} - else if (!strcmp(word, "E" )) {ferr=fscanf(in,"%lf",&physics->E );if(ferr!=1)return(1);} - else if (!strcmp(word, "V" )) {ferr=fscanf(in,"%lf",&physics->V );if(ferr!=1)return(1);} - else if (!strcmp(word, "g1" )) {ferr=fscanf(in,"%lf",&physics->g1 );if(ferr!=1)return(1);} - else if (!strcmp(word, "g2" )) {ferr=fscanf(in,"%lf",&physics->g2 );if(ferr!=1)return(1);} + else if (!strcmp(word, "omega_s")) {ferr=fscanf(in,"%lf",&physics->m_O_s);if(ferr!=1)return(1);} + else if (!strcmp(word, "E" )) {ferr=fscanf(in,"%lf",&physics->m_E );if(ferr!=1)return(1);} + else if (!strcmp(word, "V" )) {ferr=fscanf(in,"%lf",&physics->m_V );if(ferr!=1)return(1);} + else if (!strcmp(word, "g1" )) {ferr=fscanf(in,"%lf",&physics->m_g1 );if(ferr!=1)return(1);} + else if (!strcmp(word, "g2" )) {ferr=fscanf(in,"%lf",&physics->m_g2 );if(ferr!=1)return(1);} else if (!strcmp(word, "D" )) {ferr=fscanf(in,"%lf",&physics->D );if(ferr!=1)return(1);} else if (!strcmp(word, "PM_min" )) {ferr=fscanf(in,"%lf",&physics->Pm );if(ferr!=1)return(1);} - else if (!strcmp(word, "lambda" )) {ferr=fscanf(in,"%lf",&physics->l );if(ferr!=1)return(1);} - else if (!strcmp(word, "q" )) {ferr=fscanf(in,"%lf",&physics->q );if(ferr!=1)return(1);} - else if (!strcmp(word, "tf" )) {ferr=fscanf(in,"%lf",&physics->tf );if(ferr!=1)return(1);} + else if (!strcmp(word, "lambda" )) {ferr=fscanf(in,"%lf",&physics->m_l );if(ferr!=1)return(1);} + else if (!strcmp(word, "q" )) {ferr=fscanf(in,"%lf",&physics->m_q );if(ferr!=1)return(1);} + else if (!strcmp(word, "tf" )) {ferr=fscanf(in,"%lf",&physics->m_tf );if(ferr!=1)return(1);} else if (!strcmp(word, "tcl" )) {ferr=fscanf(in,"%lf",&physics->tcl);if(ferr!=1)return(1);} } } else { @@ -83,8 +83,8 @@ int FPPowerSystemInitialize(void *s,void *m) } fclose(in); - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in FPPowerSystemInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -101,9 +101,9 @@ int FPPowerSystemInitialize(void *s,void *m) solver->PrintStep = FPPowerSystemPrintStep; /* Calculate and print the PDF integral of the initial solution */ - IERR FPPowerSystemPostStep(solver->u,solver,mpi,0.0,0); CHECKERR(ierr); - if (!mpi->rank) IERR FPPowerSystemPrintStep(solver,mpi,0.0); CHECKERR(ierr); + IERR FPPowerSystemPostStep(solver->m_u,solver,mpi,0.0,0); CHECKERR(ierr); + if (!mpi->m_rank) IERR FPPowerSystemPrintStep(solver,mpi,0.0); CHECKERR(ierr); - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemPostStep.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemPostStep.c index bcfb5ce6..56f722d4 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemPostStep.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemPostStep.c @@ -5,31 +5,31 @@ #include #include -int FPPowerSystemPostStep(double *u,void* s,void *m,double t,int iter) +int FPPowerSystemPostStep(double *a_u,void* a_s,void *a_m,double a_t,int a_iter) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPPowerSystem *params = (FPPowerSystem*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPPowerSystem *params = (FPPowerSystem*) solver->m_physics; _DECLARE_IERR_; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; double local_sum = 0; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); - double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); - double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dyinv); - local_sum += (u[p] / (dxinv * dyinv)); + double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); + double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dyinv); + local_sum += (a_u[p] / (dxinv * dyinv)); _ArrayIncrementIndex_(ndims,dim,index,done); } double local_integral = local_sum; double global_integral = 0; - IERR MPISum_double(&global_integral,&local_integral,1,&mpi->world); CHECKERR(ierr); - params->pdf_integral = global_integral; + IERR MPISum_double(&global_integral,&local_integral,1,&mpi->m_world); CHECKERR(ierr); + params->m_pdf_integral = global_integral; return(0); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemPrintStep.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemPrintStep.c index 54c3aac2..13e2010b 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemPrintStep.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemPrintStep.c @@ -2,10 +2,10 @@ #include #include -int FPPowerSystemPrintStep(void* s,void *m,double t) +int FPPowerSystemPrintStep(void* a_s,void *a_m,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem *params = (FPPowerSystem*) solver->physics; - printf("Domain integral of the probability density function: %1.16E\n",params->pdf_integral); + HyPar *solver = (HyPar*) a_s; + FPPowerSystem *params = (FPPowerSystem*) solver->m_physics; + printf("Domain integral of the probability density function: %1.16E\n",params->m_pdf_integral); return(0); } diff --git a/src/PhysicalModels/FPPowerSystem/FPPowerSystemUpwind.c b/src/PhysicalModels/FPPowerSystem/FPPowerSystemUpwind.c index 8cc2d935..975fadb3 100644 --- a/src/PhysicalModels/FPPowerSystem/FPPowerSystemUpwind.c +++ b/src/PhysicalModels/FPPowerSystem/FPPowerSystemUpwind.c @@ -6,46 +6,46 @@ double FPPowerSystemDriftFunction(int,void*,double,double,double); -int FPPowerSystemUpwind(double *fI,double *fL,double *fR,double *uL,double *uR, - double *u,int dir,void *s,double t) +int FPPowerSystemUpwind(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR, + double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem *params = (FPPowerSystem*)solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem *params = (FPPowerSystem*)solver->m_physics; int done,v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0, p); double x = 0,y = 0; /* x,y coordinates of the interface */ - if (dir == 0) { + if (a_dir == 0) { /* x-interface */ double x1, x2; - _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->x,x1); - _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->x,x2); + _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->m_x,x1); + _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->m_x,x2); x = 0.5 * ( x1 + x2 ); - _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->x,y); - } else if (dir == 1) { + _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->m_x,y); + } else if (a_dir == 1) { /* y-interface */ - _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->x,x); + _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->m_x,x); double y1, y2; - _GetCoordinate_(1,index_inter[1]-1,dim,ghosts,solver->x,y1); - _GetCoordinate_(1,index_inter[1] ,dim,ghosts,solver->x,y2); + _GetCoordinate_(1,index_inter[1]-1,dim,ghosts,solver->m_x,y1); + _GetCoordinate_(1,index_inter[1] ,dim,ghosts,solver->m_x,y2); y = 0.5 * ( y1 + y2 ); } - double drift = FPPowerSystemDriftFunction(dir,params,x,y,t); + double drift = FPPowerSystemDriftFunction(a_dir,params,x,y,a_t); for (v = 0; v < nvars; v++) - fI[nvars*p+v] = drift * (drift > 0 ? fL[nvars*p+v] : fR[nvars*p+v] ); + a_fI[nvars*p+v] = drift * (drift > 0 ? a_fL[nvars*p+v] : a_fR[nvars*p+v] ); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusAdvection.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusAdvection.c index 548ba725..a9cf8f1c 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusAdvection.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusAdvection.c @@ -4,20 +4,20 @@ #include #include -int FPPowerSystem1BusAdvection(double *f,double *u,int dir,void *s,double t) +int FPPowerSystem1BusAdvection(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + HyPar *solver = (HyPar*) a_s; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; /* calculate total size of arrays */ int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims); int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars; - /* f = u */ - _ArrayCopy1D_(u,f,size); + /* a_f = a_u */ + _ArrayCopy1D_(a_u,a_f,size); return(0); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusCleanup.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusCleanup.c index 4d48d277..d09beaf3 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusCleanup.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusCleanup.c @@ -1,7 +1,7 @@ #include #include -int FPPowerSystem1BusCleanup(void *s) +int FPPowerSystem1BusCleanup(void *a_s) { return(0); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeCFL.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeCFL.c index 34b7c4bf..b571102b 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeCFL.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeCFL.c @@ -8,28 +8,28 @@ double FPPowerSystem1BusDriftFunction(int,void*,double,double,double); -double FPPowerSystem1BusComputeCFL(void *s,void *m,double dt,double t) +double FPPowerSystem1BusComputeCFL(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_cfl = 0; int index[ndims]; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { - double x; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->x,x); - double y; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->x,y); - double dxinv; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - double dyinv; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); - double drift_x= FPPowerSystem1BusDriftFunction(_XDIR_,params,x,y,t); - double drift_y= FPPowerSystem1BusDriftFunction(_YDIR_,params,x,y,t); - - double local_cfl_x = absolute(drift_x) * dt * dxinv; - double local_cfl_y = absolute(drift_y) * dt * dyinv; + double x; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_x,x); + double y; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_x,y); + double dxinv; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); + double dyinv; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); + double drift_x= FPPowerSystem1BusDriftFunction(_XDIR_,params,x,y,a_t); + double drift_y= FPPowerSystem1BusDriftFunction(_YDIR_,params,x,y,a_t); + + double local_cfl_x = absolute(drift_x) * a_dt * dxinv; + double local_cfl_y = absolute(drift_y) * a_dt * dyinv; if (local_cfl_x > max_cfl) max_cfl = local_cfl_x; if (local_cfl_y > max_cfl) max_cfl = local_cfl_y; diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeDiffNumber.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeDiffNumber.c index 0a313ffa..206f72d7 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeDiffNumber.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusComputeDiffNumber.c @@ -8,26 +8,26 @@ double FPPowerSystem1BusDissipationFunction(int,int,void*,double); -double FPPowerSystem1BusComputeDiffNumber(void *s,void *m,double dt,double t) +double FPPowerSystem1BusComputeDiffNumber(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_diff = 0; int index[ndims]; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { - double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); - double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dyinv); - double dissp_yx= FPPowerSystem1BusDissipationFunction(_YDIR_,_XDIR_,params,t); - double dissp_yy= FPPowerSystem1BusDissipationFunction(_YDIR_,_YDIR_,params,t); + double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); + double dyinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dyinv); + double dissp_yx= FPPowerSystem1BusDissipationFunction(_YDIR_,_XDIR_,params,a_t); + double dissp_yy= FPPowerSystem1BusDissipationFunction(_YDIR_,_YDIR_,params,a_t); - double local_diff_yx = absolute(dissp_yx) * dt * dyinv * dxinv; - double local_diff_yy = absolute(dissp_yy) * dt * dyinv * dyinv; + double local_diff_yx = absolute(dissp_yx) * a_dt * dyinv * dxinv; + double local_diff_yy = absolute(dissp_yy) * a_dt * dyinv * dyinv; if (local_diff_yx > max_diff) max_diff = local_diff_yx; if (local_diff_yy > max_diff) max_diff = local_diff_yy; diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusDiffusion.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusDiffusion.c index 890f539a..e807b905 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusDiffusion.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusDiffusion.c @@ -6,48 +6,48 @@ double FPPowerSystem1BusDissipationFunction(int,int,void*,double); -int FPPowerSystem1BusDiffusionLaplacian(double *f,double *u,int dir,void *s,double t) +int FPPowerSystem1BusDiffusionLaplacian(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; /* calculate total size of arrays */ int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims); int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars; /* calculate dissipation coefficient -- constant in x and y */ - double dissipation = FPPowerSystem1BusDissipationFunction(dir,dir,params,t); + double dissipation = FPPowerSystem1BusDissipationFunction(a_dir,a_dir,params,a_t); - /* f = dissipation * u */ - _ArrayScaleCopy1D_(u,dissipation,f,size); + /* a_f = dissipation * a_u */ + _ArrayScaleCopy1D_(a_u,dissipation,a_f,size); return(0); } -int FPPowerSystem1BusDiffusionGeneral(double *f,double *u,int dir1,int dir2,void *s,double t) +int FPPowerSystem1BusDiffusionGeneral(double *a_f,double *a_u,int a_dir1,int a_dir2,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; /* calculate total size of arrays */ int bounds[ndims]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,ndims); int size; _ArrayProduct1D_(bounds,ndims,size); size *= nvars; /* calculate dissipation coefficient -- constant in x and y */ - double dissipation = FPPowerSystem1BusDissipationFunction(dir1,dir2,params,t); + double dissipation = FPPowerSystem1BusDissipationFunction(a_dir1,a_dir2,params,a_t); - /* f = dissipation * u */ - _ArrayScaleCopy1D_(u,dissipation,f,size); + /* a_f = dissipation * a_u */ + _ArrayScaleCopy1D_(a_u,dissipation,a_f,size); return(0); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusFunctions.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusFunctions.c index f475ecdc..c551f51d 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusFunctions.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusFunctions.c @@ -1,24 +1,24 @@ #include #include -double FPPowerSystem1BusDriftFunction(int dir,void *p,double x,double y, double t) +double FPPowerSystem1BusDriftFunction(int a_dir,void *a_p,double a_x,double a_y, double a_t) { - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) p; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) a_p; double drift = 0; - if (dir == _XDIR_) { - drift = params->omegaB * (y - params->omegaS); - } else if (dir == _YDIR_) { + if (a_dir == _XDIR_) { + drift = params->omegaB * (a_y - params->omegaS); + } else if (a_dir == _YDIR_) { drift = (params->omegaS/(2*params->H)) - * (params->Pm_avg - params->Pmax*sin(x) - params->D*(y-params->omegaS)); + * (params->Pm_avg - params->Pmax*sin(a_x) - params->D*(a_y-params->omegaS)); } return drift; } -double FPPowerSystem1BusDissipationFunction(int dir1,int dir2,void *p,double t) +double FPPowerSystem1BusDissipationFunction(int a_dir1,int a_dir2,void *a_p,double a_t) { - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) p; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) a_p; double sigma = params->sigma; double omegaS = params->omegaS; @@ -28,17 +28,17 @@ double FPPowerSystem1BusDissipationFunction(int dir1,int dir2,void *p,double t) double D = params->D; double dissp = 0; - if (dir1 == _YDIR_) { + if (a_dir1 == _YDIR_) { double term = (sigma*sigma*omegaS*omegaS) / (4.0*H*H); - double expterm = exp(-t/lambda); + double expterm = exp(-a_t/lambda); - if (dir2 == _XDIR_) { - dissp = term * (lambda*omegaB) * (lambda*(1-expterm) - t*expterm); + if (a_dir2 == _XDIR_) { + dissp = term * (lambda*omegaB) * (lambda*(1-expterm) - a_t*expterm); /* dissp = term * lambda*omegaB*lambda; */ - } else if (dir2 == _YDIR_) { + } else if (a_dir2 == _YDIR_) { double gamma = D*omegaS / (2.0*H); - dissp = term * (lambda*(1-expterm) + (gamma*lambda*(t*expterm-lambda*(1-expterm))) ); + dissp = term * (lambda*(1-expterm) + (gamma*lambda*(a_t*expterm-lambda*(1-expterm))) ); /* dissp = term * params->lambda * (1 - params->lambda*gamma); */ } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusInitialize.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusInitialize.c index 950d7faf..5d04f236 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusInitialize.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusInitialize.c @@ -18,21 +18,21 @@ int FPPowerSystem1BusUpwind (double*,double*,double*,double*, int FPPowerSystem1BusPostStep (double*,void*,void*,double,int); int FPPowerSystem1BusPrintStep (void*,void*,double); -int FPPowerSystem1BusInitialize(void *s,void *m) +int FPPowerSystem1BusInitialize(void *a_s,void *a_m) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPPowerSystem1Bus *physics = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPPowerSystem1Bus *physics = (FPPowerSystem1Bus*) solver->m_physics; int ferr; _DECLARE_IERR_; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in FPPowerSystem1BusInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in FPPowerSystem1BusInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } @@ -48,9 +48,9 @@ int FPPowerSystem1BusInitialize(void *s,void *m) physics->lambda = 100.0 / physics->omegaB; /* reading physical model specific inputs */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -77,18 +77,18 @@ int FPPowerSystem1BusInitialize(void *s,void *m) } #ifndef serial - IERR MPIBroadcast_double(&physics->omegaS,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->omegaB,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->H ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->D ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->Pm_avg,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->Pmax ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->sigma ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&physics->lambda,1,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->omegaS,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->omegaB,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->H ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->D ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->Pm_avg,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->Pmax ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->sigma ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&physics->lambda,1,0,&mpi->m_world); CHECKERR(ierr); #endif - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in FPPowerSystem1BusInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -107,8 +107,8 @@ int FPPowerSystem1BusInitialize(void *s,void *m) /* check that solver is using the correct diffusion formulation */ /* - if ((strcmp(solver->spatial_type_par,_NC_2STAGE_)) && (strcmp(solver->spatial_type_par,_NC_1_5STAGE_))) { - if (!mpi->rank) { + if ((strcmp(solver->m_spatial_type_par,_NC_2STAGE_)) && (strcmp(solver->m_spatial_type_par,_NC_1_5STAGE_))) { + if (!mpi->m_rank) { fprintf(stderr,"Error in FPPowerSystem1BusInitialize(): Parabolic term spatial discretization must be "); fprintf(stderr,"\"%s\" or \"%s\".\n",_NC_2STAGE_,_NC_1_5STAGE_); } @@ -116,6 +116,6 @@ int FPPowerSystem1BusInitialize(void *s,void *m) } */ - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPostStep.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPostStep.c index 7e6a9313..6bd726fe 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPostStep.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPostStep.c @@ -5,31 +5,31 @@ #include #include -int FPPowerSystem1BusPostStep(double *u,void* s,void *m,double t,int iter) +int FPPowerSystem1BusPostStep(double *a_u,void* a_s,void *a_m,double a_t,int a_iter) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; _DECLARE_IERR_; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; double local_sum = 0; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); - double dxinv; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - double dyinv; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); - local_sum += (u[p] / (dxinv * dyinv)); + double dxinv; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); + double dyinv; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); + local_sum += (a_u[p] / (dxinv * dyinv)); _ArrayIncrementIndex_(ndims,dim,index,done); } double local_integral = local_sum; double global_integral = 0; - IERR MPISum_double(&global_integral,&local_integral,1,&mpi->world); CHECKERR(ierr); - params->pdf_integral = global_integral; + IERR MPISum_double(&global_integral,&local_integral,1,&mpi->m_world); CHECKERR(ierr); + params->m_pdf_integral = global_integral; return(0); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPrintStep.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPrintStep.c index fdb56f0a..c117213c 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPrintStep.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusPrintStep.c @@ -2,10 +2,10 @@ #include #include -int FPPowerSystem1BusPrintStep(void* s,void *m,double t) +int FPPowerSystem1BusPrintStep(void* a_s,void *a_m,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; - printf("Domain integral of the probability density function: %1.16E\n",params->pdf_integral); + HyPar *solver = (HyPar*) a_s; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; + printf("Domain integral of the probability density function: %1.16E\n",params->m_pdf_integral); return(0); } diff --git a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusUpwind.c b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusUpwind.c index 953ce136..5ce32950 100644 --- a/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusUpwind.c +++ b/src/PhysicalModels/FPPowerSystem1Bus/FPPowerSystem1BusUpwind.c @@ -6,46 +6,46 @@ double FPPowerSystem1BusDriftFunction(int,void*,double,double,double); -int FPPowerSystem1BusUpwind(double *fI,double *fL,double *fR,double *uL,double *uR, - double *u,int dir,void *s,double t) +int FPPowerSystem1BusUpwind(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR, + double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem1Bus *params = (FPPowerSystem1Bus*) solver->m_physics; int done,v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0, p); double x = 0,y = 0; /* x,y coordinates of the interface */ - if (dir == 0) { + if (a_dir == 0) { /* x-interface */ double x1, x2; - _GetCoordinate_(_XDIR_,index_inter[_XDIR_]-1,dim,ghosts,solver->x,x1); - _GetCoordinate_(_XDIR_,index_inter[_XDIR_] ,dim,ghosts,solver->x,x2); + _GetCoordinate_(_XDIR_,index_inter[_XDIR_]-1,dim,ghosts,solver->m_x,x1); + _GetCoordinate_(_XDIR_,index_inter[_XDIR_] ,dim,ghosts,solver->m_x,x2); x = 0.5 * ( x1 + x2 ); - _GetCoordinate_(_YDIR_,index_inter[_YDIR_],dim,ghosts,solver->x,y); - } else if (dir == 1) { + _GetCoordinate_(_YDIR_,index_inter[_YDIR_],dim,ghosts,solver->m_x,y); + } else if (a_dir == 1) { /* y-interface */ - _GetCoordinate_(_XDIR_,index_inter[_XDIR_],dim,ghosts,solver->x,x); + _GetCoordinate_(_XDIR_,index_inter[_XDIR_],dim,ghosts,solver->m_x,x); double y1, y2; - _GetCoordinate_(_YDIR_,index_inter[_YDIR_]-1,dim,ghosts,solver->x,y1); - _GetCoordinate_(_YDIR_,index_inter[_YDIR_] ,dim,ghosts,solver->x,y2); + _GetCoordinate_(_YDIR_,index_inter[_YDIR_]-1,dim,ghosts,solver->m_x,y1); + _GetCoordinate_(_YDIR_,index_inter[_YDIR_] ,dim,ghosts,solver->m_x,y2); y = 0.5 * ( y1 + y2 ); } - double drift = FPPowerSystem1BusDriftFunction(dir,params,x,y,t); + double drift = FPPowerSystem1BusDriftFunction(a_dir,params,x,y,a_t); for (v = 0; v < nvars; v++) - fI[nvars*p+v] = drift * (drift > 0 ? fL[nvars*p+v] : fR[nvars*p+v] ); + a_fI[nvars*p+v] = drift * (drift > 0 ? a_fL[nvars*p+v] : a_fR[nvars*p+v] ); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusAdvection.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusAdvection.c index 25327363..ee737f52 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusAdvection.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusAdvection.c @@ -14,14 +14,14 @@ solution. The advection velocity is multiplied during upwinding FPPowerSystem3BusUpwind(). */ int FPPowerSystem3BusAdvection( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir, /*!< Spatial dimension for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir, /*!< Spatial dimension for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - _ArrayCopy1D_(u,f,solver->npoints_local_wghosts); + HyPar *solver = (HyPar*) a_s; + _ArrayCopy1D_(a_u,a_f,solver->m_npoints_local_wghosts); return(0); } diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusCleanup.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusCleanup.c index a33fe9fc..d03abd6c 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusCleanup.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusCleanup.c @@ -8,10 +8,10 @@ /*! Clean up allocations in the #FPPowerSystem3Bus system */ int FPPowerSystem3BusCleanup( - void *s /*!< Object of type #FPPowerSystem3Bus */ + void *a_s /*!< Object of type #FPPowerSystem3Bus */ ) { - FPPowerSystem3Bus *physics = (FPPowerSystem3Bus*) s; + FPPowerSystem3Bus *physics = (FPPowerSystem3Bus*) a_s; free(physics->G); free(physics->B); return(0); diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeCFL.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeCFL.c index f21a2db1..8df83297 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeCFL.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeCFL.c @@ -17,40 +17,40 @@ int FPPowerSystem3BusDriftFunction(int,void*,double*,double,double*); is computed over the local domain on this processor only. */ double FPPowerSystem3BusComputeCFL( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_cfl = 0; int index[ndims]; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { double x[ndims], dxinv[ndims], drift[ndims]; - _GetCoordinate_(0,index[0],dim,ghosts,solver->x,x[0]); - _GetCoordinate_(1,index[1],dim,ghosts,solver->x,x[1]); - _GetCoordinate_(2,index[2],dim,ghosts,solver->x,x[2]); - _GetCoordinate_(3,index[3],dim,ghosts,solver->x,x[3]); - _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv[0]); - _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dxinv[1]); - _GetCoordinate_(2,index[2],dim,ghosts,solver->dxinv,dxinv[2]); - _GetCoordinate_(3,index[3],dim,ghosts,solver->dxinv,dxinv[3]); + _GetCoordinate_(0,index[0],dim,ghosts,solver->m_x,x[0]); + _GetCoordinate_(1,index[1],dim,ghosts,solver->m_x,x[1]); + _GetCoordinate_(2,index[2],dim,ghosts,solver->m_x,x[2]); + _GetCoordinate_(3,index[3],dim,ghosts,solver->m_x,x[3]); + _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv[0]); + _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dxinv[1]); + _GetCoordinate_(2,index[2],dim,ghosts,solver->m_dxinv,dxinv[2]); + _GetCoordinate_(3,index[3],dim,ghosts,solver->m_dxinv,dxinv[3]); - FPPowerSystem3BusDriftFunction(0,params,x,t,drift); + FPPowerSystem3BusDriftFunction(0,params,x,a_t,drift); double local_cfl[ndims]; - local_cfl[0] = absolute(drift[0]) * dt * dxinv[0]; - local_cfl[1] = absolute(drift[1]) * dt * dxinv[1]; - local_cfl[2] = absolute(drift[2]) * dt * dxinv[2]; - local_cfl[3] = absolute(drift[3]) * dt * dxinv[3]; + local_cfl[0] = absolute(drift[0]) * a_dt * dxinv[0]; + local_cfl[1] = absolute(drift[1]) * a_dt * dxinv[1]; + local_cfl[2] = absolute(drift[2]) * a_dt * dxinv[2]; + local_cfl[3] = absolute(drift[3]) * a_dt * dxinv[3]; if (local_cfl[0] > max_cfl) max_cfl = local_cfl[0]; if (local_cfl[1] > max_cfl) max_cfl = local_cfl[1]; diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeDiffNumber.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeDiffNumber.c index 29d565d4..b237151d 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeDiffNumber.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusComputeDiffNumber.c @@ -17,35 +17,35 @@ int FPPowerSystem3BusDissipationFunction(int,int,void*,double,double*); is computed over the local domain on this processor only. */ double FPPowerSystem3BusComputeDiffNumber( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_diff = 0; int index[ndims]; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { double dxinv[ndims],dissp[ndims*ndims]; - _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv[0]); - _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dxinv[1]); - _GetCoordinate_(2,index[2],dim,ghosts,solver->dxinv,dxinv[2]); - _GetCoordinate_(3,index[3],dim,ghosts,solver->dxinv,dxinv[3]); - FPPowerSystem3BusDissipationFunction(0,0,params,t,dissp); + _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv[0]); + _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dxinv[1]); + _GetCoordinate_(2,index[2],dim,ghosts,solver->m_dxinv,dxinv[2]); + _GetCoordinate_(3,index[3],dim,ghosts,solver->m_dxinv,dxinv[3]); + FPPowerSystem3BusDissipationFunction(0,0,params,a_t,dissp); double local_diff[ndims]; - local_diff[0] = absolute(dissp[0*ndims+0]) * dt * dxinv[0] * dxinv[0]; - local_diff[1] = absolute(dissp[1*ndims+1]) * dt * dxinv[1] * dxinv[1]; - local_diff[2] = absolute(dissp[2*ndims+2]) * dt * dxinv[2] * dxinv[2]; - local_diff[3] = absolute(dissp[3*ndims+3]) * dt * dxinv[3] * dxinv[3]; + local_diff[0] = absolute(dissp[0*ndims+0]) * a_dt * dxinv[0] * dxinv[0]; + local_diff[1] = absolute(dissp[1*ndims+1]) * a_dt * dxinv[1] * dxinv[1]; + local_diff[2] = absolute(dissp[2*ndims+2]) * a_dt * dxinv[2] * dxinv[2]; + local_diff[3] = absolute(dissp[3*ndims+3]) * a_dt * dxinv[3] * dxinv[3]; if (local_diff[0] > max_diff) max_diff = local_diff[0]; if (local_diff[1] > max_diff) max_diff = local_diff[1]; diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusDiffusion.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusDiffusion.c index 7ddc7d94..8c21c89f 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusDiffusion.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusDiffusion.c @@ -13,20 +13,20 @@ int FPPowerSystem3BusDissipationFunction(int,int,void*,double,double*); /*! Compute the dissipation term for the #FPPowerSystem3Bus system */ int FPPowerSystem3BusDiffusion( - double *f, /*!< Array to hold the computed dissipation term vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir1, /*!< First spatial dimension for the dissipation term being computed */ - int dir2, /*!< Second spatial dimension for the dissipation term being computed */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed dissipation term vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir1, /*!< First spatial dimension for the dissipation term being computed */ + int a_dir2, /*!< Second spatial dimension for the dissipation term being computed */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; static double dissipation[_MODEL_NDIMS_*_MODEL_NDIMS_]; @@ -40,8 +40,8 @@ int FPPowerSystem3BusDiffusion( int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - FPPowerSystem3BusDissipationFunction(dir1,dir2,params,t,dissipation); - for (v = 0; v < _MODEL_NVARS_; v++) f[_MODEL_NVARS_*p+v] = dissipation[dir1*_MODEL_NDIMS_+dir2] * u[_MODEL_NVARS_*p+v]; + FPPowerSystem3BusDissipationFunction(a_dir1,a_dir2,params,a_t,dissipation); + for (v = 0; v < _MODEL_NVARS_; v++) a_f[_MODEL_NVARS_*p+v] = dissipation[a_dir1*_MODEL_NDIMS_+a_dir2] * a_u[_MODEL_NVARS_*p+v]; _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusFunctions.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusFunctions.c index 9e2b2afa..12e79430 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusFunctions.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusFunctions.c @@ -12,15 +12,15 @@ /*! Compute the electrical power of each generator, given their phases and other system parameters */ static void ComputeElectricalPower( - double theta1, /*!< Phase of generator 1 */ - double theta2, /*!< Phase of generator 2 */ - void *p, /*!< Object of type #FPPowerSystem3Bus */ - double *Pe1, /*!< Electrical power of generator 1 */ - double *Pe2, /*!< Electrical power of generator 2 */ - double *Pe3 /*!< Electrical power of generator 3 */ + double a_theta1, /*!< Phase of generator 1 */ + double a_theta2, /*!< Phase of generator 2 */ + void *a_p, /*!< Object of type #FPPowerSystem3Bus */ + double *a_Pe1, /*!< Electrical power of generator 1 */ + double *a_Pe2, /*!< Electrical power of generator 2 */ + double *a_Pe3 /*!< Electrical power of generator 3 */ ) { - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) p; + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) a_p; double E1 = params->E1; double E2 = params->E2; @@ -30,8 +30,8 @@ static void ComputeElectricalPower( double *B = params->B; double Eph[3][2]; - Eph[0][0] = E1*cos(theta1); Eph[0][1] = E1*sin(theta1); - Eph[1][0] = E2*cos(theta2); Eph[1][1] = E2*sin(theta2); + Eph[0][0] = E1*cos(a_theta1); Eph[0][1] = E1*sin(a_theta1); + Eph[1][0] = E2*cos(a_theta2); Eph[1][1] = E2*sin(a_theta2); Eph[2][0] = E3; Eph[2][1] = 0.0; double Y[3][3][2]; @@ -67,26 +67,26 @@ static void ComputeElectricalPower( YEph[1][1] = - YEph[1][1]; YEph[2][1] = - YEph[2][1]; - *Pe1 = Eph[0][0]*YEph[0][0] - Eph[0][1]*YEph[0][1]; - *Pe2 = Eph[1][0]*YEph[1][0] - Eph[1][1]*YEph[1][1]; - *Pe3 = Eph[2][0]*YEph[2][0] - Eph[2][1]*YEph[2][1]; + *a_Pe1 = Eph[0][0]*YEph[0][0] - Eph[0][1]*YEph[0][1]; + *a_Pe2 = Eph[1][0]*YEph[1][0] - Eph[1][1]*YEph[1][1]; + *a_Pe3 = Eph[2][0]*YEph[2][0] - Eph[2][1]*YEph[2][1]; } /*! Compute the drift (advection) coefficients for the 3-bus power system */ int FPPowerSystem3BusDriftFunction( - int dir, /*!< Spatial dimension (not used) */ - void *p, /*!< Object of type #FPPowerSystem3Bus */ - double *x, /*!< Spatial coordinates */ - double t, /*!< Current simulation time */ - double *drift /*!< Array to hold the drift velocities */ + int a_dir, /*!< Spatial dimension (not used) */ + void *a_p, /*!< Object of type #FPPowerSystem3Bus */ + double *a_x, /*!< Spatial coordinates */ + double a_t, /*!< Current simulation time */ + double *a_drift /*!< Array to hold the drift velocities */ ) { - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) p; + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) a_p; - double theta1 = x[0]; - double theta2 = x[1]; - double Omega1 = x[2]; - double Omega2 = x[3]; + double theta1 = a_x[0]; + double theta2 = a_x[1]; + double Omega1 = a_x[2]; + double Omega2 = a_x[3]; double omegaB = params->omegaB; double Pm1_avg = params->Pm1_avg; @@ -95,7 +95,7 @@ int FPPowerSystem3BusDriftFunction( double H1 = params->H1; double H2 = params->H2; double Href = params->Href; - double gamma = params->gamma; + double gamma = params->m_gamma; double Pe1, Pe2, Peref; ComputeElectricalPower(theta1,theta2,params,&Pe1,&Pe2,&Peref); @@ -105,26 +105,26 @@ int FPPowerSystem3BusDriftFunction( double S1 = Pe1 / (2*H1) - Peref / (2*Href); double S2 = Pe2 / (2*H2) - Peref / (2*Href); - drift[0] = omegaB * Omega1; - drift[1] = omegaB * Omega2; - drift[2] = F1 - gamma*Omega1 - S1; - drift[3] = F2 - gamma*Omega2 - S2; + a_drift[0] = omegaB * Omega1; + a_drift[1] = omegaB * Omega2; + a_drift[2] = F1 - gamma*Omega1 - S1; + a_drift[3] = F2 - gamma*Omega2 - S2; return(0); } /*! Compute the dissipation coefficient for the 3-bus power system */ int FPPowerSystem3BusDissipationFunction( - int dir1, /*!< First spatial dimension for the dissipation coefficient */ - int dir2, /*!< Second spatial dimension for the dissipation coefficient */ - void *p, /*!< Object of type #FPPowerSystem3Bus */ - double t, /*!< Current simulation time */ - double *dissp /*!< Matrix of size ndims*ndims to hold the dissipation + int a_dir1, /*!< First spatial dimension for the dissipation coefficient */ + int a_dir2, /*!< Second spatial dimension for the dissipation coefficient */ + void *a_p, /*!< Object of type #FPPowerSystem3Bus */ + double a_t, /*!< Current simulation time */ + double *a_dissp /*!< Matrix of size ndims*ndims to hold the dissipation coefficients (row-major format)*/ ) { - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) p; - _ArraySetValue_(dissp,_MODEL_NDIMS_*_MODEL_NDIMS_,0.0); + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) a_p; + _ArraySetValue_(a_dissp,_MODEL_NDIMS_*_MODEL_NDIMS_,0.0); double sigma11 = params->sigma[0][0]; double sigma12 = params->sigma[0][1]; @@ -136,32 +136,32 @@ int FPPowerSystem3BusDissipationFunction( double lambda21 = params->lambda[1][0]; double lambda22 = params->lambda[1][1]; - double gamma = params->gamma; + double gamma = params->m_gamma; double omegaB = params->omegaB; #if 0 /* steady state coefficients */ - dissp[2*_MODEL_NDIMS_+0] = sigma11*sigma11*lambda11*lambda11*omegaB; - dissp[2*_MODEL_NDIMS_+1] = sigma12*sigma12*lambda12*lambda12*omegaB; - dissp[3*_MODEL_NDIMS_+0] = sigma21*sigma21*lambda21*lambda21*omegaB; - dissp[3*_MODEL_NDIMS_+1] = sigma22*sigma22*lambda22*lambda22*omegaB; - - dissp[2*_MODEL_NDIMS_+2] = sigma11*sigma11*lambda11*(1.0-gamma*lambda11); - dissp[2*_MODEL_NDIMS_+3] = sigma12*sigma12*lambda12*(1.0-gamma*lambda12); - dissp[3*_MODEL_NDIMS_+2] = sigma21*sigma21*lambda21*(1.0-gamma*lambda21); - dissp[3*_MODEL_NDIMS_+3] = sigma22*sigma22*lambda22*(1.0-gamma*lambda22); + a_dissp[2*_MODEL_NDIMS_+0] = sigma11*sigma11*lambda11*lambda11*omegaB; + a_dissp[2*_MODEL_NDIMS_+1] = sigma12*sigma12*lambda12*lambda12*omegaB; + a_dissp[3*_MODEL_NDIMS_+0] = sigma21*sigma21*lambda21*lambda21*omegaB; + a_dissp[3*_MODEL_NDIMS_+1] = sigma22*sigma22*lambda22*lambda22*omegaB; + + a_dissp[2*_MODEL_NDIMS_+2] = sigma11*sigma11*lambda11*(1.0-gamma*lambda11); + a_dissp[2*_MODEL_NDIMS_+3] = sigma12*sigma12*lambda12*(1.0-gamma*lambda12); + a_dissp[3*_MODEL_NDIMS_+2] = sigma21*sigma21*lambda21*(1.0-gamma*lambda21); + a_dissp[3*_MODEL_NDIMS_+3] = sigma22*sigma22*lambda22*(1.0-gamma*lambda22); #endif /* time-dependent coefficients */ - dissp[2*_MODEL_NDIMS_+0] = sigma11*sigma11*lambda11*omegaB*(lambda11*(1-exp(-t/lambda11))-t*exp(-t/lambda11)); - dissp[2*_MODEL_NDIMS_+1] = sigma12*sigma12*lambda12*omegaB*(lambda12*(1-exp(-t/lambda12))-t*exp(-t/lambda12)); - dissp[3*_MODEL_NDIMS_+0] = sigma21*sigma21*lambda21*omegaB*(lambda21*(1-exp(-t/lambda21))-t*exp(-t/lambda21)); - dissp[3*_MODEL_NDIMS_+1] = sigma22*sigma22*lambda22*omegaB*(lambda22*(1-exp(-t/lambda22))-t*exp(-t/lambda22)); - - dissp[2*_MODEL_NDIMS_+2] = sigma11*sigma11*(lambda11*(1-exp(-t/lambda11))+gamma*lambda11*(t*exp(-t/lambda11)-lambda11*(1-exp(-t/lambda11)))); - dissp[2*_MODEL_NDIMS_+3] = sigma12*sigma12*(lambda12*(1-exp(-t/lambda12))+gamma*lambda12*(t*exp(-t/lambda12)-lambda12*(1-exp(-t/lambda12)))); - dissp[3*_MODEL_NDIMS_+2] = sigma21*sigma21*(lambda21*(1-exp(-t/lambda21))+gamma*lambda21*(t*exp(-t/lambda21)-lambda21*(1-exp(-t/lambda21)))); - dissp[3*_MODEL_NDIMS_+3] = sigma22*sigma22*(lambda22*(1-exp(-t/lambda22))+gamma*lambda22*(t*exp(-t/lambda22)-lambda22*(1-exp(-t/lambda22)))); + a_dissp[2*_MODEL_NDIMS_+0] = sigma11*sigma11*lambda11*omegaB*(lambda11*(1-exp(-a_t/lambda11))-a_t*exp(-a_t/lambda11)); + a_dissp[2*_MODEL_NDIMS_+1] = sigma12*sigma12*lambda12*omegaB*(lambda12*(1-exp(-a_t/lambda12))-a_t*exp(-a_t/lambda12)); + a_dissp[3*_MODEL_NDIMS_+0] = sigma21*sigma21*lambda21*omegaB*(lambda21*(1-exp(-a_t/lambda21))-a_t*exp(-a_t/lambda21)); + a_dissp[3*_MODEL_NDIMS_+1] = sigma22*sigma22*lambda22*omegaB*(lambda22*(1-exp(-a_t/lambda22))-a_t*exp(-a_t/lambda22)); + + a_dissp[2*_MODEL_NDIMS_+2] = sigma11*sigma11*(lambda11*(1-exp(-a_t/lambda11))+gamma*lambda11*(a_t*exp(-a_t/lambda11)-lambda11*(1-exp(-a_t/lambda11)))); + a_dissp[2*_MODEL_NDIMS_+3] = sigma12*sigma12*(lambda12*(1-exp(-a_t/lambda12))+gamma*lambda12*(a_t*exp(-a_t/lambda12)-lambda12*(1-exp(-a_t/lambda12)))); + a_dissp[3*_MODEL_NDIMS_+2] = sigma21*sigma21*(lambda21*(1-exp(-a_t/lambda21))+gamma*lambda21*(a_t*exp(-a_t/lambda21)-lambda21*(1-exp(-a_t/lambda21)))); + a_dissp[3*_MODEL_NDIMS_+3] = sigma22*sigma22*(lambda22*(1-exp(-a_t/lambda22))+gamma*lambda22*(a_t*exp(-a_t/lambda22)-lambda22*(1-exp(-a_t/lambda22)))); return(0); } diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusInitialize.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusInitialize.c index cdf8dcb6..ab9415a3 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusInitialize.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusInitialize.c @@ -25,23 +25,23 @@ int FPPowerSystem3BusUpwind (double*,double*,double*,double*, and set the physics-related function pointers in #HyPar. */ int FPPowerSystem3BusInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - FPPowerSystem3Bus *physics = (FPPowerSystem3Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + FPPowerSystem3Bus *physics = (FPPowerSystem3Bus*) solver->m_physics; int ferr, N; _DECLARE_IERR_; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in FPPowerSystem3BusInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in FPPowerSystem3BusInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } @@ -67,7 +67,7 @@ int FPPowerSystem3BusInitialize( physics->lambda[0][1] = 0.0; physics->lambda[1][0] = 0.0; physics->lambda[1][1] = 10.0/physics->omegaB; - physics->gamma = 0.25; + physics->m_gamma = 0.25; physics->G = (double*) calloc (3*3,sizeof(double)); physics->B = (double*) calloc (3*3,sizeof(double)); @@ -94,10 +94,10 @@ int FPPowerSystem3BusInitialize( /* reading physical model specific inputs - all processes */ FILE *in; - if ((!mpi->rank) && (!count)) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if ((!mpi->m_rank) && (!s_count)) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) { - if (!mpi->rank) fprintf(stderr,"Error: File \"physics.inp\" not found.\n"); + if (!mpi->m_rank) fprintf(stderr,"Error: File \"physics.inp\" not found.\n"); return(1); } else { char word[_MAX_STRING_SIZE_]; @@ -115,7 +115,7 @@ int FPPowerSystem3BusInitialize( else if (!strcmp(word,"E2" )) {ferr=fscanf(in,"%lf",&physics->E2 ) ;if(ferr!=1)return(1);} else if (!strcmp(word,"Eref" )) {ferr=fscanf(in,"%lf",&physics->Eref ) ;if(ferr!=1)return(1);} else if (!strcmp(word,"omegaB" )) {ferr=fscanf(in,"%lf",&physics->omegaB ) ;if(ferr!=1)return(1);} - else if (!strcmp(word,"gamma" )) {ferr=fscanf(in,"%lf",&physics->gamma ) ;if(ferr!=1)return(1);} + else if (!strcmp(word,"gamma" )) {ferr=fscanf(in,"%lf",&physics->m_gamma ) ;if(ferr!=1)return(1);} else if (!strcmp(word,"sigma" )) { ferr=fscanf(in,"%lf",&physics->sigma[0][0]) ;if(ferr!=1)return(1); ferr=fscanf(in,"%lf",&physics->sigma[0][1]) ;if(ferr!=1)return(1); @@ -149,14 +149,14 @@ int FPPowerSystem3BusInitialize( } } } else { - if (!mpi->rank) fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n"); + if (!mpi->m_rank) fprintf(stderr,"Error: Illegal format in file \"physics.inp\".\n"); return(1); } } fclose(in); - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in FPPowerSystem3BusInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -170,6 +170,6 @@ int FPPowerSystem3BusInitialize( solver->HFunction = FPPowerSystem3BusDiffusion; solver->Upwind = FPPowerSystem3BusUpwind; - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusUpwind.c b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusUpwind.c index e967b0b5..606a50ad 100644 --- a/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusUpwind.c +++ b/src/PhysicalModels/FPPowerSystem3Bus/FPPowerSystem3BusUpwind.c @@ -16,69 +16,69 @@ int FPPowerSystem3BusDriftFunction(int,void*,double*,double,double*); solution in this function to get the advective flux. */ int FPPowerSystem3BusUpwind( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->physics; + HyPar *solver = (HyPar*) a_s; + FPPowerSystem3Bus *params = (FPPowerSystem3Bus*) solver->m_physics; int done,v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0, p); double x[ndims]; /* coordinates of the interface */ double x1, x2, drift[ndims]; - if (dir == 0) { - _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->x,x1); - _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->x,x2); + if (a_dir == 0) { + _GetCoordinate_(0,index_inter[0]-1,dim,ghosts,solver->m_x,x1); + _GetCoordinate_(0,index_inter[0] ,dim,ghosts,solver->m_x,x2); x[0] = 0.5 * ( x1 + x2 ); - _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->x,x[1]); - _GetCoordinate_(2,index_inter[2],dim,ghosts,solver->x,x[2]); - _GetCoordinate_(3,index_inter[3],dim,ghosts,solver->x,x[3]); - } else if (dir == 1) { - _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->x,x[0]); - _GetCoordinate_(1,index_inter[1]-1,dim,ghosts,solver->x,x1); - _GetCoordinate_(1,index_inter[1] ,dim,ghosts,solver->x,x2); + _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->m_x,x[1]); + _GetCoordinate_(2,index_inter[2],dim,ghosts,solver->m_x,x[2]); + _GetCoordinate_(3,index_inter[3],dim,ghosts,solver->m_x,x[3]); + } else if (a_dir == 1) { + _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->m_x,x[0]); + _GetCoordinate_(1,index_inter[1]-1,dim,ghosts,solver->m_x,x1); + _GetCoordinate_(1,index_inter[1] ,dim,ghosts,solver->m_x,x2); x[1] = 0.5 * ( x1 + x2 ); - _GetCoordinate_(2,index_inter[2],dim,ghosts,solver->x,x[2]); - _GetCoordinate_(3,index_inter[3],dim,ghosts,solver->x,x[3]); - } else if (dir == 2) { - _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->x,x[0]); - _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->x,x[1]); - _GetCoordinate_(2,index_inter[2]-1,dim,ghosts,solver->x,x1); - _GetCoordinate_(2,index_inter[2] ,dim,ghosts,solver->x,x2); + _GetCoordinate_(2,index_inter[2],dim,ghosts,solver->m_x,x[2]); + _GetCoordinate_(3,index_inter[3],dim,ghosts,solver->m_x,x[3]); + } else if (a_dir == 2) { + _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->m_x,x[0]); + _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->m_x,x[1]); + _GetCoordinate_(2,index_inter[2]-1,dim,ghosts,solver->m_x,x1); + _GetCoordinate_(2,index_inter[2] ,dim,ghosts,solver->m_x,x2); x[2] = 0.5 * ( x1 + x2 ); - _GetCoordinate_(3,index_inter[3],dim,ghosts,solver->x,x[3]); - } else if (dir == 3) { - _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->x,x[0]); - _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->x,x[1]); - _GetCoordinate_(2,index_inter[2],dim,ghosts,solver->x,x[2]); - _GetCoordinate_(3,index_inter[3]-1,dim,ghosts,solver->x,x1); - _GetCoordinate_(3,index_inter[3] ,dim,ghosts,solver->x,x2); + _GetCoordinate_(3,index_inter[3],dim,ghosts,solver->m_x,x[3]); + } else if (a_dir == 3) { + _GetCoordinate_(0,index_inter[0],dim,ghosts,solver->m_x,x[0]); + _GetCoordinate_(1,index_inter[1],dim,ghosts,solver->m_x,x[1]); + _GetCoordinate_(2,index_inter[2],dim,ghosts,solver->m_x,x[2]); + _GetCoordinate_(3,index_inter[3]-1,dim,ghosts,solver->m_x,x1); + _GetCoordinate_(3,index_inter[3] ,dim,ghosts,solver->m_x,x2); x[3] = 0.5 * ( x1 + x2 ); } - FPPowerSystem3BusDriftFunction(dir,params,x,t,drift); + FPPowerSystem3BusDriftFunction(a_dir,params,x,a_t,drift); for (v = 0; v < nvars; v++) - fI[nvars*p+v] = drift[dir] * (drift[dir] > 0 ? fL[nvars*p+v] : fR[nvars*p+v] ); + a_fI[nvars*p+v] = drift[a_dir] * (drift[a_dir] > 0 ? a_fL[nvars*p+v] : a_fR[nvars*p+v] ); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/LinearADR/LinearADRAdvection.c b/src/PhysicalModels/LinearADR/LinearADRAdvection.c index 353c666c..1a2d3490 100644 --- a/src/PhysicalModels/LinearADR/LinearADRAdvection.c +++ b/src/PhysicalModels/LinearADR/LinearADRAdvection.c @@ -34,22 +34,22 @@ X (number of solution components - HyPar::nvars), with the inner loop being the solution components. */ -int LinearADRAdvection( double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the solution */ - int dir,/*!< Spatial dimension \f$d\f$ */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ +int LinearADRAdvection( double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the solution */ + int a_dir,/*!< Spatial dimension \f$d\f$ */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *param = (LinearADR*) solver->physics; - double *adv = param->a; + HyPar *solver = (HyPar*) a_s; + LinearADR *param = (LinearADR*) solver->m_physics; + double *adv = param->m_a; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], @@ -63,20 +63,20 @@ int LinearADRAdvection( double *f, /*!< Array to hold the computed flux (same s _ArraySetValue_(offset,ndims,-ghosts); int done = 0; _ArraySetValue_(index,ndims,0); - if (param->constant_advection == 1) { + if (param->m_constant_advection == 1) { while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); for (v = 0; v < nvars; v++) { - f[nvars*p+v] = param->a[nvars*dir+v] * u[nvars*p+v]; + a_f[nvars*p+v] = param->m_a[nvars*a_dir+v] * a_u[nvars*p+v]; } _ArrayIncrementIndex_(ndims,bounds,index,done); } - } else if (param->constant_advection == 0) { + } else if (param->m_constant_advection == 0) { while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); for (v = 0; v < nvars; v++) { - double a = adv[nvars*ndims*p+nvars*dir+v]; - f[nvars*p+v] = a * u[nvars*p+v]; + double a = adv[nvars*ndims*p+nvars*a_dir+v]; + a_f[nvars*p+v] = a * a_u[nvars*p+v]; } _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -84,7 +84,7 @@ int LinearADRAdvection( double *f, /*!< Array to hold the computed flux (same s while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); for (v = 0; v < nvars; v++) { - f[nvars*p+v] = 0.0; + a_f[nvars*p+v] = 0.0; } _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/LinearADR/LinearADRAdvectionField.c b/src/PhysicalModels/LinearADR/LinearADRAdvectionField.c index f0bdd3fc..fa4f1ebb 100644 --- a/src/PhysicalModels/LinearADR/LinearADRAdvectionField.c +++ b/src/PhysicalModels/LinearADR/LinearADRAdvectionField.c @@ -30,59 +30,59 @@ * the file with data that has the grid dimensions as the full grid. The * field on the current grid is obtained by interpolation. */ -int LinearADRAdvectionField(void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables*/ - int idx, /*!< Index of this simulation */ - int nsims, /*!< Total number of simulations */ - int *dim_adv /*!< Grid dimensions of the advection field stored in file */ +int LinearADRAdvectionField(void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables*/ + int a_idx, /*!< Index of this simulation */ + int a_nsims, /*!< Total number of simulations */ + int *a_dim_adv /*!< Grid dimensions of the advection field stored in file */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - LinearADR *param = (LinearADR*) solver->physics; - double *adv = param->a; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + LinearADR *param = (LinearADR*) solver->m_physics; + double *adv = param->m_a; /* sanity checks */ - if (param->constant_advection == 1) { - fprintf(stderr,"Error in LinearADRAdvectionField(): param->constant_advection == 1!\n"); + if (param->m_constant_advection == 1) { + fprintf(stderr,"Error in LinearADRAdvectionField(): param->m_constant_advection == 1!\n"); return(1); } - if (!strcmp(param->adv_filename,"none")) { - fprintf(stderr,"Error in LinearADRAdvectionField(): param->adv_filename is \"none\"!\n"); + if (!strcmp(param->m_adv_filename,"none")) { + fprintf(stderr,"Error in LinearADRAdvectionField(): param->m_adv_filename is \"none\"!\n"); return(1); } int d, done, flag; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; /* number of advection field components at a grid point is * number of spatial dimensions times number of solution * components */ - int adv_nvar = solver->ndims * solver->nvars; - if (param->adv_arr_size != adv_nvar*solver->npoints_local_wghosts) { + int adv_nvar = solver->m_ndims * solver->m_nvars; + if (param->m_adv_arr_size != adv_nvar*solver->m_npoints_local_wghosts) { fprintf(stderr,"Error in LinearADRAdvectionField(): Incorrect adv_arr_size\n"); return(1); } char fname_root[_MAX_STRING_SIZE_]; - strcpy(fname_root, param->adv_filename); - if (idx >= 0) { - if (nsims > 1) { + strcpy(fname_root, param->m_adv_filename); + if (a_idx >= 0) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(idx, index, (int)log10(nsims)+1); + GetStringFromInteger(a_idx, index, (int)log10(a_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } } /* read spatially-varying advection field from provided file */ - if (dim_adv == NULL) { - int ierr = ReadArray( solver->ndims, + if (a_dim_adv == NULL) { + int ierr = ReadArray( solver->m_ndims, adv_nvar, - solver->dim_global, - solver->dim_local, - solver->ghosts, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, solver, mpi, NULL, @@ -95,12 +95,12 @@ int LinearADRAdvectionField(void *s, /*!< Solver object of type #HyPar */ return ierr; } } else { - int ierr = ReadArraywInterp(solver->ndims, + int ierr = ReadArraywInterp(solver->m_ndims, adv_nvar, - solver->dim_global, - solver->dim_local, - dim_adv, - solver->ghosts, + solver->m_dim_global, + solver->m_dim_local, + a_dim_adv, + solver->m_ghosts, solver, mpi, NULL, @@ -116,14 +116,14 @@ int LinearADRAdvectionField(void *s, /*!< Solver object of type #HyPar */ if (!flag) { /* if advection file not available, set it to zero */ - _ArraySetValue_(adv,solver->npoints_local_wghosts*adv_nvar,0.0); + _ArraySetValue_(adv,solver->m_npoints_local_wghosts*adv_nvar,0.0); } /* if parallel, exchange MPI-boundary ghost point data */ - IERR MPIExchangeBoundariesnD( solver->ndims, + IERR MPIExchangeBoundariesnD( solver->m_ndims, adv_nvar, - solver->dim_local, - solver->ghosts, + solver->m_dim_local, + solver->m_ghosts, mpi, adv ); @@ -132,58 +132,58 @@ int LinearADRAdvectionField(void *s, /*!< Solver object of type #HyPar */ number of MPI ranks along that dimension is 1 (if more than 1, MPIExchangeBoundariesnD() called above has taken care of it). - Else, extrapolate at the boundaries. */ - int indexb[solver->ndims], - indexi[solver->ndims], - bounds[solver->ndims], - offset[solver->ndims]; - for (d = 0; d < solver->ndims; d++) { - if (solver->isPeriodic[d] && (mpi->iproc[d] == 1)) { - _ArrayCopy1D_(dim,bounds,solver->ndims); bounds[d] = ghosts; + int indexb[solver->m_ndims], + indexi[solver->m_ndims], + bounds[solver->m_ndims], + offset[solver->m_ndims]; + for (d = 0; d < solver->m_ndims; d++) { + if (solver->m_is_periodic[d] && (mpi->m_iproc[d] == 1)) { + _ArrayCopy1D_(dim,bounds,solver->m_ndims); bounds[d] = ghosts; /* left boundary */ - done = 0; _ArraySetValue_(indexb,solver->ndims,0); - _ArraySetValue_(offset,solver->ndims,0); offset[d] = -ghosts; + done = 0; _ArraySetValue_(indexb,solver->m_ndims,0); + _ArraySetValue_(offset,solver->m_ndims,0); offset[d] = -ghosts; while (!done) { - _ArrayCopy1D_(indexb,indexi,solver->ndims); indexi[d] = indexb[d] + dim[d] - ghosts; - int p1; _ArrayIndex1DWO_(solver->ndims,dim,indexb,offset,ghosts,p1); - int p2; _ArrayIndex1D_ (solver->ndims,dim,indexi,ghosts,p2); + _ArrayCopy1D_(indexb,indexi,solver->m_ndims); indexi[d] = indexb[d] + dim[d] - ghosts; + int p1; _ArrayIndex1DWO_(solver->m_ndims,dim,indexb,offset,ghosts,p1); + int p2; _ArrayIndex1D_ (solver->m_ndims,dim,indexi,ghosts,p2); _ArrayCopy1D_((adv+p2*adv_nvar), (adv+p1*adv_nvar), adv_nvar); - _ArrayIncrementIndex_(solver->ndims,bounds,indexb,done); + _ArrayIncrementIndex_(solver->m_ndims,bounds,indexb,done); } /* right boundary */ - done = 0; _ArraySetValue_(indexb,solver->ndims,0); - _ArraySetValue_(offset,solver->ndims,0); offset[d] = dim[d]; + done = 0; _ArraySetValue_(indexb,solver->m_ndims,0); + _ArraySetValue_(offset,solver->m_ndims,0); offset[d] = dim[d]; while (!done) { - _ArrayCopy1D_(indexb,indexi,solver->ndims); - int p1; _ArrayIndex1DWO_(solver->ndims,dim,indexb,offset,ghosts,p1); - int p2; _ArrayIndex1D_ (solver->ndims,dim,indexi,ghosts,p2); + _ArrayCopy1D_(indexb,indexi,solver->m_ndims); + int p1; _ArrayIndex1DWO_(solver->m_ndims,dim,indexb,offset,ghosts,p1); + int p2; _ArrayIndex1D_ (solver->m_ndims,dim,indexi,ghosts,p2); _ArrayCopy1D_((adv+p2*adv_nvar), (adv+p1*adv_nvar), adv_nvar); - _ArrayIncrementIndex_(solver->ndims,bounds,indexb,done); + _ArrayIncrementIndex_(solver->m_ndims,bounds,indexb,done); } } else { /* left boundary */ - if (!mpi->ip[d]) { - _ArrayCopy1D_(dim,bounds,solver->ndims); bounds[d] = ghosts; - _ArraySetValue_(offset,solver->ndims,0); offset[d] = -ghosts; - done = 0; _ArraySetValue_(indexb,solver->ndims,0); + if (!mpi->m_ip[d]) { + _ArrayCopy1D_(dim,bounds,solver->m_ndims); bounds[d] = ghosts; + _ArraySetValue_(offset,solver->m_ndims,0); offset[d] = -ghosts; + done = 0; _ArraySetValue_(indexb,solver->m_ndims,0); while (!done) { - _ArrayCopy1D_(indexb,indexi,solver->ndims); indexi[d] = ghosts-1-indexb[d]; - int p1; _ArrayIndex1DWO_(solver->ndims,dim,indexb,offset,ghosts,p1); - int p2; _ArrayIndex1D_ (solver->ndims,dim,indexi,ghosts,p2); + _ArrayCopy1D_(indexb,indexi,solver->m_ndims); indexi[d] = ghosts-1-indexb[d]; + int p1; _ArrayIndex1DWO_(solver->m_ndims,dim,indexb,offset,ghosts,p1); + int p2; _ArrayIndex1D_ (solver->m_ndims,dim,indexi,ghosts,p2); _ArrayCopy1D_((adv+p2*adv_nvar), (adv+p1*adv_nvar), adv_nvar); - _ArrayIncrementIndex_(solver->ndims,bounds,indexb,done); + _ArrayIncrementIndex_(solver->m_ndims,bounds,indexb,done); } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { - _ArrayCopy1D_(dim,bounds,solver->ndims); bounds[d] = ghosts; - _ArraySetValue_(offset,solver->ndims,0); offset[d] = dim[d]; - done = 0; _ArraySetValue_(indexb,solver->ndims,0); + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { + _ArrayCopy1D_(dim,bounds,solver->m_ndims); bounds[d] = ghosts; + _ArraySetValue_(offset,solver->m_ndims,0); offset[d] = dim[d]; + done = 0; _ArraySetValue_(indexb,solver->m_ndims,0); while (!done) { - _ArrayCopy1D_(indexb,indexi,solver->ndims); indexi[d] = dim[d]-1-indexb[d]; - int p1; _ArrayIndex1DWO_(solver->ndims,dim,indexb,offset,ghosts,p1); - int p2; _ArrayIndex1D_ (solver->ndims,dim,indexi,ghosts,p2); + _ArrayCopy1D_(indexb,indexi,solver->m_ndims); indexi[d] = dim[d]-1-indexb[d]; + int p1; _ArrayIndex1DWO_(solver->m_ndims,dim,indexb,offset,ghosts,p1); + int p2; _ArrayIndex1D_ (solver->m_ndims,dim,indexi,ghosts,p2); _ArrayCopy1D_((adv+p2*adv_nvar), (adv+p1*adv_nvar), adv_nvar); - _ArrayIncrementIndex_(solver->ndims,bounds,indexb,done); + _ArrayIncrementIndex_(solver->m_ndims,bounds,indexb,done); } } } diff --git a/src/PhysicalModels/LinearADR/LinearADRCleanup.c b/src/PhysicalModels/LinearADR/LinearADRCleanup.c index cf5c2485..0da9e59a 100644 --- a/src/PhysicalModels/LinearADR/LinearADRCleanup.c +++ b/src/PhysicalModels/LinearADR/LinearADRCleanup.c @@ -7,11 +7,11 @@ #include /*! Clean up the linear advection-diffusion-reaction model */ -int LinearADRCleanup(void *s /*!< Solver object of type #HyPar */) +int LinearADRCleanup(void *a_s /*!< Solver object of type #HyPar */) { - LinearADR *physics = (LinearADR*) s; - if (physics->a) free(physics->a); - if (physics->d) free(physics->d); + LinearADR *physics = (LinearADR*) a_s; + if (physics->m_a) free(physics->m_a); + if (physics->m_d) free(physics->m_d); return(0); } diff --git a/src/PhysicalModels/LinearADR/LinearADRComputeCFL.c b/src/PhysicalModels/LinearADR/LinearADRComputeCFL.c index c3540437..8b49f58d 100644 --- a/src/PhysicalModels/LinearADR/LinearADRComputeCFL.c +++ b/src/PhysicalModels/LinearADR/LinearADRComputeCFL.c @@ -12,35 +12,35 @@ /*! Computes the maximum CFL number over the domain. Note that the CFL is computed over the local domain on this processor only. */ -double LinearADRComputeCFL( void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ +double LinearADRComputeCFL( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *params = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + LinearADR *params = (LinearADR*) solver->m_physics; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_cfl = 0; - if (params->constant_advection == 1) { + if (params->m_constant_advection == 1) { int d, i, v; for (d = 0; d < ndims; d++) { for (i = 0; i < dim[d]; i++) { for (v = 0; v < nvars; v++) { - double dxinv; _GetCoordinate_(d,i,dim,ghosts,solver->dxinv,dxinv); - double local_cfl = params->a[nvars*d+v]*dt*dxinv; + double dxinv; _GetCoordinate_(d,i,dim,ghosts,solver->m_dxinv,dxinv); + double local_cfl = params->m_a[nvars*d+v]*a_dt*dxinv; if (local_cfl > max_cfl) max_cfl = local_cfl; } } } - } else if (params->constant_advection == 0) { + } else if (params->m_constant_advection == 0) { int d; for (d = 0; d < ndims; d++) { @@ -48,11 +48,11 @@ double LinearADRComputeCFL( void *s, /*!< Solver object of type #HyPar */ int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); - double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); + double dxinv; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); int v; for (v = 0; v < nvars; v++) { - double a = params->a[nvars*ndims*p+nvars*d+v]; - double local_cfl = a*dt*dxinv; + double a = params->m_a[nvars*ndims*p+nvars*d+v]; + double local_cfl = a*a_dt*dxinv; if (local_cfl > max_cfl) max_cfl = local_cfl; } _ArrayIncrementIndex_(ndims,dim,index,done); diff --git a/src/PhysicalModels/LinearADR/LinearADRComputeDiffNumber.c b/src/PhysicalModels/LinearADR/LinearADRComputeDiffNumber.c index 7ecb4107..e6356f8d 100644 --- a/src/PhysicalModels/LinearADR/LinearADRComputeDiffNumber.c +++ b/src/PhysicalModels/LinearADR/LinearADRComputeDiffNumber.c @@ -11,27 +11,27 @@ /*! Computes the maximum diffusion number over the domain. Note that the * diffusion number is computed over the local domain on this processor only. */ -double LinearADRComputeDiffNumber( void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ +double LinearADRComputeDiffNumber( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *params = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + LinearADR *params = (LinearADR*) solver->m_physics; int d, i, v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; double max_diffno = 0; for (d = 0; d < ndims; d++) { for (i = 0; i < dim[d]; i++) { for (v = 0; v < nvars; v++) { - double dxinv; _GetCoordinate_(d,i,dim,ghosts,solver->dxinv,dxinv); - double local_diffno = params->d[nvars*d+v] * dt * dxinv * dxinv; + double dxinv; _GetCoordinate_(d,i,dim,ghosts,solver->m_dxinv,dxinv); + double local_diffno = params->m_d[nvars*d+v] * a_dt * dxinv * dxinv; if (local_diffno > max_diffno) max_diffno = local_diffno; } } diff --git a/src/PhysicalModels/LinearADR/LinearADRDiffusion.c b/src/PhysicalModels/LinearADR/LinearADRDiffusion.c index 82ac503f..ca435aaf 100644 --- a/src/PhysicalModels/LinearADR/LinearADRDiffusion.c +++ b/src/PhysicalModels/LinearADR/LinearADRDiffusion.c @@ -23,21 +23,21 @@ \sum_d \frac {\partial^2} {\partial x_d^2} \left( \nu_d u \right) \f} */ -int LinearADRDiffusionG( double *f, /*!< Array to hold the computed diffusion term (same size and layout as u) */ - double *u, /*!< Array containing the solution */ - int dir,/*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ +int LinearADRDiffusionG( double *a_f, /*!< Array to hold the computed diffusion term (same size and layout as a_u) */ + double *a_u, /*!< Array containing the solution */ + int a_dir,/*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *param = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + LinearADR *param = (LinearADR*) solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -50,7 +50,7 @@ int LinearADRDiffusionG( double *f, /*!< Array to hold the computed diffusion int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - for (v = 0; v < nvars; v++) f[nvars*p+v] = param->d[nvars*dir+v] * u[nvars*p+v]; + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = param->m_d[nvars*a_dir+v] * a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -71,27 +71,27 @@ int LinearADRDiffusionG( double *f, /*!< Array to hold the computed diffusion \b Note: it's not correctly implemented. Will implement when necessary. */ -int LinearADRDiffusionH( double *f, /*!< Array to hold the computed diffusion term (same size and layout as u) */ - double *u, /*!< Array containing the solution */ - int dir1, /*!< First spatial dimension of the double derivative \f$d_1\f$ */ - int dir2, /*!< Second spatial dimension of the double derivative \f$d_2\f$ */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ +int LinearADRDiffusionH( double *a_f, /*!< Array to hold the computed diffusion term (same size and layout as a_u) */ + double *a_u, /*!< Array containing the solution */ + int a_dir1, /*!< First spatial dimension of the double derivative \f$d_1\f$ */ + int a_dir2, /*!< Second spatial dimension of the double derivative \f$d_2\f$ */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *param = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + LinearADR *param = (LinearADR*) solver->m_physics; int i, v; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; int index[ndims], bounds[ndims], offset[ndims]; - if (dir1 == dir2) { + if (a_dir1 == a_dir2) { - int dir = dir1; + int dir = a_dir1; /* set bounds for array index to include ghost points */ _ArrayCopy1D_(dim,bounds,ndims); @@ -103,11 +103,11 @@ int LinearADRDiffusionH( double *f, /*!< Array to hold the computed diffusio int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - for (v = 0; v < nvars; v++) f[nvars*p+v] = param->d[nvars*dir+v] * u[nvars*p+v]; + for (v = 0; v < nvars; v++) a_f[nvars*p+v] = param->m_d[nvars*dir+v] * a_u[nvars*p+v]; _ArrayIncrementIndex_(ndims,bounds,index,done); } - } else _ArraySetValue_(f,solver->npoints_local_wghosts*nvars,0.0); + } else _ArraySetValue_(a_f,solver->m_npoints_local_wghosts*nvars,0.0); return(0); diff --git a/src/PhysicalModels/LinearADR/LinearADRInitialize.c b/src/PhysicalModels/LinearADR/LinearADRInitialize.c index ff394625..59352ef3 100644 --- a/src/PhysicalModels/LinearADR/LinearADRInitialize.c +++ b/src/PhysicalModels/LinearADR/LinearADRInitialize.c @@ -56,31 +56,31 @@ int LinearADRDiffusionJacobian (double*,double*,void*,int,int); + "physics.inp" is \b optional; if absent, default values will be used. + Please do *not* specify both "advection" and "advection_filename"! */ -int LinearADRInitialize(void *s, /*!< Solver object of type #HyPar */ - void *m /*!< Object of type #MPIVariables containing MPI-related info */ ) +int LinearADRInitialize(void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related info */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - LinearADR *physics = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + LinearADR *physics = (LinearADR*) solver->m_physics; int i,ferr; - static int count = 0; + static int s_count = 0; /* default values */ - physics->constant_advection = -1; - strcpy(physics->adv_filename,"none"); - physics->a = NULL; - physics->adv_arr_size = -1; - strcpy(physics->centered_flux,"no"); + physics->m_constant_advection = -1; + strcpy(physics->m_adv_filename,"none"); + physics->m_a = NULL; + physics->m_adv_arr_size = -1; + strcpy(physics->m_centered_flux,"no"); - physics->d = (double*) calloc (solver->ndims*solver->nvars,sizeof(double)); - _ArraySetValue_(physics->d,solver->ndims*solver->nvars,0.0); + physics->m_d = (double*) calloc (solver->m_ndims*solver->m_nvars,sizeof(double)); + _ArraySetValue_(physics->m_d,solver->m_ndims*solver->m_nvars,0.0); /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) { @@ -98,37 +98,37 @@ int LinearADRInitialize(void *s, /*!< Solver object of type #HyPar */ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "advection_filename")) { - if (physics->constant_advection != -1) { + if (physics->m_constant_advection != -1) { fprintf(stderr,"Error in LinearADRInitialize():\n"); fprintf(stderr,"Maybe advection_filename and advection are both specified.\n"); return 1; } else { /* read filename for spatially-varying advection field */ - physics->constant_advection = 0; - physics->adv_arr_size = solver->npoints_local_wghosts*solver->ndims*solver->nvars; - physics->a = (double*) calloc ( physics->adv_arr_size, sizeof(double) ); - _ArraySetValue_(physics->a, physics->adv_arr_size, 0.0); - ferr = fscanf(in,"%s",physics->adv_filename); if (ferr != 1) return(ferr); + physics->m_constant_advection = 0; + physics->m_adv_arr_size = solver->m_npoints_local_wghosts*solver->m_ndims*solver->m_nvars; + physics->m_a = (double*) calloc ( physics->m_adv_arr_size, sizeof(double) ); + _ArraySetValue_(physics->m_a, physics->m_adv_arr_size, 0.0); + ferr = fscanf(in,"%s",physics->m_adv_filename); if (ferr != 1) return(ferr); } } else if (!strcmp(word, "advection")) { - if (physics->constant_advection != -1) { + if (physics->m_constant_advection != -1) { fprintf(stderr,"Error in LinearADRInitialize():\n"); fprintf(stderr,"Maybe advection_filename and advection are both specified.\n"); return 1; } else { /* read advection coefficients */ - physics->constant_advection = 1; - physics->adv_arr_size = solver->ndims*solver->nvars; - physics->a = (double*) calloc ( physics->adv_arr_size, sizeof(double) ); - for (i=0; indims*solver->nvars; i++) ferr = fscanf(in,"%lf",&physics->a[i]); + physics->m_constant_advection = 1; + physics->m_adv_arr_size = solver->m_ndims*solver->m_nvars; + physics->m_a = (double*) calloc ( physics->m_adv_arr_size, sizeof(double) ); + for (i=0; im_ndims*solver->m_nvars; i++) ferr = fscanf(in,"%lf",&physics->m_a[i]); if (ferr != 1) return(1); } } else if (!strcmp(word, "diffusion")) { /* read diffusion coefficients */ - for (i=0; indims*solver->nvars; i++) ferr = fscanf(in,"%lf",&physics->d[i]); + for (i=0; im_ndims*solver->m_nvars; i++) ferr = fscanf(in,"%lf",&physics->m_d[i]); if (ferr != 1) return(1); } else if (!strcmp(word, "centered_flux")) { - ferr = fscanf(in, "%s", physics->centered_flux); + ferr = fscanf(in, "%s", physics->m_centered_flux); if (ferr != 1) return(ferr); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; @@ -151,32 +151,32 @@ int LinearADRInitialize(void *s, /*!< Solver object of type #HyPar */ } #ifndef serial - MPIBroadcast_integer(&physics->constant_advection,1,0,&mpi->world); - MPIBroadcast_integer(&physics->adv_arr_size,1,0,&mpi->world); + MPIBroadcast_integer(&physics->m_constant_advection,1,0,&mpi->m_world); + MPIBroadcast_integer(&physics->m_adv_arr_size,1,0,&mpi->m_world); #endif - if (mpi->rank) { - physics->a = (double*) calloc (physics->adv_arr_size,sizeof(double)); - _ArraySetValue_(physics->a, physics->adv_arr_size, 0.0); + if (mpi->m_rank) { + physics->m_a = (double*) calloc (physics->m_adv_arr_size,sizeof(double)); + _ArraySetValue_(physics->m_a, physics->m_adv_arr_size, 0.0); } - if (physics->constant_advection == 1) { + if (physics->m_constant_advection == 1) { #ifndef serial - MPIBroadcast_double(physics->a,physics->adv_arr_size,0,&mpi->world); + MPIBroadcast_double(physics->m_a,physics->m_adv_arr_size,0,&mpi->m_world); #endif - } else if (physics->constant_advection == 0) { + } else if (physics->m_constant_advection == 0) { #ifndef serial - MPIBroadcast_character(physics->adv_filename, _MAX_STRING_SIZE_,0,&mpi->world); + MPIBroadcast_character(physics->m_adv_filename, _MAX_STRING_SIZE_,0,&mpi->m_world); #endif } #ifndef serial - MPIBroadcast_double(physics->d,solver->ndims*solver->nvars,0,&mpi->world); - MPIBroadcast_character(physics->centered_flux, _MAX_STRING_SIZE_,0,&mpi->world); + MPIBroadcast_double(physics->m_d,solver->m_ndims*solver->m_nvars,0,&mpi->m_world); + MPIBroadcast_character(physics->m_centered_flux, _MAX_STRING_SIZE_,0,&mpi->m_world); #endif - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in LinearADRInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -193,13 +193,13 @@ int LinearADRInitialize(void *s, /*!< Solver object of type #HyPar */ solver->JFunction = LinearADRAdvectionJacobian; solver->KFunction = LinearADRDiffusionJacobian; - if (!strcmp(physics->centered_flux,"no")) { + if (!strcmp(physics->m_centered_flux,"no")) { solver->Upwind = LinearADRUpwind; } else { solver->Upwind = LinearADRCenteredFlux; } - if (physics->constant_advection == 0) { + if (physics->m_constant_advection == 0) { solver->PhysicsInput = LinearADRAdvectionField; solver->PhysicsOutput = LinearADRWriteAdvField; } else { @@ -207,6 +207,6 @@ int LinearADRInitialize(void *s, /*!< Solver object of type #HyPar */ solver->PhysicsOutput = NULL; } - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/LinearADR/LinearADRJacobian.c b/src/PhysicalModels/LinearADR/LinearADRJacobian.c index 8629a79e..91076472 100644 --- a/src/PhysicalModels/LinearADR/LinearADRJacobian.c +++ b/src/PhysicalModels/LinearADR/LinearADRJacobian.c @@ -8,24 +8,24 @@ /*! Function to compute the flux Jacobian for the hyperbolic (advection) part of the linear-advection-diffusion-reaction model. */ -int LinearADRAdvectionJacobian( double* Jac, /*!< Jacobian matrix of size 1 (nvar = 1) */ - double* u, /*!< solution at a grid point */ - void* p, /*!< object containing physics-related parameters */ - int dir, /*!< dimension (x/y/z) */ - int nvars,/*!< number of components */ - int upw /*!< 0 -> send back complete Jacobian, +int LinearADRAdvectionJacobian( double* a_Jac, /*!< Jacobian matrix of size 1 (nvar = 1) */ + double* a_u, /*!< solution at a grid point */ + void* a_p, /*!< object containing physics-related parameters */ + int a_dir, /*!< dimension (x/y/z) */ + int a_nvars,/*!< number of components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux*/ ) { - LinearADR *param = (LinearADR*) p; + LinearADR *param = (LinearADR*) a_p; - if (param->a) { - *Jac = (1-absolute(upw))*absolute(param->a[dir]) - + absolute(upw) * (1+upw) * max(0,param->a[dir]) * 0.5 - - absolute(upw) * (1-upw) * min(0,param->a[dir]) * 0.5 ; + if (param->m_a) { + *a_Jac = (1-absolute(a_upw))*absolute(param->m_a[a_dir]) + + absolute(a_upw) * (1+a_upw) * max(0,param->m_a[a_dir]) * 0.5 + - absolute(a_upw) * (1-a_upw) * min(0,param->m_a[a_dir]) * 0.5 ; } else { /* no advection term */ - *Jac = 0.0; + *a_Jac = 0.0; } return 0; @@ -33,17 +33,17 @@ int LinearADRAdvectionJacobian( double* Jac, /*!< Jacobian matrix of size 1 (nv /*! Function to compute the Jacobian for the parabolic (diffusion) part of the linear-advection-diffusion-reaction model. */ -int LinearADRDiffusionJacobian( double* Jac, /*!< Jacobian matrix of size 1 (nvar = 1) */ - double* u, /*!< solution at a grid point */ - void* p, /*!< object containing physics-related parameters */ - int dir, /*!< dimension (x/y/z) */ - int nvars /*!< number of components */ ) +int LinearADRDiffusionJacobian( double* a_Jac, /*!< Jacobian matrix of size 1 (nvar = 1) */ + double* a_u, /*!< solution at a grid point */ + void* a_p, /*!< object containing physics-related parameters */ + int a_dir, /*!< dimension (x/y/z) */ + int a_nvars /*!< number of components */ ) { - LinearADR *param = (LinearADR*) p; + LinearADR *param = (LinearADR*) a_p; int v; - for (v = 0; v < nvars; v++) { - Jac[nvars*v+v] = -param->d[nvars*dir+v]; + for (v = 0; v < a_nvars; v++) { + a_Jac[a_nvars*v+v] = -param->m_d[a_nvars*a_dir+v]; } return 0; diff --git a/src/PhysicalModels/LinearADR/LinearADRReaction.c b/src/PhysicalModels/LinearADR/LinearADRReaction.c index 639982f6..d1823ae7 100644 --- a/src/PhysicalModels/LinearADR/LinearADRReaction.c +++ b/src/PhysicalModels/LinearADR/LinearADRReaction.c @@ -9,8 +9,8 @@ #include /*! Not yet implemented */ -int LinearADRReaction( void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ +int LinearADRReaction( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { return(0); diff --git a/src/PhysicalModels/LinearADR/LinearADRUpwind.c b/src/PhysicalModels/LinearADR/LinearADRUpwind.c index 79a56989..7617f0b7 100644 --- a/src/PhysicalModels/LinearADR/LinearADRUpwind.c +++ b/src/PhysicalModels/LinearADR/LinearADRUpwind.c @@ -13,67 +13,67 @@ #include /*! Upwinding scheme for linear advection */ -int LinearADRUpwind( double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ +int LinearADRUpwind( double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *param = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + LinearADR *param = (LinearADR*) solver->m_physics; int done,v; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts= solver->m_ghosts; + int *dim = solver->m_dim_local; - double *a = param->a; + double *a = param->m_a; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; - if (param->constant_advection == 1) { + if (param->m_constant_advection == 1) { done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (v = 0; v < nvars; v++) { - fI[nvars*p+v] = (a[nvars*dir+v] > 0 ? fL[nvars*p+v] : fR[nvars*p+v] ); + a_fI[nvars*p+v] = (a[nvars*a_dir+v] > 0 ? a_fL[nvars*p+v] : a_fR[nvars*p+v] ); } } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } - } else if (param->constant_advection == 0) { + } else if (param->m_constant_advection == 0) { done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); for (v = 0; v < nvars; v++) { - double eigL = a[nvars*ndims*pL+nvars*dir+v], - eigR = a[nvars*ndims*pR+nvars*dir+v]; + double eigL = a[nvars*ndims*pL+nvars*a_dir+v], + eigR = a[nvars*ndims*pR+nvars*a_dir+v]; if ((eigL > 0) && (eigR > 0)) { - fI[nvars*p+v] = fL[nvars*p+v]; + a_fI[nvars*p+v] = a_fL[nvars*p+v]; } else if ((eigL < 0) && (eigR < 0)) { - fI[nvars*p+v] = fR[nvars*p+v]; + a_fI[nvars*p+v] = a_fR[nvars*p+v]; } else { double alpha = max(absolute(eigL), absolute(eigR)); - fI[nvars*p+v] = 0.5 * (fL[nvars*p+v] + fR[nvars*p+v] - alpha * (uR[nvars*p+v] - uL[nvars*p+v])); + a_fI[nvars*p+v] = 0.5 * (a_fL[nvars*p+v] + a_fR[nvars*p+v] - alpha * (a_uR[nvars*p+v] - a_uL[nvars*p+v])); } } } @@ -85,10 +85,10 @@ int LinearADRUpwind( double *fI, /*!< Computed upwind interface flux */ done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (v = 0; v < nvars; v++) { - fI[nvars*p+v] = 0.0; + a_fI[nvars*p+v] = 0.0; } } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); @@ -100,36 +100,36 @@ int LinearADRUpwind( double *fI, /*!< Computed upwind interface flux */ } /*! Centered scheme for linear advection */ -int LinearADRCenteredFlux( double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ +int LinearADRCenteredFlux( double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - LinearADR *param = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + LinearADR *param = (LinearADR*) solver->m_physics; - int ndims = solver->ndims; - int nvars = solver->nvars; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int ghosts= solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; int done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (int v = 0; v < nvars; v++) { - fI[nvars*p+v] = 0.5 * (fL[nvars*p+v] + fR[nvars*p+v]); + a_fI[nvars*p+v] = 0.5 * (a_fL[nvars*p+v] + a_fR[nvars*p+v]); } } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); diff --git a/src/PhysicalModels/LinearADR/LinearADRWriteAdvField.c b/src/PhysicalModels/LinearADR/LinearADRWriteAdvField.c index 6ef64ebf..f2864131 100644 --- a/src/PhysicalModels/LinearADR/LinearADRWriteAdvField.c +++ b/src/PhysicalModels/LinearADR/LinearADRWriteAdvField.c @@ -15,43 +15,43 @@ #include /*! Write out the advection field to file */ -int LinearADRWriteAdvField( void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int LinearADRWriteAdvField( void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - LinearADR *param = (LinearADR*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + LinearADR *param = (LinearADR*) solver->m_physics; - if (param->constant_advection == 0) { + if (param->m_constant_advection == 0) { char fname_root[_MAX_STRING_SIZE_] = "advection_field"; - if (solver->nsims > 1) { + if (solver->m_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } - int adv_nvar = solver->ndims * solver->nvars; - WriteArray( solver->ndims, + int adv_nvar = solver->m_ndims * solver->m_nvars; + WriteArray( solver->m_ndims, adv_nvar, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - param->a, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + param->m_a, solver,mpi, fname_root ); - if (!strcmp(solver->plot_solution, "yes")) { - PlotArray( solver->ndims, + if (!strcmp(solver->m_plot_solution, "yes")) { + PlotArray( solver->m_ndims, adv_nvar, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - param->a, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + param->m_a, a_t, solver,mpi, fname_root ); diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DCleanup.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DCleanup.c index ab0d59ac..edfa9a6d 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DCleanup.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DCleanup.c @@ -8,13 +8,13 @@ /*! Function to clean up all allocations in the 2D Navier Stokes module. */ -int NavierStokes2DCleanup(void *s /*!< Object of type #NavierStokes2D*/) +int NavierStokes2DCleanup(void *a_s /*!< Object of type #NavierStokes2D*/) { - NavierStokes2D *param = (NavierStokes2D*) s; + NavierStokes2D *param = (NavierStokes2D*) a_s; - free(param->grav_field_f); - free(param->grav_field_g); - free(param->fast_jac); + free(param->m_grav_field_f); + free(param->m_grav_field_g); + free(param->m_fast_jac); free(param->solution); return(0); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DComputeCFL.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DComputeCFL.c index 6893d33e..ec2f776d 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DComputeCFL.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DComputeCFL.c @@ -14,35 +14,35 @@ is computed over the local domain on this processor only. */ double NavierStokes2DComputeCFL( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; _DECLARE_IERR_; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; - double *u = solver->u; + double *u = solver->m_u; double max_cfl = 0; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double rho,vx,vy,e,P,c,dxinv,dyinv,local_cfl[2]; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma); + _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->m_gamma); - c = sqrt(param->gamma*P/rho); /* speed of sound */ - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */ + c = sqrt(param->m_gamma*P/rho); /* speed of sound */ + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); /* 1/dy */ - local_cfl[_XDIR_] = (absolute(vx)+c)*dt*dxinv; /* local cfl for this grid point (x) */ - local_cfl[_YDIR_] = (absolute(vy)+c)*dt*dyinv; /* local cfl for this grid point (y) */ + local_cfl[_XDIR_] = (absolute(vx)+c)*a_dt*dxinv; /* local cfl for this grid point (x) */ + local_cfl[_YDIR_] = (absolute(vy)+c)*a_dt*dyinv; /* local cfl for this grid point (y) */ if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_]; if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_]; diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DEigen.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DEigen.c index e86bfe43..fb38b2c2 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DEigen.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DEigen.c @@ -17,15 +17,15 @@ to interpolation functions for a characteristic-based reconstruction. */ int NavierStokes2DLeftEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *L, /*!< Array of size nvar^2 = 4^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_L, /*!< Array of size nvar^2 = 4^2 to save the matrix of left eigenvectors in (row-major format). */ - void *p, /*!< Object of type #NavierStokes2D with physics-related variables */ - int dir /*!< Spatial dimension (x or y) */ + void *a_p, /*!< Object of type #NavierStokes2D with physics-related variables */ + int a_dir /*!< Spatial dimension (x or y) */ ) { - NavierStokes2D *param = (NavierStokes2D*) p; - _NavierStokes2DLeftEigenvectors_(u,L,param->gamma,dir); + NavierStokes2D *param = (NavierStokes2D*) a_p; + _NavierStokes2DLeftEigenvectors_(a_u,a_L,param->m_gamma,a_dir); return(0); } @@ -36,14 +36,14 @@ int NavierStokes2DLeftEigenvectors( to interpolation functions for a characteristic-based reconstruction. */ int NavierStokes2DRightEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *R, /*!< Array of size nvar^2 = 4^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_R, /*!< Array of size nvar^2 = 4^2 to save the matrix of right eigenvectors in (row-major format). */ - void *p, /*!< Object of type #NavierStokes2D with physics-related variables */ - int dir /*!< Spatial dimension (x or y) */ + void *a_p, /*!< Object of type #NavierStokes2D with physics-related variables */ + int a_dir /*!< Spatial dimension (x or y) */ ) { - NavierStokes2D *param = (NavierStokes2D*) p; - _NavierStokes2DRightEigenvectors_(u,R,param->gamma,dir); + NavierStokes2D *param = (NavierStokes2D*) a_p; + _NavierStokes2DRightEigenvectors_(a_u,a_R,param->m_gamma,a_dir); return(0); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux.c index 35340afa..44673cc0 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux.c @@ -19,17 +19,17 @@ Note: the flux function needs to be computed at the ghost points as well. */ int NavierStokes2DFlux( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir,/*!< Spatial dimension (x or y) for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir,/*!< Spatial dimension (x or y) for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; /* set bounds for array index to include ghost points */ @@ -41,8 +41,8 @@ int NavierStokes2DFlux( while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); double rho, vx, vy, e, P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma); - _NavierStokes2DSetFlux_((f+_MODEL_NVARS_*p),rho,vx,vy,e,P,dir); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->m_gamma); + _NavierStokes2DSetFlux_((a_f+_MODEL_NVARS_*p),rho,vx,vy,e,P,a_dir); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } @@ -61,17 +61,17 @@ int NavierStokes2DFlux( Note: the flux function needs to be computed at the ghost points as well. */ int NavierStokes2DStiffFlux( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir,/*!< Spatial dimension (x or y) for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir,/*!< Spatial dimension (x or y) for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -83,8 +83,8 @@ int NavierStokes2DStiffFlux( int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double *Af = param->fast_jac+(2*p+dir)*JacSize; - MatVecMult4(_MODEL_NVARS_,(f+_MODEL_NVARS_*p),Af,(u+_MODEL_NVARS_*p)); + double *Af = param->m_fast_jac+(2*p+a_dir)*JacSize; + MatVecMult4(_MODEL_NVARS_,(a_f+_MODEL_NVARS_*p),Af,(a_u+_MODEL_NVARS_*p)); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } @@ -102,17 +102,17 @@ int NavierStokes2DStiffFlux( Note: the flux function needs to be computed at the ghost points as well. */ int NavierStokes2DNonStiffFlux( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir,/*!< Spatial dimension (x or y) for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir,/*!< Spatial dimension (x or y) for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; static double ftot[_MODEL_NVARS_], fstiff[_MODEL_NVARS_]; @@ -127,13 +127,13 @@ int NavierStokes2DNonStiffFlux( int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); /* compute total flux */ double rho, vx, vy, e, P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma); - _NavierStokes2DSetFlux_(ftot,rho,vx,vy,e,P,dir); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->m_gamma); + _NavierStokes2DSetFlux_(ftot,rho,vx,vy,e,P,a_dir); /* compute stiff stuff */ - double *Af = param->fast_jac+(2*p+dir)*JacSize; - MatVecMult4(_MODEL_NVARS_,fstiff,Af,(u+_MODEL_NVARS_*p)); + double *Af = param->m_fast_jac+(2*p+a_dir)*JacSize; + MatVecMult4(_MODEL_NVARS_,fstiff,Af,(a_u+_MODEL_NVARS_*p)); /* subtract stiff flux from total flux */ - _ArraySubtract1D_((f+_MODEL_NVARS_*p),ftot,fstiff,_MODEL_NVARS_); + _ArraySubtract1D_((a_f+_MODEL_NVARS_*p),ftot,fstiff,_MODEL_NVARS_); /* Done */ _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux_GPU.cu b/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux_GPU.cu index 59b9464a..8a43cd4e 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux_GPU.cu +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DFlux_GPU.cu @@ -50,8 +50,8 @@ extern "C" int gpuNavierStokes2DFlux( { HyPar *solver = (HyPar*) s; NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int ngrid_points = 1; for (int i=0; i<_MODEL_NDIMS_; i++) ngrid_points *= (dim[i]+2*ghosts); int nblocks = (ngrid_points - 1) / GPU_THREADS_PER_BLOCK + 1; diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DFunctions.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DFunctions.c index e13bf51a..043ed44b 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DFunctions.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DFunctions.c @@ -13,13 +13,13 @@ to interpolation functions for a characteristic-based reconstruction. */ int NavierStokes2DRoeAverage( - double *uavg, /*!< The computed Roe-averaged state */ - double *uL, /*!< Left state (conserved variables)*/ - double *uR, /*!< Right state (conserved variables)*/ - void *p /*!< Object of type #NavierStokes2D with physics-related variables */ + double *a_uavg, /*!< The computed Roe-averaged state */ + double *a_uL, /*!< Left state (conserved variables)*/ + double *a_uR, /*!< Right state (conserved variables)*/ + void *a_p /*!< Object of type #NavierStokes2D with physics-related variables */ ) { - NavierStokes2D *param = (NavierStokes2D*) p; - _NavierStokes2DRoeAverage_(uavg,uL,uR,param->gamma); + NavierStokes2D *param = (NavierStokes2D*) a_p; + _NavierStokes2DRoeAverage_(a_uavg,a_uL,a_uR,param->m_gamma); return(0); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DGravityField.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DGravityField.c index c67bad0c..3ed42012 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DGravityField.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DGravityField.c @@ -31,18 +31,18 @@ for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes2DGravityField( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; - double *f = param->grav_field_f; - double *g = param->grav_field_g; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + double *f = param->m_grav_field_f; + double *g = param->m_grav_field_g; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_], d, done; @@ -52,15 +52,15 @@ int NavierStokes2DGravityField( /* set offset such that index is compatible with ghost point arrangement */ _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts); - double p0 = param->p0; - double rho0 = param->rho0; + double p0 = param->m_p0; + double rho0 = param->m_rho0; double RT = p0 / rho0; - double gamma= param->gamma; - double R = param->R; + double gamma= param->m_gamma; + double R = param->m_R; double Cp = gamma*R / (gamma-1.0); double T0 = p0 / (rho0 * R); - double gx = param->grav_x; - double gy = param->grav_y; + double gx = param->m_grav_x; + double gy = param->m_grav_y; double Nbv = param->N_bv; /* set the value of the gravity field */ @@ -68,8 +68,8 @@ int NavierStokes2DGravityField( if (param->HB == 1) { while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord); - double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->m_x,xcoord); + double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); f[p] = exp( (gx*xcoord+gy*ycoord)/RT); g[p] = exp(-(gx*xcoord+gy*ycoord)/RT); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); @@ -77,8 +77,8 @@ int NavierStokes2DGravityField( } else if (param->HB == 2) { while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord); - double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->m_x,xcoord); + double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); f[p] = raiseto((1.0-(gx*xcoord+gy*ycoord)/(Cp*T0)), (-1.0 /(gamma-1.0))); g[p] = raiseto((1.0-(gx*xcoord+gy*ycoord)/(Cp*T0)), (gamma/(gamma-1.0))); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); @@ -86,9 +86,9 @@ int NavierStokes2DGravityField( } else if (param->HB == 3) { while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); if (gx != 0) { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes2DGravityField(): HB = 3 is implemented only for "); fprintf(stderr,"gravity force along the y-coordinate.\n"); } @@ -117,7 +117,7 @@ int NavierStokes2DGravityField( int indexb[_MODEL_NDIMS_], indexi[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { /* left boundary */ - if (!mpi->ip[d]) { + if (!mpi->m_ip[d]) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = -ghosts; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -131,7 +131,7 @@ int NavierStokes2DGravityField( } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = dim[d]; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize.c index e812b2eb..01a0f5a8 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize.c @@ -101,46 +101,46 @@ int gpuNavierStokes2DParabolicFunction (double*,double*,void*,void*,doubl \b Note: "physics.inp" is \b optional; if absent, default values will be used. */ int NavierStokes2DInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes2D *physics = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes2D *physics = (NavierStokes2D*) solver->m_physics; int ferr = 0; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in NavierStokes2DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in NavierStokes2DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->gamma = 1.4; - physics->Pr = 0.72; - physics->Re = -1; + physics->m_gamma = 1.4; + physics->m_Pr = 0.72; + physics->m_Re = -1; physics->Minf = 1.0; physics->C1 = 1.458e-6; physics->C2 = 110.4; - physics->grav_x = 0.0; - physics->grav_y = 0.0; - physics->rho0 = 1.0; - physics->p0 = 1.0; + physics->m_grav_x = 0.0; + physics->m_grav_y = 0.0; + physics->m_rho0 = 1.0; + physics->m_p0 = 1.0; physics->HB = 1; - physics->R = 1.0; + physics->m_R = 1.0; physics->N_bv = 0.0; - strcpy(physics->upw_choice,"roe"); + strcpy(physics->m_upw_choice,"roe"); /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -150,29 +150,29 @@ int NavierStokes2DInitialize( while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gamma")) { - ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_gamma); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upw_choice); if (ferr != 1) return(1); + ferr = fscanf(in,"%s",physics->m_upw_choice); if (ferr != 1) return(1); } else if (!strcmp(word,"Pr")) { - ferr = fscanf(in,"%lf",&physics->Pr); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_Pr); if (ferr != 1) return(1); } else if (!strcmp(word,"Re")) { - ferr = fscanf(in,"%lf",&physics->Re); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_Re); if (ferr != 1) return(1); } else if (!strcmp(word,"Minf")) { ferr = fscanf(in,"%lf",&physics->Minf); if (ferr != 1) return(1); } else if (!strcmp(word,"gravity")) { - ferr = fscanf(in,"%lf",&physics->grav_x); if (ferr != 1) return(1); - ferr = fscanf(in,"%lf",&physics->grav_y); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_grav_x); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_grav_y); if (ferr != 1) return(1); } else if (!strcmp(word,"rho_ref")) { - ferr = fscanf(in,"%lf",&physics->rho0); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_rho0); if (ferr != 1) return(1); } else if (!strcmp(word,"p_ref")) { - ferr = fscanf(in,"%lf",&physics->p0); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_p0); if (ferr != 1) return(1); } else if (!strcmp(word,"HB")) { ferr = fscanf(in,"%d",&physics->HB); if (ferr != 1) return(1); if (physics->HB==3) { ferr = fscanf(in,"%lf",&physics->N_bv); if (ferr != 1) return(1); } } else if (!strcmp(word,"R")) { - ferr = fscanf(in,"%lf",&physics->R); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_R); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr); @@ -188,43 +188,43 @@ int NavierStokes2DInitialize( fclose(in); } - IERR MPIBroadcast_character (physics->upw_choice,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->gamma ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Pr ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Re ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Minf ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->grav_x ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->grav_y ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->rho0 ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->p0 ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->R ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->N_bv ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->HB ,1 ,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_upw_choice,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_gamma ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_Pr ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_Re ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->Minf ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_grav_x ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_grav_y ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_rho0 ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_p0 ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_R ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->N_bv ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->HB ,1 ,0,&mpi->m_world); CHECKERR(ierr); /* Scaling the Reynolds number with the M_inf */ - physics->Re /= physics->Minf; + physics->m_Re /= physics->Minf; /* check that a well-balanced upwinding scheme is being used for cases with gravity */ - if ( ((physics->grav_x != 0.0) || (physics->grav_y != 0.0)) - && (strcmp(physics->upw_choice,_LLF_ )) - && (strcmp(physics->upw_choice,_RUSANOV_)) - && (strcmp(physics->upw_choice,_ROE_ )) ) { - if (!mpi->rank) { + if ( ((physics->m_grav_x != 0.0) || (physics->m_grav_y != 0.0)) + && (strcmp(physics->m_upw_choice,_LLF_ )) + && (strcmp(physics->m_upw_choice,_RUSANOV_)) + && (strcmp(physics->m_upw_choice,_ROE_ )) ) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes2DInitialize: %s, %s or %s upwinding is needed for flows ",_LLF_,_ROE_,_RUSANOV_); fprintf(stderr,"with gravitational forces.\n"); } return(1); } /* check that solver has the correct choice of diffusion formulation */ - if (strcmp(solver->spatial_type_par,_NC_2STAGE_) && (physics->Re > 0)) { - if (!mpi->rank) + if (strcmp(solver->m_spatial_type_par,_NC_2STAGE_) && (physics->m_Re > 0)) { + if (!mpi->m_rank) fprintf(stderr,"Error in NavierStokes2DInitialize(): Parabolic term spatial discretization must be \"%s\"\n",_NC_2STAGE_); return(1); } /* initializing physical model-specific functions */ #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS) - if (solver->use_gpu) { + if (solver->m_use_gpu) { solver->FFunction = gpuNavierStokes2DFlux; solver->SFunction = gpuNavierStokes2DSource; solver->UFunction = gpuNavierStokes2DModifiedSolution; @@ -243,19 +243,19 @@ int NavierStokes2DInitialize( #endif #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS) - if (solver->use_gpu) { - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (solver->m_use_gpu) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes2DInitialize(): Not yet implemented on GPU!"); } return 1; } else { solver->JFunction = NavierStokes2DJacobian; - if (!strcmp(physics->upw_choice,_RUSANOV_)) solver->Upwind = gpuNavierStokes2DUpwindRusanov; + if (!strcmp(physics->m_upw_choice,_RUSANOV_)) solver->Upwind = gpuNavierStokes2DUpwindRusanov; else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes2DInitialize(): %s is not implemented on GPU. ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"Only choice is %s.\n",_RUSANOV_); } return 1; @@ -263,30 +263,30 @@ int NavierStokes2DInitialize( } } else { #endif - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { solver->FdFFunction = NavierStokes2DNonStiffFlux; solver->dFFunction = NavierStokes2DStiffFlux; solver->JFunction = NavierStokes2DStiffJacobian; - if (!strcmp(physics->upw_choice,_ROE_)) { + if (!strcmp(physics->m_upw_choice,_ROE_)) { solver->Upwind = NavierStokes2DUpwindRoe; solver->UpwinddF = NavierStokes2DUpwinddFRoe; solver->UpwindFdF = NavierStokes2DUpwindFdFRoe; - } else if (!strcmp(physics->upw_choice,_RF_)) { + } else if (!strcmp(physics->m_upw_choice,_RF_)) { solver->Upwind = NavierStokes2DUpwindRF; solver->UpwinddF = NavierStokes2DUpwinddFRF; solver->UpwindFdF = NavierStokes2DUpwindFdFRF; - } else if (!strcmp(physics->upw_choice,_LLF_)) { + } else if (!strcmp(physics->m_upw_choice,_LLF_)) { solver->Upwind = NavierStokes2DUpwindLLF; solver->UpwinddF = NavierStokes2DUpwinddFLLF; solver->UpwindFdF = NavierStokes2DUpwindFdFLLF; - } else if (!strcmp(physics->upw_choice,_RUSANOV_)) { + } else if (!strcmp(physics->m_upw_choice,_RUSANOV_)) { solver->Upwind = NavierStokes2DUpwindRusanovModified; solver->UpwinddF = NavierStokes2DUpwinddFRusanovModified; solver->UpwindFdF = NavierStokes2DUpwindFdFRusanovModified; } else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes2DInitialize(): %s is not a valid upwinding scheme ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"for use with split hyperbolic flux form. Use %s, %s, %s, or %s.\n", _ROE_,_RF_,_LLF_,_RUSANOV_); } @@ -294,15 +294,15 @@ int NavierStokes2DInitialize( } } else { solver->JFunction = NavierStokes2DJacobian; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = NavierStokes2DUpwindRoe; - else if (!strcmp(physics->upw_choice,_RF_ )) solver->Upwind = NavierStokes2DUpwindRF; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = NavierStokes2DUpwindLLF; - else if (!strcmp(physics->upw_choice,_SWFS_ )) solver->Upwind = NavierStokes2DUpwindSWFS; - else if (!strcmp(physics->upw_choice,_RUSANOV_)) solver->Upwind = NavierStokes2DUpwindRusanov; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->Upwind = NavierStokes2DUpwindRoe; + else if (!strcmp(physics->m_upw_choice,_RF_ )) solver->Upwind = NavierStokes2DUpwindRF; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->Upwind = NavierStokes2DUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_SWFS_ )) solver->Upwind = NavierStokes2DUpwindSWFS; + else if (!strcmp(physics->m_upw_choice,_RUSANOV_)) solver->Upwind = NavierStokes2DUpwindRusanov; else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes2DInitialize(): %s is not a valid upwinding scheme. ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"Choices are %s, %s, %s, %s, and %s.\n",_ROE_,_RF_,_LLF_,_SWFS_,_RUSANOV_); } return(1); @@ -314,14 +314,14 @@ int NavierStokes2DInitialize( /* set the value of gamma in all the boundary objects */ int n; - DomainBoundary *boundary = (DomainBoundary*) solver->boundary; - for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma; + DomainBoundary *boundary = (DomainBoundary*) solver->m_boundary; + for (n = 0; n < solver->m_n_boundary_zones; n++) boundary[n].m_gamma = physics->m_gamma; - /* hijack the main solver's dissipation function pointer - * to this model's own function, since it's difficult to express + /* hijack the main solver'a_s dissipation function pointer + * to this model'a_s own function, since it'a_s difficult to express * the dissipation terms in the general form */ #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS) - if (solver->use_gpu) { + if (solver->m_use_gpu) { solver->ParabolicFunction = gpuNavierStokes2DParabolicFunction; } else { #endif @@ -331,21 +331,21 @@ int NavierStokes2DInitialize( #endif /* allocate array to hold the gravity field */ - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int d, size = 1; for (d=0; d<_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts); - physics->grav_field_f = (double*) calloc (size, sizeof(double)); - physics->grav_field_g = (double*) calloc (size, sizeof(double)); + physics->m_grav_field_f = (double*) calloc (size, sizeof(double)); + physics->m_grav_field_g = (double*) calloc (size, sizeof(double)); /* allocate arrays to hold the fast Jacobian for split form of the hyperbolic flux */ - physics->fast_jac = (double*) calloc (2*size*_MODEL_NVARS_*_MODEL_NVARS_,sizeof(double)); + physics->m_fast_jac = (double*) calloc (2*size*_MODEL_NVARS_*_MODEL_NVARS_,sizeof(double)); physics->solution = (double*) calloc (size*_MODEL_NVARS_,sizeof(double)); /* initialize the gravity fields */ IERR NavierStokes2DGravityField(solver,mpi); CHECKERR(ierr); #if defined(HAVE_CUDA) && defined(CUDA_VAR_ORDERDING_AOS) - if (solver->use_gpu) gpuNavierStokes2DInitialize(s,m); + if (solver->m_use_gpu) gpuNavierStokes2DInitialize(a_s,a_m); #endif - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize_GPU.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize_GPU.c index 2544ddf2..7b611baa 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize_GPU.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DInitialize_GPU.c @@ -9,23 +9,23 @@ /*! Initialize GPU-related arrays. */ int gpuNavierStokes2DInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *physics = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *physics = (NavierStokes2D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int d, size = 1; for (d = 0; d <_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts); gpuMalloc((void**)&physics->gpu_grav_field_f, size*sizeof(double)); gpuMalloc((void**)&physics->gpu_grav_field_g, size*sizeof(double)); gpuMalloc((void**)&physics->gpu_fast_jac, 2*size*_MODEL_NVARS_*_MODEL_NVARS_*sizeof(double)); gpuMalloc((void**)&physics->gpu_solution, size*_MODEL_NVARS_*sizeof(double)); - gpuMemcpy(physics->gpu_grav_field_f, physics->grav_field_f, size*sizeof(double), gpuMemcpyHostToDevice); - gpuMemcpy(physics->gpu_grav_field_g, physics->grav_field_g, size*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(physics->gpu_grav_field_f, physics->m_grav_field_f, size*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(physics->gpu_grav_field_g, physics->m_grav_field_g, size*sizeof(double), gpuMemcpyHostToDevice); gpuMemset(physics->gpu_fast_jac, 0, 2*size*_MODEL_NVARS_*_MODEL_NVARS_*sizeof(double)); gpuMemset(physics->gpu_solution, 0, size*_MODEL_NVARS_*sizeof(double)); diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DJacobian.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DJacobian.c index 3fcf4355..0757ac9f 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DJacobian.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DJacobian.c @@ -12,33 +12,33 @@ is returned as a 1D array (double) of 16 elements in row-major format. */ int NavierStokes2DJacobian( - double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 16 */ - double *u, /*!< solution at a grid point (array of size nvar = 4) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (0 -> x, 1 -> y) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, + double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 16 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 4) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (0 -> x, 1 -> y) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - NavierStokes2D *param = (NavierStokes2D*) p; + NavierStokes2D *param = (NavierStokes2D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _NavierStokes2DEigenvalues_ (u,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (u,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_(u,R,param->gamma,dir); + _NavierStokes2DEigenvalues_ (a_u,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (a_u,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_(a_u,R,param->m_gamma,a_dir); - int aupw = absolute(upw), k; - k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 5; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 10; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 15; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + int aupw = absolute(a_upw), k; + k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 5; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 10; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 15; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); MatMult4(_MODEL_NVARS_,DL,D,L); - MatMult4(_MODEL_NVARS_,Jac,R,DL); + MatMult4(_MODEL_NVARS_,a_Jac,R,DL); return(0); } @@ -49,33 +49,33 @@ int NavierStokes2DJacobian( in row-major format. */ int NavierStokes2DStiffJacobian( - double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 16 */ - double *u, /*!< solution at a grid point (array of size nvar = 4) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (0 -> x, 1 -> y) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, + double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 16 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 4) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (0 -> x, 1 -> y) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - NavierStokes2D *param = (NavierStokes2D*) p; + NavierStokes2D *param = (NavierStokes2D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _NavierStokes2DEigenvalues_ (u,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (u,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_(u,R,param->gamma,dir); + _NavierStokes2DEigenvalues_ (a_u,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (a_u,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_(a_u,R,param->m_gamma,a_dir); - int aupw = absolute(upw), k; - k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 5; D[k] = ( dir == _YDIR_ ? 0.0 : absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ) ); - k = 10; D[k] = ( dir == _XDIR_ ? 0.0 : absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ) ); + int aupw = absolute(a_upw), k; + k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 5; D[k] = ( a_dir == _YDIR_ ? 0.0 : absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ) ); + k = 10; D[k] = ( a_dir == _XDIR_ ? 0.0 : absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ) ); k = 15; D[k] = 0.0; MatMult4(_MODEL_NVARS_,DL,D,L); - MatMult4(_MODEL_NVARS_,Jac,R,DL); + MatMult4(_MODEL_NVARS_,a_Jac,R,DL); return(0); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution.c index 6c671602..6bb036d5 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution.c @@ -29,20 +29,20 @@ for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes2DModifiedSolution( - double *uC, /*!< Array to hold the computed modified solution */ - double *u, /*!< Solution vector array */ - int d, /*!< spatial dimension (not used) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of time #MPIVariables */ + double *a_uC, /*!< Array to hold the computed modified solution */ + double *a_u, /*!< Solution vector array */ + int a_d, /*!< spatial dimension (not used) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of time #MPIVariables */ double waqt /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -53,16 +53,16 @@ int NavierStokes2DModifiedSolution( _ArraySetValue_(offset,ndims,-ghosts); int done = 0; _ArraySetValue_(index,ndims,0); - double inv_gamma_m1 = 1.0 / (param->gamma-1.0); + double inv_gamma_m1 = 1.0 / (param->m_gamma-1.0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double rho, uvel, vvel, E, P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,uvel,vvel,E,P,param->gamma); - uC[_MODEL_NVARS_*p+0] = u[_MODEL_NVARS_*p+0] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+1] = u[_MODEL_NVARS_*p+1] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+2] = u[_MODEL_NVARS_*p+2] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+3] = (P*inv_gamma_m1)*(1.0/param->grav_field_g[p]) + (0.5*rho*(uvel*uvel+vvel*vvel))*param->grav_field_f[p]; + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,uvel,vvel,E,P,param->m_gamma); + a_uC[_MODEL_NVARS_*p+0] = a_u[_MODEL_NVARS_*p+0] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+1] = a_u[_MODEL_NVARS_*p+1] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+2] = a_u[_MODEL_NVARS_*p+2] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+3] = (P*inv_gamma_m1)*(1.0/param->m_grav_field_g[p]) + (0.5*rho*(uvel*uvel+vvel*vvel))*param->m_grav_field_f[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution_GPU.cu b/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution_GPU.cu index fa591df6..30f9a80b 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution_GPU.cu +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DModifiedSolution_GPU.cu @@ -68,9 +68,9 @@ extern "C" int gpuNavierStokes2DModifiedSolution( HyPar *solver = (HyPar*) s; NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int size = 1; for (int i=0; i physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes2D *physics = (NavierStokes2D*) solver->m_physics; int i,j,v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int imax = solver->dim_local[0]; - int jmax = solver->dim_local[1]; - int *dim = solver->dim_local; - int nvars = solver->nvars; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int imax = solver->m_dim_local[0]; + int jmax = solver->m_dim_local[1]; + int *dim = solver->m_dim_local; + int nvars = solver->m_nvars; + int ndims = solver->m_ndims; int size = (imax+2*ghosts)*(jmax+2*ghosts)*nvars; - _ArraySetValue_(par,size,0.0); - if (physics->Re <= 0) return(0); /* inviscid flow */ - solver->count_par++; + _ArraySetValue_(a_par,size,0.0); + if (physics->m_Re <= 0) return(0); /* inviscid flow */ + solver->m_count_par++; - static double two_third = 2.0/3.0; - double inv_gamma_m1 = 1.0 / (physics->gamma-1.0); - double inv_Re = 1.0 / physics->Re; - double inv_Pr = 1.0 / physics->Pr; + static double s_two_third = 2.0/3.0; + double inv_gamma_m1 = 1.0 / (physics->m_gamma-1.0); + double inv_Re = 1.0 / physics->m_Re; + double inv_Pr = 1.0 / physics->m_Pr; double *Q; /* primitive variables */ Q = (double*) calloc (size,sizeof(double)); @@ -73,9 +73,9 @@ int NavierStokes2DParabolicFunction( int p,index[2]; index[0]=i; index[1]=j; double energy,pressure; _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars; - _NavierStokes2DGetFlowVar_( (u+p),Q[p+0],Q[p+1],Q[p+2],energy, - pressure,physics->gamma); - Q[p+3] = physics->gamma*pressure/Q[p+0]; /* temperature */ + _NavierStokes2DGetFlowVar_( (a_u+p),Q[p+0],Q[p+1],Q[p+2],energy, + pressure,physics->m_gamma); + Q[p+3] = physics->m_gamma*pressure/Q[p+0]; /* temperature */ } } @@ -85,18 +85,18 @@ int NavierStokes2DParabolicFunction( IERR solver->FirstDerivativePar(QDerivX,Q,_XDIR_,1,solver,mpi); CHECKERR(ierr); IERR solver->FirstDerivativePar(QDerivY,Q,_YDIR_,1,solver,mpi); CHECKERR(ierr); - IERR MPIExchangeBoundariesnD(solver->ndims,solver->nvars,dim, - solver->ghosts,mpi,QDerivX); CHECKERR(ierr); - IERR MPIExchangeBoundariesnD(solver->ndims,solver->nvars,dim, - solver->ghosts,mpi,QDerivY); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(solver->m_ndims,solver->m_nvars,dim, + solver->m_ghosts,mpi,QDerivX); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(solver->m_ndims,solver->m_nvars,dim, + solver->m_ghosts,mpi,QDerivY); CHECKERR(ierr); for (i=-ghosts; i<(imax+ghosts); i++) { for (j=-ghosts; j<(jmax+ghosts); j++) { int p,index[2]; index[0]=i; index[1]=j; double dxinv, dyinv; _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); _ArrayScale1D_((QDerivX+p),dxinv,nvars); _ArrayScale1D_((QDerivY+p),dyinv,nvars); } @@ -121,11 +121,11 @@ int NavierStokes2DParabolicFunction( uy = (QDerivY+p)[1]; vy = (QDerivY+p)[2]; - /* calculate viscosity coeff based on Sutherland's law */ + /* calculate viscosity coeff based on Sutherland'a_s law */ double mu = raiseto(T, 0.76); double tau_xx, tau_xy, qx; - tau_xx = two_third * (mu*inv_Re) * (2*ux - vy); + tau_xx = s_two_third * (mu*inv_Re) * (2*ux - vy); tau_xy = (mu*inv_Re) * (uy + vx); qx = ( (mu*inv_Re) * inv_gamma_m1 * inv_Pr ) * Tx; @@ -141,8 +141,8 @@ int NavierStokes2DParabolicFunction( int p,index[2]; index[0]=i; index[1]=j; double dxinv; _ArrayIndex1D_(ndims,dim,index,ghosts,p); p *= nvars; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - for (v=0; vm_dxinv,dxinv); + for (v=0; vdxinv,dyinv); - for (v=0; vm_dxinv,dyinv); + for (v=0; vphysics; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int imax = solver->dim_local[0]; - int jmax = solver->dim_local[1]; - int nvars = solver->nvars; + int ghosts = solver->m_ghosts; + int imax = solver->m_dim_local[0]; + int jmax = solver->m_dim_local[1]; + int nvars = solver->m_nvars; int size = (imax+2*ghosts)*(jmax+2*ghosts)*nvars; gpuArraySetValue(par, size, 0.0); diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep.c index bedd3ea1..35cfe215 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep.c @@ -31,16 +31,16 @@ 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DPreStep( - double *u, /*!< Solution vector */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + double *a_u, /*!< Solution vector */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double waqt /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts, dir, p; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts, dir, p; double *A; static const int ndims = _MODEL_NDIMS_; static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_; @@ -53,30 +53,30 @@ int NavierStokes2DPreStep( /* set offset such that index is compatible with ghost point arrangement */ _ArraySetValue_(offset,ndims,-ghosts); /* copy the solution to act as a reference for linearization */ - _ArrayCopy1D_(u,param->solution,(solver->npoints_local_wghosts*_MODEL_NVARS_)); + _ArrayCopy1D_(a_u,param->solution,(solver->m_npoints_local_wghosts*_MODEL_NVARS_)); int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); dir = _XDIR_; - A = (param->fast_jac + 2*JacSize*p + dir*JacSize); + A = (param->m_fast_jac + 2*JacSize*p + dir*JacSize); /* get the eigenvalues, and left & right eigenvectors */ - _NavierStokes2DEigenvalues_ ((u+_MODEL_NVARS_*p),D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ ((u+_MODEL_NVARS_*p),L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_((u+_MODEL_NVARS_*p),R,param->gamma,dir); - /* remove the entropy modes (corresponding to eigenvalues u) */ + _NavierStokes2DEigenvalues_ ((a_u+_MODEL_NVARS_*p),D,param->m_gamma,dir); + _NavierStokes2DLeftEigenvectors_ ((a_u+_MODEL_NVARS_*p),L,param->m_gamma,dir); + _NavierStokes2DRightEigenvectors_((a_u+_MODEL_NVARS_*p),R,param->m_gamma,dir); + /* remove the entropy modes (corresponding to eigenvalues a_u) */ D[2*_MODEL_NVARS_+2] = D[3*_MODEL_NVARS_+3] = 0.0; /* assemble the Jacobian */ MatMult4(_MODEL_NVARS_,DL,D,L ); MatMult4(_MODEL_NVARS_,A ,R,DL); dir = _YDIR_; - A = (param->fast_jac + 2*JacSize*p + dir*JacSize); + A = (param->m_fast_jac + 2*JacSize*p + dir*JacSize); /* get the eigenvalues, and left & right eigenvectors */ - _NavierStokes2DEigenvalues_ ((u+_MODEL_NVARS_*p),D,param->gamma,dir) - _NavierStokes2DLeftEigenvectors_ ((u+_MODEL_NVARS_*p),L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_((u+_MODEL_NVARS_*p),R,param->gamma,dir); + _NavierStokes2DEigenvalues_ ((a_u+_MODEL_NVARS_*p),D,param->m_gamma,dir) + _NavierStokes2DLeftEigenvectors_ ((a_u+_MODEL_NVARS_*p),L,param->m_gamma,dir); + _NavierStokes2DRightEigenvectors_((a_u+_MODEL_NVARS_*p),R,param->m_gamma,dir); /* remove the entropy modes (corresponding to eigenvalues v) */ D[1*_MODEL_NVARS_+1] = D[3*_MODEL_NVARS_+3] = 0.0; /* assemble the Jacobian */ diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep_GPU.cu b/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep_GPU.cu index 0e647e95..1b8c7324 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep_GPU.cu +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DPreStep_GPU.cu @@ -88,8 +88,8 @@ extern "C" int gpuNavierStokes2DPreStep( { HyPar *solver = (HyPar*) s; NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static int bounds[_MODEL_NDIMS_]; _ArrayAddCopy1D_(dim,(2*ghosts),bounds,_MODEL_NDIMS_); @@ -99,12 +99,12 @@ extern "C" int gpuNavierStokes2DPreStep( double cpu_time = 0.0; clock_t cpu_start, cpu_end; - gpuMemcpy(solver->gpu_u, u, N_grid*_MODEL_NVARS_*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(solver->m_gpu_u, u, N_grid*_MODEL_NVARS_*sizeof(double), gpuMemcpyHostToDevice); gpuMemcpy(param->gpu_solution, u, N_grid*_MODEL_NVARS_*sizeof(double), gpuMemcpyHostToDevice); int nblocks = (N_grid - 1) / GPU_THREADS_PER_BLOCK + 1; cpu_start = clock(); - NavierStokes2DPreStep_kernel<<>>(N_grid, param->gamma, solver->gpu_u, param->gpu_fast_jac); + NavierStokes2DPreStep_kernel<<>>(N_grid, param->gamma, solver->m_gpu_u, param->gpu_fast_jac); cudaDeviceSynchronize(); cpu_end = clock(); cpu_time += (double)(cpu_end - cpu_start) / CLOCKS_PER_SEC; diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource.c index c49f2bd6..b10fef37 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource.c @@ -35,46 +35,46 @@ static int NavierStokes2DSourceUpwind (double*,double*,double*,double*,int,voi for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes2DSource( - double *source, /*!< Array to hold the computed source */ - double *u, /*!< Solution vector array */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_source, /*!< Array to hold the computed source */ + double *a_u, /*!< Solution vector array */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar* ) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; - if ((param->grav_x == 0.0) && (param->grav_y == 0.0)) + if ((param->m_grav_x == 0.0) && (param->m_grav_y == 0.0)) return(0); /* no gravitational forces */ int v, done, p, p1, p2; - double *SourceI = solver->fluxI; /* interace source term */ - double *SourceC = solver->fluxC; /* cell-centered source term */ - double *SourceL = solver->fL; - double *SourceR = solver->fR; - - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *x = solver->x; - double *dxinv = solver->dxinv; - double RT = param->p0 / param->rho0; + double *SourceI = solver->m_flux_i; /* interace a_source term */ + double *SourceC = solver->m_flux_c; /* cell-centered a_source term */ + double *SourceL = solver->m_f_l; + double *SourceR = solver->m_f_r; + + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *x = solver->m_x; + double *dxinv = solver->m_dxinv; + double RT = param->m_p0 / param->m_rho0; int index[ndims],index1[ndims],index2[ndims],dim_interface[ndims]; /* Along X-direction */ - if (param->grav_x != 0.0) { + if (param->m_grav_x != 0.0) { /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_XDIR_]++; - /* calculate the split source function exp(-phi/RT) */ - IERR NavierStokes2DSourceFunction(SourceC,u,x,solver,mpi,t,_XDIR_); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR NavierStokes2DSourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the split a_source function exp(-phi/RT) */ + IERR NavierStokes2DSourceFunction(SourceC,a_u,x,solver,mpi,a_t,_XDIR_); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR NavierStokes2DSourceUpwind(SourceI,SourceL,SourceR,a_u,_XDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -85,10 +85,10 @@ int NavierStokes2DSource( double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse); double rho, uvel, vvel, e, P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,uvel,vvel,e,P,param->gamma); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,uvel,vvel,e,P,param->m_gamma); double term[_MODEL_NVARS_] = {0.0, rho*RT, 0.0, rho*RT*uvel}; for (v=0; v<_MODEL_NVARS_; v++) { - source[_MODEL_NVARS_*p+v] += ( (term[v]*param->grav_field_f[p]) + a_source[_MODEL_NVARS_*p+v] += ( (term[v]*param->m_grav_field_f[p]) * (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse ); } uvel = P; /* useless statement to avoid compiler warnings */ @@ -97,18 +97,18 @@ int NavierStokes2DSource( } /* Along Y-direction */ - if (param->grav_y != 0.0) { + if (param->m_grav_y != 0.0) { /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_YDIR_]++; - /* calculate the split source function exp(-phi/RT) */ - IERR NavierStokes2DSourceFunction(SourceC,u,x,solver,mpi,t,_YDIR_); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR NavierStokes2DSourceUpwind(SourceI,SourceL,SourceR,u,_YDIR_,solver,t); - - /* calculate the final cell-centered source term */ + /* calculate the split a_source function exp(-phi/RT) */ + IERR NavierStokes2DSourceFunction(SourceC,a_u,x,solver,mpi,a_t,_YDIR_); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR NavierStokes2DSourceUpwind(SourceI,SourceL,SourceR,a_u,_YDIR_,solver,a_t); + + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -119,10 +119,10 @@ int NavierStokes2DSource( double dy_inverse; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,dxinv,dy_inverse); double rho, uvel, vvel, e, P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*p),rho,uvel,vvel,e,P,param->gamma); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*p),rho,uvel,vvel,e,P,param->m_gamma); double term[_MODEL_NVARS_] = {0.0, 0.0, rho*RT, rho*RT*vvel}; for (v=0; v<_MODEL_NVARS_; v++) { - source[_MODEL_NVARS_*p+v] += ( (term[v]*param->grav_field_f[p]) + a_source[_MODEL_NVARS_*p+v] += ( (term[v]*param->m_grav_field_f[p]) * (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dy_inverse ); } uvel = P; /* useless statement to avoid compiler warnings */ @@ -149,21 +149,21 @@ int NavierStokes2DSource( for Atmospheric Flows, Submitted */ int NavierStokes2DSourceFunction( - double *f, /*!< Array to hold the computed source function */ - double *u, /*!< Solution vector array */ - double *x, /*!< Array of spatial coordinates (grid) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current simulation time */ - int dir /*!< Spatial dimension (x or y) */ + double *a_f, /*!< Array to hold the computed source function */ + double *a_u, /*!< Solution vector array */ + double *a_x, /*!< Array of spatial coordinates (grid) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current simulation time */ + int a_dir /*!< Spatial dimension (x or y) */ ) { - HyPar *solver = (HyPar* ) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -176,10 +176,10 @@ int NavierStokes2DSourceFunction( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = param->grav_field_g[p] * (dir == _XDIR_); - (f+_MODEL_NVARS_*p)[2] = param->grav_field_g[p] * (dir == _YDIR_); - (f+_MODEL_NVARS_*p)[3] = param->grav_field_g[p]; + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = param->m_grav_field_g[p] * (a_dir == _XDIR_); + (a_f+_MODEL_NVARS_*p)[2] = param->m_grav_field_g[p] * (a_dir == _YDIR_); + (a_f+_MODEL_NVARS_*p)[3] = param->m_grav_field_g[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -198,33 +198,33 @@ int NavierStokes2DSourceFunction( for Atmospheric Flows, Submitted */ int NavierStokes2DSourceUpwind( - double *fI, /*!< Array to hold the computed "upwind" interface source function */ - double *fL, /*!< Interface source function value computed using left-biased interpolation */ - double *fR, /*!< Interface source function value computed using right-biased interpolation */ - double *u, /*!< Solution vector array */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_fI, /*!< Array to hold the computed "upwind" interface source function */ + double *a_fL, /*!< Interface source function value computed using left-biased interpolation */ + double *a_fR, /*!< Interface source function value computed using right-biased interpolation */ + double *a_u, /*!< Solution vector array */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource_GPU.cu b/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource_GPU.cu index afa22b36..4aee8d3e 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource_GPU.cu +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DSource_GPU.cu @@ -169,11 +169,11 @@ extern "C" int gpuNavierStokes2DSource( double *SourceL = solver->fL; double *SourceR = solver->fR; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *gpu_x = solver->gpu_x; - double *gpu_dxinv = solver->gpu_dxinv; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *gpu_x = solver->m_gpu_x; + double *gpu_dxinv = solver->m_gpu_dxinv; double RT = param->p0 / param->rho0; /* Along X-direction */ @@ -194,7 +194,7 @@ extern "C" int gpuNavierStokes2DSource( int nblocks = (ngrid_points - 1) / GPU_THREADS_PER_BLOCK + 1; NavierStokes2DSource_Xdir_kernel<<>>( ngrid_points, ghosts, ndims, param->gamma, RT, - solver->gpu_dim_local, gpu_dxinv, param->gpu_grav_field_f, SourceI, gpu_u, source + solver->m_gpu_dim_local, gpu_dxinv, param->gpu_grav_field_f, SourceI, gpu_u, source ); } @@ -215,7 +215,7 @@ extern "C" int gpuNavierStokes2DSource( int nblocks = (ngrid_points - 1) / GPU_THREADS_PER_BLOCK + 1; NavierStokes2DSource_Ydir_kernel<<>>( ngrid_points, ghosts, ndims, param->gamma, RT, - solver->gpu_dim_local, gpu_dxinv, param->gpu_grav_field_f, SourceI, gpu_u, source + solver->m_gpu_dim_local, gpu_dxinv, param->gpu_grav_field_f, SourceI, gpu_u, source ); } return(0); @@ -250,9 +250,9 @@ int gpuNavierStokes2DSourceFunction( HyPar *solver = (HyPar* ) s; NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; double cpu_time = 0.0; clock_t cpu_start, cpu_end; @@ -295,8 +295,8 @@ int gpuNavierStokes2DSourceUpwind( HyPar *solver = (HyPar*) s; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int bounds_inter[ndims]; double cpu_time = 0.0; diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind.c b/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind.c index 79b158d8..ec0e8e1c 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind.c +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind.c @@ -32,26 +32,26 @@ */ int NavierStokes2DUpwindRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -59,30 +59,30 @@ int NavierStokes2DUpwindRoe( done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); - _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); - /* Harten's Entropy Fix - Page 362 of Leveque */ + /* Harten'a_s Entropy Fix - Page 362 of Leveque */ int k; double delta = 0.000001, delta2 = delta*delta; - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=5; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=10; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); @@ -92,10 +92,10 @@ int NavierStokes2DUpwindRoe( MatMult4(_MODEL_NVARS_,modA,R,DL); MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -118,63 +118,63 @@ int NavierStokes2DUpwindRoe( Note that this upwinding scheme cannot be used for solving flows with non-zero gravitational forces. */ int NavierStokes2DUpwindRF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done,k; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Roe-Fixed upwinding scheme */ - _NavierStokes2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param->gamma); + _NavierStokes2DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param->m_gamma); - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_(uavg,R,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_(uavg,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _NavierStokes2DEigenvalues_((uL+_MODEL_NVARS_*p),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((a_uL+_MODEL_NVARS_*p),D,param->m_gamma,a_dir); eigL[0] = D[0]; eigL[1] = D[5]; eigL[2] = D[10]; eigL[3] = D[15]; - _NavierStokes2DEigenvalues_((uR+_MODEL_NVARS_*p),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((a_uR+_MODEL_NVARS_*p),D,param->m_gamma,a_dir); eigR[0] = D[0]; eigR[1] = D[5]; eigR[2] = D[10]; eigR[3] = D[15]; - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); eigC[0] = D[0]; eigC[1] = D[5]; eigC[2] = D[10]; @@ -190,7 +190,7 @@ int NavierStokes2DUpwindRF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -221,67 +221,67 @@ int NavierStokes2DUpwindRF( for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes2DUpwindLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); /* Local Lax-Friedrich upwinding scheme */ - _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _NavierStokes2DEigenvalues_((u+_MODEL_NVARS_*pL),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param->m_gamma,a_dir); eigL[0] = D[0]; eigL[1] = D[5]; eigL[2] = D[10]; eigL[3] = D[15]; - _NavierStokes2DEigenvalues_((u+_MODEL_NVARS_*pR),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param->m_gamma,a_dir); eigR[0] = D[0]; eigR[1] = D[5]; eigR[2] = D[10]; eigR[3] = D[15]; - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); eigC[0] = D[0]; eigC[1] = D[5]; eigC[2] = D[10]; @@ -298,7 +298,7 @@ int NavierStokes2DUpwindLLF( fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3])); /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -314,53 +314,53 @@ int NavierStokes2DUpwindLLF( Note that this method cannot be used for flows with non-zero gravitational forces. */ int NavierStokes2DUpwindSWFS( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done,k; _DECLARE_IERR_; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double fp[_MODEL_NVARS_], fm[_MODEL_NVARS_],uavg[_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - double rho,vx,vy,e,P,c,gamma=param->gamma,term,Mach,lp[_MODEL_NVARS_],lm[_MODEL_NVARS_]; + double rho,vx,vy,e,P,c,gamma=param->m_gamma,term,Mach,lp[_MODEL_NVARS_],lm[_MODEL_NVARS_]; /* Steger Warming flux splitting */ - _NavierStokes2DRoeAverage_(uavg,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param->gamma); - _NavierStokes2DGetFlowVar_(uavg,rho,vx,vy,e,P,param->gamma); - Mach = (dir==_XDIR_ ? vx : vy) / sqrt(gamma*P/rho); + _NavierStokes2DRoeAverage_(uavg,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param->m_gamma); + _NavierStokes2DGetFlowVar_(uavg,rho,vx,vy,e,P,param->m_gamma); + Mach = (a_dir==_XDIR_ ? vx : vy) / sqrt(gamma*P/rho); if (Mach < -1.0) { - _ArrayCopy1D_((fR+_MODEL_NVARS_*p),(fI+_MODEL_NVARS_*p),_MODEL_NVARS_); + _ArrayCopy1D_((a_fR+_MODEL_NVARS_*p),(a_fI+_MODEL_NVARS_*p),_MODEL_NVARS_); } else if (Mach < 1.0) { double kx = 0, ky = 0; - kx = (dir==_XDIR_ ? 1.0 : 0.0); - ky = (dir==_YDIR_ ? 1.0 : 0.0); + kx = (a_dir==_XDIR_ ? 1.0 : 0.0); + ky = (a_dir==_YDIR_ ? 1.0 : 0.0); - _NavierStokes2DGetFlowVar_((uL+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma); + _NavierStokes2DGetFlowVar_((a_uL+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->m_gamma); c = sqrt(gamma*P/rho); term = rho/(2.0*gamma); lp[0] = lp[1] = kx*vx + ky*vy; @@ -375,7 +375,7 @@ int NavierStokes2DUpwindSWFS( + 0.5*lp[3]*((vx-c*kx)*(vx-c*kx) + (vy-c*ky)*(vy-c*ky)) + ((3.0-gamma)*(lp[2]+lp[3])*c*c)/(2.0*(gamma-1.0)) ); - _NavierStokes2DGetFlowVar_((uR+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->gamma); + _NavierStokes2DGetFlowVar_((a_uR+_MODEL_NVARS_*p),rho,vx,vy,e,P,param->m_gamma); c = sqrt(gamma*P/rho); term = rho/(2.0*gamma); lm[0] = lm[1] = kx*vx + ky*vy; @@ -390,11 +390,11 @@ int NavierStokes2DUpwindSWFS( + 0.5*lm[3]*((vx-c*kx)*(vx-c*kx) + (vy-c*ky)*(vy-c*ky)) + ((3.0-gamma)*(lm[2]+lm[3])*c*c)/(2.0*(gamma-1.0)) ); - _ArrayAdd1D_((fI+_MODEL_NVARS_*p),fp,fm,_MODEL_NVARS_); + _ArrayAdd1D_((a_fI+_MODEL_NVARS_*p),fp,fm,_MODEL_NVARS_); } else { - _ArrayCopy1D_((fL+_MODEL_NVARS_*p),(fI+_MODEL_NVARS_*p),_MODEL_NVARS_); + _ArrayCopy1D_((a_fL+_MODEL_NVARS_*p),(a_fI+_MODEL_NVARS_*p),_MODEL_NVARS_); } @@ -426,63 +426,63 @@ int NavierStokes2DUpwindSWFS( */ int NavierStokes2DUpwindRusanov( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local, done; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; + int *dim = solver->m_dim_local, done; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_]; - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); - _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); + _NavierStokes2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); double c, vel[_MODEL_NDIMS_], rho,E,P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaL = c + absolute(vel[dir]), betaL = absolute(vel[dir]); - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaR = c + absolute(vel[dir]), betaR = absolute(vel[dir]); - _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaavg = c + absolute(vel[dir]), betaavg = absolute(vel[dir]); - - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaL = c + absolute(vel[a_dir]), betaL = absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaR = c + absolute(vel[a_dir]), betaR = absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaavg = c + absolute(vel[a_dir]), betaavg = absolute(vel[a_dir]); + + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -497,26 +497,26 @@ int NavierStokes2DUpwindRusanov( */ int NavierStokes2DUpwindRusanovModified( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -524,53 +524,53 @@ int NavierStokes2DUpwindRusanovModified( done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); - _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); double c, vel[_MODEL_NDIMS_], rho,E,P; - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaL = c + absolute(vel[dir]), betaL = absolute(vel[dir]); - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaR = c + absolute(vel[dir]), betaR = absolute(vel[dir]); - _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaavg = c + absolute(vel[dir]), betaavg = absolute(vel[dir]); - - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaL = c + absolute(vel[a_dir]), betaL = absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaR = c + absolute(vel[a_dir]), betaR = absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaavg = c + absolute(vel[a_dir]), betaavg = absolute(vel[a_dir]); + + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); double beta = kappa*max3(betaL,betaR,betaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); D[0] = alpha; - D[5] = (dir == _XDIR_ ? alpha : beta); - D[10] = (dir == _YDIR_ ? alpha : beta); + D[5] = (a_dir == _XDIR_ ? alpha : beta); + D[10] = (a_dir == _YDIR_ ? alpha : beta); D[15] = beta; MatMult4(_MODEL_NVARS_,DL,D,L); MatMult4(_MODEL_NVARS_,modA,R,DL); MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0])-udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1])-udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2])-udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3])-udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -587,27 +587,27 @@ int NavierStokes2DUpwindRusanovModified( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwinddFRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -615,43 +615,43 @@ int NavierStokes2DUpwinddFRoe( done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); - _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); - /* Harten's Entropy Fix - Page 362 of Leveque */ + /* Harten'a_s Entropy Fix - Page 362 of Leveque */ int k; double delta = 0.000001, delta2 = delta*delta; - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); - k=5; D[k] = (dir == _YDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); - k=10; D[k] = (dir == _XDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); + k=5; D[k] = (a_dir == _YDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); + k=10; D[k] = (a_dir == _XDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); k=15; D[k] = 0.0; MatMult4(_MODEL_NVARS_,DL,D,L); MatMult4(_MODEL_NVARS_,modA,R,DL); MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -668,71 +668,71 @@ int NavierStokes2DUpwinddFRoe( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwinddFRF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done,k; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Roe-Fixed upwinding scheme */ - _NavierStokes2DRoeAverage_(uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); + _NavierStokes2DRoeAverage_(uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_(uavg,R,param->gamma,dir); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_(uavg,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->m_gamma,a_dir); eigL[0] = D[0]; - eigL[1] = (dir == _YDIR_ ? 0.0 : D[5]); - eigL[2] = (dir == _XDIR_ ? 0.0 : D[10]); + eigL[1] = (a_dir == _YDIR_ ? 0.0 : D[5]); + eigL[2] = (a_dir == _XDIR_ ? 0.0 : D[10]); eigL[3] = 0.0; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->m_gamma,a_dir); eigR[0] = D[0]; - eigR[1] = (dir == _YDIR_ ? 0.0 : D[5]); - eigR[2] = (dir == _XDIR_ ? 0.0 : D[10]); + eigR[1] = (a_dir == _YDIR_ ? 0.0 : D[5]); + eigR[2] = (a_dir == _XDIR_ ? 0.0 : D[10]); eigR[3] = 0.0; - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); eigC[0] = D[0]; - eigC[1] = (dir == _YDIR_ ? 0.0 : D[5]); - eigC[2] = (dir == _XDIR_ ? 0.0 : D[10]); + eigC[1] = (a_dir == _YDIR_ ? 0.0 : D[5]); + eigC[2] = (a_dir == _XDIR_ ? 0.0 : D[10]); eigC[3] = 0.0; for (k = 0; k < _MODEL_NVARS_; k++) { @@ -745,7 +745,7 @@ int NavierStokes2DUpwinddFRF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -762,71 +762,71 @@ int NavierStokes2DUpwinddFRF( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwinddFLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); /* Local Lax-Friedrich upwinding scheme */ - _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->m_gamma,a_dir); eigL[0] = D[0]; - eigL[1] = (dir == _YDIR_ ? 0.0 : D[5]); - eigL[2] = (dir == _XDIR_ ? 0.0 : D[10]); + eigL[1] = (a_dir == _YDIR_ ? 0.0 : D[5]); + eigL[2] = (a_dir == _XDIR_ ? 0.0 : D[10]); eigL[3] = 0.0; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->m_gamma,a_dir); eigR[0] = D[0]; - eigR[1] = (dir == _YDIR_ ? 0.0 : D[5]); - eigR[2] = (dir == _XDIR_ ? 0.0 : D[10]); + eigR[1] = (a_dir == _YDIR_ ? 0.0 : D[5]); + eigR[2] = (a_dir == _XDIR_ ? 0.0 : D[10]); eigR[3] = 0.0; - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); eigC[0] = D[0]; - eigC[1] = (dir == _YDIR_ ? 0.0 : D[5]); - eigC[2] = (dir == _XDIR_ ? 0.0 : D[10]); + eigC[1] = (a_dir == _YDIR_ ? 0.0 : D[5]); + eigC[2] = (a_dir == _XDIR_ ? 0.0 : D[10]); eigC[3] = 0.0; double alpha; @@ -840,7 +840,7 @@ int NavierStokes2DUpwinddFLLF( fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3])); /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -857,27 +857,27 @@ int NavierStokes2DUpwinddFLLF( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwinddFRusanovModified( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -885,53 +885,53 @@ int NavierStokes2DUpwinddFRusanovModified( done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_], udiss[_MODEL_NVARS_], uavg[_MODEL_NVARS_]; - /* Rusanov's upwinding scheme */ + /* Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); - _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); double c, vel[_MODEL_NDIMS_], rho,E,P; - _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaL = c + absolute(vel[dir]); - _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaR = c + absolute(vel[dir]); - _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaavg = c + absolute(vel[dir]); - - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaL = c + absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaR = c + absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaavg = c + absolute(vel[a_dir]); + + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); D[0] = alpha; - D[5] = (dir == _YDIR_ ? 0.0 : alpha); - D[10] = (dir == _XDIR_ ? 0.0 : alpha); + D[5] = (a_dir == _YDIR_ ? 0.0 : alpha); + D[10] = (a_dir == _XDIR_ ? 0.0 : alpha); D[15] = 0.0; MatMult4(_MODEL_NVARS_,DL,D,L); MatMult4(_MODEL_NVARS_,modA,R,DL); MatVecMult4(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -948,27 +948,27 @@ int NavierStokes2DUpwinddFRusanovModified( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwindFdFRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -976,30 +976,30 @@ int NavierStokes2DUpwindFdFRoe( done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); int k; double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_], udiss_total[_MODEL_NVARS_],udiss_stiff[_MODEL_NVARS_]; double delta = 0.000001, delta2 = delta*delta; - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); /* Compute total dissipation */ - _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=5; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=10; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); @@ -1009,13 +1009,13 @@ int NavierStokes2DUpwindFdFRoe( MatVecMult4(_MODEL_NVARS_,udiss_total,modA,udiff); /* Compute dissipation corresponding to acoustic modes */ - _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); k=0; D[k] = kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); - k=5; D[k] = (dir == _YDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); - k=10; D[k] = (dir == _XDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); + k=5; D[k] = (a_dir == _YDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); + k=10; D[k] = (a_dir == _XDIR_ ? 0.0 : kappa * (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ) ); k=15; D[k] = 0.0; MatMult4(_MODEL_NVARS_,DL,D,L); MatMult4(_MODEL_NVARS_,modA,R,DL); @@ -1024,10 +1024,10 @@ int NavierStokes2DUpwindFdFRoe( /* Compute the dissipation term for the entropy modes */ _ArraySubtract1D_(udiss,udiss_total,udiss_stiff,_MODEL_NVARS_); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -1044,71 +1044,71 @@ int NavierStokes2DUpwindFdFRoe( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwindFdFRF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done,k; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Roe-Fixed upwinding scheme */ - _NavierStokes2DRoeAverage_(uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); + _NavierStokes2DRoeAverage_(uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_(uavg,R,param->gamma,dir); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_(uavg,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->m_gamma,a_dir); eigL[0] = 0.0; - eigL[1] = (dir == _XDIR_ ? 0.0 : D[5]); - eigL[2] = (dir == _YDIR_ ? 0.0 : D[10]); + eigL[1] = (a_dir == _XDIR_ ? 0.0 : D[5]); + eigL[2] = (a_dir == _YDIR_ ? 0.0 : D[10]); eigL[3] = D[15]; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->m_gamma,a_dir); eigR[0] = 0.0; - eigR[1] = (dir == _XDIR_ ? 0.0 : D[5]); - eigR[2] = (dir == _YDIR_ ? 0.0 : D[10]); + eigR[1] = (a_dir == _XDIR_ ? 0.0 : D[5]); + eigR[2] = (a_dir == _YDIR_ ? 0.0 : D[10]); eigR[3] = D[15]; - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); eigC[0] = 0.0; - eigC[1] = (dir == _XDIR_ ? 0.0 : D[5]); - eigC[2] = (dir == _YDIR_ ? 0.0 : D[10]); + eigC[1] = (a_dir == _XDIR_ ? 0.0 : D[5]); + eigC[2] = (a_dir == _YDIR_ ? 0.0 : D[10]); eigC[3] = D[15]; for (k = 0; k < _MODEL_NVARS_; k++) { @@ -1121,7 +1121,7 @@ int NavierStokes2DUpwindFdFRF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -1138,71 +1138,71 @@ int NavierStokes2DUpwindFdFRF( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwindFdFLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); /* Local Lax-Friedrich upwinding scheme */ - _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DEigenvalues_ (uavg,D,param->gamma,dir); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); + _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DEigenvalues_ (uavg,D,param->m_gamma,a_dir); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult4(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult4(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult4(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[4],eigC[4],eigR[4]; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pL),D,param->m_gamma,a_dir); eigL[0] = 0.0; - eigL[1] = (dir == _XDIR_ ? 0.0 : D[5]); - eigL[2] = (dir == _YDIR_ ? 0.0 : D[10]); + eigL[1] = (a_dir == _XDIR_ ? 0.0 : D[5]); + eigL[2] = (a_dir == _YDIR_ ? 0.0 : D[10]); eigL[3] = D[15]; - _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->gamma,dir); + _NavierStokes2DEigenvalues_((uref+_MODEL_NVARS_*pR),D,param->m_gamma,a_dir); eigR[0] = 0.0; - eigR[1] = (dir == _XDIR_ ? 0.0 : D[5]); - eigR[2] = (dir == _YDIR_ ? 0.0 : D[10]); + eigR[1] = (a_dir == _XDIR_ ? 0.0 : D[5]); + eigR[2] = (a_dir == _YDIR_ ? 0.0 : D[10]); eigR[3] = D[15]; - _NavierStokes2DEigenvalues_(uavg,D,param->gamma,dir); + _NavierStokes2DEigenvalues_(uavg,D,param->m_gamma,a_dir); eigC[0] = 0.0; - eigC[1] = (dir == _XDIR_ ? 0.0 : D[5]); - eigC[2] = (dir == _YDIR_ ? 0.0 : D[10]); + eigC[1] = (a_dir == _XDIR_ ? 0.0 : D[5]); + eigC[2] = (a_dir == _YDIR_ ? 0.0 : D[10]); eigC[3] = D[15]; double alpha; @@ -1216,7 +1216,7 @@ int NavierStokes2DUpwindFdFLLF( fc[3] = 0.5 * (fcL[3] + fcR[3] + alpha * (ucL[3]-ucR[3])); /* calculate the interface flux from the characteristic flux */ - MatVecMult4(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult4(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -1233,27 +1233,27 @@ int NavierStokes2DUpwindFdFLLF( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes2DUpwindFdFRusanovModified( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x or y) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x or y) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes2D *param = (NavierStokes2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes2D *param = (NavierStokes2D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[2], bounds_inter[2]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -1261,72 +1261,72 @@ int NavierStokes2DUpwindFdFRusanovModified( done = 0; int index_outer[2] = {0,0}; int index_inter[2]; while (!done) { index_inter[0] = index_outer[0]; index_inter[1] = index_outer[1]; - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_], udiss[_MODEL_NVARS_], uavg[_MODEL_NVARS_], udiss_total[_MODEL_NVARS_],udiss_acoustic[_MODEL_NVARS_]; - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ double c, vel[_MODEL_NDIMS_], rho,E,P, alphaL, alphaR, alphaavg, betaL, betaR, betaavg, alpha, beta, - kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); /* Compute total dissipation */ - _NavierStokes2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaL = c + absolute(vel[dir]); - betaL = absolute(vel[dir]); - _NavierStokes2DGetFlowVar_((u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaR = c + absolute(vel[dir]); - betaR = absolute(vel[dir]); - _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaavg = c + absolute(vel[dir]); - betaavg = absolute(vel[dir]); + _NavierStokes2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaL = c + absolute(vel[a_dir]); + betaL = absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_((a_u+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaR = c + absolute(vel[a_dir]); + betaR = absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaavg = c + absolute(vel[a_dir]); + betaavg = absolute(vel[a_dir]); alpha = kappa*max3(alphaL,alphaR,alphaavg); beta = kappa*max3(betaL,betaR,betaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); D[0] = alpha; - D[5] = (dir == _XDIR_ ? alpha : beta); - D[10] = (dir == _YDIR_ ? alpha : beta); + D[5] = (a_dir == _XDIR_ ? alpha : beta); + D[10] = (a_dir == _YDIR_ ? alpha : beta); D[15] = beta; MatMult4(_MODEL_NVARS_,DL,D,L); MatMult4(_MODEL_NVARS_,modA,R,DL); MatVecMult4(_MODEL_NVARS_,udiss_total,modA,udiff); /* Compute dissipation for the linearized acoustic modes */ - _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes2DLeftEigenvectors_ (uavg,L,param->gamma,dir); - _NavierStokes2DRightEigenvectors_ (uavg,R,param->gamma,dir); - _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaL = c + absolute(vel[dir]); - _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaR = c + absolute(vel[dir]); - _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaavg = c + absolute(vel[dir]); - kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + _NavierStokes2DRoeAverage_ (uavg,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes2DLeftEigenvectors_ (uavg,L,param->m_gamma,a_dir); + _NavierStokes2DRightEigenvectors_ (uavg,R,param->m_gamma,a_dir); + _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pL),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaL = c + absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_((uref+_MODEL_NVARS_*pR),rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaR = c + absolute(vel[a_dir]); + _NavierStokes2DGetFlowVar_(uavg,rho,vel[0],vel[1],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaavg = c + absolute(vel[a_dir]); + kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); alpha = kappa*max3(alphaL,alphaR,alphaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); D[0] = alpha; - D[5] = (dir == _YDIR_ ? 0.0 : alpha); - D[10] = (dir == _XDIR_ ? 0.0 : alpha); + D[5] = (a_dir == _YDIR_ ? 0.0 : alpha); + D[10] = (a_dir == _XDIR_ ? 0.0 : alpha); D[15] = 0.0; MatMult4(_MODEL_NVARS_,DL,D,L); MatMult4(_MODEL_NVARS_,modA,R,DL); @@ -1335,10 +1335,10 @@ int NavierStokes2DUpwindFdFRusanovModified( /* Compute dissipation for the entropy modes */ _ArraySubtract1D_(udiss,udiss_total,udiss_acoustic,_MODEL_NVARS_); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind_GPU.cu b/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind_GPU.cu index b74aab93..66ce0b3d 100644 --- a/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind_GPU.cu +++ b/src/PhysicalModels/NavierStokes2D/NavierStokes2DUpwind_GPU.cu @@ -104,7 +104,7 @@ extern "C" int gpuNavierStokes2DUpwindRusanov( { HyPar *solver = (HyPar *) s; NavierStokes2D *param = (NavierStokes2D*) solver->physics; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[2]; bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[dir] = 1; @@ -118,7 +118,7 @@ extern "C" int gpuNavierStokes2DUpwindRusanov( cpu_start = clock(); NavierStokes2DUpwindRusanov_kernel<<>>( - ngrid_points, dir, solver->ghosts, param->gamma, solver->dim_local, + ngrid_points, dir, solver->m_ghosts, param->gamma, solver->m_dim_local, param->gpu_grav_field_g, fL, fR, uL, uR, u, fI); cudaDeviceSynchronize(); cpu_end = clock(); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup.c index f6daeae7..3760c2c3 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup.c @@ -8,13 +8,13 @@ /*! Function to clean up all allocations in the 3D Navier Stokes module. */ -int NavierStokes3DCleanup(void *s /*!< Object of type #NavierStokes3D*/) +int NavierStokes3DCleanup(void *a_s /*!< Object of type #NavierStokes3D*/) { - NavierStokes3D *param = (NavierStokes3D*) s; + NavierStokes3D *param = (NavierStokes3D*) a_s; - free(param->grav_field_f); - free(param->grav_field_g); - free(param->fast_jac); + free(param->m_grav_field_f); + free(param->m_grav_field_g); + free(param->m_fast_jac); free(param->solution); return(0); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup_GPU.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup_GPU.c index 8c7199fc..386f8d2c 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup_GPU.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DCleanup_GPU.c @@ -10,9 +10,9 @@ /*! Function to clean up all allocations in the 3D Navier Stokes module. */ -int gpuNavierStokes3DCleanup(void *s /*!< Object of type #NavierStokes3D*/) +int gpuNavierStokes3DCleanup(void *a_s /*!< Object of type #NavierStokes3D*/) { - NavierStokes3D *param = (NavierStokes3D*) s; + NavierStokes3D *param = (NavierStokes3D*) a_s; gpuFree(param->gpu_Q); gpuFree(param->gpu_QDerivX); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DComputeCFL.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DComputeCFL.c index 99289702..1bcdb856 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DComputeCFL.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DComputeCFL.c @@ -14,36 +14,36 @@ is computed over the local domain on this processor only. */ double NavierStokes3DComputeCFL( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; - double *u = solver->u; + double *u = solver->m_u; double max_cfl = 0; int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double rho, vx, vy, vz, e, P, c, dxinv, dyinv, dzinv, local_cfl[3]; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,param->gamma); + _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,param->m_gamma); - c = sqrt(param->gamma*P/rho); /* speed of sound */ - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */ - _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->dxinv,dzinv); /* 1/dz */ + c = sqrt(param->m_gamma*P/rho); /* speed of sound */ + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); /* 1/dy */ + _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->m_dxinv,dzinv); /* 1/dz */ - local_cfl[_XDIR_] = (absolute(vx)+c)*dt*dxinv; /* local cfl for this grid point (x) */ - local_cfl[_YDIR_] = (absolute(vy)+c)*dt*dyinv; /* local cfl for this grid point (y) */ - local_cfl[_ZDIR_] = (absolute(vz)+c)*dt*dzinv; /* local cfl for this grid point (z) */ + local_cfl[_XDIR_] = (absolute(vx)+c)*a_dt*dxinv; /* local cfl for this grid point (x) */ + local_cfl[_YDIR_] = (absolute(vy)+c)*a_dt*dyinv; /* local cfl for this grid point (y) */ + local_cfl[_ZDIR_] = (absolute(vz)+c)*a_dt*dzinv; /* local cfl for this grid point (z) */ if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_]; if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_]; if (local_cfl[_ZDIR_] > max_cfl) max_cfl = local_cfl[_ZDIR_]; diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DEigen.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DEigen.c index 6e35e0ab..5ddfc066 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DEigen.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DEigen.c @@ -18,15 +18,15 @@ to interpolation functions for a characteristic-based reconstruction. */ int NavierStokes3DLeftEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *L, /*!< Array of size nvar^2 = 5^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_L, /*!< Array of size nvar^2 = 5^2 to save the matrix of left eigenvectors in (row-major format). */ - void *p, /*!< Object of type #NavierStokes3D with physics-related variables */ - int dir /*!< Spatial dimension (x, y, or z) */ + void *a_p, /*!< Object of type #NavierStokes3D with physics-related variables */ + int a_dir /*!< Spatial dimension (x, y, or z) */ ) { - NavierStokes3D *param = (NavierStokes3D*) p; - _NavierStokes3DLeftEigenvectors_(u,_NavierStokes3D_stride_,L,param->gamma,dir); + NavierStokes3D *param = (NavierStokes3D*) a_p; + _NavierStokes3DLeftEigenvectors_(a_u,_NavierStokes3D_stride_,a_L,param->m_gamma,a_dir); return(0); } @@ -37,14 +37,14 @@ int NavierStokes3DLeftEigenvectors( to interpolation functions for a characteristic-based reconstruction. */ int NavierStokes3DRightEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *R, /*!< Array of size nvar^2 = 5^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_R, /*!< Array of size nvar^2 = 5^2 to save the matrix of right eigenvectors in (row-major format). */ - void *p, /*!< Object of type #NavierStokes3D with physics-related variables */ - int dir /*!< Spatial dimension (x, y, or z) */ + void *a_p, /*!< Object of type #NavierStokes3D with physics-related variables */ + int a_dir /*!< Spatial dimension (x, y, or z) */ ) { - NavierStokes3D *param = (NavierStokes3D*) p; - _NavierStokes3DRightEigenvectors_(u,_NavierStokes3D_stride_,R,param->gamma,dir); + NavierStokes3D *param = (NavierStokes3D*) a_p; + _NavierStokes3DRightEigenvectors_(a_u,_NavierStokes3D_stride_,a_R,param->m_gamma,a_dir); return(0); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux.c index 4f5ebad7..36faf3a2 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux.c @@ -21,20 +21,20 @@ Note: the flux function needs to be computed at the ghost points as well. */ int NavierStokes3DFlux( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir,/*!< Spatial dimension (x, y, or z) for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir,/*!< Spatial dimension (x, y, or z) for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -48,8 +48,8 @@ int NavierStokes3DFlux( while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double rho, vx, vy, vz, e, P; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,param->gamma); - _NavierStokes3DSetFlux_((f+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,dir); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,param->m_gamma); + _NavierStokes3DSetFlux_((a_f+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,a_dir); _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -68,17 +68,17 @@ int NavierStokes3DFlux( Note: the flux function needs to be computed at the ghost points as well. */ int NavierStokes3DStiffFlux( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir,/*!< Spatial dimension (x,y, or z) for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir,/*!< Spatial dimension (x,y, or z) for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -90,8 +90,8 @@ int NavierStokes3DStiffFlux( int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double *Af = param->fast_jac+(_MODEL_NDIMS_*p+dir)*JacSize; - MatVecMult5(_MODEL_NVARS_,(f+_MODEL_NVARS_*p),Af,(u+_MODEL_NVARS_*p)); + double *Af = param->m_fast_jac+(_MODEL_NDIMS_*p+a_dir)*JacSize; + MatVecMult5(_MODEL_NVARS_,(a_f+_MODEL_NVARS_*p),Af,(a_u+_MODEL_NVARS_*p)); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } @@ -109,17 +109,17 @@ int NavierStokes3DStiffFlux( Note: the flux function needs to be computed at the ghost points as well. */ int NavierStokes3DNonStiffFlux( - double *f, /*!< Array to hold the computed flux vector (same layout as u) */ - double *u, /*!< Array with the solution vector */ - int dir,/*!< Spatial dimension (x,y, or z) for which to compute the flux */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_f, /*!< Array to hold the computed flux vector (same layout as a_u) */ + double *a_u, /*!< Array with the solution vector */ + int a_dir,/*!< Spatial dimension (x,y, or z) for which to compute the flux */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int JacSize = _MODEL_NVARS_*_MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; static double ftot[_MODEL_NVARS_], fstiff[_MODEL_NVARS_]; @@ -134,13 +134,13 @@ int NavierStokes3DNonStiffFlux( int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); /* compute total flux */ double rho, vx, vy, vz, e, P; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,param->gamma); - _NavierStokes3DSetFlux_(ftot,_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,dir); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,param->m_gamma); + _NavierStokes3DSetFlux_(ftot,_NavierStokes3D_stride_,rho,vx,vy,vz,e,P,a_dir); /* compute stiff stuff */ - double *Af = param->fast_jac+(_MODEL_NDIMS_*p+dir)*JacSize; - MatVecMult5(_MODEL_NVARS_,fstiff,Af,(u+_MODEL_NVARS_*p)); + double *Af = param->m_fast_jac+(_MODEL_NDIMS_*p+a_dir)*JacSize; + MatVecMult5(_MODEL_NVARS_,fstiff,Af,(a_u+_MODEL_NVARS_*p)); /* subtract stiff flux from total flux */ - _ArraySubtract1D_((f+_MODEL_NVARS_*p),ftot,fstiff,_MODEL_NVARS_); + _ArraySubtract1D_((a_f+_MODEL_NVARS_*p),ftot,fstiff,_MODEL_NVARS_); /* Done */ _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux_GPU.cu b/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux_GPU.cu index a75df5f9..fbf77d96 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux_GPU.cu +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DFlux_GPU.cu @@ -52,10 +52,10 @@ extern "C" int gpuNavierStokes3DFlux( HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DFlux_kernel<<>>( - solver->npoints_local_wghosts, dir, param->gamma, u, f + solver->m_npoints_local_wghosts, dir, param->gamma, u, f ); cudaDeviceSynchronize(); @@ -104,10 +104,10 @@ extern "C" int gpuNavierStokes3DFlux( HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DFlux_kernel<<>>( - solver->npoints_local_wghosts, dir, param->gamma, u, f + solver->m_npoints_local_wghosts, dir, param->gamma, u, f ); cudaDeviceSynchronize(); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DFunctions.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DFunctions.c index 7286dc89..b2db0e8f 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DFunctions.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DFunctions.c @@ -16,30 +16,30 @@ to interpolation functions for a characteristic-based reconstruction. */ int NavierStokes3DRoeAverage( - double *uavg, /*!< The computed Roe-averaged state */ - double *uL, /*!< Left state (conserved variables)*/ - double *uR, /*!< Right state (conserved variables)*/ - void *p /*!< Object of type #NavierStokes3D with physics-related variables */ + double *a_uavg, /*!< The computed Roe-averaged state */ + double *a_uL, /*!< Left state (conserved variables)*/ + double *a_uR, /*!< Right state (conserved variables)*/ + void *a_p /*!< Object of type #NavierStokes3D with physics-related variables */ ) { - NavierStokes3D *param = (NavierStokes3D*) p; - _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,uL,uR,param->gamma); + NavierStokes3D *param = (NavierStokes3D*) a_p; + _NavierStokes3DRoeAverage_(a_uavg,_NavierStokes3D_stride_,a_uL,a_uR,param->m_gamma); return(0); } /*! Compute the pressure from the conserved solution on a grid */ -int NavierStokes3DComputePressure( double* P, /*!< Array to hold the computed pressure (same layout as u) */ - const double* const u, /*!< Array with the solution vector */ - void* s /*!< Solver object of type #HyPar */ +int NavierStokes3DComputePressure( double* a_P, /*!< Array to hold the computed pressure (same layout as a_u) */ + const double* const a_u, /*!< Array with the solution vector */ + void* a_s /*!< Solver object of type #HyPar */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -53,8 +53,8 @@ int NavierStokes3DComputePressure( double* P, /*!< Array to hold th while (!done) { int idx; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,idx); double rho, vx, vy, vz, e, pressure; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*idx),_NavierStokes3D_stride_,rho,vx,vy,vz,e,pressure,param->gamma); - P[idx] = pressure; + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*idx),_NavierStokes3D_stride_,rho,vx,vy,vz,e,pressure,param->m_gamma); + a_P[idx] = pressure; _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -62,18 +62,18 @@ int NavierStokes3DComputePressure( double* P, /*!< Array to hold th } /*! Compute the temperature from the conserved solution on a grid */ -int NavierStokes3DComputeTemperature( double* T, /*!< Array to hold the computed pressure (same layout as u) */ - const double* const u, /*!< Array with the solution vector */ - void* s /*!< Solver object of type #HyPar */ +int NavierStokes3DComputeTemperature( double* a_T, /*!< Array to hold the computed pressure (same layout as a_u) */ + const double* const a_u, /*!< Array with the solution vector */ + void* a_s /*!< Solver object of type #HyPar */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -87,8 +87,8 @@ int NavierStokes3DComputeTemperature( double* T, /*!< Array to hold while (!done) { int idx; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,idx); double rho, vx, vy, vz, e, pressure; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*idx),_NavierStokes3D_stride_,rho,vx,vy,vz,e,pressure,param->gamma); - T[idx] = pressure/rho; + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*idx),_NavierStokes3D_stride_,rho,vx,vy,vz,e,pressure,param->m_gamma); + a_T[idx] = pressure/rho; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DGravityField.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DGravityField.c index 47f34ed6..198b3631 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DGravityField.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DGravityField.c @@ -31,18 +31,18 @@ for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580 */ int NavierStokes3DGravityField( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; - double *f = param->grav_field_f; - double *g = param->grav_field_g; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + double *f = param->m_grav_field_f; + double *g = param->m_grav_field_g; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_], d, done; @@ -52,16 +52,16 @@ int NavierStokes3DGravityField( /* set offset such that index is compatible with ghost point arrangement */ _ArraySetValue_(offset,_MODEL_NDIMS_,-ghosts); - double p0 = param->p0; - double rho0 = param->rho0; + double p0 = param->m_p0; + double rho0 = param->m_rho0; double RT = p0 / rho0; - double gamma= param->gamma; - double R = param->R; + double gamma= param->m_gamma; + double R = param->m_R; double Cp = gamma*R / (gamma-1.0); double T0 = p0 / (rho0 * R); - double gx = param->grav_x; - double gy = param->grav_y; - double gz = param->grav_z; + double gx = param->m_grav_x; + double gy = param->m_grav_y; + double gz = param->m_grav_z; double Nbv = param->N_bv; /* set the value of the gravity field */ @@ -69,9 +69,9 @@ int NavierStokes3DGravityField( if (param->HB == 1) { while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord); - double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); - double zcoord; _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord); + double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->m_x,xcoord); + double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); + double zcoord; _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->m_x,zcoord); f[p] = exp( (gx*xcoord+gy*ycoord+gz*zcoord)/RT); g[p] = exp(-(gx*xcoord+gy*ycoord+gz*zcoord)/RT); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); @@ -79,9 +79,9 @@ int NavierStokes3DGravityField( } else if (param->HB == 2) { while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->x,xcoord); - double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); - double zcoord; _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord); + double xcoord; _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->m_x,xcoord); + double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); + double zcoord; _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->m_x,zcoord); f[p] = raiseto((1.0-(gx*xcoord+gy*ycoord+gz*zcoord)/(Cp*T0)), (-1.0 /(gamma-1.0))); g[p] = raiseto((1.0-(gx*xcoord+gy*ycoord+gz*zcoord)/(Cp*T0)), (gamma/(gamma-1.0))); _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); @@ -89,9 +89,9 @@ int NavierStokes3DGravityField( } else if (param->HB == 3) { while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - double zcoord; _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord); + double zcoord; _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->m_x,zcoord); if ((gx != 0) || (gy != 0)) { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DGravityField(): HB = 3 is implemented only for "); fprintf(stderr,"gravity force along the z-coordinate.\n"); } @@ -120,7 +120,7 @@ int NavierStokes3DGravityField( int indexb[_MODEL_NDIMS_], indexi[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { /* left boundary */ - if (!mpi->ip[d]) { + if (!mpi->m_ip[d]) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = -ghosts; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -134,7 +134,7 @@ int NavierStokes3DGravityField( } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = dim[d]; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DIBForces.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DIBForces.c index 0d1445fe..6c7b15b8 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DIBForces.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DIBForces.c @@ -34,98 +34,98 @@ int NavierStokes3DComputeTemperature(double*, const double* const, void*); The shear force array will be of the size (4 X #ImmersedBoundary::nfacets_local), where the ordering of the data is: x-component, y-component, z-component, magnitude. */ -static int ComputeShear(void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - const double* const u,/*!< Array containing the conserved flow variables */ - double** const sf /*!< Array for (x,y,z)-components & magnitude of shear */ +static int ComputeShear(void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + const double* const a_u,/*!< Array containing the conserved flow variables */ + double** const a_sf /*!< Array for (x,y,z)-components & magnitude of shear */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes3D *physics = (NavierStokes3D*) solver->physics; - ImmersedBoundary *IB = (ImmersedBoundary*) solver->ib; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes3D *physics = (NavierStokes3D*) solver->m_physics; + ImmersedBoundary *IB = (ImmersedBoundary*) solver->m_ib; - if ((*sf) != NULL) { + if ((*a_sf) != NULL) { fprintf(stderr, "Error in ComputeShear()\n"); fprintf(stderr, " shear force array is not NULL!\n"); return 1; } - if (!solver->flag_ib) return(0); + if (!solver->m_flag_ib) return(0); - int nfacets_local = IB->nfacets_local; - FacetMap *fmap = IB->fmap; + int nfacets_local = IB->m_nfacets_local; + FacetMap *fmap = IB->m_fmap; static double v[_MODEL_NVARS_]; int nv = 4; if (nfacets_local > 0) { - (*sf) = (double*) calloc (nv*nfacets_local, sizeof(double)); + (*a_sf) = (double*) calloc (nv*nfacets_local, sizeof(double)); - if (physics->Re > 0) { + if (physics->m_Re > 0) { for (int n = 0; n < nfacets_local; n++) { double *alpha; int *nodes, j, k; - alpha = &(fmap[n].interp_coeffs[0]); - nodes = &(fmap[n].interp_nodes[0]); + alpha = &(fmap[n].m_interp_coeffs[0]); + nodes = &(fmap[n].m_interp_nodes[0]); _ArraySetValue_(v,_MODEL_NVARS_,0.0); for (j=0; j<_IB_NNODES_; j++) { for (k=0; k<_MODEL_NVARS_; k++) { - v[k] += ( alpha[j] * u[_MODEL_NVARS_*nodes[j]+k] ); + v[k] += ( alpha[j] * a_u[_MODEL_NVARS_*nodes[j]+k] ); } } double rho_c, uvel_c, vvel_c, wvel_c, energy_c, pressure_c; - _NavierStokes3DGetFlowVar_(v,_NavierStokes3D_stride_,rho_c,uvel_c,vvel_c,wvel_c,energy_c,pressure_c,physics->gamma); + _NavierStokes3DGetFlowVar_(v,_NavierStokes3D_stride_,rho_c,uvel_c,vvel_c,wvel_c,energy_c,pressure_c,physics->m_gamma); - alpha = &(fmap[n].interp_coeffs_ns[0]); - nodes = &(fmap[n].interp_nodes_ns[0]); + alpha = &(fmap[n].m_interp_coeffs_ns[0]); + nodes = &(fmap[n].m_interp_nodes_ns[0]); _ArraySetValue_(v,_MODEL_NVARS_,0.0); for (j=0; j<_IB_NNODES_; j++) { for (k=0; k<_MODEL_NVARS_; k++) { - v[k] += ( alpha[j] * u[_MODEL_NVARS_*nodes[j]+k] ); + v[k] += ( alpha[j] * a_u[_MODEL_NVARS_*nodes[j]+k] ); } } double rho_ns, uvel_ns, vvel_ns, wvel_ns, energy_ns, pressure_ns; - _NavierStokes3DGetFlowVar_(v,_NavierStokes3D_stride_,rho_ns,uvel_ns,vvel_ns,wvel_ns,energy_ns,pressure_ns,physics->gamma); + _NavierStokes3DGetFlowVar_(v,_NavierStokes3D_stride_,rho_ns,uvel_ns,vvel_ns,wvel_ns,energy_ns,pressure_ns,physics->m_gamma); - double u_x = (uvel_ns - uvel_c) / fmap[n].dx; - double v_x = (vvel_ns - vvel_c) / fmap[n].dx; - double w_x = (wvel_ns - wvel_c) / fmap[n].dx; + double u_x = (uvel_ns - uvel_c) / fmap[n].m_dx; + double v_x = (vvel_ns - vvel_c) / fmap[n].m_dx; + double w_x = (wvel_ns - wvel_c) / fmap[n].m_dx; - double u_y = (uvel_ns - uvel_c) / fmap[n].dy; - double v_y = (vvel_ns - vvel_c) / fmap[n].dy; - double w_y = (wvel_ns - wvel_c) / fmap[n].dy; + double u_y = (uvel_ns - uvel_c) / fmap[n].m_dy; + double v_y = (vvel_ns - vvel_c) / fmap[n].m_dy; + double w_y = (wvel_ns - wvel_c) / fmap[n].m_dy; - double u_z = (uvel_ns - uvel_c) / fmap[n].dz; - double v_z = (vvel_ns - vvel_c) / fmap[n].dz; - double w_z = (wvel_ns - wvel_c) / fmap[n].dz; + double u_z = (uvel_ns - uvel_c) / fmap[n].m_dz; + double v_z = (vvel_ns - vvel_c) / fmap[n].m_dz; + double w_z = (wvel_ns - wvel_c) / fmap[n].m_dz; - double nx = fmap[n].facet->nx; - double ny = fmap[n].facet->ny; - double nz = fmap[n].facet->nz; + double nx = fmap[n].m_facet->m_nx; + double ny = fmap[n].m_facet->m_ny; + double nz = fmap[n].m_facet->m_nz; - double T = physics->gamma*pressure_c/rho_c; + double T = physics->m_gamma*pressure_c/rho_c; double mu = raiseto(T, 0.76); - double inv_Re = 1.0/physics->Re; + double inv_Re = 1.0/physics->m_Re; double tau_x = (mu*inv_Re) * (2*u_x*nx + (u_y+v_x)*ny + (u_z+w_x)*nz); double tau_y = (mu*inv_Re) * ((v_x+u_y)*nx + 2*v_y*ny + (v_z+w_y)*nz); double tau_z = (mu*inv_Re) * ((w_x+u_z)*nx + (w_y+v_z)*ny + 2*w_z*nz); - (*sf)[n*nv+_XDIR_] = tau_x; - (*sf)[n*nv+_YDIR_] = tau_y; - (*sf)[n*nv+_ZDIR_] = tau_z; + (*a_sf)[n*nv+_XDIR_] = tau_x; + (*a_sf)[n*nv+_YDIR_] = tau_y; + (*a_sf)[n*nv+_ZDIR_] = tau_z; - (*sf)[n*nv+_ZDIR_+1] = sqrt(tau_x*tau_x + tau_y*tau_y + tau_z*tau_z); + (*a_sf)[n*nv+_ZDIR_+1] = sqrt(tau_x*tau_x + tau_y*tau_y + tau_z*tau_z); } } else { - _ArraySetValue_((*sf), nv*nfacets_local, 0.0); + _ArraySetValue_((*a_sf), nv*nfacets_local, 0.0); } @@ -135,18 +135,18 @@ static int ComputeShear(void *s, /*!< Solver object of type #HyPar } /*! Write the surface data on the immersed body to a ASCII Tecplot file. */ -static int WriteSurfaceData( void* m, /*!< MPI object of type #MPIVariables */ - void* ib, /*!< Immersed body object of type #ImmersedBoundary */ - const double* const p_surface, /*!< array with local surface pressure data */ - const double* const T_surface, /*!< array with local surface temperature data */ - const double* const ngrad_p_surface,/*!< array with local normal gradient of surface pressure data */ - const double* const ngrad_T_surface,/*!< array with local normal gradient of surface temperature data */ - const double* const shear, /*!< array with local shear data */ - char* filename /*!< Name of file to write */ +static int WriteSurfaceData( void* a_m, /*!< MPI object of type #MPIVariables */ + void* a_ib, /*!< Immersed body object of type #ImmersedBoundary */ + const double* const a_p_surface, /*!< array with local surface pressure data */ + const double* const a_T_surface, /*!< array with local surface temperature data */ + const double* const a_ngrad_p_surface,/*!< array with local normal gradient of surface pressure data */ + const double* const a_ngrad_T_surface,/*!< array with local normal gradient of surface temperature data */ + const double* const a_shear, /*!< array with local shear data */ + char* a_filename /*!< Name of file to write */ ) { - MPIVariables *mpi = (MPIVariables*) m; - ImmersedBoundary *IB = (ImmersedBoundary*) ib; + MPIVariables *mpi = (MPIVariables*) a_m; + ImmersedBoundary *IB = (ImmersedBoundary*) a_ib; int ierr; #ifndef serial @@ -155,44 +155,44 @@ static int WriteSurfaceData( void* m, /*!< MPI objec /* collect the surface data into global arrays */ double* p_surface_g = NULL; - ierr = IBAssembleGlobalFacetData(mpi, IB, p_surface, &p_surface_g, 1); + ierr = IBAssembleGlobalFacetData(mpi, IB, a_p_surface, &p_surface_g, 1); if (ierr) { fprintf(stderr,"IBAssembleGlobalFacetData() returned with an error.\n"); return 1; } double* T_surface_g = NULL; - ierr = IBAssembleGlobalFacetData(mpi, IB, T_surface, &T_surface_g, 1); + ierr = IBAssembleGlobalFacetData(mpi, IB, a_T_surface, &T_surface_g, 1); if (ierr) { fprintf(stderr,"IBAssembleGlobalFacetData() returned with an error.\n"); return 1; } double* ngrad_p_surface_g = NULL; - ierr = IBAssembleGlobalFacetData(mpi, IB, ngrad_p_surface, &ngrad_p_surface_g, 1); + ierr = IBAssembleGlobalFacetData(mpi, IB, a_ngrad_p_surface, &ngrad_p_surface_g, 1); if (ierr) { fprintf(stderr,"IBAssembleGlobalFacetData() returned with an error.\n"); return 1; } double* ngrad_T_surface_g = NULL; - ierr = IBAssembleGlobalFacetData(mpi, IB, ngrad_T_surface, &ngrad_T_surface_g, 1); + ierr = IBAssembleGlobalFacetData(mpi, IB, a_ngrad_T_surface, &ngrad_T_surface_g, 1); if (ierr) { fprintf(stderr,"IBAssembleGlobalFacetData() returned with an error.\n"); return 1; } double* shear_g = NULL; - ierr = IBAssembleGlobalFacetData(mpi, IB, shear, &shear_g, 4); + ierr = IBAssembleGlobalFacetData(mpi, IB, a_shear, &shear_g, 4); if (ierr) { fprintf(stderr,"IBAssembleGlobalFacetData() returned with an error.\n"); return 1; } /* Rank 0 writes the file */ - if (!mpi->rank) { + if (!mpi->m_rank) { - int nfacets_global = IB->body->nfacets; - const Facet3D* const facets = IB->body->surface; + int nfacets_global = IB->m_body->m_nfacets; + const Facet3D* const facets = IB->m_body->m_surface; FILE *out; - out = fopen(filename,"w"); + out = fopen(a_filename,"w"); fprintf(out,"TITLE = \"Surface data created by HyPar.\"\n"); fprintf(out,"VARIABLES = \"X\", \"Y\", \"Z\", "); fprintf(out,"\"Surface_Pressure\", "); @@ -208,9 +208,9 @@ static int WriteSurfaceData( void* m, /*!< MPI objec for (int n = 0; n < nfacets_global; n++) { fprintf( out, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n", - facets[n].x1, - facets[n].y1, - facets[n].z1, + facets[n].m_x1, + facets[n].m_y1, + facets[n].m_z1, p_surface_g[n], T_surface_g[n], ngrad_p_surface_g[n], @@ -220,9 +220,9 @@ static int WriteSurfaceData( void* m, /*!< MPI objec shear_g[4*n+_ZDIR_], shear_g[4*n+_ZDIR_+1] ); fprintf( out, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n", - facets[n].x2, - facets[n].y2, - facets[n].z2, + facets[n].m_x2, + facets[n].m_y2, + facets[n].m_z2, p_surface_g[n], T_surface_g[n], ngrad_p_surface_g[n], @@ -232,9 +232,9 @@ static int WriteSurfaceData( void* m, /*!< MPI objec shear_g[4*n+_ZDIR_], shear_g[4*n+_ZDIR_+1] ); fprintf( out, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\n", - facets[n].x3, - facets[n].y3, - facets[n].z3, + facets[n].m_x3, + facets[n].m_y3, + facets[n].m_z3, p_surface_g[n], T_surface_g[n], ngrad_p_surface_g[n], @@ -261,29 +261,29 @@ static int WriteSurfaceData( void* m, /*!< MPI objec /*! Calculate the aerodynamic forces on the immersed body surface and write them to file */ -int NavierStokes3DIBForces( void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int NavierStokes3DIBForces( void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes3D *physics = (NavierStokes3D*) solver->physics; - ImmersedBoundary *IB = (ImmersedBoundary*) solver->ib; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes3D *physics = (NavierStokes3D*) solver->m_physics; + ImmersedBoundary *IB = (ImmersedBoundary*) solver->m_ib; int ierr; - if (!solver->flag_ib) return(0); + if (!solver->m_flag_ib) return(0); - int npts = solver->npoints_local_wghosts; + int npts = solver->m_npoints_local_wghosts; double* pressure = (double*) calloc (npts, sizeof(double)); - ierr = NavierStokes3DComputePressure(pressure, solver->u, solver); + ierr = NavierStokes3DComputePressure(pressure, solver->m_u, solver); if (ierr) { fprintf(stderr,"Error in NavierStokes3DIBForces()\n"); fprintf(stderr," NavierStokes3DComputePressure() returned with error.\n"); return 1; } double* temperature = (double*) calloc(npts, sizeof(double)); - ierr = NavierStokes3DComputeTemperature(temperature, solver->u, solver); + ierr = NavierStokes3DComputeTemperature(temperature, solver->m_u, solver); if (ierr) { fprintf(stderr,"Error in NavierStokes3DIBForces()\n"); fprintf(stderr," NavierStokes3DComputeTemperature() returned with error.\n"); @@ -324,7 +324,7 @@ int NavierStokes3DIBForces( void* s, /*!< Solver object of type #HyPar */ } /* Compute shear forces */ double *shear = NULL; - ierr = ComputeShear(solver, mpi, solver->u, &shear); + ierr = ComputeShear(solver, mpi, solver->m_u, &shear); if (ierr) { fprintf(stderr,"Error in NavierStokes3DIBForces()\n"); fprintf(stderr," ComputeShear() returned with error.\n"); @@ -332,19 +332,19 @@ int NavierStokes3DIBForces( void* s, /*!< Solver object of type #HyPar */ } char surface_filename[_MAX_STRING_SIZE_] = "surface"; - if (solver->nsims == 1) { - if (!strcmp(solver->op_overwrite,"no")) { - strcat(surface_filename,solver->filename_index); + if (solver->m_nsims == 1) { + if (!strcmp(solver->m_op_overwrite,"no")) { + strcat(surface_filename,solver->m_filename_index); } } else { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); strcat(surface_filename, "_"); strcat(surface_filename, index); strcat(surface_filename, "_"); } strcat(surface_filename,".dat"); - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Writing immersed body surface data file %s.\n",surface_filename); } ierr = WriteSurfaceData( mpi, diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DImmersedBoundary.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DImmersedBoundary.c index 302f13e3..3ad55edf 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DImmersedBoundary.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DImmersedBoundary.c @@ -16,67 +16,67 @@ points (grid points within the immersed body that are within stencil-width distance of interior points, i.e., points in the interior of the computational domain). */ -int NavierStokes3DIBAdiabatic(void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< Solver object of type #HyPar */ - double *u, /*!< Array with the solution vector */ - double t /*!< Current simulation time */ +int NavierStokes3DIBAdiabatic(void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< Solver object of type #HyPar */ + double *a_u, /*!< Array with the solution vector */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ImmersedBoundary *IB = (ImmersedBoundary*) solver->ib; - IBNode *boundary = IB->boundary; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ImmersedBoundary *IB = (ImmersedBoundary*) solver->m_ib; + IBNode *boundary = IB->m_boundary; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; static double v[_MODEL_NVARS_]; - int n, j, k, nb = IB->n_boundary_nodes; + int n, j, k, nb = IB->m_n_boundary_nodes; - if (!solver->flag_ib) return(0); + if (!solver->m_flag_ib) return(0); - /* Ideally, this shouldn't be here - But this function is called everywhere + /* Ideally, this shouldn'a_t be here - But this function is called everywhere (through ApplyIBConditions()) *before* MPIExchangeBoundariesnD is called! */ - MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->dim_local,solver->ghosts,mpi,u); + MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_dim_local,solver->m_ghosts,mpi,a_u); - double inv_gamma_m1 = 1.0 / (param->gamma - 1.0); + double inv_gamma_m1 = 1.0 / (param->m_gamma - 1.0); double ramp_fac = 1.0; - if (param->t_ib_ramp > 0) { - double x = t/param->t_ib_ramp; - if (!strcmp(param->ib_ramp_type,_IB_RAMP_LINEAR_)) { + if (param->m_t_ib_ramp > 0) { + double x = a_t/param->m_t_ib_ramp; + if (!strcmp(param->m_ib_ramp_type,_IB_RAMP_LINEAR_)) { ramp_fac = x; - } else if (!strcmp(param->ib_ramp_type,_IB_RAMP_SMOOTHEDSLAB_)) { + } else if (!strcmp(param->m_ib_ramp_type,_IB_RAMP_SMOOTHEDSLAB_)) { double a = 0.0; double b = 1.0; double c = 0.5; - double r = param->t_ib_ramp/param->t_ib_width; + double r = param->m_t_ib_ramp/param->m_t_ib_width; ramp_fac = (a*exp(c*r)+b*exp(r*x))/(exp(c*r)+exp(r*x)); - } else if (!strcmp(param->ib_ramp_type,_IB_RAMP_DISABLE_)) { + } else if (!strcmp(param->m_ib_ramp_type,_IB_RAMP_DISABLE_)) { ramp_fac = 0.0; } else { fprintf(stderr,"Error in NavierStokes3DImmersedBoundary():\n"); - fprintf(stderr," Ramp type %s not recognized.\n", param->ib_ramp_type); + fprintf(stderr," Ramp type %s not recognized.\n", param->m_ib_ramp_type); return 1; } } for (n=0; ngamma); + _NavierStokes3DGetFlowVar_(v,_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,param->m_gamma); double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt; - _NavierStokes3DGetFlowVar_( (u+_MODEL_NVARS_*node_index), + _NavierStokes3DGetFlowVar_( (a_u+_MODEL_NVARS_*node_index), _NavierStokes3D_stride_, rho_gpt, uvel_gpt, @@ -84,7 +84,7 @@ int NavierStokes3DIBAdiabatic(void *s, /*!< Solver object of type #HyPar */ wvel_gpt, energy_gpt, pressure_gpt, - param->gamma ); + param->m_gamma ); double rho_ib_target, uvel_ib_target, vvel_ib_target, wvel_ib_target, pressure_ib_target; rho_ib_target = rho; @@ -102,11 +102,11 @@ int NavierStokes3DIBAdiabatic(void *s, /*!< Solver object of type #HyPar */ energy_ib = inv_gamma_m1*pressure_ib + 0.5*rho_ib*(uvel_ib*uvel_ib+vvel_ib*vvel_ib+wvel_ib*wvel_ib); - u[_MODEL_NVARS_*node_index+0] = rho_ib; - u[_MODEL_NVARS_*node_index+1] = rho_ib * uvel_ib; - u[_MODEL_NVARS_*node_index+2] = rho_ib * vvel_ib; - u[_MODEL_NVARS_*node_index+3] = rho_ib * wvel_ib; - u[_MODEL_NVARS_*node_index+4] = energy_ib; + a_u[_MODEL_NVARS_*node_index+0] = rho_ib; + a_u[_MODEL_NVARS_*node_index+1] = rho_ib * uvel_ib; + a_u[_MODEL_NVARS_*node_index+2] = rho_ib * vvel_ib; + a_u[_MODEL_NVARS_*node_index+3] = rho_ib * wvel_ib; + a_u[_MODEL_NVARS_*node_index+4] = energy_ib; } return 0; @@ -116,68 +116,68 @@ int NavierStokes3DIBAdiabatic(void *s, /*!< Solver object of type #HyPar */ points (grid points within the immersed body that are within stencil-width distance of interior points, i.e., points in the interior of the computational domain). */ -int NavierStokes3DIBIsothermal( void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< Solver object of type #HyPar */ - double *u, /*!< Array with the solution vector */ - double t /*!< Current simulation time */ +int NavierStokes3DIBIsothermal( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< Solver object of type #HyPar */ + double *a_u, /*!< Array with the solution vector */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ImmersedBoundary *IB = (ImmersedBoundary*) solver->ib; - IBNode *boundary = IB->boundary; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ImmersedBoundary *IB = (ImmersedBoundary*) solver->m_ib; + IBNode *boundary = IB->m_boundary; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; static double v[_MODEL_NVARS_]; - int n, j, k, nb = IB->n_boundary_nodes; + int n, j, k, nb = IB->m_n_boundary_nodes; - if (!solver->flag_ib) return(0); + if (!solver->m_flag_ib) return(0); - /* Ideally, this shouldn't be here - But this function is called everywhere + /* Ideally, this shouldn'a_t be here - But this function is called everywhere (through ApplyIBConditions()) *before* MPIExchangeBoundariesnD is called! */ - MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->dim_local,solver->ghosts,mpi,u); + MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_dim_local,solver->m_ghosts,mpi,a_u); - double inv_gamma_m1 = 1.0 / (param->gamma - 1.0); + double inv_gamma_m1 = 1.0 / (param->m_gamma - 1.0); double ramp_fac = 1.0; - if (param->t_ib_ramp > 0) { - double x = t/param->t_ib_ramp; - if (!strcmp(param->ib_ramp_type,_IB_RAMP_LINEAR_)) { + if (param->m_t_ib_ramp > 0) { + double x = a_t/param->m_t_ib_ramp; + if (!strcmp(param->m_ib_ramp_type,_IB_RAMP_LINEAR_)) { ramp_fac = x; - } else if (!strcmp(param->ib_ramp_type,_IB_RAMP_SMOOTHEDSLAB_)) { + } else if (!strcmp(param->m_ib_ramp_type,_IB_RAMP_SMOOTHEDSLAB_)) { double a = 0.0; double b = 1.0; double c = 0.5; - double r = param->t_ib_ramp/param->t_ib_width; + double r = param->m_t_ib_ramp/param->m_t_ib_width; ramp_fac = (a*exp(c*r)+b*exp(r*x))/(exp(c*r)+exp(r*x)); - } else if (!strcmp(param->ib_ramp_type,_IB_RAMP_DISABLE_)) { + } else if (!strcmp(param->m_ib_ramp_type,_IB_RAMP_DISABLE_)) { ramp_fac = 0.0; } else { fprintf(stderr,"Error in NavierStokes3DImmersedBoundary():\n"); - fprintf(stderr," Ramp type %s not recognized.\n", param->ib_ramp_type); + fprintf(stderr," Ramp type %s not recognized.\n", param->m_ib_ramp_type); return 1; } } for (n=0; ngamma); + _NavierStokes3DGetFlowVar_(v,_NavierStokes3D_stride_,rho,uvel,vvel,wvel,energy,pressure,param->m_gamma); temperature = pressure / rho; double rho_gpt, uvel_gpt, vvel_gpt, wvel_gpt, energy_gpt, pressure_gpt, temperature_gpt; - _NavierStokes3DGetFlowVar_( (u+_MODEL_NVARS_*node_index), + _NavierStokes3DGetFlowVar_( (a_u+_MODEL_NVARS_*node_index), _NavierStokes3D_stride_, rho_gpt, uvel_gpt, @@ -185,7 +185,7 @@ int NavierStokes3DIBIsothermal( void *s, /*!< Solver object of type #HyPar */ wvel_gpt, energy_gpt, pressure_gpt, - param->gamma ); + param->m_gamma ); temperature_gpt = pressure_gpt / rho_gpt; double rho_ib_target, @@ -212,11 +212,11 @@ int NavierStokes3DIBIsothermal( void *s, /*!< Solver object of type #HyPar */ energy_ib = inv_gamma_m1*pressure_ib + 0.5*rho_ib*(uvel_ib*uvel_ib+vvel_ib*vvel_ib+wvel_ib*wvel_ib); - u[_MODEL_NVARS_*node_index+0] = rho_ib; - u[_MODEL_NVARS_*node_index+1] = rho_ib * uvel_ib; - u[_MODEL_NVARS_*node_index+2] = rho_ib * vvel_ib; - u[_MODEL_NVARS_*node_index+3] = rho_ib * wvel_ib; - u[_MODEL_NVARS_*node_index+4] = energy_ib; + a_u[_MODEL_NVARS_*node_index+0] = rho_ib; + a_u[_MODEL_NVARS_*node_index+1] = rho_ib * uvel_ib; + a_u[_MODEL_NVARS_*node_index+2] = rho_ib * vvel_ib; + a_u[_MODEL_NVARS_*node_index+3] = rho_ib * wvel_ib; + a_u[_MODEL_NVARS_*node_index+4] = energy_ib; } return(0); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize.c index e955032b..628139e3 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize.c @@ -113,54 +113,54 @@ int gpuNavierStokes3DPreStep (double*,void*,void*,double); \b Note: "physics.inp" is \b optional; if absent, default values will be used. */ -int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ +int NavierStokes3DInitialize( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes3D *physics = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes3D *physics = (NavierStokes3D*) solver->m_physics; int ferr = 0; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in NavierStokes3DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in NavierStokes3DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->gamma = 1.4; - physics->Pr = 0.72; - physics->Re = -1; + physics->m_gamma = 1.4; + physics->m_Pr = 0.72; + physics->m_Re = -1; physics->Minf = 1.0; physics->C1 = 1.458e-6; physics->C2 = 110.4; - physics->grav_x = 0.0; - physics->grav_y = 0.0; - physics->grav_z = 0.0; - physics->rho0 = 1.0; - physics->p0 = 1.0; + physics->m_grav_x = 0.0; + physics->m_grav_y = 0.0; + physics->m_grav_z = 0.0; + physics->m_rho0 = 1.0; + physics->m_p0 = 1.0; physics->HB = 1; - physics->R = 1.0; + physics->m_R = 1.0; physics->N_bv = 0.0; physics->T_ib_wall = -DBL_MAX; - physics->t_ib_ramp = -1.0; - physics->t_ib_width= 0.05; + physics->m_t_ib_ramp = -1.0; + physics->m_t_ib_width= 0.05; physics->ib_T_tol = 5; - strcpy(physics->upw_choice,"roe"); - strcpy(physics->ib_write_surface_data,"yes"); - strcpy(physics->ib_wall_type,"adiabatic"); - strcpy(physics->ib_ramp_type,"linear"); + strcpy(physics->m_upw_choice,"roe"); + strcpy(physics->m_ib_write_surface_data,"yes"); + strcpy(physics->m_ib_wall_type,"adiabatic"); + strcpy(physics->m_ib_ramp_type,"linear"); /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -178,25 +178,25 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ return 1; } if (!strcmp(word, "gamma")) { - ferr = fscanf(in,"%lf",&physics->gamma); + ferr = fscanf(in,"%lf",&physics->m_gamma); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upw_choice); + ferr = fscanf(in,"%s",physics->m_upw_choice); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"Pr")) { - ferr = fscanf(in,"%lf",&physics->Pr); + ferr = fscanf(in,"%lf",&physics->m_Pr); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"Re")) { - ferr = fscanf(in,"%lf",&physics->Re); + ferr = fscanf(in,"%lf",&physics->m_Re); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; @@ -208,29 +208,29 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ return 1; } } else if (!strcmp(word,"gravity")) { - ferr = fscanf(in,"%lf",&physics->grav_x); + ferr = fscanf(in,"%lf",&physics->m_grav_x); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - ferr = fscanf(in,"%lf",&physics->grav_y); + ferr = fscanf(in,"%lf",&physics->m_grav_y); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - ferr = fscanf(in,"%lf",&physics->grav_z); + ferr = fscanf(in,"%lf",&physics->m_grav_z); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"rho_ref")) { - ferr = fscanf(in,"%lf",&physics->rho0); + ferr = fscanf(in,"%lf",&physics->m_rho0); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"p_ref")) { - ferr = fscanf(in,"%lf",&physics->p0); + ferr = fscanf(in,"%lf",&physics->m_p0); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; @@ -249,61 +249,61 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ } } } else if (!strcmp(word,"R")) { - ferr = fscanf(in,"%lf",&physics->R); + ferr = fscanf(in,"%lf",&physics->m_R); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"ib_surface_data")) { - ferr = fscanf(in,"%s",physics->ib_write_surface_data); + ferr = fscanf(in,"%s",physics->m_ib_write_surface_data); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } else if (!strcmp(word,"ib_wall_type")) { - ferr = fscanf(in,"%s",physics->ib_wall_type); + ferr = fscanf(in,"%s",physics->m_ib_wall_type); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - if (!strcmp(physics->ib_wall_type,_IB_ISOTHERMAL_)) { + if (!strcmp(physics->m_ib_wall_type,_IB_ISOTHERMAL_)) { ferr = fscanf(in,"%lf",&physics->T_ib_wall); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } } - if (!solver->flag_ib) { + if (!solver->m_flag_ib) { printf("Warning: in NavierStokes3DInitialize().\n"); printf("Warning: no immersed body present; specification of ib_wall_type unnecessary.\n"); } } else if (!strcmp(word,"ib_ramp_time")) { - ferr = fscanf(in,"%lf",&physics->t_ib_ramp); + ferr = fscanf(in,"%lf",&physics->m_t_ib_ramp); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - if (!solver->flag_ib) { + if (!solver->m_flag_ib) { printf("Warning: in NavierStokes3DInitialize().\n"); printf("Warning: no immersed body present; specification of ib_ramp_time unnecessary.\n"); } } else if (!strcmp(word,"ib_ramp_width")) { - ferr = fscanf(in,"%lf",&physics->t_ib_width); + ferr = fscanf(in,"%lf",&physics->m_t_ib_width); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - if (!solver->flag_ib) { + if (!solver->m_flag_ib) { printf("Warning: in NavierStokes3DInitialize().\n"); printf("Warning: no immersed body present; specification of ib_ramp_width unnecessary.\n"); } } else if (!strcmp(word,"ib_ramp_type")) { - ferr = fscanf(in,"%s",physics->ib_ramp_type); + ferr = fscanf(in,"%s",physics->m_ib_ramp_type); if (ferr != 1) { fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - if (!solver->flag_ib) { + if (!solver->m_flag_ib) { printf("Warning: in NavierStokes3DInitialize().\n"); printf("Warning: no immersed body present; specification of ib_ramp_type unnecessary.\n"); } @@ -313,7 +313,7 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ fprintf(stderr, "Read error while reading physics.inp in NavierStokes3DInitialize().\n"); return 1; } - if (!solver->flag_ib) { + if (!solver->m_flag_ib) { printf("Warning: in NavierStokes3DInitialize().\n"); printf("Warning: no immersed body present; specification of ib_T_tolerance unnecessary.\n"); } @@ -332,53 +332,53 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ fclose(in); } - IERR MPIBroadcast_character (physics->upw_choice ,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->ib_write_surface_data ,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->ib_wall_type ,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->ib_ramp_type ,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->gamma ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Pr ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Re ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Minf ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->grav_x ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->grav_y ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->grav_z ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->rho0 ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->p0 ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->R ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->N_bv ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->T_ib_wall ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->t_ib_ramp ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->t_ib_width ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->ib_T_tol ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->HB ,1 ,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_upw_choice ,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_ib_write_surface_data ,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_ib_wall_type ,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_ib_ramp_type ,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_gamma ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_Pr ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_Re ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->Minf ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_grav_x ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_grav_y ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_grav_z ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_rho0 ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_p0 ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_R ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->N_bv ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->T_ib_wall ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_t_ib_ramp ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_t_ib_width ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->ib_T_tol ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->HB ,1 ,0,&mpi->m_world); CHECKERR(ierr); /* if file output is disabled in HyPar, respect that */ - if (!strcmp(solver->op_file_format,"none")) { - if (!strcmp(physics->ib_write_surface_data,"yes")) { - if (!mpi->rank) { - printf("Warning from NavierStokes3DInitialize(): solver->op_file_format is set to \"none\", thus "); - printf("setting physics->ib_write_surface_data to \"no\" (no solution files will be written).\n"); + if (!strcmp(solver->m_op_file_format,"none")) { + if (!strcmp(physics->m_ib_write_surface_data,"yes")) { + if (!mpi->m_rank) { + printf("Warning from NavierStokes3DInitialize(): solver->m_op_file_format is set to \"none\", thus "); + printf("setting physics->m_ib_write_surface_data to \"no\" (no solution files will be written).\n"); } } - strcpy(physics->ib_write_surface_data,"no"); + strcpy(physics->m_ib_write_surface_data,"no"); } /* Scaling Re by M_inf */ - physics->Re /= physics->Minf; + physics->m_Re /= physics->Minf; /* check that a well-balanced upwinding scheme is being used for cases with gravity */ - if ( ((physics->grav_x != 0.0) || (physics->grav_y != 0.0) || (physics->grav_z != 0.0) ) - && (strcmp(physics->upw_choice,_RUSANOV_)) ) { - if (!mpi->rank) { + if ( ((physics->m_grav_x != 0.0) || (physics->m_grav_y != 0.0) || (physics->m_grav_z != 0.0) ) + && (strcmp(physics->m_upw_choice,_RUSANOV_)) ) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DInitialize: %s upwinding is needed for flows ",_RUSANOV_); fprintf(stderr,"with gravitational forces.\n"); } return(1); } /* check that solver has the correct choice of diffusion formulation, if viscous flow */ - if (strcmp(solver->spatial_type_par,_NC_2STAGE_) && (physics->Re > 0)) { - if (!mpi->rank) { + if (strcmp(solver->m_spatial_type_par,_NC_2STAGE_) && (physics->m_Re > 0)) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DInitialize(): Parabolic term spatial discretization must be \"%s\"\n",_NC_2STAGE_); } return(1); @@ -386,7 +386,7 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ /* initializing physical model-specific functions */ #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { solver->PreStep = gpuNavierStokes3DPreStep; solver->FFunction = gpuNavierStokes3DFlux; solver->SFunction = gpuNavierStokes3DSource; @@ -405,39 +405,39 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ } #endif - if (solver->flag_ib) { - if (!strcmp(physics->ib_wall_type,_IB_ADIABATIC_)) { + if (solver->m_flag_ib) { + if (!strcmp(physics->m_ib_wall_type,_IB_ADIABATIC_)) { solver->IBFunction = NavierStokes3DIBAdiabatic; - } else if (!strcmp(physics->ib_wall_type,_IB_ISOTHERMAL_)) { + } else if (!strcmp(physics->m_ib_wall_type,_IB_ISOTHERMAL_)) { solver->IBFunction = NavierStokes3DIBIsothermal; } else { fprintf(stderr, "Error in NavierStokes3DInitialize()\n"); fprintf(stderr, " invalid value for IB wall type (%s).\n", - physics->ib_wall_type ); + physics->m_ib_wall_type ); } - if (!strcmp(physics->ib_write_surface_data,"yes")) { + if (!strcmp(physics->m_ib_write_surface_data,"yes")) { solver->PhysicsOutput = NavierStokes3DIBForces; } } #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DInitialize(): Not available on GPU!"); } return 1; } else { solver->JFunction = NavierStokes3DJacobian; - if (!strcmp(physics->upw_choice,_ROE_ )) { + if (!strcmp(physics->m_upw_choice,_ROE_ )) { solver->Upwind = gpuNavierStokes3DUpwindRoe; - } else if (!strcmp(physics->upw_choice,_RUSANOV_)) { + } else if (!strcmp(physics->m_upw_choice,_RUSANOV_)) { solver->Upwind = gpuNavierStokes3DUpwindRusanov; } else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DInitialize(): %s is not a valid upwinding scheme on GPU. ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"Choices are %s and %s.\n",_ROE_,_RUSANOV_); } return(1); @@ -447,22 +447,22 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ } else { #endif - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { solver->FdFFunction = NavierStokes3DNonStiffFlux; solver->dFFunction = NavierStokes3DStiffFlux; solver->JFunction = NavierStokes3DStiffJacobian; - if (!strcmp(physics->upw_choice,_ROE_)) { + if (!strcmp(physics->m_upw_choice,_ROE_)) { solver->Upwind = NavierStokes3DUpwindRoe; solver->UpwinddF = NavierStokes3DUpwinddFRoe; solver->UpwindFdF = NavierStokes3DUpwindFdFRoe; - } else if (!strcmp(physics->upw_choice,_RUSANOV_)) { + } else if (!strcmp(physics->m_upw_choice,_RUSANOV_)) { solver->Upwind = NavierStokes3DUpwindRusanovModified; solver->UpwinddF = NavierStokes3DUpwinddFRusanovModified; solver->UpwindFdF = NavierStokes3DUpwindFdFRusanovModified; } else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DInitialize(): %s is not a valid upwinding scheme ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"for use with split hyperbolic flux form. Use %s or %s.\n", _ROE_,_RUSANOV_); } @@ -470,14 +470,14 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ } } else { solver->JFunction = NavierStokes3DJacobian; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = NavierStokes3DUpwindRoe; - else if (!strcmp(physics->upw_choice,_RF_ )) solver->Upwind = NavierStokes3DUpwindRF; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = NavierStokes3DUpwindLLF; - else if (!strcmp(physics->upw_choice,_RUSANOV_)) solver->Upwind = NavierStokes3DUpwindRusanov; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->Upwind = NavierStokes3DUpwindRoe; + else if (!strcmp(physics->m_upw_choice,_RF_ )) solver->Upwind = NavierStokes3DUpwindRF; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->Upwind = NavierStokes3DUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_RUSANOV_)) solver->Upwind = NavierStokes3DUpwindRusanov; else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in NavierStokes3DInitialize(): %s is not a valid upwinding scheme. ", - physics->upw_choice); + physics->m_upw_choice); fprintf(stderr,"Choices are %s, %s, %s, and %s.\n",_ROE_,_RF_,_LLF_,_RUSANOV_); } return(1); @@ -490,14 +490,14 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ /* set the value of gamma in all the boundary objects */ int n; - DomainBoundary *boundary = (DomainBoundary*) solver->boundary; - for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma; + DomainBoundary *boundary = (DomainBoundary*) solver->m_boundary; + for (n = 0; n < solver->m_n_boundary_zones; n++) boundary[n].m_gamma = physics->m_gamma; - /* finally, hijack the main solver's dissipation function pointer - * to this model's own function, since it's difficult to express + /* finally, hijack the main solver'a_s dissipation function pointer + * to this model'a_s own function, since it'a_s difficult to express * the dissipation terms in the general form */ #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { solver->ParabolicFunction = gpuNavierStokes3DParabolicFunction; } else { #endif @@ -507,21 +507,21 @@ int NavierStokes3DInitialize( void *s, /*!< Solver object of type #HyPar */ #endif /* allocate array to hold the gravity field */ - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int d, size = 1; for (d=0; d<_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts); - physics->grav_field_f = (double*) calloc (size, sizeof(double)); - physics->grav_field_g = (double*) calloc (size, sizeof(double)); + physics->m_grav_field_f = (double*) calloc (size, sizeof(double)); + physics->m_grav_field_g = (double*) calloc (size, sizeof(double)); /* allocate arrays to hold the fast Jacobian for split form of the hyperbolic flux */ - physics->fast_jac = (double*) calloc (_MODEL_NDIMS_*size*_MODEL_NVARS_*_MODEL_NVARS_,sizeof(double)); + physics->m_fast_jac = (double*) calloc (_MODEL_NDIMS_*size*_MODEL_NVARS_*_MODEL_NVARS_,sizeof(double)); physics->solution = (double*) calloc (size*_MODEL_NVARS_,sizeof(double)); /* initialize the gravity fields */ IERR NavierStokes3DGravityField(solver,mpi); CHECKERR(ierr); #if defined(HAVE_CUDA) - if (solver->use_gpu) gpuNavierStokes3DInitialize(s,m); + if (solver->m_use_gpu) gpuNavierStokes3DInitialize(a_s,a_m); #endif - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize_GPU.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize_GPU.c index b74c055a..a2f38bb9 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize_GPU.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DInitialize_GPU.c @@ -8,15 +8,15 @@ /*! Initialize GPU-related arrays. */ int gpuNavierStokes3DInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *physics = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *physics = (NavierStokes3D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int d, size = 1; for (d = 0; d <_MODEL_NDIMS_; d++) size *= (dim[d] + 2*ghosts); gpuMalloc((void**)&physics->gpu_Q, size*_MODEL_NVARS_*sizeof(double)); @@ -35,8 +35,8 @@ int gpuNavierStokes3DInitialize( gpuMemset(physics->gpu_QDerivZ, 0, size*_MODEL_NVARS_*sizeof(double)); gpuMemset(physics->gpu_FViscous, 0, size*_MODEL_NVARS_*sizeof(double)); gpuMemset(physics->gpu_FDeriv, 0, size*_MODEL_NVARS_*sizeof(double)); - gpuMemcpy(physics->gpu_grav_field_f, physics->grav_field_f, size*sizeof(double), gpuMemcpyHostToDevice); - gpuMemcpy(physics->gpu_grav_field_g, physics->grav_field_g, size*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(physics->gpu_grav_field_f, physics->m_grav_field_f, size*sizeof(double), gpuMemcpyHostToDevice); + gpuMemcpy(physics->gpu_grav_field_g, physics->m_grav_field_g, size*sizeof(double), gpuMemcpyHostToDevice); gpuMemset(physics->gpu_fast_jac, 0, _MODEL_NDIMS_*size*_MODEL_NVARS_*_MODEL_NVARS_*sizeof(double)); gpuMemset(physics->gpu_solution, 0, size*_MODEL_NVARS_*sizeof(double)); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DJacobian.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DJacobian.c index 81a977c3..1f442d2c 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DJacobian.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DJacobian.c @@ -13,34 +13,34 @@ is returned as a 1D array (double) of 25 elements in row-major format. */ int NavierStokes3DJacobian( - double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 25 */ - double *u, /*!< solution at a grid point (array of size nvar = 5) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (0 -> x, 1 -> y, 2 -> z) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, + double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 25 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 5) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (0 -> x, 1 -> y, 2 -> z) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - NavierStokes3D *param = (NavierStokes3D*) p; + NavierStokes3D *param = (NavierStokes3D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _NavierStokes3DEigenvalues_ (u,_NavierStokes3D_stride_,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ (u,_NavierStokes3D_stride_,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_(u,_NavierStokes3D_stride_,R,param->gamma,dir); + _NavierStokes3DEigenvalues_ (a_u,_NavierStokes3D_stride_,D,param->m_gamma,a_dir); + _NavierStokes3DLeftEigenvectors_ (a_u,_NavierStokes3D_stride_,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_(a_u,_NavierStokes3D_stride_,R,param->m_gamma,a_dir); - int aupw = absolute(upw), k; - k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 6; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 12; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 18; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + int aupw = absolute(a_upw), k; + k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 6; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 12; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 18; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); MatMult5(_MODEL_NVARS_,DL,D,L); - MatMult5(_MODEL_NVARS_,Jac,R,DL); + MatMult5(_MODEL_NVARS_,a_Jac,R,DL); return(0); } @@ -51,48 +51,48 @@ int NavierStokes3DJacobian( in row-major format. */ int NavierStokes3DStiffJacobian( - double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 25 */ - double *u, /*!< solution at a grid point (array of size nvar = 5) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (0 -> x, 1 -> y, 2 -> z) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, + double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 25 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 5) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (0 -> x, 1 -> y, 2 -> z) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - NavierStokes3D *param = (NavierStokes3D*) p; + NavierStokes3D *param = (NavierStokes3D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _NavierStokes3DEigenvalues_ (u,_NavierStokes3D_stride_,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ (u,_NavierStokes3D_stride_,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_(u,_NavierStokes3D_stride_,R,param->gamma,dir); + _NavierStokes3DEigenvalues_ (a_u,_NavierStokes3D_stride_,D,param->m_gamma,a_dir); + _NavierStokes3DLeftEigenvectors_ (a_u,_NavierStokes3D_stride_,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_(a_u,_NavierStokes3D_stride_,R,param->m_gamma,a_dir); - int aupw = absolute(upw), k; - if (dir == _XDIR_) { + int aupw = absolute(a_upw), k; + if (a_dir == _XDIR_) { k = 0; D[k] = 0.0; - k = 6; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + k = 6; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); k = 12; D[k] = 0.0; k = 18; D[k] = 0.0; - k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - } else if (dir == _YDIR_) { + k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + } else if (a_dir == _YDIR_) { k = 0; D[k] = 0.0; k = 6; D[k] = 0.0; - k = 12; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + k = 12; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); k = 18; D[k] = 0.0; - k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - } else if (dir == _ZDIR_) { + k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + } else if (a_dir == _ZDIR_) { k = 0; D[k] = 0.0; k = 6; D[k] = 0.0; k = 12; D[k] = 0.0; - k = 18; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + k = 18; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 24; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); } MatMult5(_MODEL_NVARS_,DL,D,L); - MatMult5(_MODEL_NVARS_,Jac,R,DL); + MatMult5(_MODEL_NVARS_,a_Jac,R,DL); return(0); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution.c index 0c39cff4..422949a5 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution.c @@ -29,20 +29,20 @@ for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes3DModifiedSolution( - double *uC, /*!< Array to hold the computed modified solution */ - double *u, /*!< Solution vector array */ - int d, /*!< spatial dimension (not used) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of time #MPIVariables */ + double *a_uC, /*!< Array to hold the computed modified solution */ + double *a_u, /*!< Solution vector array */ + int a_d, /*!< spatial dimension (not used) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of time #MPIVariables */ double waqt /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -53,16 +53,16 @@ int NavierStokes3DModifiedSolution( _ArraySetValue_(offset,ndims,-ghosts); int done = 0; _ArraySetValue_(index,ndims,0); - double inv_gamma_m1 = 1.0 / (param->gamma-1.0); + double inv_gamma_m1 = 1.0 / (param->m_gamma-1.0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double rho, uvel, vvel, wvel, E, P; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,E,P,param->gamma); - uC[_MODEL_NVARS_*p+0] = u[_MODEL_NVARS_*p+0] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+1] = u[_MODEL_NVARS_*p+1] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+2] = u[_MODEL_NVARS_*p+2] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+3] = u[_MODEL_NVARS_*p+3] * param->grav_field_f[p]; - uC[_MODEL_NVARS_*p+4] = (P*inv_gamma_m1)*(1.0/param->grav_field_g[p]) + (0.5*rho*(uvel*uvel+vvel*vvel+wvel*wvel))*param->grav_field_f[p]; + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,uvel,vvel,wvel,E,P,param->m_gamma); + a_uC[_MODEL_NVARS_*p+0] = a_u[_MODEL_NVARS_*p+0] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+1] = a_u[_MODEL_NVARS_*p+1] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+2] = a_u[_MODEL_NVARS_*p+2] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+3] = a_u[_MODEL_NVARS_*p+3] * param->m_grav_field_f[p]; + a_uC[_MODEL_NVARS_*p+4] = (P*inv_gamma_m1)*(1.0/param->m_grav_field_g[p]) + (0.5*rho*(uvel*uvel+vvel*vvel+wvel*wvel))*param->m_grav_field_f[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution_GPU.cu b/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution_GPU.cu index 3408219c..9ef39cc3 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution_GPU.cu +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DModifiedSolution_GPU.cu @@ -70,10 +70,10 @@ extern "C" int gpuNavierStokes3DModifiedSolution( NavierStokes3D *param = (NavierStokes3D*) solver->physics; double inv_gamma_m1 = 1.0 / (param->gamma-1.0); - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DModifiedSolution_kernel<<>>( - solver->npoints_local_wghosts, param->gamma, inv_gamma_m1, + solver->m_npoints_local_wghosts, param->gamma, inv_gamma_m1, param->gpu_grav_field_f, param->gpu_grav_field_g, u, uC ); cudaDeviceSynchronize(); @@ -143,10 +143,10 @@ extern "C" int gpuNavierStokes3DModifiedSolution( NavierStokes3D *param = (NavierStokes3D*) solver->physics; double inv_gamma_m1 = 1.0 / (param->gamma-1.0); - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DModifiedSolution_kernel<<>>( - solver->npoints_local_wghosts, param->gamma, inv_gamma_m1, + solver->m_npoints_local_wghosts, param->gamma, inv_gamma_m1, param->gpu_grav_field_f, param->gpu_grav_field_g, u, uC ); cudaDeviceSynchronize(); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction.c index 8e49e841..b8131157 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction.c @@ -48,34 +48,34 @@ number is based on speed of sound, instead of the freestream velocity). */ int NavierStokes3DParabolicFunction( - double *par, /*!< Array to hold the computed viscous terms */ - double *u, /*!< Solution vector array */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_par, /*!< Array to hold the computed viscous terms */ + double *a_u, /*!< Solution vector array */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes3D *physics = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes3D *physics = (NavierStokes3D*) solver->m_physics; int i,j,k,v; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int imax = solver->dim_local[0]; - int jmax = solver->dim_local[1]; - int kmax = solver->dim_local[2]; - int *dim = solver->dim_local; - int size = solver->npoints_local_wghosts; + int ghosts = solver->m_ghosts; + int imax = solver->m_dim_local[0]; + int jmax = solver->m_dim_local[1]; + int kmax = solver->m_dim_local[2]; + int *dim = solver->m_dim_local; + int size = solver->m_npoints_local_wghosts; - _ArraySetValue_(par,size*_MODEL_NVARS_,0.0); - if (physics->Re <= 0) return(0); /* inviscid flow */ - solver->count_par++; + _ArraySetValue_(a_par,size*_MODEL_NVARS_,0.0); + if (physics->m_Re <= 0) return(0); /* inviscid flow */ + solver->m_count_par++; - static double two_third = 2.0/3.0; - double inv_gamma_m1 = 1.0 / (physics->gamma-1.0); - double inv_Re = 1.0 / physics->Re; - double inv_Pr = 1.0 / physics->Pr; + static double s_two_third = 2.0/3.0; + double inv_gamma_m1 = 1.0 / (physics->m_gamma-1.0); + double inv_Re = 1.0 / physics->m_Re; + double inv_Pr = 1.0 / physics->m_Pr; #if defined(CPU_STAT) clock_t startEvent, stopEvent; @@ -94,7 +94,7 @@ int NavierStokes3DParabolicFunction( int p,index[3]; index[0]=i; index[1]=j; index[2]=k; double energy,pressure; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _NavierStokes3DGetFlowVar_( (u+p), + _NavierStokes3DGetFlowVar_( (a_u+p), _NavierStokes3D_stride_, Q[p+0], Q[p+1], @@ -102,8 +102,8 @@ int NavierStokes3DParabolicFunction( Q[p+3], energy, pressure, - physics->gamma); - Q[p+4] = physics->gamma*pressure/Q[p+0]; /* temperature */ + physics->m_gamma); + Q[p+4] = physics->m_gamma*pressure/Q[p+0]; /* temperature */ } } } @@ -122,12 +122,12 @@ int NavierStokes3DParabolicFunction( IERR solver->FirstDerivativePar(QDerivY,Q,_YDIR_,1,solver,mpi); CHECKERR(ierr); IERR solver->FirstDerivativePar(QDerivZ,Q,_ZDIR_,1,solver,mpi); CHECKERR(ierr); - IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->dim_local, - solver->ghosts,mpi,QDerivX); CHECKERR(ierr); - IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->dim_local, - solver->ghosts,mpi,QDerivY); CHECKERR(ierr); - IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->dim_local, - solver->ghosts,mpi,QDerivY); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_dim_local, + solver->m_ghosts,mpi,QDerivX); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_dim_local, + solver->m_ghosts,mpi,QDerivY); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_dim_local, + solver->m_ghosts,mpi,QDerivY); CHECKERR(ierr); for (i=-ghosts; i<(imax+ghosts); i++) { for (j=-ghosts; j<(jmax+ghosts); j++) { @@ -135,9 +135,9 @@ int NavierStokes3DParabolicFunction( int p,index[3]; index[0]=i; index[1]=j; index[2]=k; double dxinv, dyinv, dzinv; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); - _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->dxinv,dzinv); + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); + _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->m_dxinv,dzinv); _ArrayScale1D_((QDerivX+p),dxinv,_MODEL_NVARS_); _ArrayScale1D_((QDerivY+p),dyinv,_MODEL_NVARS_); _ArrayScale1D_((QDerivZ+p),dzinv,_MODEL_NVARS_); @@ -170,7 +170,7 @@ int NavierStokes3DParabolicFunction( uz = (QDerivZ+p)[1]; wz = (QDerivZ+p)[3]; - /* calculate viscosity coeff based on Sutherland's law */ + /* calculate viscosity coeff based on Sutherland'a_s law */ double mu = raiseto(T, 0.76); /* if (p/_MODEL_NVARS_ == 49841) { @@ -180,7 +180,7 @@ int NavierStokes3DParabolicFunction( */ double tau_xx, tau_xy, tau_xz, qx; - tau_xx = two_third * (mu*inv_Re) * (2*ux - vy - wz); + tau_xx = s_two_third * (mu*inv_Re) * (2*ux - vy - wz); tau_xy = (mu*inv_Re) * (uy + vx); tau_xz = (mu*inv_Re) * (uz + wx); qx = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tx; @@ -201,8 +201,8 @@ int NavierStokes3DParabolicFunction( int p,index[3]; index[0]=i; index[1]=j; index[2]=k; double dxinv; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - for (v=0; v<_MODEL_NVARS_; v++) (par+p)[v] += (dxinv * (FDeriv+p)[v] ); + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); + for (v=0; v<_MODEL_NVARS_; v++) (a_par+p)[v] += (dxinv * (FDeriv+p)[v] ); } } } @@ -229,12 +229,12 @@ int NavierStokes3DParabolicFunction( vz = (QDerivZ+p)[2]; wz = (QDerivZ+p)[3]; - /* calculate viscosity coeff based on Sutherland's law */ + /* calculate viscosity coeff based on Sutherland'a_s law */ double mu = raiseto(T, 0.76); double tau_yx, tau_yy, tau_yz, qy; tau_yx = (mu*inv_Re) * (uy + vx); - tau_yy = two_third * (mu*inv_Re) * (-ux + 2*vy - wz); + tau_yy = s_two_third * (mu*inv_Re) * (-ux + 2*vy - wz); tau_yz = (mu*inv_Re) * (vz + wy); qy = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Ty; @@ -254,8 +254,8 @@ int NavierStokes3DParabolicFunction( int p,index[3]; index[0]=i; index[1]=j; index[2]=k; double dyinv; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); - for (v=0; v<_MODEL_NVARS_; v++) (par+p)[v] += (dyinv * (FDeriv+p)[v] ); + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); + for (v=0; v<_MODEL_NVARS_; v++) (a_par+p)[v] += (dyinv * (FDeriv+p)[v] ); } } } @@ -282,13 +282,13 @@ int NavierStokes3DParabolicFunction( vz = (QDerivZ+p)[2]; wz = (QDerivZ+p)[3]; - /* calculate viscosity coeff based on Sutherland's law */ + /* calculate viscosity coeff based on Sutherland'a_s law */ double mu = raiseto(T,0.76); double tau_zx, tau_zy, tau_zz, qz; tau_zx = (mu*inv_Re) * (uz + wx); tau_zy = (mu*inv_Re) * (vz + wy); - tau_zz = two_third * (mu*inv_Re) * (-ux - vy + 2*wz); + tau_zz = s_two_third * (mu*inv_Re) * (-ux - vy + 2*wz); qz = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tz; (FViscous+p)[0] = 0.0; @@ -307,8 +307,8 @@ int NavierStokes3DParabolicFunction( int p,index[3]; index[0]=i; index[1]=j; index[2]=k; double dzinv; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->dxinv,dzinv); - for (v=0; v<_MODEL_NVARS_; v++) (par+p)[v] += (dzinv * (FDeriv+p)[v] ); + _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->m_dxinv,dzinv); + for (v=0; v<_MODEL_NVARS_; v++) (a_par+p)[v] += (dzinv * (FDeriv+p)[v] ); } } } @@ -320,6 +320,6 @@ int NavierStokes3DParabolicFunction( free(FViscous); free(FDeriv); - if (solver->flag_ib) _ArrayBlockMultiply_(par,solver->iblank,size,_MODEL_NVARS_); + if (solver->m_flag_ib) _ArrayBlockMultiply_(a_par,solver->m_iblank,size,_MODEL_NVARS_); return(0); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction_GPU.cu b/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction_GPU.cu index f33c8783..8a549eb6 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction_GPU.cu +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DParabolicFunction_GPU.cu @@ -74,7 +74,7 @@ void gpuNavierStokes3DParabolicFunction_QDeriv_kernel( __global__ void gpuNavierStokes3DParabolicFunction_Xdir_kernel( int npoints_grid, - double two_third, + double s_two_third, double inv_gamma_m1, double inv_Re, double inv_Pr, @@ -109,7 +109,7 @@ void gpuNavierStokes3DParabolicFunction_Xdir_kernel( /* calculate viscosity coeff based on Sutherland's law */ double mu = raiseto(T, 0.76); double tau_xx, tau_xy, tau_xz, qx; - tau_xx = two_third * (mu*inv_Re) * (2*ux - vy - wz); + tau_xx = s_two_third * (mu*inv_Re) * (2*ux - vy - wz); tau_xy = (mu*inv_Re) * (uy + vx); tau_xz = (mu*inv_Re) * (uz + wx); qx = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tx; @@ -127,7 +127,7 @@ void gpuNavierStokes3DParabolicFunction_Xdir_kernel( __global__ void gpuNavierStokes3DParabolicFunction_Ydir_kernel( int npoints_grid, - double two_third, + double s_two_third, double inv_gamma_m1, double inv_Re, double inv_Pr, @@ -163,7 +163,7 @@ void gpuNavierStokes3DParabolicFunction_Ydir_kernel( double tau_yx, tau_yy, tau_yz, qy; tau_yx = (mu*inv_Re) * (uy + vx); - tau_yy = two_third * (mu*inv_Re) * (-ux + 2*vy - wz); + tau_yy = s_two_third * (mu*inv_Re) * (-ux + 2*vy - wz); tau_yz = (mu*inv_Re) * (vz + wy); qy = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Ty; @@ -180,7 +180,7 @@ void gpuNavierStokes3DParabolicFunction_Ydir_kernel( __global__ void gpuNavierStokes3DParabolicFunction_Zdir_kernel( int npoints_grid, - double two_third, + double s_two_third, double inv_gamma_m1, double inv_Re, double inv_Pr, @@ -217,7 +217,7 @@ void gpuNavierStokes3DParabolicFunction_Zdir_kernel( double tau_zx, tau_zy, tau_zz, qz; tau_zx = (mu*inv_Re) * (uz + wx); tau_zy = (mu*inv_Re) * (vz + wy); - tau_zz = two_third * (mu*inv_Re) * (-ux - vy + 2*wz); + tau_zz = s_two_third * (mu*inv_Re) * (-ux - vy + 2*wz); qz = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tz; (FViscous+p)[0] = 0.0; @@ -301,15 +301,15 @@ extern "C" int gpuNavierStokes3DParabolicFunction( MPIVariables *mpi = (MPIVariables*) m; NavierStokes3D *physics = (NavierStokes3D*) solver->physics; - int ghosts = solver->ghosts; - int *dim = solver->gpu_dim_local; - int size = solver->npoints_local_wghosts; + int ghosts = solver->m_ghosts; + int *dim = solver->m_gpu_dim_local; + int size = solver->m_npoints_local_wghosts; gpuMemset(par, 0, size*_MODEL_NVARS_*sizeof(double)); if (physics->Re <= 0) return (0); /* inviscid flow */ solver->count_par++; - static double two_third = 2.0/3.0; + static double s_two_third = 2.0/3.0; double inv_gamma_m1 = 1.0 / (physics->gamma-1.0); double inv_Re = 1.0 / physics->Re; double inv_Pr = 1.0 / physics->Pr; @@ -318,10 +318,10 @@ extern "C" int gpuNavierStokes3DParabolicFunction( double *QDerivX = physics->gpu_QDerivX; double *QDerivY = physics->gpu_QDerivY; double *QDerivZ = physics->gpu_QDerivZ; - double *dxinv = solver->gpu_dxinv; + double *dxinv = solver->m_gpu_dxinv; int nblocks = (size-1)/GPU_THREADS_PER_BLOCK + 1; - int nblocks_par = (solver->npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks_par = (solver->m_npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; @@ -355,12 +355,12 @@ extern "C" int gpuNavierStokes3DParabolicFunction( solver->FirstDerivativePar(QDerivY,Q,_YDIR_,1,solver,mpi); solver->FirstDerivativePar(QDerivZ,Q,_ZDIR_,1,solver,mpi); - gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->gpu_dim_local, - solver->ghosts,mpi,QDerivX); - gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->gpu_dim_local, - solver->ghosts,mpi,QDerivY); - gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->gpu_dim_local, - solver->ghosts,mpi,QDerivY); + gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_gpu_dim_local, + solver->m_ghosts,mpi,QDerivX); + gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_gpu_dim_local, + solver->m_ghosts,mpi,QDerivY); + gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_gpu_dim_local, + solver->m_ghosts,mpi,QDerivY); #if defined(GPU_STAT) checkCuda( cudaEventRecord(startEvent, 0) ); @@ -396,7 +396,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_Xdir_kernel<<>>( - size, two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, + size, s_two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, QDerivX, QDerivY, QDerivZ, FViscous ); cudaDeviceSynchronize(); @@ -419,7 +419,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_par_kernel<<>>( - solver->npoints_local, ghosts, _XDIR_, dim, dxinv, FDeriv, par + solver->m_npoints_local, ghosts, _XDIR_, dim, dxinv, FDeriv, par ); cudaDeviceSynchronize(); @@ -428,7 +428,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( checkCuda( cudaEventSynchronize(stopEvent) ); checkCuda( cudaEventElapsedTime(&milliseconds, startEvent, stopEvent) ); - memory_accessed = (solver->npoints_local + 2*solver->npoints_local*_MODEL_NVARS_)*sizeof(double); + memory_accessed = (solver->m_npoints_local + 2*solver->m_npoints_local*_MODEL_NVARS_)*sizeof(double); printf("%-50s GPU time (secs) = %.6f bandwidth (GB/s) = %6.2f\n", "NavierStokes3DParabolicFunction_par", milliseconds*1e-3, (1e-6*(memory_accessed)/milliseconds)); @@ -440,7 +440,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_Ydir_kernel<<>>( - size, two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, + size, s_two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, QDerivX, QDerivY, QDerivZ, FViscous ); cudaDeviceSynchronize(); @@ -458,7 +458,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( solver->FirstDerivativePar(FDeriv,FViscous,_YDIR_,1,solver,mpi); gpuNavierStokes3DParabolicFunction_par_kernel<<>>( - solver->npoints_local, ghosts, _YDIR_, dim, dxinv, FDeriv, par + solver->m_npoints_local, ghosts, _YDIR_, dim, dxinv, FDeriv, par ); cudaDeviceSynchronize(); @@ -468,7 +468,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_Zdir_kernel<<>>( - size, two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, + size, s_two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, QDerivX, QDerivY, QDerivZ, FViscous ); cudaDeviceSynchronize(); @@ -485,7 +485,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( solver->FirstDerivativePar(FDeriv,FViscous,_ZDIR_,1,solver,mpi); gpuNavierStokes3DParabolicFunction_par_kernel<<>>( - solver->npoints_local, ghosts, _ZDIR_, dim, dxinv, FDeriv, par + solver->m_npoints_local, ghosts, _ZDIR_, dim, dxinv, FDeriv, par ); cudaDeviceSynchronize(); @@ -494,7 +494,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( checkCuda( cudaEventDestroy(stopEvent) ); #endif - if (solver->flag_ib) gpuArrayBlockMultiply(par,solver->gpu_iblank,size,_MODEL_NVARS_); + if (solver->flag_ib) gpuArrayBlockMultiply(par,solver->m_gpu_iblank,size,_MODEL_NVARS_); return (0); } @@ -568,7 +568,7 @@ void gpuNavierStokes3DParabolicFunction_QDeriv_kernel( __global__ void gpuNavierStokes3DParabolicFunction_Xdir_kernel( int npoints_grid, - double two_third, + double s_two_third, double inv_gamma_m1, double inv_Re, double inv_Pr, @@ -601,7 +601,7 @@ void gpuNavierStokes3DParabolicFunction_Xdir_kernel( /* calculate viscosity coeff based on Sutherland's law */ double mu = raiseto(T, 0.76); double tau_xx, tau_xy, tau_xz, qx; - tau_xx = two_third * (mu*inv_Re) * (2*ux - vy - wz); + tau_xx = s_two_third * (mu*inv_Re) * (2*ux - vy - wz); tau_xy = (mu*inv_Re) * (uy + vx); tau_xz = (mu*inv_Re) * (uz + wx); qx = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tx; @@ -619,7 +619,7 @@ void gpuNavierStokes3DParabolicFunction_Xdir_kernel( __global__ void gpuNavierStokes3DParabolicFunction_Ydir_kernel( int npoints_grid, - double two_third, + double s_two_third, double inv_gamma_m1, double inv_Re, double inv_Pr, @@ -653,7 +653,7 @@ void gpuNavierStokes3DParabolicFunction_Ydir_kernel( double tau_yx, tau_yy, tau_yz, qy; tau_yx = (mu*inv_Re) * (uy + vx); - tau_yy = two_third * (mu*inv_Re) * (-ux + 2*vy - wz); + tau_yy = s_two_third * (mu*inv_Re) * (-ux + 2*vy - wz); tau_yz = (mu*inv_Re) * (vz + wy); qy = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Ty; @@ -670,7 +670,7 @@ void gpuNavierStokes3DParabolicFunction_Ydir_kernel( __global__ void gpuNavierStokes3DParabolicFunction_Zdir_kernel( int npoints_grid, - double two_third, + double s_two_third, double inv_gamma_m1, double inv_Re, double inv_Pr, @@ -705,7 +705,7 @@ void gpuNavierStokes3DParabolicFunction_Zdir_kernel( double tau_zx, tau_zy, tau_zz, qz; tau_zx = (mu*inv_Re) * (uz + wx); tau_zy = (mu*inv_Re) * (vz + wy); - tau_zz = two_third * (mu*inv_Re) * (-ux - vy + 2*wz); + tau_zz = s_two_third * (mu*inv_Re) * (-ux - vy + 2*wz); qz = ( mu*inv_Re * inv_gamma_m1 * inv_Pr ) * Tz; (FViscous+p)[0] = 0.0; @@ -792,15 +792,15 @@ extern "C" int gpuNavierStokes3DParabolicFunction( MPIVariables *mpi = (MPIVariables*) m; NavierStokes3D *physics = (NavierStokes3D*) solver->physics; - int ghosts = solver->ghosts; - int *dim = solver->gpu_dim_local; - int size = solver->npoints_local_wghosts; + int ghosts = solver->m_ghosts; + int *dim = solver->m_gpu_dim_local; + int size = solver->m_npoints_local_wghosts; gpuMemset(par, 0, size*_MODEL_NVARS_*sizeof(double)); if (physics->Re <= 0) return (0); /* inviscid flow */ solver->count_par++; - static double two_third = 2.0/3.0; + static double s_two_third = 2.0/3.0; double inv_gamma_m1 = 1.0 / (physics->gamma-1.0); double inv_Re = 1.0 / physics->Re; double inv_Pr = 1.0 / physics->Pr; @@ -809,10 +809,10 @@ extern "C" int gpuNavierStokes3DParabolicFunction( double *QDerivX = physics->gpu_QDerivX; double *QDerivY = physics->gpu_QDerivY; double *QDerivZ = physics->gpu_QDerivZ; - double *dxinv = solver->gpu_dxinv; + double *dxinv = solver->m_gpu_dxinv; int nblocks = (size-1)/GPU_THREADS_PER_BLOCK + 1; - int nblocks_par = (solver->npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks_par = (solver->m_npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; #if defined(GPU_STAT) cudaEvent_t startEvent, stopEvent; @@ -844,12 +844,12 @@ extern "C" int gpuNavierStokes3DParabolicFunction( solver->FirstDerivativePar(QDerivY,Q,_YDIR_,1,solver,mpi); solver->FirstDerivativePar(QDerivZ,Q,_ZDIR_,1,solver,mpi); - gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->gpu_dim_local, - solver->ghosts,mpi,QDerivX); - gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->gpu_dim_local, - solver->ghosts,mpi,QDerivY); - gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->gpu_dim_local, - solver->ghosts,mpi,QDerivY); + gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_gpu_dim_local, + solver->m_ghosts,mpi,QDerivX); + gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_gpu_dim_local, + solver->m_ghosts,mpi,QDerivY); + gpuMPIExchangeBoundariesnD(_MODEL_NDIMS_,_MODEL_NVARS_,solver->m_gpu_dim_local, + solver->m_ghosts,mpi,QDerivY); #if defined(GPU_STAT) checkCuda( cudaEventRecord(startEvent, 0) ); @@ -883,7 +883,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_Xdir_kernel<<>>( - size, two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, + size, s_two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, QDerivX, QDerivY, QDerivZ, FViscous ); cudaDeviceSynchronize(); @@ -906,7 +906,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_par_kernel<<>>( - solver->npoints_local, size, ghosts, _XDIR_, dim, dxinv, FDeriv, par + solver->m_npoints_local, size, ghosts, _XDIR_, dim, dxinv, FDeriv, par ); cudaDeviceSynchronize(); @@ -915,7 +915,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( checkCuda( cudaEventSynchronize(stopEvent) ); checkCuda( cudaEventElapsedTime(&milliseconds, startEvent, stopEvent) ); - memory_accessed = (solver->npoints_local + 2*solver->npoints_local*_MODEL_NVARS_)*sizeof(double); + memory_accessed = (solver->m_npoints_local + 2*solver->m_npoints_local*_MODEL_NVARS_)*sizeof(double); printf("%-50s GPU time (secs) = %.6f bandwidth (GB/s) = %6.2f\n", "NavierStokes3DParabolicFunction_par", milliseconds*1e-3, (1e-6*(memory_accessed)/milliseconds)); @@ -928,7 +928,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_Ydir_kernel<<>>( - size, two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, + size, s_two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, QDerivX, QDerivY, QDerivZ, FViscous ); cudaDeviceSynchronize(); @@ -946,7 +946,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( solver->FirstDerivativePar(FDeriv,FViscous,_YDIR_,1,solver,mpi); gpuNavierStokes3DParabolicFunction_par_kernel<<>>( - solver->npoints_local, size, ghosts, _YDIR_, dim, dxinv, FDeriv, par + solver->m_npoints_local, size, ghosts, _YDIR_, dim, dxinv, FDeriv, par ); cudaDeviceSynchronize(); @@ -956,7 +956,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( #endif gpuNavierStokes3DParabolicFunction_Zdir_kernel<<>>( - size, two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, + size, s_two_third, inv_gamma_m1, inv_Re, inv_Pr, Q, QDerivX, QDerivY, QDerivZ, FViscous ); cudaDeviceSynchronize(); @@ -974,7 +974,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( solver->FirstDerivativePar(FDeriv,FViscous,_ZDIR_,1,solver,mpi); gpuNavierStokes3DParabolicFunction_par_kernel<<>>( - solver->npoints_local, size, ghosts, _ZDIR_, dim, dxinv, FDeriv, par + solver->m_npoints_local, size, ghosts, _ZDIR_, dim, dxinv, FDeriv, par ); cudaDeviceSynchronize(); @@ -983,7 +983,7 @@ extern "C" int gpuNavierStokes3DParabolicFunction( checkCuda( cudaEventDestroy(stopEvent) ); #endif - if (solver->flag_ib) gpuArrayBlockMultiply(par,solver->gpu_iblank,size,_MODEL_NVARS_); + if (solver->flag_ib) gpuArrayBlockMultiply(par,solver->m_gpu_iblank,size,_MODEL_NVARS_); return (0); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep.c index 4ddca9c6..4e1813ac 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep.c @@ -30,16 +30,16 @@ 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes3DPreStep( - double *u, /*!< Solution vector */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + double *a_u, /*!< Solution vector */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double waqt /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts, dir, p; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts, dir, p; double *A; static const int ndims = _MODEL_NDIMS_; @@ -53,7 +53,7 @@ int NavierStokes3DPreStep( /* set offset such that index is compatible with ghost point arrangement */ _ArraySetValue_(offset,ndims,-ghosts); /* copy the solution to act as a reference for linearization */ - _ArrayCopy1D_(u,param->solution,(solver->npoints_local_wghosts*_MODEL_NVARS_)); + _ArrayCopy1D_(a_u,param->solution,(solver->m_npoints_local_wghosts*_MODEL_NVARS_)); int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { @@ -61,23 +61,23 @@ int NavierStokes3DPreStep( int q = _MODEL_NVARS_*p; dir = _XDIR_; - A = (param->fast_jac + _MODEL_NDIMS_*JacSize*p + dir*JacSize); + A = (param->m_fast_jac + _MODEL_NDIMS_*JacSize*p + dir*JacSize); /* get the eigenvalues, and left & right eigenvectors */ - _NavierStokes3DEigenvalues_ ((u+q),_NavierStokes3D_stride_,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ ((u+q),_NavierStokes3D_stride_,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_((u+q),_NavierStokes3D_stride_,R,param->gamma,dir); - /* remove the entropy modes (corresponding to eigenvalues u) */ + _NavierStokes3DEigenvalues_ ((a_u+q),_NavierStokes3D_stride_,D,param->m_gamma,dir); + _NavierStokes3DLeftEigenvectors_ ((a_u+q),_NavierStokes3D_stride_,L,param->m_gamma,dir); + _NavierStokes3DRightEigenvectors_((a_u+q),_NavierStokes3D_stride_,R,param->m_gamma,dir); + /* remove the entropy modes (corresponding to eigenvalues a_u) */ D[0] = D[12] = D[18] = 0.0; /* assemble the Jacobian */ MatMult5(_MODEL_NVARS_,DL,D,L ); MatMult5(_MODEL_NVARS_,A ,R,DL); dir = _YDIR_; - A = (param->fast_jac + _MODEL_NDIMS_*JacSize*p + dir*JacSize); + A = (param->m_fast_jac + _MODEL_NDIMS_*JacSize*p + dir*JacSize); /* get the eigenvalues, and left & right eigenvectors */ - _NavierStokes3DEigenvalues_ ((u+q),_NavierStokes3D_stride_,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ ((u+q),_NavierStokes3D_stride_,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_((u+q),_NavierStokes3D_stride_,R,param->gamma,dir); + _NavierStokes3DEigenvalues_ ((a_u+q),_NavierStokes3D_stride_,D,param->m_gamma,dir); + _NavierStokes3DLeftEigenvectors_ ((a_u+q),_NavierStokes3D_stride_,L,param->m_gamma,dir); + _NavierStokes3DRightEigenvectors_((a_u+q),_NavierStokes3D_stride_,R,param->m_gamma,dir); /* remove the entropy modes (corresponding to eigenvalues v) */ D[0] = D[6] = D[18] = 0.0; /* assemble the Jacobian */ @@ -85,11 +85,11 @@ int NavierStokes3DPreStep( MatMult5(_MODEL_NVARS_,A ,R,DL); dir = _ZDIR_; - A = (param->fast_jac + _MODEL_NDIMS_*JacSize*p + dir*JacSize); + A = (param->m_fast_jac + _MODEL_NDIMS_*JacSize*p + dir*JacSize); /* get the eigenvalues, and left & right eigenvectors */ - _NavierStokes3DEigenvalues_ ((u+q),_NavierStokes3D_stride_,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ ((u+q),_NavierStokes3D_stride_,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_((u+q),_NavierStokes3D_stride_,R,param->gamma,dir); + _NavierStokes3DEigenvalues_ ((a_u+q),_NavierStokes3D_stride_,D,param->m_gamma,dir); + _NavierStokes3DLeftEigenvectors_ ((a_u+q),_NavierStokes3D_stride_,L,param->m_gamma,dir); + _NavierStokes3DRightEigenvectors_((a_u+q),_NavierStokes3D_stride_,R,param->m_gamma,dir); /* remove the entropy modes (corresponding to eigenvalues v) */ D[0] = D[6] = D[12] = 0.0; /* assemble the Jacobian */ diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep_GPU.cu b/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep_GPU.cu index df834e89..2b995032 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep_GPU.cu +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DPreStep_GPU.cu @@ -99,11 +99,11 @@ extern "C" int gpuNavierStokes3DPreStep( HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; - gpuArrayCopy1D(u,param->gpu_solution,(solver->npoints_local_wghosts)*_MODEL_NVARS_); + gpuArrayCopy1D(u,param->gpu_solution,(solver->m_npoints_local_wghosts)*_MODEL_NVARS_); gpuNavierStokes3DPreStep_kernel<<>>( - solver->npoints_local_wghosts, param->gamma, u, param->gpu_fast_jac + solver->m_npoints_local_wghosts, param->gamma, u, param->gpu_fast_jac ); cudaDeviceSynchronize(); @@ -199,11 +199,11 @@ extern "C" int gpuNavierStokes3DPreStep( HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; - gpuArrayCopy1D(u,param->gpu_solution,(solver->npoints_local_wghosts)*_MODEL_NVARS_); + gpuArrayCopy1D(u,param->gpu_solution,(solver->m_npoints_local_wghosts)*_MODEL_NVARS_); gpuNavierStokes3DPreStep_kernel<<>>( - solver->npoints_local_wghosts, param->gamma, u, param->gpu_fast_jac + solver->m_npoints_local_wghosts, param->gamma, u, param->gpu_fast_jac ); cudaDeviceSynchronize(); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource.c index 7d6f48fa..6961f784 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource.c @@ -36,49 +36,49 @@ int NavierStokes3DSourceUpwind (double*,double*,double*,double*,int,void*,doub for Atmospheric Flows, AIAA Journal, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes3DSource( - double *source, /*!< Array to hold the computed source */ - double *u, /*!< Solution vector array */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_source, /*!< Array to hold the computed source */ + double *a_u, /*!< Solution vector array */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar* ) s; - MPIVariables *mpi = (MPIVariables*) m; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; - if ((param->grav_x == 0.0) && (param->grav_y == 0.0) && (param->grav_z == 0.0)) + if ((param->m_grav_x == 0.0) && (param->m_grav_y == 0.0) && (param->m_grav_z == 0.0)) return(0); /* no gravitational forces */ int v, done, p, p1, p2, dir; - double *SourceI = solver->fluxI; /* interace source term */ - double *SourceC = solver->fluxC; /* cell-centered source term */ - double *SourceL = solver->fL; - double *SourceR = solver->fR; - - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *x = solver->x; - double *dxinv = solver->dxinv; - double RT = param->p0 / param->rho0; + double *SourceI = solver->m_flux_i; /* interace a_source term */ + double *SourceC = solver->m_flux_c; /* cell-centered a_source term */ + double *SourceL = solver->m_f_l; + double *SourceR = solver->m_f_r; + + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *x = solver->m_x; + double *dxinv = solver->m_dxinv; + double RT = param->m_p0 / param->m_rho0; static int index[_MODEL_NDIMS_],index1[_MODEL_NDIMS_],index2[_MODEL_NDIMS_],dim_interface[_MODEL_NDIMS_]; static double grav[_MODEL_NDIMS_]; - grav[_XDIR_] = param->grav_x; - grav[_YDIR_] = param->grav_y; - grav[_ZDIR_] = param->grav_z; + grav[_XDIR_] = param->m_grav_x; + grav[_YDIR_] = param->m_grav_y; + grav[_ZDIR_] = param->m_grav_z; for (dir = 0; dir < _MODEL_NDIMS_; dir++) { if (grav[dir] != 0.0) { /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,_MODEL_NDIMS_); dim_interface[dir]++; - /* calculate the split source function exp(-phi/RT) */ - IERR NavierStokes3DSourceFunction(SourceC,u,x,solver,mpi,t,dir); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,dir,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,dir,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR NavierStokes3DSourceUpwind(SourceI,SourceL,SourceR,u,dir,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the split a_source function exp(-phi/RT) */ + IERR NavierStokes3DSourceFunction(SourceC,a_u,x,solver,mpi,a_t,dir); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,dir,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,dir,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR NavierStokes3DSourceUpwind(SourceI,SourceL,SourceR,a_u,dir,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { _ArrayCopy1D_(index,index1,_MODEL_NDIMS_); @@ -89,10 +89,10 @@ int NavierStokes3DSource( double dx_inverse; _GetCoordinate_(dir,index[dir],dim,ghosts,dxinv,dx_inverse); double rho, vel[_MODEL_NDIMS_], e, P; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],e,P,param->gamma); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*p),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],e,P,param->m_gamma); double term[_MODEL_NVARS_] = {0.0, rho*RT*(dir==_XDIR_), rho*RT*(dir==_YDIR_), rho*RT*(dir==_ZDIR_), rho*RT*vel[dir]}; for (v=0; v<_MODEL_NVARS_; v++) { - source[_MODEL_NVARS_*p+v] += ( (term[v]*param->grav_field_f[p]) + a_source[_MODEL_NVARS_*p+v] += ( (term[v]*param->m_grav_field_f[p]) * (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse ); } vel[0] = P; /* useless statement to avoid compiler warnings */ @@ -122,20 +122,20 @@ int NavierStokes3DSource( for Atmospheric Flows, AIAA Journal, http://dx.doi.org/10.2514/1.J054580. */ int NavierStokes3DSourceFunction( - double *f, /*!< Array to hold the computed source function */ - double *u, /*!< Solution vector array */ - double *x, /*!< Array of spatial coordinates (grid) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current simulation time */ - int dir /*!< Spatial dimension (x, y, or z) */ + double *a_f, /*!< Array to hold the computed source function */ + double *a_u, /*!< Solution vector array */ + double *a_x, /*!< Array of spatial coordinates (grid) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current simulation time */ + int a_dir /*!< Spatial dimension (a_x, y, or z) */ ) { - HyPar *solver = (HyPar* ) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; /* set bounds for array index to include ghost points */ @@ -148,11 +148,11 @@ int NavierStokes3DSourceFunction( int done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = param->grav_field_g[p] * (dir == _XDIR_); - (f+_MODEL_NVARS_*p)[2] = param->grav_field_g[p] * (dir == _YDIR_); - (f+_MODEL_NVARS_*p)[3] = param->grav_field_g[p] * (dir == _ZDIR_); - (f+_MODEL_NVARS_*p)[4] = param->grav_field_g[p]; + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = param->m_grav_field_g[p] * (a_dir == _XDIR_); + (a_f+_MODEL_NVARS_*p)[2] = param->m_grav_field_g[p] * (a_dir == _YDIR_); + (a_f+_MODEL_NVARS_*p)[3] = param->m_grav_field_g[p] * (a_dir == _ZDIR_); + (a_f+_MODEL_NVARS_*p)[4] = param->m_grav_field_g[p]; _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds,index,done); } @@ -172,32 +172,32 @@ int NavierStokes3DSourceFunction( for Atmospheric Flows, Submitted */ int NavierStokes3DSourceUpwind( - double *fI, /*!< Array to hold the computed "upwind" interface source function */ - double *fL, /*!< Interface source function value computed using left-biased interpolation */ - double *fR, /*!< Interface source function value computed using right-biased interpolation */ - double *u, /*!< Solution vector array */ - int dir, /*!< Spatial dimension (x,y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current simulation time */ + double *a_fI, /*!< Array to hold the computed "upwind" interface source function */ + double *a_fL, /*!< Interface source function value computed using left-biased interpolation */ + double *a_fR, /*!< Interface source function value computed using right-biased interpolation */ + double *a_u, /*!< Solution vector array */ + int a_dir, /*!< Spatial dimension (x,y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - int done,k, *dim = solver->dim_local; + HyPar *solver = (HyPar*) a_s; + int done,k, *dim = solver->m_dim_local; _DECLARE_IERR_; static int index_outer[_MODEL_NDIMS_], index_inter[_MODEL_NDIMS_], bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,_MODEL_NDIMS_,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource_GPU.cu b/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource_GPU.cu index 372a09af..402f4e13 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource_GPU.cu +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DSource_GPU.cu @@ -123,10 +123,10 @@ int gpuNavierStokes3DSourceFunction( { HyPar *solver = (HyPar* ) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DSourceFunction_kernel<<>>( - solver->npoints_local_wghosts, dir, param->gpu_grav_field_g, f + solver->m_npoints_local_wghosts, dir, param->gpu_grav_field_g, f ); cudaDeviceSynchronize(); @@ -156,7 +156,7 @@ int gpuNavierStokes3DSourceUpwind( ) { HyPar *solver = (HyPar*) s; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; _DECLARE_IERR_; int bounds_inter[_MODEL_NDIMS_]; @@ -216,10 +216,10 @@ extern "C" int gpuNavierStokes3DSource( double *SourceL = solver->fL; double *SourceR = solver->fR; - int ghosts = solver->ghosts; - int *dim = solver->gpu_dim_local; - double *x = solver->gpu_x; - double *dxinv = solver->gpu_dxinv; + int ghosts = solver->m_ghosts; + int *dim = solver->m_gpu_dim_local; + double *x = solver->m_gpu_x; + double *dxinv = solver->m_gpu_dxinv; double RT = param->p0 / param->rho0; static double grav[_MODEL_NDIMS_]; @@ -227,7 +227,7 @@ extern "C" int gpuNavierStokes3DSource( grav[_YDIR_] = param->grav_y; grav[_ZDIR_] = param->grav_z; - int nblocks = (solver->npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; for (dir = 0; dir < _MODEL_NDIMS_; dir++) { if (grav[dir] != 0.0) { /* calculate the split source function exp(-phi/RT) */ @@ -239,7 +239,7 @@ extern "C" int gpuNavierStokes3DSource( gpuNavierStokes3DSourceUpwind(SourceI,SourceL,SourceR,u,dir,solver,t); /* calculate the final cell-centered source term */ gpuNavierStokes3DSource_grav_kernel<<>>( - solver->npoints_local, ghosts, dir, param->gamma, RT, + solver->m_npoints_local, ghosts, dir, param->gamma, RT, dim, dxinv, param->gpu_grav_field_f, SourceI, u, source ); } @@ -365,10 +365,10 @@ int gpuNavierStokes3DSourceFunction( { HyPar *solver = (HyPar* ) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int nblocks = (solver->npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local_wghosts-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DSourceFunction_kernel<<>>( - solver->npoints_local_wghosts, solver->ghosts, dir, solver->gpu_dim_local, param->gpu_grav_field_g, f + solver->m_npoints_local_wghosts, solver->m_ghosts, dir, solver->m_gpu_dim_local, param->gpu_grav_field_g, f ); cudaDeviceSynchronize(); @@ -398,7 +398,7 @@ int gpuNavierStokes3DSourceUpwind( ) { HyPar *solver = (HyPar*) s; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_inter[_MODEL_NDIMS_]; _ArrayCopy1D_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; @@ -457,10 +457,10 @@ extern "C" int gpuNavierStokes3DSource( double *SourceL = solver->fL; double *SourceR = solver->fR; - int ghosts = solver->ghosts; - int *dim = solver->gpu_dim_local; - double *x = solver->gpu_x; - double *dxinv = solver->gpu_dxinv; + int ghosts = solver->m_ghosts; + int *dim = solver->m_gpu_dim_local; + double *x = solver->m_gpu_x; + double *dxinv = solver->m_gpu_dxinv; double RT = param->p0 / param->rho0; static double grav[_MODEL_NDIMS_]; @@ -468,11 +468,11 @@ extern "C" int gpuNavierStokes3DSource( grav[_YDIR_] = param->grav_y; grav[_ZDIR_] = param->grav_z; - int nblocks = (solver->npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; + int nblocks = (solver->m_npoints_local-1)/GPU_THREADS_PER_BLOCK + 1; for (dir = 0; dir < _MODEL_NDIMS_; dir++) { if (grav[dir] != 0.0) { int bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D_(solver->dim_local,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D_(solver->m_dim_local,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; int npoints_fluxI; _ArrayProduct1D_(bounds_inter,_MODEL_NDIMS_,npoints_fluxI); /* calculate the split source function exp(-phi/RT) */ @@ -484,7 +484,7 @@ extern "C" int gpuNavierStokes3DSource( gpuNavierStokes3DSourceUpwind(SourceI,SourceL,SourceR,u,dir,solver,t); /* calculate the final cell-centered source term */ gpuNavierStokes3DSource_grav_kernel<<>>( - solver->npoints_local, solver->npoints_local_wghosts, npoints_fluxI, + solver->m_npoints_local, solver->m_npoints_local_wghosts, npoints_fluxI, ghosts, dir, param->gamma, RT, dim, dxinv, param->gpu_grav_field_f, SourceI, u, source ); diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind.c b/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind.c index 5023107b..3cd0c966 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind.c +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind.c @@ -15,7 +15,7 @@ #include #endif -static const int dummy = 1; +static const int s_dummy = 1; /*! Roe's upwinding scheme. \f{equation}{ @@ -38,26 +38,26 @@ static const int dummy = 1; */ int NavierStokes3DUpwindRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x, y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x, y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -71,28 +71,28 @@ int NavierStokes3DUpwindRoe( while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); - udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); + udiff[4] = 0.5 * (a_uR[_MODEL_NVARS_*p+4] - a_uL[_MODEL_NVARS_*p+4]); - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DEigenvalues_ (uavg,dummy,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DEigenvalues_ (uavg,s_dummy,D,param->m_gamma,a_dir); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); - /* Harten's Entropy Fix - Page 362 of Leveque */ + /* Harten'a_s Entropy Fix - Page 362 of Leveque */ int k; double delta = 0.000001, delta2 = delta*delta; k=0; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); @@ -105,19 +105,19 @@ int NavierStokes3DUpwindRoe( MatMult5(_MODEL_NVARS_,modA,R,DL); MatVecMult5(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; - fI[_MODEL_NVARS_*p+4] = 0.5 * (fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4]) - udiss[4]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+4] = 0.5 * (a_fL[_MODEL_NVARS_*p+4]+a_fR[_MODEL_NVARS_*p+4]) - udiss[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } #if defined(CPU_STAT) stopEvent = clock(); - printf("%-50s CPU time (secs) = %.6f dir = %d\n", - "NavierStokes3DUpwindRoe", (double)(stopEvent-startEvent)/CLOCKS_PER_SEC, dir); + printf("%-50s CPU time (secs) = %.6f a_dir = %d\n", + "NavierStokes3DUpwindRoe", (double)(stopEvent-startEvent)/CLOCKS_PER_SEC, a_dir); #endif return(0); @@ -138,63 +138,63 @@ int NavierStokes3DUpwindRoe( Note that this upwinding scheme cannot be used for solving flows with non-zero gravitational forces. */ int NavierStokes3DUpwindRF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x, y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x, y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int done,k; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[3] = {0,0,0}, index_inter[3]; while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Roe-Fixed upwinding scheme */ - _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param->gamma); + _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param->m_gamma); - _NavierStokes3DLeftEigenvectors_(uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_(uavg,dummy,R,param->gamma,dir); + _NavierStokes3DLeftEigenvectors_(uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_(uavg,s_dummy,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult5(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult5(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult5(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult5(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[_MODEL_NVARS_],eigC[_MODEL_NVARS_],eigR[_MODEL_NVARS_]; - _NavierStokes3DEigenvalues_((uL+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->gamma,dir); + _NavierStokes3DEigenvalues_((a_uL+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->m_gamma,a_dir); eigL[0] = D[0]; eigL[1] = D[6]; eigL[2] = D[12]; eigL[3] = D[18]; eigL[4] = D[24]; - _NavierStokes3DEigenvalues_((uR+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->gamma,dir); + _NavierStokes3DEigenvalues_((a_uR+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->m_gamma,a_dir); eigR[0] = D[0]; eigR[1] = D[6]; eigR[2] = D[12]; eigR[3] = D[18]; eigR[4] = D[24]; - _NavierStokes3DEigenvalues_(uavg,dummy,D,param->gamma,dir); + _NavierStokes3DEigenvalues_(uavg,s_dummy,D,param->m_gamma,a_dir); eigC[0] = D[0]; eigC[1] = D[6]; eigC[2] = D[12]; @@ -211,7 +211,7 @@ int NavierStokes3DUpwindRF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult5(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult5(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -242,63 +242,63 @@ int NavierStokes3DUpwindRF( for Atmospheric Flows, 54 (4), 2016, pp. 1370-1385, http://dx.doi.org/10.2514/1.J054580 */ int NavierStokes3DUpwindLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x, y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x, y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; int index_outer[3] = {0,0,0}, index_inter[3]; while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double uavg[_MODEL_NVARS_], fcL[_MODEL_NVARS_], fcR[_MODEL_NVARS_], ucL[_MODEL_NVARS_], ucR[_MODEL_NVARS_], fc[_MODEL_NVARS_]; /* Local Lax-Friedrich upwinding scheme */ - _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,(uL+_MODEL_NVARS_*p),(uR+_MODEL_NVARS_*p),param->gamma); + _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,(a_uL+_MODEL_NVARS_*p),(a_uR+_MODEL_NVARS_*p),param->m_gamma); - _NavierStokes3DLeftEigenvectors_(uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_(uavg,dummy,R,param->gamma,dir); + _NavierStokes3DLeftEigenvectors_(uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_(uavg,s_dummy,R,param->m_gamma,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult5(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult5(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult5(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult5(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult5(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); double eigL[_MODEL_NVARS_],eigC[_MODEL_NVARS_],eigR[_MODEL_NVARS_]; - _NavierStokes3DEigenvalues_((uL+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->gamma,dir); + _NavierStokes3DEigenvalues_((a_uL+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->m_gamma,a_dir); eigL[0] = D[0]; eigL[1] = D[6]; eigL[2] = D[12]; eigL[3] = D[18]; eigL[4] = D[24]; - _NavierStokes3DEigenvalues_((uR+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->gamma,dir); + _NavierStokes3DEigenvalues_((a_uR+_MODEL_NVARS_*p),_NavierStokes3D_stride_,D,param->m_gamma,a_dir); eigR[0] = D[0]; eigR[1] = D[6]; eigR[2] = D[12]; eigR[3] = D[18]; eigR[4] = D[24]; - _NavierStokes3DEigenvalues_(uavg,dummy,D,param->gamma,dir); + _NavierStokes3DEigenvalues_(uavg,s_dummy,D,param->m_gamma,a_dir); eigC[0] = D[0]; eigC[1] = D[6]; eigC[2] = D[12]; @@ -318,7 +318,7 @@ int NavierStokes3DUpwindLLF( fc[4] = 0.5 * (fcL[4] + fcR[4] + alpha * (ucL[4]-ucR[4])); /* calculate the interface flux from the characteristic flux */ - MatVecMult5(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult5(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -347,24 +347,24 @@ int NavierStokes3DUpwindLLF( */ int NavierStokes3DUpwindRusanov( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x,y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x,y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local, done; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local, done; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[a_dir]++; static double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_]; @@ -374,44 +374,44 @@ int NavierStokes3DUpwindRusanov( done = 0; _ArraySetValue_(index_outer,_MODEL_NDIMS_,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); int q = p*_MODEL_NVARS_; - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[q+0] - uL[q+0]); - udiff[1] = 0.5 * (uR[q+1] - uL[q+1]); - udiff[2] = 0.5 * (uR[q+2] - uL[q+2]); - udiff[3] = 0.5 * (uR[q+3] - uL[q+3]); - udiff[4] = 0.5 * (uR[q+4] - uL[q+4]); + udiff[0] = 0.5 * (a_uR[q+0] - a_uL[q+0]); + udiff[1] = 0.5 * (a_uR[q+1] - a_uL[q+1]); + udiff[2] = 0.5 * (a_uR[q+2] - a_uL[q+2]); + udiff[3] = 0.5 * (a_uR[q+3] - a_uL[q+3]); + udiff[4] = 0.5 * (a_uR[q+4] - a_uL[q+4]); - _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); + _NavierStokes3DRoeAverage_(uavg,_NavierStokes3D_stride_,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); double c, vel[_MODEL_NDIMS_], rho,E,P; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaL = c + absolute(vel[dir]); - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaR = c + absolute(vel[dir]); - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaavg = c + absolute(vel[dir]); - - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaL = c + absolute(vel[a_dir]); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaR = c + absolute(vel[a_dir]); + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaavg = c + absolute(vel[a_dir]); + + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); - fI[q+0] = 0.5*(fL[q+0]+fR[q+0])-alpha*udiff[0]; - fI[q+1] = 0.5*(fL[q+1]+fR[q+1])-alpha*udiff[1]; - fI[q+2] = 0.5*(fL[q+2]+fR[q+2])-alpha*udiff[2]; - fI[q+3] = 0.5*(fL[q+3]+fR[q+3])-alpha*udiff[3]; - fI[q+4] = 0.5*(fL[q+4]+fR[q+4])-alpha*udiff[4]; + a_fI[q+0] = 0.5*(a_fL[q+0]+a_fR[q+0])-alpha*udiff[0]; + a_fI[q+1] = 0.5*(a_fL[q+1]+a_fR[q+1])-alpha*udiff[1]; + a_fI[q+2] = 0.5*(a_fL[q+2]+a_fR[q+2])-alpha*udiff[2]; + a_fI[q+3] = 0.5*(a_fL[q+3]+a_fR[q+3])-alpha*udiff[3]; + a_fI[q+4] = 0.5*(a_fL[q+4]+a_fR[q+4])-alpha*udiff[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -428,27 +428,27 @@ int NavierStokes3DUpwindRusanov( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes3DUpwinddFRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x, y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x, y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -456,43 +456,43 @@ int NavierStokes3DUpwinddFRoe( done = 0; int index_outer[3] = {0,0,0}, index_inter[3]; while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); - udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); + udiff[4] = 0.5 * (a_uR[_MODEL_NVARS_*p+4] - a_uL[_MODEL_NVARS_*p+4]); - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DEigenvalues_ (uavg,dummy,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DEigenvalues_ (uavg,s_dummy,D,param->m_gamma,a_dir); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); - /* Harten's Entropy Fix - Page 362 of Leveque */ + /* Harten'a_s Entropy Fix - Page 362 of Leveque */ int k; double delta = 0.000001, delta2 = delta*delta; - if (dir == _XDIR_) { + if (a_dir == _XDIR_) { k=0; D[k] = 0.0; k=6; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=12; D[k] = 0.0; k=18; D[k] = 0.0; k=24; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); - } else if (dir == _YDIR_) { + } else if (a_dir == _YDIR_) { k=0; D[k] = 0.0; k=6; D[k] = 0.0; k=12; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=18; D[k] = 0.0; k=24; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); - } else if (dir == _ZDIR_) { + } else if (a_dir == _ZDIR_) { k=0; D[k] = 0.0; k=6; D[k] = 0.0; k=12; D[k] = 0.0; @@ -504,11 +504,11 @@ int NavierStokes3DUpwinddFRoe( MatMult5(_MODEL_NVARS_,modA,R,DL); MatVecMult5(_MODEL_NVARS_,udiss,modA,udiff); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; - fI[_MODEL_NVARS_*p+4] = 0.5 * (fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4]) - udiss[4]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+4] = 0.5 * (a_fL[_MODEL_NVARS_*p+4]+a_fR[_MODEL_NVARS_*p+4]) - udiss[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -525,27 +525,27 @@ int NavierStokes3DUpwinddFRoe( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes3DUpwindFdFRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x, y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x, y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; int done; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; double *uref = param->solution; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; @@ -553,30 +553,30 @@ int NavierStokes3DUpwindFdFRoe( done = 0; int index_outer[3] = {0,0,0}, index_inter[3]; while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + int indexL[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; int indexR[_MODEL_NDIMS_]; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); int k; double udiff[_MODEL_NVARS_],uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_], udiss_total[_MODEL_NVARS_],udiss_stiff[_MODEL_NVARS_]; double delta = 0.000001, delta2 = delta*delta; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); - udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); + udiff[4] = 0.5 * (a_uR[_MODEL_NVARS_*p+4] - a_uL[_MODEL_NVARS_*p+4]); /* Compute total dissipation */ - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DEigenvalues_ (uavg,dummy,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DEigenvalues_ (uavg,s_dummy,D,param->m_gamma,a_dir); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); k=0; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=6; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=12; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); @@ -587,23 +587,23 @@ int NavierStokes3DUpwindFdFRoe( MatVecMult5(_MODEL_NVARS_,udiss_total,modA,udiff); /* Compute dissipation corresponding to acoustic modes */ - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DEigenvalues_ (uavg,dummy,D,param->gamma,dir); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); - if (dir == _XDIR_) { + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DEigenvalues_ (uavg,s_dummy,D,param->m_gamma,a_dir); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); + if (a_dir == _XDIR_) { k=0; D[k] = 0.0; k=6; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=12; D[k] = 0.0; k=18; D[k] = 0.0; k=24; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); - } else if (dir == _YDIR_) { + } else if (a_dir == _YDIR_) { k=0; D[k] = 0.0; k=6; D[k] = 0.0; k=12; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); k=18; D[k] = 0.0; k=24; D[k] = (absolute(D[k]) < delta ? (D[k]*D[k]+delta2)/(2*delta) : absolute(D[k]) ); - } else if (dir == _ZDIR_) { + } else if (a_dir == _ZDIR_) { k=0; D[k] = 0.0; k=6; D[k] = 0.0; k=12; D[k] = 0.0; @@ -617,11 +617,11 @@ int NavierStokes3DUpwindFdFRoe( /* Compute the dissipation term for the entropy modes */ _ArraySubtract1D_(udiss,udiss_total,udiss_stiff,_MODEL_NVARS_); - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; - fI[_MODEL_NVARS_*p+3] = 0.5 * (fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3]) - udiss[3]; - fI[_MODEL_NVARS_*p+4] = 0.5 * (fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4]) - udiss[4]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5 * (a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3]) - udiss[3]; + a_fI[_MODEL_NVARS_*p+4] = 0.5 * (a_fL[_MODEL_NVARS_*p+4]+a_fR[_MODEL_NVARS_*p+4]) - udiss[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -636,24 +636,24 @@ int NavierStokes3DUpwindFdFRoe( */ int NavierStokes3DUpwindRusanovModified( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x,y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x,y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local, done; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local, done; static int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], @@ -667,62 +667,62 @@ int NavierStokes3DUpwindRusanovModified( done = 0; _ArraySetValue_(index_outer,_MODEL_NDIMS_,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); int q = p*_MODEL_NVARS_; - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[q+0] - uL[q+0]); - udiff[1] = 0.5 * (uR[q+1] - uL[q+1]); - udiff[2] = 0.5 * (uR[q+2] - uL[q+2]); - udiff[3] = 0.5 * (uR[q+3] - uL[q+3]); - udiff[4] = 0.5 * (uR[q+4] - uL[q+4]); + udiff[0] = 0.5 * (a_uR[q+0] - a_uL[q+0]); + udiff[1] = 0.5 * (a_uR[q+1] - a_uL[q+1]); + udiff[2] = 0.5 * (a_uR[q+2] - a_uL[q+2]); + udiff[3] = 0.5 * (a_uR[q+3] - a_uL[q+3]); + udiff[4] = 0.5 * (a_uR[q+4] - a_uL[q+4]); - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); double c, vel[_MODEL_NDIMS_], rho,E,P; - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaL = c + absolute(vel[dir]); - double betaL = absolute(vel[dir]); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaL = c + absolute(vel[a_dir]); + double betaL = absolute(vel[a_dir]); - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaR = c + absolute(vel[dir]); - double betaR = absolute(vel[dir]); + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaR = c + absolute(vel[a_dir]); + double betaR = absolute(vel[a_dir]); - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaavg = c + absolute(vel[dir]); - double betaavg = absolute(vel[dir]); + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaavg = c + absolute(vel[a_dir]); + double betaavg = absolute(vel[a_dir]); - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); double beta = kappa*max3(betaL,betaR,betaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); - if (dir == _XDIR_) { + if (a_dir == _XDIR_) { D[0] = beta; D[6] = alpha; D[12] = beta; D[18] = beta; D[24] = alpha; - } else if (dir == _YDIR_) { + } else if (a_dir == _YDIR_) { D[0] = beta; D[6] = beta; D[12] = alpha; D[18] = beta; D[24] = alpha; - } else if (dir == _ZDIR_) { + } else if (a_dir == _ZDIR_) { D[0] = beta; D[6] = beta; D[12] = beta; @@ -733,11 +733,11 @@ int NavierStokes3DUpwindRusanovModified( MatMult5 (_MODEL_NVARS_,modA,R,DL); MatVecMult5 (_MODEL_NVARS_,udiss,modA,udiff); - fI[q+0] = 0.5*(fL[q+0]+fR[q+0])-udiss[0]; - fI[q+1] = 0.5*(fL[q+1]+fR[q+1])-udiss[1]; - fI[q+2] = 0.5*(fL[q+2]+fR[q+2])-udiss[2]; - fI[q+3] = 0.5*(fL[q+3]+fR[q+3])-udiss[3]; - fI[q+4] = 0.5*(fL[q+4]+fR[q+4])-udiss[4]; + a_fI[q+0] = 0.5*(a_fL[q+0]+a_fR[q+0])-udiss[0]; + a_fI[q+1] = 0.5*(a_fL[q+1]+a_fR[q+1])-udiss[1]; + a_fI[q+2] = 0.5*(a_fL[q+2]+a_fR[q+2])-udiss[2]; + a_fI[q+3] = 0.5*(a_fL[q+3]+a_fR[q+3])-udiss[3]; + a_fI[q+4] = 0.5*(a_fL[q+4]+a_fR[q+4])-udiss[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -754,25 +754,25 @@ int NavierStokes3DUpwindRusanovModified( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes3DUpwinddFRusanovModified( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x,y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x,y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local, done; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local, done; double *uref = param->solution; static int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], @@ -786,52 +786,52 @@ int NavierStokes3DUpwinddFRusanovModified( done = 0; _ArraySetValue_(index_outer,_MODEL_NDIMS_,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); int q = p*_MODEL_NVARS_; - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[q+0] - uL[q+0]); - udiff[1] = 0.5 * (uR[q+1] - uL[q+1]); - udiff[2] = 0.5 * (uR[q+2] - uL[q+2]); - udiff[3] = 0.5 * (uR[q+3] - uL[q+3]); - udiff[4] = 0.5 * (uR[q+4] - uL[q+4]); + udiff[0] = 0.5 * (a_uR[q+0] - a_uL[q+0]); + udiff[1] = 0.5 * (a_uR[q+1] - a_uL[q+1]); + udiff[2] = 0.5 * (a_uR[q+2] - a_uL[q+2]); + udiff[3] = 0.5 * (a_uR[q+3] - a_uL[q+3]); + udiff[4] = 0.5 * (a_uR[q+4] - a_uL[q+4]); - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); double c, vel[_MODEL_NDIMS_], rho,E,P; - _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaL = c + absolute(vel[dir]); + _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaL = c + absolute(vel[a_dir]); - _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaR = c + absolute(vel[dir]); + _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaR = c + absolute(vel[a_dir]); - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - double alphaavg = c + absolute(vel[dir]); + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + double alphaavg = c + absolute(vel[a_dir]); - double kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + double kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); double alpha = kappa*max3(alphaL,alphaR,alphaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); - if (dir == _XDIR_) { + if (a_dir == _XDIR_) { D[6] = alpha; D[24] = alpha; - } else if (dir == _YDIR_) { + } else if (a_dir == _YDIR_) { D[12] = alpha; D[24] = alpha; - } else if (dir == _ZDIR_) { + } else if (a_dir == _ZDIR_) { D[18] = alpha; D[24] = alpha; } @@ -839,11 +839,11 @@ int NavierStokes3DUpwinddFRusanovModified( MatMult5 (_MODEL_NVARS_,modA,R,DL); MatVecMult5 (_MODEL_NVARS_,udiss,modA,udiff); - fI[q+0] = 0.5*(fL[q+0]+fR[q+0])-udiss[0]; - fI[q+1] = 0.5*(fL[q+1]+fR[q+1])-udiss[1]; - fI[q+2] = 0.5*(fL[q+2]+fR[q+2])-udiss[2]; - fI[q+3] = 0.5*(fL[q+3]+fR[q+3])-udiss[3]; - fI[q+4] = 0.5*(fL[q+4]+fR[q+4])-udiss[4]; + a_fI[q+0] = 0.5*(a_fL[q+0]+a_fR[q+0])-udiss[0]; + a_fI[q+1] = 0.5*(a_fL[q+1]+a_fR[q+1])-udiss[1]; + a_fI[q+2] = 0.5*(a_fL[q+2]+a_fR[q+2])-udiss[2]; + a_fI[q+3] = 0.5*(a_fL[q+3]+a_fR[q+3])-udiss[3]; + a_fI[q+4] = 0.5*(a_fL[q+4]+a_fR[q+4])-udiss[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -860,25 +860,25 @@ int NavierStokes3DUpwinddFRusanovModified( 38 (3), 2016, A1848-A1875, http://dx.doi.org/10.1137/15M1044369. */ int NavierStokes3DUpwindFdFRusanovModified( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (x,y, or z) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (x,y, or z) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local, done; + HyPar *solver = (HyPar*) a_s; + NavierStokes3D *param = (NavierStokes3D*) solver->m_physics; + int *dim = solver->m_dim_local, done; double *uref = param->solution; static int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[dir] = 1; - bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[dir]++; + bounds_outer[0] = dim[0]; bounds_outer[1] = dim[1]; bounds_outer[2] = dim[2]; bounds_outer[a_dir] = 1; + bounds_inter[0] = dim[0]; bounds_inter[1] = dim[1]; bounds_inter[2] = dim[2]; bounds_inter[a_dir]++; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], @@ -892,67 +892,67 @@ int NavierStokes3DUpwindFdFRusanovModified( done = 0; _ArraySetValue_(index_outer,_MODEL_NDIMS_,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); - _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[dir]--; + _ArrayCopy1D_(index_inter,indexL,_MODEL_NDIMS_); indexL[a_dir]--; _ArrayCopy1D_(index_inter,indexR,_MODEL_NDIMS_); - int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->ghosts,pL); - int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->ghosts,pR); + int pL; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexL,solver->m_ghosts,pL); + int pR; _ArrayIndex1D_(_MODEL_NDIMS_,dim,indexR,solver->m_ghosts,pR); int q = p*_MODEL_NVARS_; double udiff[_MODEL_NVARS_], udiss[_MODEL_NVARS_], uavg[_MODEL_NVARS_], udiss_total[_MODEL_NVARS_],udiss_acoustic[_MODEL_NVARS_]; - /* Modified Rusanov's upwinding scheme */ - /* Modified Rusanov's upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ + /* Modified Rusanov'a_s upwinding scheme */ double c, vel[_MODEL_NDIMS_], rho,E,P, alphaL, alphaR, alphaavg, betaL, betaR, betaavg, alpha, beta, - kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); - udiff[0] = 0.5 * (uR[q+0] - uL[q+0]); - udiff[1] = 0.5 * (uR[q+1] - uL[q+1]); - udiff[2] = 0.5 * (uR[q+2] - uL[q+2]); - udiff[3] = 0.5 * (uR[q+3] - uL[q+3]); - udiff[4] = 0.5 * (uR[q+4] - uL[q+4]); + udiff[0] = 0.5 * (a_uR[q+0] - a_uL[q+0]); + udiff[1] = 0.5 * (a_uR[q+1] - a_uL[q+1]); + udiff[2] = 0.5 * (a_uR[q+2] - a_uL[q+2]); + udiff[3] = 0.5 * (a_uR[q+3] - a_uL[q+3]); + udiff[4] = 0.5 * (a_uR[q+4] - a_uL[q+4]); /* Compute total dissipation */ - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); - - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaL = c + absolute(vel[dir]); - betaL = absolute(vel[dir]); - - _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaR = c + absolute(vel[dir]); - betaR = absolute(vel[dir]); - - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaavg = c + absolute(vel[dir]); - betaavg = absolute(vel[dir]); - - kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); + + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaL = c + absolute(vel[a_dir]); + betaL = absolute(vel[a_dir]); + + _NavierStokes3DGetFlowVar_((a_u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaR = c + absolute(vel[a_dir]); + betaR = absolute(vel[a_dir]); + + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaavg = c + absolute(vel[a_dir]); + betaavg = absolute(vel[a_dir]); + + kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); alpha = kappa*max3(alphaL,alphaR,alphaavg); beta = kappa*max3(betaL,betaR,betaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); - if (dir == _XDIR_) { + if (a_dir == _XDIR_) { D[0] = beta; D[6] = alpha; D[12] = beta; D[18] = beta; D[24] = alpha; - } else if (dir == _YDIR_) { + } else if (a_dir == _YDIR_) { D[0] = beta; D[6] = beta; D[12] = alpha; D[18] = beta; D[24] = alpha; - } else if (dir == _ZDIR_) { + } else if (a_dir == _ZDIR_) { D[0] = beta; D[6] = beta; D[12] = beta; @@ -964,33 +964,33 @@ int NavierStokes3DUpwindFdFRusanovModified( MatVecMult5 (_MODEL_NVARS_,udiss_total,modA,udiff); /* Compute dissipation for the linearized acoustic modes */ - _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->gamma); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,param->gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,param->gamma,dir); + _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(uref+_MODEL_NVARS_*pL),(uref+_MODEL_NVARS_*pR),param->m_gamma); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,param->m_gamma,a_dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,param->m_gamma,a_dir); - _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaL = c + absolute(vel[dir]); + _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pL),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaL = c + absolute(vel[a_dir]); - _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaR = c + absolute(vel[dir]); + _NavierStokes3DGetFlowVar_((uref+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaR = c + absolute(vel[a_dir]); - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,param->gamma); - c = sqrt(param->gamma*P/rho); - alphaavg = c + absolute(vel[dir]); + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,param->m_gamma); + c = sqrt(param->m_gamma*P/rho); + alphaavg = c + absolute(vel[a_dir]); - kappa = max(param->grav_field_g[pL],param->grav_field_g[pR]); + kappa = max(param->m_grav_field_g[pL],param->m_grav_field_g[pR]); alpha = kappa*max3(alphaL,alphaR,alphaavg); _ArraySetValue_(D,_MODEL_NVARS_*_MODEL_NVARS_,0.0); - if (dir == _XDIR_) { + if (a_dir == _XDIR_) { D[6] = alpha; D[24] = alpha; - } else if (dir == _YDIR_) { + } else if (a_dir == _YDIR_) { D[12] = alpha; D[24] = alpha; - } else if (dir == _ZDIR_) { + } else if (a_dir == _ZDIR_) { D[18] = alpha; D[24] = alpha; } @@ -1001,11 +1001,11 @@ int NavierStokes3DUpwindFdFRusanovModified( /* Compute dissipation for the entropy modes */ _ArraySubtract1D_(udiss,udiss_total,udiss_acoustic,_MODEL_NVARS_); - fI[q+0] = 0.5*(fL[q+0]+fR[q+0])-udiss[0]; - fI[q+1] = 0.5*(fL[q+1]+fR[q+1])-udiss[1]; - fI[q+2] = 0.5*(fL[q+2]+fR[q+2])-udiss[2]; - fI[q+3] = 0.5*(fL[q+3]+fR[q+3])-udiss[3]; - fI[q+4] = 0.5*(fL[q+4]+fR[q+4])-udiss[4]; + a_fI[q+0] = 0.5*(a_fL[q+0]+a_fR[q+0])-udiss[0]; + a_fI[q+1] = 0.5*(a_fL[q+1]+a_fR[q+1])-udiss[1]; + a_fI[q+2] = 0.5*(a_fL[q+2]+a_fR[q+2])-udiss[2]; + a_fI[q+3] = 0.5*(a_fL[q+3]+a_fR[q+3])-udiss[3]; + a_fI[q+4] = 0.5*(a_fL[q+4]+a_fR[q+4])-udiss[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind_GPU.cu b/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind_GPU.cu index d0531603..f1821894 100644 --- a/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind_GPU.cu +++ b/src/PhysicalModels/NavierStokes3D/NavierStokes3DUpwind_GPU.cu @@ -10,7 +10,7 @@ #include #include -static const int dummy = 1; +static const int s_dummy = 1; #ifdef CUDA_VAR_ORDERDING_AOS @@ -63,7 +63,7 @@ void gpuNavierStokes3DUpwindRusanov_kernel( _NavierStokes3DGetFlowVar_((u+_MODEL_NVARS_*pR),_NavierStokes3D_stride_,rho,vel[0],vel[1],vel[2],E,P,gamma); c = sqrt(gamma*P/rho); double alphaR = c + absolute(vel[dir]); - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,gamma); + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,gamma); c = sqrt(gamma*P/rho); double alphaavg = c + absolute(vel[dir]); @@ -113,7 +113,7 @@ extern "C" int gpuNavierStokes3DUpwindRusanov( { HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_inter[_MODEL_NDIMS_]; _ArrayCopy1D_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; @@ -121,7 +121,7 @@ extern "C" int gpuNavierStokes3DUpwindRusanov( int nblocks = (npoints_grid-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DUpwindRusanov_kernel<<>>( - npoints_grid, dir, solver->ghosts, param->gamma, solver->gpu_dim_local, + npoints_grid, dir, solver->m_ghosts, param->gamma, solver->m_gpu_dim_local, param->gpu_grav_field_g, fL, fR, uL, uR, u, fI ); cudaDeviceSynchronize(); @@ -174,9 +174,9 @@ void gpuNavierStokes3DUpwindRoe_kernel( udiff[4] = 0.5 * (uR[p+4] - uL[p+4]); _NavierStokes3DRoeAverage_ (uavg,_NavierStokes3D_stride_,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),gamma); - _NavierStokes3DEigenvalues_ (uavg,dummy,D,gamma,dir); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,gamma,dir); + _NavierStokes3DEigenvalues_ (uavg,s_dummy,D,gamma,dir); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,gamma,dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,gamma,dir); /* Harten's Entropy Fix - Page 362 of Leveque */ int k; @@ -234,7 +234,7 @@ extern "C" int gpuNavierStokes3DUpwindRoe( { HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_inter[_MODEL_NDIMS_]; _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; @@ -242,7 +242,7 @@ extern "C" int gpuNavierStokes3DUpwindRoe( int nblocks = (npoints_grid-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DUpwindRoe_kernel<<>>( - npoints_grid, dir, solver->ghosts, param->gamma, solver->gpu_dim_local, + npoints_grid, dir, solver->m_ghosts, param->gamma, solver->m_gpu_dim_local, param->gpu_grav_field_g, fL, fR, uL, uR, u, fI ); cudaDeviceSynchronize(); @@ -301,7 +301,7 @@ void gpuNavierStokes3DUpwindRusanov_kernel( _NavierStokes3DGetFlowVar_((u+pR),npoints_local_wghosts,rho,vel[0],vel[1],vel[2],E,P,gamma); c = sqrt(gamma*P/rho); double alphaR = c + absolute(vel[dir]); - _NavierStokes3DGetFlowVar_(uavg,dummy,rho,vel[0],vel[1],vel[2],E,P,gamma); + _NavierStokes3DGetFlowVar_(uavg,s_dummy,rho,vel[0],vel[1],vel[2],E,P,gamma); c = sqrt(gamma*P/rho); double alphaavg = c + absolute(vel[dir]); @@ -351,7 +351,7 @@ extern "C" int gpuNavierStokes3DUpwindRusanov( { HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_inter[_MODEL_NDIMS_]; _ArrayCopy1D_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; @@ -359,7 +359,7 @@ extern "C" int gpuNavierStokes3DUpwindRusanov( int nblocks = (npoints_grid-1)/GPU_THREADS_PER_BLOCK + 1; gpuNavierStokes3DUpwindRusanov_kernel<<>>( - npoints_grid, solver->npoints_local_wghosts, dir, solver->ghosts, param->gamma, solver->gpu_dim_local, + npoints_grid, solver->m_npoints_local_wghosts, dir, solver->m_ghosts, param->gamma, solver->m_gpu_dim_local, param->gpu_grav_field_g, fL, fR, uL, uR, u, fI ); cudaDeviceSynchronize(); @@ -411,9 +411,9 @@ void gpuNavierStokes3DUpwindRoe_kernel( udiff[4] = 0.5 * (uR[p+4*npoints_grid] - uL[p+4*npoints_grid]); _NavierStokes3DRoeAverage_ (uavg,npoints_local_wghosts,(u+pL),(u+pR),gamma); - _NavierStokes3DEigenvalues_ (uavg,dummy,D,gamma,dir); - _NavierStokes3DLeftEigenvectors_ (uavg,dummy,L,gamma,dir); - _NavierStokes3DRightEigenvectors_ (uavg,dummy,R,gamma,dir); + _NavierStokes3DEigenvalues_ (uavg,s_dummy,D,gamma,dir); + _NavierStokes3DLeftEigenvectors_ (uavg,s_dummy,L,gamma,dir); + _NavierStokes3DRightEigenvectors_ (uavg,s_dummy,R,gamma,dir); /* Harten's Entropy Fix - Page 362 of Leveque */ int k; @@ -471,7 +471,7 @@ extern "C" int gpuNavierStokes3DUpwindRoe( { HyPar *solver = (HyPar*) s; NavierStokes3D *param = (NavierStokes3D*) solver->physics; - int *dim = solver->dim_local; + int *dim = solver->m_dim_local; int bounds_inter[_MODEL_NDIMS_]; _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; @@ -488,7 +488,7 @@ extern "C" int gpuNavierStokes3DUpwindRoe( #endif gpuNavierStokes3DUpwindRoe_kernel<<>>( - npoints_grid, solver->npoints_local_wghosts, dir, solver->ghosts, param->gamma, solver->gpu_dim_local, + npoints_grid, solver->m_npoints_local_wghosts, dir, solver->m_ghosts, param->gamma, solver->m_gpu_dim_local, param->gpu_grav_field_g, fL, fR, uL, uR, u, fI ); diff --git a/src/PhysicalModels/Numa2D/Numa2DCleanup.c b/src/PhysicalModels/Numa2D/Numa2DCleanup.c index 392f0b1c..c4e3b7be 100644 --- a/src/PhysicalModels/Numa2D/Numa2DCleanup.c +++ b/src/PhysicalModels/Numa2D/Numa2DCleanup.c @@ -2,7 +2,7 @@ #include #include -int Numa2DCleanup(void *s) +int Numa2DCleanup(void *a_s) { return(0); } diff --git a/src/PhysicalModels/Numa2D/Numa2DComputeCFL.c b/src/PhysicalModels/Numa2D/Numa2DComputeCFL.c index 05b92f89..0dac9a63 100644 --- a/src/PhysicalModels/Numa2D/Numa2DComputeCFL.c +++ b/src/PhysicalModels/Numa2D/Numa2DComputeCFL.c @@ -6,15 +6,15 @@ #include #include -double Numa2DComputeCFL(void *s,void *m,double dt,double t) +double Numa2DComputeCFL(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - Numa2D *param = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa2D *param = (Numa2D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - double *u = solver->u; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + double *u = solver->m_u; int index[ndims]; double max_cfl = 0; @@ -23,18 +23,18 @@ double Numa2DComputeCFL(void *s,void *m,double dt,double t) int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double drho,uvel,vvel,dT,rho0,T0,P0,EP,c,ycoord; - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->x,ycoord); + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_x,ycoord); param->StandardAtmosphere (param,ycoord,&EP,&P0,&rho0,&T0); _Numa2DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); - _Numa2DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c); + _Numa2DComputeSpeedofSound_ (param->m_gamma,param->m_R,T0,dT,rho0,drho,EP,c); double dxinv, dyinv; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */ + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); /* 1/dy */ double local_cfl[2]; - local_cfl[_XDIR_] = (absolute(uvel)+c)*dt*dxinv; /* local cfl for this grid point (x) */ - local_cfl[_YDIR_] = (absolute(vvel)+c)*dt*dyinv; /* local cfl for this grid point (y) */ + local_cfl[_XDIR_] = (absolute(uvel)+c)*a_dt*dxinv; /* local cfl for this grid point (x) */ + local_cfl[_YDIR_] = (absolute(vvel)+c)*a_dt*dyinv; /* local cfl for this grid point (y) */ if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_]; if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_]; diff --git a/src/PhysicalModels/Numa2D/Numa2DFlux.c b/src/PhysicalModels/Numa2D/Numa2DFlux.c index 1f1ff3b7..a2754b60 100644 --- a/src/PhysicalModels/Numa2D/Numa2DFlux.c +++ b/src/PhysicalModels/Numa2D/Numa2DFlux.c @@ -4,15 +4,15 @@ #include #include -int Numa2DFlux(double *f,double *u,int dir,void *s,double t) +int Numa2DFlux(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa2D *param = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa2D *param = (Numa2D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -27,12 +27,12 @@ int Numa2DFlux(double *f,double *u,int dir,void *s,double t) int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double drho,uvel,vvel,dT,dP,rho0,T0,P0,EP,ycoord; - _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); param->StandardAtmosphere(param,ycoord,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); + _Numa2DGetFlowVars_ ((a_u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); _Numa2DComputePressure_ (param,T0,dT,P0,dP); - _Numa2DSetFlux_ ((f+_MODEL_NVARS_*p),dir,drho,uvel,vvel,dT,dP,rho0,T0); + _Numa2DSetFlux_ ((a_f+_MODEL_NVARS_*p),a_dir,drho,uvel,vvel,dT,dP,rho0,T0); _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -40,15 +40,15 @@ int Numa2DFlux(double *f,double *u,int dir,void *s,double t) return(0); } -int Numa2DStiffFlux(double *f,double *u,int dir,void *s,double t) +int Numa2DStiffFlux(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa2D *param = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa2D *param = (Numa2D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -63,12 +63,12 @@ int Numa2DStiffFlux(double *f,double *u,int dir,void *s,double t) int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double drho,uvel,vvel,dT,dP,rho0,T0,P0,EP,ycoord; - _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); param->StandardAtmosphere(param,ycoord,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); + _Numa2DGetFlowVars_ ((a_u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); _Numa2DComputeLinearizedPressure_ (param,T0,dT,P0,dP); - _Numa2DSetLinearFlux_ ((f+_MODEL_NVARS_*p),dir,drho,uvel,vvel,dT,dP,rho0,T0); + _Numa2DSetLinearFlux_ ((a_f+_MODEL_NVARS_*p),a_dir,drho,uvel,vvel,dT,dP,rho0,T0); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Numa2D/Numa2DFunctions.c b/src/PhysicalModels/Numa2D/Numa2DFunctions.c index cc22c0d8..4ad07534 100644 --- a/src/PhysicalModels/Numa2D/Numa2DFunctions.c +++ b/src/PhysicalModels/Numa2D/Numa2DFunctions.c @@ -2,13 +2,13 @@ #include #include -int Numa2DCalculateStandardAtmosphere_1(void *p,double z,double *ExnerP,double *P,double *rho,double *T) +int Numa2DCalculateStandardAtmosphere_1(void *a_p,double a_z,double *a_ExnerP,double *a_P,double *a_rho,double *a_T) { - Numa2D *physics = (Numa2D*) p; + Numa2D *physics = (Numa2D*) a_p; - double R = physics->R; - double gamma = physics->gamma; - double g = physics->g; + double R = physics->m_R; + double gamma = physics->m_gamma; + double g = physics->m_g; /* reference quantities at zero altitude */ double P0, T0; @@ -19,21 +19,21 @@ int Numa2DCalculateStandardAtmosphere_1(void *p,double z,double *ExnerP,double * double Cp = gamma * inv_gamma_m1 * R; double theta = T0; - *ExnerP = 1.0 - (g/(Cp*theta))*z; - *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1); - *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1); - *T = (*rho) * theta; + *a_ExnerP = 1.0 - (g/(Cp*theta))*a_z; + *a_P = P0 * raiseto((*a_ExnerP),gamma*inv_gamma_m1); + *a_rho = (P0/(R*theta)) * raiseto((*a_ExnerP),inv_gamma_m1); + *a_T = (*a_rho) * theta; return(0); } -int Numa2DCalculateStandardAtmosphere_2(void *p,double z,double *ExnerP,double *P,double *rho,double *T) +int Numa2DCalculateStandardAtmosphere_2(void *a_p,double a_z,double *a_ExnerP,double *a_P,double *a_rho,double *a_T) { - Numa2D *physics = (Numa2D*) p; + Numa2D *physics = (Numa2D*) a_p; - double R = physics->R; - double gamma = physics->gamma; - double g = physics->g; + double R = physics->m_R; + double gamma = physics->m_gamma; + double g = physics->m_g; /* reference quantities at zero altitude */ double P0, T0; @@ -44,12 +44,12 @@ int Numa2DCalculateStandardAtmosphere_2(void *p,double z,double *ExnerP,double * double inv_gamma_m1 = 1.0/(gamma-1.0); double Cp = gamma * inv_gamma_m1 * R; - double term = BV*BV*z/g; + double term = BV*BV*a_z/g; double theta = T0 * exp(term); - *ExnerP = 1.0 + (g*g/(Cp*T0*BV*BV)) * (exp(-term) - 1.0); - *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1); - *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1); - *T = (*rho) * theta; + *a_ExnerP = 1.0 + (g*g/(Cp*T0*BV*BV)) * (exp(-term) - 1.0); + *a_P = P0 * raiseto((*a_ExnerP),gamma*inv_gamma_m1); + *a_rho = (P0/(R*theta)) * raiseto((*a_ExnerP),inv_gamma_m1); + *a_T = (*a_rho) * theta; return(0); } diff --git a/src/PhysicalModels/Numa2D/Numa2DInitialize.c b/src/PhysicalModels/Numa2D/Numa2DInitialize.c index 1cb58991..e6cabb96 100644 --- a/src/PhysicalModels/Numa2D/Numa2DInitialize.c +++ b/src/PhysicalModels/Numa2D/Numa2DInitialize.c @@ -22,42 +22,42 @@ int Numa2DRusanovLinearFlux(double*,double*,double*,double*,double*,double*,i void Numa2DCalculateStandardAtmosphere_1(void*,double,double*,double*,double*,double*); void Numa2DCalculateStandardAtmosphere_2(void*,double,double*,double*,double*,double*); -int Numa2DInitialize(void *s,void *m) +int Numa2DInitialize(void *a_s,void *a_m) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Numa2D *physics = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Numa2D *physics = (Numa2D*) solver->m_physics; int ferr = 0; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in Numa2DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in Numa2DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->gamma = 1.4; - physics->R = 287.058; /* J kg^{-1} K^{-1} */ - physics->g = 9.8; /* m s^{-2} */ - physics->mu = 0.0; /* m^2 s^{-1} */ + physics->m_gamma = 1.4; + physics->m_R = 287.058; /* J kg^{-1} K^{-1} */ + physics->m_g = 9.8; /* a_m a_s^{-2} */ + physics->m_mu = 0.0; /* a_m^2 a_s^{-1} */ - physics->Pref = 101327.0; /* N m^{-2} */ + physics->Pref = 101327.0; /* N a_m^{-2} */ physics->Tref = 288.15; /* Kelvin */ - strcpy(physics->upwind,_RUSANOV_UPWINDING_); + strcpy(physics->m_upwind,_RUSANOV_UPWINDING_); /* default choice of initial atmosphere */ - physics->init_atmos = 1; + physics->m_init_atmos = 1; /* reading physical model specific inputs - rank 0 */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -67,21 +67,21 @@ int Numa2DInitialize(void *s,void *m) while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gamma")) { - ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_gamma); if (ferr != 1) return(1); } else if (!strcmp(word,"R")) { - ferr = fscanf(in,"%lf",&physics->R); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_R); if (ferr != 1) return(1); } else if (!strcmp(word,"g")) { - ferr = fscanf(in,"%lf",&physics->g); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_g); if (ferr != 1) return(1); } else if (!strcmp(word,"mu")) { - ferr = fscanf(in,"%lf",&physics->mu); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_mu); if (ferr != 1) return(1); } else if (!strcmp(word,"Pref")) { ferr = fscanf(in,"%lf",&physics->Pref); if (ferr != 1) return(1); } else if (!strcmp(word,"Tref")) { ferr = fscanf(in,"%lf",&physics->Tref); if (ferr != 1) return(1); } else if (!strcmp(word,"init_atmos")) { - ferr = fscanf(in,"%d",&physics->init_atmos); if (ferr != 1) return(1); + ferr = fscanf(in,"%d",&physics->m_init_atmos); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upwind); if (ferr != 1) return(1); + ferr = fscanf(in,"%s",physics->m_upwind); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr); @@ -98,23 +98,23 @@ int Numa2DInitialize(void *s,void *m) } #ifndef serial - IERR MPIBroadcast_double (&physics->gamma ,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->R ,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->g ,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->mu ,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Pref ,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Tref ,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->init_atmos,1 ,0,&mpi->world);CHECKERR(ierr); - IERR MPIBroadcast_character( physics->upwind ,_MAX_STRING_SIZE_,0,&mpi->world);CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_gamma ,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_R ,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_g ,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_mu ,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->Pref ,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->Tref ,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->m_init_atmos,1 ,0,&mpi->m_world);CHECKERR(ierr); + IERR MPIBroadcast_character( physics->m_upwind ,_MAX_STRING_SIZE_,0,&mpi->m_world);CHECKERR(ierr); #endif /* calculate the mean hydrostatic atmosphere as a function of altitude */ - if (physics->init_atmos == 1) { + if (physics->m_init_atmos == 1) { physics->StandardAtmosphere = Numa2DCalculateStandardAtmosphere_1; - } else if (physics->init_atmos == 2) { + } else if (physics->m_init_atmos == 2) { physics->StandardAtmosphere = Numa2DCalculateStandardAtmosphere_2; } else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in Numa2DInitialize(): invalid choice of initial atmosphere (init_atmos).\n"); return(1); } @@ -122,40 +122,40 @@ int Numa2DInitialize(void *s,void *m) CHECKERR(ierr); /* initializing physical model-specific functions */ - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) solver->dFFunction = Numa2DStiffFlux; else solver->dFFunction = NULL; solver->FFunction = Numa2DFlux; solver->ComputeCFL = Numa2DComputeCFL; solver->SFunction = Numa2DSource; - if (!strcmp(physics->upwind,_RUSANOV_UPWINDING_)) { + if (!strcmp(physics->m_upwind,_RUSANOV_UPWINDING_)) { solver->Upwind = Numa2DRusanovFlux; - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) solver->UpwinddF = Numa2DRusanovLinearFlux; else solver->UpwinddF = NULL; } else { - if (!mpi->rank) fprintf(stderr,"Error in Numa2DInitialize(): Invalid choice of upwinding scheme.\n"); + if (!mpi->m_rank) fprintf(stderr,"Error in Numa2DInitialize(): Invalid choice of upwinding scheme.\n"); return(1); } /* set the value of gamma in all the boundary objects */ int n; - DomainBoundary *boundary = (DomainBoundary*) solver->boundary; - for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma; + DomainBoundary *boundary = (DomainBoundary*) solver->m_boundary; + for (n = 0; n < solver->m_n_boundary_zones; n++) boundary[n].m_gamma = physics->m_gamma; - /* finally, hijack the main solver's dissipation function pointer - * to this model's own function, since it's difficult to express + /* finally, hijack the main solver'a_s dissipation function pointer + * to this model'a_s own function, since it'a_s difficult to express * the dissipation terms in the general form */ solver->ParabolicFunction = Numa2DParabolicFunction; /* check that solver has the correct choice of diffusion formulation */ - if (strcmp(solver->spatial_type_par,_NC_2STAGE_)) { - if (!mpi->rank) { + if (strcmp(solver->m_spatial_type_par,_NC_2STAGE_)) { + if (!mpi->m_rank) { fprintf(stderr,"Error in Numa2DInitialize(): Parabolic term spatial discretization must be \"%s\"\n",_NC_2STAGE_); } return(1); } - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/Numa2D/Numa2DParabolicFunction.c b/src/PhysicalModels/Numa2D/Numa2DParabolicFunction.c index c2bc9321..cb879797 100644 --- a/src/PhysicalModels/Numa2D/Numa2DParabolicFunction.c +++ b/src/PhysicalModels/Numa2D/Numa2DParabolicFunction.c @@ -14,26 +14,26 @@ Journal of Computational Physics, 227 (2008), pp. 3849--3877 */ -int Numa2DParabolicFunction(double *par,double *u,void *s,void *m,double t) +int Numa2DParabolicFunction(double *a_par,double *a_u,void *a_s,void *a_m,double a_t) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Numa2D *physics = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Numa2D *physics = (Numa2D*) solver->m_physics; int i,v,done; double dxinv, dyinv; _DECLARE_IERR_; - int ghosts = solver->ghosts; - int imax = solver->dim_local[0]; - int jmax = solver->dim_local[1]; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int imax = solver->m_dim_local[0]; + int jmax = solver->m_dim_local[1]; + int *dim = solver->m_dim_local; int size = (imax+2*ghosts)*(jmax+2*ghosts)*_MODEL_NVARS_; - _ArraySetValue_(par,size,0.0); - if (physics->mu <= 0) return(0); /* inviscid flow */ - solver->count_par++; + _ArraySetValue_(a_par,size,0.0); + if (physics->m_mu <= 0) return(0); /* inviscid flow */ + solver->m_count_par++; - double mu = physics->mu; + double mu = physics->m_mu; /* allocate some arrays */ double *Q, *QDeriv, *FViscous, *FDeriv; @@ -53,9 +53,9 @@ int Numa2DParabolicFunction(double *par,double *u,void *s,void *m,double t) int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); double drho,uvel,vvel,dT,rho0,T0,P0,EP,ycoord; - _GetCoordinate_ (_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + _GetCoordinate_ (_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); physics->StandardAtmosphere (physics,ycoord,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ( (u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); + _Numa2DGetFlowVars_ ( (a_u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); Q[_MODEL_NVARS_*p+0] = rho0 + drho; /* density */ Q[_MODEL_NVARS_*p+1] = uvel; /* x-velocity */ @@ -72,7 +72,7 @@ int Numa2DParabolicFunction(double *par,double *u,void *s,void *m,double t) done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->dxinv,dxinv); + _GetCoordinate_(_XDIR_,index[_XDIR_]-ghosts,dim,ghosts,solver->m_dxinv,dxinv); double rho, ux, vx, tx; rho = Q [_MODEL_NVARS_*p+0]; @@ -92,8 +92,8 @@ int Numa2DParabolicFunction(double *par,double *u,void *s,void *m,double t) done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); - for (v=0; v<_MODEL_NVARS_; v++) (par+p)[v] += (dxinv * (FDeriv+p)[v] ); + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); + for (v=0; v<_MODEL_NVARS_; v++) (a_par+p)[v] += (dxinv * (FDeriv+p)[v] ); _ArrayIncrementIndex_(_MODEL_NDIMS_,dim,index,done); } @@ -104,7 +104,7 @@ int Numa2DParabolicFunction(double *par,double *u,void *s,void *m,double t) done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1DWO_(_MODEL_NDIMS_,dim,index,offset,ghosts,p); - _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->dxinv,dyinv); + _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_dxinv,dyinv); double rho, uy, vy, ty; rho = Q [_MODEL_NVARS_*p+0]; @@ -124,8 +124,8 @@ int Numa2DParabolicFunction(double *par,double *u,void *s,void *m,double t) done = 0; _ArraySetValue_(index,_MODEL_NDIMS_,0); while (!done) { int p; _ArrayIndex1D_(_MODEL_NDIMS_,dim,index,ghosts,p); p *= _MODEL_NVARS_; - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); - for (v=0; v<_MODEL_NVARS_; v++) (par+p)[v] += (dyinv * (FDeriv+p)[v] ); + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); + for (v=0; v<_MODEL_NVARS_; v++) (a_par+p)[v] += (dyinv * (FDeriv+p)[v] ); _ArrayIncrementIndex_(_MODEL_NDIMS_,dim,index,done); } diff --git a/src/PhysicalModels/Numa2D/Numa2DSource.c b/src/PhysicalModels/Numa2D/Numa2DSource.c index 2228c956..174437aa 100644 --- a/src/PhysicalModels/Numa2D/Numa2DSource.c +++ b/src/PhysicalModels/Numa2D/Numa2DSource.c @@ -4,15 +4,15 @@ #include #include -int Numa2DSource(double *S,double *u,void *s,void *m,double t) +int Numa2DSource(double *a_S,double *a_u,void *a_s,void *a_m,double a_t) { - HyPar *solver = (HyPar*) s; - Numa2D *param = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa2D *param = (Numa2D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -27,10 +27,10 @@ int Numa2DSource(double *S,double *u,void *s,void *m,double t) int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double drho,uvel,vvel,dT,rho0,P0,EP,T0,ycoord; - _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->x,ycoord); + _GetCoordinate_(_YDIR_,index[_YDIR_]-ghosts,dim,ghosts,solver->m_x,ycoord); param->StandardAtmosphere (param,ycoord,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); - _Numa2DSetSource_ ((S+_MODEL_NVARS_*p),param,drho); + _Numa2DGetFlowVars_ ((a_u+_MODEL_NVARS_*p),drho,uvel,vvel,dT,rho0); + _Numa2DSetSource_ ((a_S+_MODEL_NVARS_*p),param,drho); /* some useless statements to avoid compiler warnings */ uvel = dT; diff --git a/src/PhysicalModels/Numa2D/Numa2DUpwind.c b/src/PhysicalModels/Numa2D/Numa2DUpwind.c index a66f2902..20f49aa5 100644 --- a/src/PhysicalModels/Numa2D/Numa2DUpwind.c +++ b/src/PhysicalModels/Numa2D/Numa2DUpwind.c @@ -6,59 +6,59 @@ #include #include -int Numa2DRusanovFlux(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Numa2DRusanovFlux(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa2D *param = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa2D *param = (Numa2D*) solver->m_physics; int done; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D2_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D2_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D2_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D2_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { _ArrayCopy1D2_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double udiff[_MODEL_NVARS_],drho,vel[2],dT,rho0,P0,T0,EP,c; double ycoordL, ycoordR; - if (dir == _YDIR_) { - _GetCoordinate_(_YDIR_,(index_inter[_YDIR_]-1),dim,ghosts,solver->x,ycoordL); - _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->x,ycoordR); + if (a_dir == _YDIR_) { + _GetCoordinate_(_YDIR_,(index_inter[_YDIR_]-1),dim,ghosts,solver->m_x,ycoordL); + _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->m_x,ycoordR); } else { - _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->x,ycoordL); + _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->m_x,ycoordL); ycoordR = ycoordL; } - /* Rusanov's upwinding scheme */ + /* Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); /* left of the interface */ param->StandardAtmosphere (param,ycoordL,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); - _Numa2DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c); - double alphaL = c + absolute(vel[dir]); + _Numa2DGetFlowVars_ ((a_uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); + _Numa2DComputeSpeedofSound_ (param->m_gamma,param->m_R,T0,dT,rho0,drho,EP,c); + double alphaL = c + absolute(vel[a_dir]); /* right of the interface */ param->StandardAtmosphere (param,ycoordR,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); - _Numa2DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c); - double alphaR = c + absolute(vel[dir]); + _Numa2DGetFlowVars_ ((a_uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); + _Numa2DComputeSpeedofSound_ (param->m_gamma,param->m_R,T0,dT,rho0,drho,EP,c); + double alphaR = c + absolute(vel[a_dir]); double alpha = max(alphaL,alphaR); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -66,59 +66,59 @@ int Numa2DRusanovFlux(double *fI,double *fL,double *fR,double *uL,double *uR,dou return(0); } -int Numa2DRusanovLinearFlux(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Numa2DRusanovLinearFlux(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa2D *param = (Numa2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa2D *param = (Numa2D*) solver->m_physics; int done; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D2_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D2_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D2_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D2_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; done = 0; int index_outer[2] = {0,0}, index_inter[2]; while (!done) { _ArrayCopy1D2_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D2_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double udiff[_MODEL_NVARS_],drho,vel[2],dT,rho0,P0,T0,EP,c; double ycoordL, ycoordR; - if (dir == _YDIR_) { - _GetCoordinate_(_YDIR_,(index_inter[_YDIR_]-1),dim,ghosts,solver->x,ycoordL); - _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->x,ycoordR); + if (a_dir == _YDIR_) { + _GetCoordinate_(_YDIR_,(index_inter[_YDIR_]-1),dim,ghosts,solver->m_x,ycoordL); + _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->m_x,ycoordR); } else { - _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->x,ycoordL); + _GetCoordinate_(_YDIR_,(index_inter[_YDIR_] ),dim,ghosts,solver->m_x,ycoordL); ycoordR = ycoordL; } - /* Rusanov's upwinding scheme */ + /* Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); /* left of the interface */ param->StandardAtmosphere (param,ycoordL,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); - _Numa2DComputeLinearizedSpeedofSound_ (param->gamma,param->R,T0,rho0,EP,c); + _Numa2DGetFlowVars_ ((a_uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); + _Numa2DComputeLinearizedSpeedofSound_ (param->m_gamma,param->m_R,T0,rho0,EP,c); double alphaL = c; /* right of the interface */ param->StandardAtmosphere (param,ycoordR,&EP,&P0,&rho0,&T0); - _Numa2DGetFlowVars_ ((uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); - _Numa2DComputeLinearizedSpeedofSound_ (param->gamma,param->R,T0,rho0,EP,c); + _Numa2DGetFlowVars_ ((a_uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],dT,rho0); + _Numa2DComputeLinearizedSpeedofSound_ (param->m_gamma,param->m_R,T0,rho0,EP,c); double alphaR = c; double alpha = max(alphaL,alphaR); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; /* some harmless statements to avoid compiler warnings */ vel[0] = vel[1]; diff --git a/src/PhysicalModels/Numa3D/Numa3DCleanup.c b/src/PhysicalModels/Numa3D/Numa3DCleanup.c index dc309b86..0426b7a2 100644 --- a/src/PhysicalModels/Numa3D/Numa3DCleanup.c +++ b/src/PhysicalModels/Numa3D/Numa3DCleanup.c @@ -2,7 +2,7 @@ #include #include -int Numa3DCleanup(void *s) +int Numa3DCleanup(void *a_s) { return(0); } diff --git a/src/PhysicalModels/Numa3D/Numa3DComputeCFL.c b/src/PhysicalModels/Numa3D/Numa3DComputeCFL.c index dc9e96c7..ecc0b7c9 100644 --- a/src/PhysicalModels/Numa3D/Numa3DComputeCFL.c +++ b/src/PhysicalModels/Numa3D/Numa3DComputeCFL.c @@ -6,15 +6,15 @@ #include #include -double Numa3DComputeCFL(void *s,void *m,double dt,double t) +double Numa3DComputeCFL(void *a_s,void *a_m,double a_dt,double a_t) { - HyPar *solver = (HyPar*) s; - Numa3D *param = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa3D *param = (Numa3D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - double *u = solver->u; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + double *u = solver->m_u; int index[ndims]; double max_cfl = 0; @@ -23,20 +23,20 @@ double Numa3DComputeCFL(void *s,void *m,double dt,double t) int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double drho,uvel,vvel,wvel,dT,rho0,T0,P0,EP,c,zcoord; - _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->x,zcoord); + _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->m_x,zcoord); param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0); _Numa3DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); - _Numa3DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c); + _Numa3DComputeSpeedofSound_ (param->m_gamma,param->m_R,T0,dT,rho0,drho,EP,c); double dxinv, dyinv, dzinv; - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */ - _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->dxinv,dzinv); /* 1/dz */ + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); /* 1/dy */ + _GetCoordinate_(_ZDIR_,index[_ZDIR_],dim,ghosts,solver->m_dxinv,dzinv); /* 1/dz */ double local_cfl[3]; - local_cfl[_XDIR_] = (absolute(uvel)+c)*dt*dxinv; /* local cfl for this grid point (x) */ - local_cfl[_YDIR_] = (absolute(vvel)+c)*dt*dyinv; /* local cfl for this grid point (y) */ - local_cfl[_ZDIR_] = (absolute(wvel)+c)*dt*dzinv; /* local cfl for this grid point (z) */ + local_cfl[_XDIR_] = (absolute(uvel)+c)*a_dt*dxinv; /* local cfl for this grid point (x) */ + local_cfl[_YDIR_] = (absolute(vvel)+c)*a_dt*dyinv; /* local cfl for this grid point (y) */ + local_cfl[_ZDIR_] = (absolute(wvel)+c)*a_dt*dzinv; /* local cfl for this grid point (z) */ if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_]; if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_]; if (local_cfl[_ZDIR_] > max_cfl) max_cfl = local_cfl[_ZDIR_]; diff --git a/src/PhysicalModels/Numa3D/Numa3DFlux.c b/src/PhysicalModels/Numa3D/Numa3DFlux.c index 005f316b..285fd454 100644 --- a/src/PhysicalModels/Numa3D/Numa3DFlux.c +++ b/src/PhysicalModels/Numa3D/Numa3DFlux.c @@ -4,15 +4,15 @@ #include #include -int Numa3DFlux(double *f,double *u,int dir,void *s,double t) +int Numa3DFlux(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa3D *param = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa3D *param = (Numa3D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -27,12 +27,12 @@ int Numa3DFlux(double *f,double *u,int dir,void *s,double t) int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double drho,uvel,vvel,wvel,dT,dP,rho0,T0,P0,EP,zcoord; - _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord); + _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->m_x,zcoord); param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); + _Numa3DGetFlowVars_ ((a_u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); _Numa3DComputePressure_ (param,T0,dT,P0,dP); - _Numa3DSetFlux_ ((f+_MODEL_NVARS_*p),dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0); + _Numa3DSetFlux_ ((a_f+_MODEL_NVARS_*p),a_dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0); _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -40,15 +40,15 @@ int Numa3DFlux(double *f,double *u,int dir,void *s,double t) return(0); } -int Numa3DStiffFlux(double *f,double *u,int dir,void *s,double t) +int Numa3DStiffFlux(double *a_f,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa3D *param = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa3D *param = (Numa3D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -63,12 +63,12 @@ int Numa3DStiffFlux(double *f,double *u,int dir,void *s,double t) int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double drho,uvel,vvel,wvel,dT,dP,rho0,T0,P0,EP,zcoord; - _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord); + _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->m_x,zcoord); param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_ ((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); + _Numa3DGetFlowVars_ ((a_u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); _Numa3DComputeLinearizedPressure_ (param,T0,dT,P0,dP); - _Numa3DSetLinearFlux_ ((f+_MODEL_NVARS_*p),dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0); + _Numa3DSetLinearFlux_ ((a_f+_MODEL_NVARS_*p),a_dir,drho,uvel,vvel,wvel,dT,dP,rho0,T0); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Numa3D/Numa3DFunctions.c b/src/PhysicalModels/Numa3D/Numa3DFunctions.c index da099166..93669ce9 100644 --- a/src/PhysicalModels/Numa3D/Numa3DFunctions.c +++ b/src/PhysicalModels/Numa3D/Numa3DFunctions.c @@ -2,13 +2,13 @@ #include #include -int Numa3DCalculateStandardAtmosphere_1(void *p,double z,double *ExnerP,double *P,double *rho,double *T) +int Numa3DCalculateStandardAtmosphere_1(void *a_p,double a_z,double *a_ExnerP,double *a_P,double *a_rho,double *a_T) { - Numa3D *physics = (Numa3D*) p; + Numa3D *physics = (Numa3D*) a_p; - double R = physics->R; - double gamma = physics->gamma; - double g = physics->g; + double R = physics->m_R; + double gamma = physics->m_gamma; + double g = physics->m_g; /* reference quantities at zero altitude */ double P0, T0; @@ -19,21 +19,21 @@ int Numa3DCalculateStandardAtmosphere_1(void *p,double z,double *ExnerP,double * double Cp = gamma * inv_gamma_m1 * R; double theta = T0; - *ExnerP = 1.0 - (g/(Cp*theta))*z; - *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1); - *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1); - *T = (*rho) * theta; + *a_ExnerP = 1.0 - (g/(Cp*theta))*a_z; + *a_P = P0 * raiseto((*a_ExnerP),gamma*inv_gamma_m1); + *a_rho = (P0/(R*theta)) * raiseto((*a_ExnerP),inv_gamma_m1); + *a_T = (*a_rho) * theta; return(0); } -int Numa3DCalculateStandardAtmosphere_2(void *p,double z,double *ExnerP,double *P,double *rho,double *T) +int Numa3DCalculateStandardAtmosphere_2(void *a_p,double a_z,double *a_ExnerP,double *a_P,double *a_rho,double *a_T) { - Numa3D *physics = (Numa3D*) p; + Numa3D *physics = (Numa3D*) a_p; - double R = physics->R; - double gamma = physics->gamma; - double g = physics->g; + double R = physics->m_R; + double gamma = physics->m_gamma; + double g = physics->m_g; /* reference quantities at zero altitude */ double P0, T0; @@ -44,12 +44,12 @@ int Numa3DCalculateStandardAtmosphere_2(void *p,double z,double *ExnerP,double * double inv_gamma_m1 = 1.0/(gamma-1.0); double Cp = gamma * inv_gamma_m1 * R; - double term = BV*BV*z/g; + double term = BV*BV*a_z/g; double theta = T0 * exp(term); - *ExnerP = 1.0 + (g*g/(Cp*T0*BV*BV)) * (exp(-term) - 1.0); - *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1); - *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1); - *T = (*rho) * theta; + *a_ExnerP = 1.0 + (g*g/(Cp*T0*BV*BV)) * (exp(-term) - 1.0); + *a_P = P0 * raiseto((*a_ExnerP),gamma*inv_gamma_m1); + *a_rho = (P0/(R*theta)) * raiseto((*a_ExnerP),inv_gamma_m1); + *a_T = (*a_rho) * theta; return(0); } diff --git a/src/PhysicalModels/Numa3D/Numa3DInitialize.c b/src/PhysicalModels/Numa3D/Numa3DInitialize.c index 849aa072..3b47b64e 100644 --- a/src/PhysicalModels/Numa3D/Numa3DInitialize.c +++ b/src/PhysicalModels/Numa3D/Numa3DInitialize.c @@ -21,42 +21,42 @@ int Numa3DRusanovLinearFlux(double*,double*,double*,double*,double*,double*,i void Numa3DCalculateStandardAtmosphere_1(void*,double,double*,double*,double*,double*); void Numa3DCalculateStandardAtmosphere_2(void*,double,double*,double*,double*,double*); -int Numa3DInitialize(void *s,void *m) +int Numa3DInitialize(void *a_s,void *a_m) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Numa3D *physics = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Numa3D *physics = (Numa3D*) solver->m_physics; int ferr = 0; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in Numa3DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in Numa3DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->gamma = 1.4; - physics->R = 287.058; /* J kg^{-1} K^{-1} */ - physics->Omega = 7.2921150E-05; /* rad s^{-1} */ - physics->g = 9.8; /* m s^{-2} */ + physics->m_gamma = 1.4; + physics->m_R = 287.058; /* J kg^{-1} K^{-1} */ + physics->m_Omega = 7.2921150E-05; /* rad a_s^{-1} */ + physics->m_g = 9.8; /* a_m a_s^{-2} */ - physics->Pref = 101327.0; /* N m^{-2} */ + physics->Pref = 101327.0; /* N a_m^{-2} */ physics->Tref = 288.15; /* Kelvin */ - strcpy(physics->upwind,_RUSANOV_UPWINDING_); + strcpy(physics->m_upwind,_RUSANOV_UPWINDING_); /* default choice of initial atmosphere */ - physics->init_atmos = 1; + physics->m_init_atmos = 1; /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -66,21 +66,21 @@ int Numa3DInitialize(void *s,void *m) while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gamma")) { - ferr = fscanf(in,"%lf",&physics->gamma); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_gamma); if (ferr != 1) return(1); } else if (!strcmp(word,"R")) { - ferr = fscanf(in,"%lf",&physics->R); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_R); if (ferr != 1) return(1); } else if (!strcmp(word,"g")) { - ferr = fscanf(in,"%lf",&physics->g); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_g); if (ferr != 1) return(1); } else if (!strcmp(word,"Omega")) { - ferr = fscanf(in,"%lf",&physics->Omega); if (ferr != 1) return(1); + ferr = fscanf(in,"%lf",&physics->m_Omega); if (ferr != 1) return(1); } else if (!strcmp(word,"Pref")) { ferr = fscanf(in,"%lf",&physics->Pref); if (ferr != 1) return(1); } else if (!strcmp(word,"Tref")) { ferr = fscanf(in,"%lf",&physics->Tref); if (ferr != 1) return(1); } else if (!strcmp(word,"init_atmos")) { - ferr = fscanf(in,"%d",&physics->init_atmos); if (ferr != 1) return(1); + ferr = fscanf(in,"%d",&physics->m_init_atmos); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upwind); if (ferr != 1) return(1); + ferr = fscanf(in,"%s",physics->m_upwind); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr); @@ -97,23 +97,23 @@ int Numa3DInitialize(void *s,void *m) } #ifndef serial - IERR MPIBroadcast_double (&physics->gamma ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->R ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->g ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Omega ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Pref ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->Tref ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->init_atmos ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character ( physics->upwind ,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_gamma ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_R ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_g ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_Omega ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->Pref ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->Tref ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->m_init_atmos ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character ( physics->m_upwind ,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); #endif /* calculate the mean hydrostatic atmosphere as a function of altitude */ - if (physics->init_atmos == 1) { + if (physics->m_init_atmos == 1) { physics->StandardAtmosphere = Numa3DCalculateStandardAtmosphere_1; - } else if (physics->init_atmos == 2) { + } else if (physics->m_init_atmos == 2) { physics->StandardAtmosphere = Numa3DCalculateStandardAtmosphere_2; } else { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in Numa3DInitialize(): invalid choice of initial atmosphere (init_atmos).\n"); return(1); } @@ -121,27 +121,27 @@ int Numa3DInitialize(void *s,void *m) CHECKERR(ierr); /* initializing physical model-specific functions */ - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) solver->dFFunction = Numa3DStiffFlux; else solver->dFFunction = NULL; solver->FFunction = Numa3DFlux; solver->ComputeCFL = Numa3DComputeCFL; solver->SFunction = Numa3DSource; - if (!strcmp(physics->upwind,_RUSANOV_UPWINDING_)) { + if (!strcmp(physics->m_upwind,_RUSANOV_UPWINDING_)) { solver->Upwind = Numa3DRusanovFlux; - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) solver->UpwinddF = Numa3DRusanovLinearFlux; else solver->UpwinddF = NULL; } else { - if (!mpi->rank) fprintf(stderr,"Error in Numa3DInitialize(): Invalid choice of upwinding scheme.\n"); + if (!mpi->m_rank) fprintf(stderr,"Error in Numa3DInitialize(): Invalid choice of upwinding scheme.\n"); return(1); } /* set the value of gamma in all the boundary objects */ int n; - DomainBoundary *boundary = (DomainBoundary*) solver->boundary; - for (n = 0; n < solver->nBoundaryZones; n++) boundary[n].gamma = physics->gamma; + DomainBoundary *boundary = (DomainBoundary*) solver->m_boundary; + for (n = 0; n < solver->m_n_boundary_zones; n++) boundary[n].m_gamma = physics->m_gamma; - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/Numa3D/Numa3DSource.c b/src/PhysicalModels/Numa3D/Numa3DSource.c index 9fce0cd0..618e5494 100644 --- a/src/PhysicalModels/Numa3D/Numa3DSource.c +++ b/src/PhysicalModels/Numa3D/Numa3DSource.c @@ -4,15 +4,15 @@ #include #include -int Numa3DSource(double *S,double *u,void *s,void *m,double t) +int Numa3DSource(double *a_S,double *a_u,void *a_s,void *a_m,double a_t) { - HyPar *solver = (HyPar*) s; - Numa3D *param = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa3D *param = (Numa3D*) solver->m_physics; int i; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -27,10 +27,10 @@ int Numa3DSource(double *S,double *u,void *s,void *m,double t) int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double drho,uvel,vvel,wvel,dT,rho0,P0,EP,T0,zcoord; - _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->x,zcoord); + _GetCoordinate_(_ZDIR_,index[_ZDIR_]-ghosts,dim,ghosts,solver->m_x,zcoord); param->StandardAtmosphere(param,zcoord,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_((u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); - _Numa3DSetSource_ ((S+_MODEL_NVARS_*p),param,uvel,vvel,drho,rho0); + _Numa3DGetFlowVars_((a_u+_MODEL_NVARS_*p),drho,uvel,vvel,wvel,dT,rho0); + _Numa3DSetSource_ ((a_S+_MODEL_NVARS_*p),param,uvel,vvel,drho,rho0); _ArrayIncrementIndex_(ndims,bounds,index,done); diff --git a/src/PhysicalModels/Numa3D/Numa3DUpwind.c b/src/PhysicalModels/Numa3D/Numa3DUpwind.c index 82b17993..166035de 100644 --- a/src/PhysicalModels/Numa3D/Numa3DUpwind.c +++ b/src/PhysicalModels/Numa3D/Numa3DUpwind.c @@ -6,61 +6,61 @@ #include #include -int Numa3DRusanovFlux(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Numa3DRusanovFlux(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa3D *param = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa3D *param = (Numa3D*) solver->m_physics; int done; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; done = 0; int index_outer[3] = {0,0,0}, index_inter[3]; while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double udiff[_MODEL_NVARS_],drho,vel[3],dT,rho0,P0,T0,EP,c; double zcoordL, zcoordR; - if (dir == _ZDIR_) { - _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_]-1),dim,ghosts,solver->x,zcoordL); - _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordR); + if (a_dir == _ZDIR_) { + _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_]-1),dim,ghosts,solver->m_x,zcoordL); + _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->m_x,zcoordR); } else { - _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordL); + _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->m_x,zcoordL); zcoordR = zcoordL; } - /* Rusanov's upwinding scheme */ + /* Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); - udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); + udiff[4] = 0.5 * (a_uR[_MODEL_NVARS_*p+4] - a_uL[_MODEL_NVARS_*p+4]); /* left of the interface */ param->StandardAtmosphere(param,zcoordL,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_ ((uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); - _Numa3DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c); - double alphaL = c + absolute(vel[dir]); + _Numa3DGetFlowVars_ ((a_uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); + _Numa3DComputeSpeedofSound_ (param->m_gamma,param->m_R,T0,dT,rho0,drho,EP,c); + double alphaL = c + absolute(vel[a_dir]); /* right of the interface */ param->StandardAtmosphere(param,zcoordR,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_ ((uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); - _Numa3DComputeSpeedofSound_ (param->gamma,param->R,T0,dT,rho0,drho,EP,c); - double alphaR = c + absolute(vel[dir]); + _Numa3DGetFlowVars_ ((a_uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); + _Numa3DComputeSpeedofSound_ (param->m_gamma,param->m_R,T0,dT,rho0,drho,EP,c); + double alphaR = c + absolute(vel[a_dir]); double alpha = max(alphaL,alphaR); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; - fI[_MODEL_NVARS_*p+4] = 0.5*(fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4])-alpha*udiff[4]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; + a_fI[_MODEL_NVARS_*p+4] = 0.5*(a_fL[_MODEL_NVARS_*p+4]+a_fR[_MODEL_NVARS_*p+4])-alpha*udiff[4]; } _ArrayIncrementIndex_(_MODEL_NDIMS_,bounds_outer,index_outer,done); } @@ -68,61 +68,61 @@ int Numa3DRusanovFlux(double *fI,double *fL,double *fR,double *uL,double *uR,dou return(0); } -int Numa3DRusanovLinearFlux(double *fI,double *fL,double *fR,double *uL,double *uR,double *u,int dir,void *s,double t) +int Numa3DRusanovLinearFlux(double *a_fI,double *a_fL,double *a_fR,double *a_uL,double *a_uR,double *a_u,int a_dir,void *a_s,double a_t) { - HyPar *solver = (HyPar*) s; - Numa3D *param = (Numa3D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Numa3D *param = (Numa3D*) solver->m_physics; int done; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int bounds_outer[_MODEL_NDIMS_], bounds_inter[_MODEL_NDIMS_]; - _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[dir] = 1; - _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[dir] += 1; + _ArrayCopy1D3_(dim,bounds_outer,_MODEL_NDIMS_); bounds_outer[a_dir] = 1; + _ArrayCopy1D3_(dim,bounds_inter,_MODEL_NDIMS_); bounds_inter[a_dir] += 1; done = 0; int index_outer[3] = {0,0,0}, index_inter[3]; while (!done) { _ArrayCopy1D3_(index_outer,index_inter,_MODEL_NDIMS_); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D3_(_MODEL_NDIMS_,bounds_inter,index_inter,0,p); double udiff[_MODEL_NVARS_],drho,vel[3],dT,rho0,P0,T0,EP,c; double zcoordL, zcoordR; - if (dir == _ZDIR_) { - _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_]-1),dim,ghosts,solver->x,zcoordL); - _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordR); + if (a_dir == _ZDIR_) { + _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_]-1),dim,ghosts,solver->m_x,zcoordL); + _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->m_x,zcoordR); } else { - _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->x,zcoordL); + _GetCoordinate_(_ZDIR_,(index_inter[_ZDIR_] ),dim,ghosts,solver->m_x,zcoordL); zcoordR = zcoordL; } - /* Rusanov's upwinding scheme */ + /* Rusanov'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); - udiff[3] = 0.5 * (uR[_MODEL_NVARS_*p+3] - uL[_MODEL_NVARS_*p+3]); - udiff[4] = 0.5 * (uR[_MODEL_NVARS_*p+4] - uL[_MODEL_NVARS_*p+4]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); + udiff[3] = 0.5 * (a_uR[_MODEL_NVARS_*p+3] - a_uL[_MODEL_NVARS_*p+3]); + udiff[4] = 0.5 * (a_uR[_MODEL_NVARS_*p+4] - a_uL[_MODEL_NVARS_*p+4]); /* left of the interface */ param->StandardAtmosphere (param,zcoordL,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_ ((uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); - _Numa3DComputeLinearizedSpeedofSound_ (param->gamma,param->R,T0,rho0,EP,c); - double alphaL = c + absolute(vel[dir]); + _Numa3DGetFlowVars_ ((a_uL+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); + _Numa3DComputeLinearizedSpeedofSound_ (param->m_gamma,param->m_R,T0,rho0,EP,c); + double alphaL = c + absolute(vel[a_dir]); /* right of the interface */ param->StandardAtmosphere(param,zcoordR,&EP,&P0,&rho0,&T0); - _Numa3DGetFlowVars_ ((uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); - _Numa3DComputeLinearizedSpeedofSound_ (param->gamma,param->R,T0,rho0,EP,c); - double alphaR = c + absolute(vel[dir]); + _Numa3DGetFlowVars_ ((a_uR+_MODEL_NVARS_*p),drho,vel[0],vel[1],vel[2],dT,rho0); + _Numa3DComputeLinearizedSpeedofSound_ (param->m_gamma,param->m_R,T0,rho0,EP,c); + double alphaR = c + absolute(vel[a_dir]); double alpha = max(alphaL,alphaR); - fI[_MODEL_NVARS_*p+0] = 0.5*(fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; - fI[_MODEL_NVARS_*p+1] = 0.5*(fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; - fI[_MODEL_NVARS_*p+2] = 0.5*(fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; - fI[_MODEL_NVARS_*p+3] = 0.5*(fL[_MODEL_NVARS_*p+3]+fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; - fI[_MODEL_NVARS_*p+4] = 0.5*(fL[_MODEL_NVARS_*p+4]+fR[_MODEL_NVARS_*p+4])-alpha*udiff[4]; + a_fI[_MODEL_NVARS_*p+0] = 0.5*(a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0])-alpha*udiff[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5*(a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1])-alpha*udiff[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5*(a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2])-alpha*udiff[2]; + a_fI[_MODEL_NVARS_*p+3] = 0.5*(a_fL[_MODEL_NVARS_*p+3]+a_fR[_MODEL_NVARS_*p+3])-alpha*udiff[3]; + a_fI[_MODEL_NVARS_*p+4] = 0.5*(a_fL[_MODEL_NVARS_*p+4]+a_fR[_MODEL_NVARS_*p+4])-alpha*udiff[4]; vel[0] = dT; /* useless statement to avoid compiler warning */ } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DCleanup.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DCleanup.c index 18f4d8f6..86f057c0 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DCleanup.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DCleanup.c @@ -8,10 +8,10 @@ /*! Function to clean up all physics-related allocations for the 1D shallow water equations */ int ShallowWater1DCleanup( - void *s /*!< Solver object of type #HyPar */ + void *a_s /*!< Solver object of type #HyPar */ ) { - ShallowWater1D *param = (ShallowWater1D*) s; - free(param->b); + ShallowWater1D *param = (ShallowWater1D*) a_s; + free(param->m_b); return(0); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DComputeCFL.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DComputeCFL.c index 3ff760a9..18c2f9ed 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DComputeCFL.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DComputeCFL.c @@ -15,20 +15,20 @@ is computed over the local domain on this processor only. */ double ShallowWater1DComputeCFL( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; - double *u = solver->u; + double *u = solver->m_u; double max_cfl = 0; int done = 0; _ArraySetValue_(index,ndims,0); @@ -36,9 +36,9 @@ double ShallowWater1DComputeCFL( int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); double h, v, c, dxinv, local_cfl; _ShallowWater1DGetFlowVar_((u+_MODEL_NVARS_*p),h,v); - _GetCoordinate_(0,index[0],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - c = sqrt(param->g*h); /* speed of gravity waves */ - local_cfl = (absolute(v)+c)*dt*dxinv; /* local cfl for this grid point */ + _GetCoordinate_(0,index[0],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + c = sqrt(param->m_g*h); /* speed of gravity waves */ + local_cfl = (absolute(v)+c)*a_dt*dxinv; /* local cfl for this grid point */ if (local_cfl > max_cfl) max_cfl = local_cfl; _ArrayIncrementIndex_(ndims,dim,index,done); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DEigen.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DEigen.c index 60b8db50..5fd754a6 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DEigen.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DEigen.c @@ -17,15 +17,15 @@ to interpolation functions for a characteristic-based reconstruction. */ int ShallowWater1DLeftEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *L, /*!< Array of size nvar^2 = 2^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_L, /*!< Array of size nvar^2 = 2^2 to save the matrix of left eigenvectors in (row-major format). */ - void *p, /*!< Object of type #ShallowWater1D with physics-related variables */ - int dir /*!< Spatial dimension (not used, since this is a 1D system) */ + void *a_p, /*!< Object of type #ShallowWater1D with physics-related variables */ + int a_dir /*!< Spatial dimension (not used, since this is a 1D system) */ ) { - ShallowWater1D *param = (ShallowWater1D*) p; - _ShallowWater1DLeftEigenvectors_(u,L,param,dir); + ShallowWater1D *param = (ShallowWater1D*) a_p; + _ShallowWater1DLeftEigenvectors_(a_u,a_L,param,a_dir); return(0); } @@ -36,14 +36,14 @@ int ShallowWater1DLeftEigenvectors( to interpolation functions for a characteristic-based reconstruction. */ int ShallowWater1DRightEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *R, /*!< Array of size nvar^2 = 2^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_R, /*!< Array of size nvar^2 = 2^2 to save the matrix of right eigenvectors in (row-major format). */ - void *p, /*!< Object of type #ShallowWater1D with physics-related variables */ - int dir /*!< Spatial dimension (not used, since this is a 1D system) */ + void *a_p, /*!< Object of type #ShallowWater1D with physics-related variables */ + int a_dir /*!< Spatial dimension (not used, since this is a 1D system) */ ) { - ShallowWater1D *param = (ShallowWater1D*) p; - _ShallowWater1DRightEigenvectors_(u,R,param,dir); + ShallowWater1D *param = (ShallowWater1D*) a_p; + _ShallowWater1DRightEigenvectors_(a_u,a_R,param,a_dir); return(0); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DFlux.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DFlux.c index d1064b34..a3446ce1 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DFlux.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DFlux.c @@ -14,17 +14,17 @@ \f} */ int ShallowWater1DFlux( - double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the conserved solution */ - int dir,/*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ + double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the conserved solution */ + int a_dir,/*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int ndims = _MODEL_NDIMS_; static const int nvars = _MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -38,8 +38,8 @@ int ShallowWater1DFlux( while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double h, v; - _ShallowWater1DGetFlowVar_((u+nvars*p),h,v); - _ShallowWater1DSetFlux_((f+nvars*p),h,v,param->g); + _ShallowWater1DGetFlowVar_((a_u+nvars*p),h,v); + _ShallowWater1DSetFlux_((a_f+nvars*p),h,v,param->m_g); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DFunctions.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DFunctions.c index 5659d791..09dac5a2 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DFunctions.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DFunctions.c @@ -14,13 +14,13 @@ to interpolation functions for a characteristic-based reconstruction. */ int ShallowWater1DRoeAverage( - double *uavg, /*!< The computed Roe-averaged state */ - double *uL, /*!< Left state (conserved variables)*/ - double *uR, /*!< Right state (conserved variables)*/ - void *p /*!< Object of type #ShallowWater1D with physics-related variables */ + double *a_uavg, /*!< The computed Roe-averaged state */ + double *a_uL, /*!< Left state (conserved variables)*/ + double *a_uR, /*!< Right state (conserved variables)*/ + void *a_p /*!< Object of type #ShallowWater1D with physics-related variables */ ) { - ShallowWater1D *param = (ShallowWater1D*) p; - _ShallowWater1DRoeAverage_(uavg,uL,uR,param); + ShallowWater1D *param = (ShallowWater1D*) a_p; + _ShallowWater1DRoeAverage_(a_uavg,a_uL,a_uR,param); return(0); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DInitialize.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DInitialize.c index b9ed91b7..bf7e623b 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DInitialize.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DInitialize.c @@ -35,35 +35,35 @@ int ShallowWater1DWriteTopography (void*,void*,double); and set the physics-related function pointers in #HyPar. */ int ShallowWater1DInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< Object of type #MPIVariables containing MPI-related info */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related info */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater1D *physics = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater1D *physics = (ShallowWater1D*) solver->m_physics; int ferr, d; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in ShallowWater1DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in ShallowWater1DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->g = 1.0; - physics->bt_type = 0; - strcpy(physics->upw_choice,"roe"); + physics->m_g = 1.0; + physics->m_bt_type = 0; + strcpy(physics->m_upw_choice,"roe"); /* reading physical model specific inputs */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -73,13 +73,13 @@ int ShallowWater1DInitialize( while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gravity")) { - ferr = fscanf(in,"%lf",&physics->g); + ferr = fscanf(in,"%lf",&physics->m_g); if (ferr != 1) return(1); } else if (!strcmp(word, "topography_type")) { - ferr = fscanf(in,"%d",&physics->bt_type); + ferr = fscanf(in,"%d",&physics->m_bt_type); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upw_choice); + ferr = fscanf(in,"%s",physics->m_upw_choice); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; @@ -97,9 +97,9 @@ int ShallowWater1DInitialize( } #ifndef serial - IERR MPIBroadcast_double (&physics->g ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->bt_type ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->upw_choice,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_g ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->m_bt_type ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_upw_choice,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); #endif /* initializing physical model-specific functions */ @@ -108,11 +108,11 @@ int ShallowWater1DInitialize( solver->SFunction = ShallowWater1DSource; solver->UFunction = ShallowWater1DModifiedSolution; solver->JFunction = ShallowWater1DJacobian; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = ShallowWater1DUpwindRoe; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = ShallowWater1DUpwindLLF; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->Upwind = ShallowWater1DUpwindRoe; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->Upwind = ShallowWater1DUpwindLLF; else { - if (!mpi->rank) fprintf(stderr,"Error in ShallowWater1DInitialize(): %s is not a valid upwinding scheme.\n", - physics->upw_choice); + if (!mpi->m_rank) fprintf(stderr,"Error in ShallowWater1DInitialize(): %s is not a valid upwinding scheme.\n", + physics->m_upw_choice); return(1); } solver->AveragingFunction = ShallowWater1DRoeAverage; @@ -120,14 +120,14 @@ int ShallowWater1DInitialize( solver->GetRightEigenvectors = ShallowWater1DRightEigenvectors; solver->PhysicsOutput = ShallowWater1DWriteTopography; - if (!strcmp(physics->upw_choice,_LLF_ )) physics->SourceUpwind = ShallowWater1DSourceUpwindLLF; - else if (!strcmp(physics->upw_choice,_ROE_ )) physics->SourceUpwind = ShallowWater1DSourceUpwindRoe; + if (!strcmp(physics->m_upw_choice,_LLF_ )) physics->SourceUpwind = ShallowWater1DSourceUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_ROE_ )) physics->SourceUpwind = ShallowWater1DSourceUpwindRoe; /* allocate array to hold the bottom topography field */ - physics->b = (double*) calloc (solver->npoints_local_wghosts, sizeof(double)); + physics->m_b = (double*) calloc (solver->m_npoints_local_wghosts, sizeof(double)); /* set function pointer to read this topography */ solver->PhysicsInput = ShallowWater1DTopography; - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DJacobian.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DJacobian.c index 3c535b24..579ea6bb 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DJacobian.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DJacobian.c @@ -12,31 +12,31 @@ is returned as a 1D array (double) of 4 elements in row-major format. */ int ShallowWater1DJacobian( - double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 4 */ - double *u, /*!< solution at a grid point (array of size nvar = 2) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< dimension (x/y/z) (not used, since this is 1D system) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, + double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 4 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 2) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< dimension (x/y/z) (not used, since this is 1D system) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - ShallowWater1D *param = (ShallowWater1D*) p; + ShallowWater1D *param = (ShallowWater1D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _ShallowWater1DEigenvalues_ (u,D,param,0); - _ShallowWater1DLeftEigenvectors_ (u,L,param,0); - _ShallowWater1DRightEigenvectors_(u,R,param,0); + _ShallowWater1DEigenvalues_ (a_u,D,param,0); + _ShallowWater1DLeftEigenvectors_ (a_u,L,param,0); + _ShallowWater1DRightEigenvectors_(a_u,R,param,0); - int aupw = absolute(upw), k; - k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 3; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + int aupw = absolute(a_upw), k; + k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 3; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); MatMult2(2,DL,D,L); - MatMult2(2,Jac,R,DL); + MatMult2(2,a_Jac,R,DL); return(0); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DModifiedSolution.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DModifiedSolution.c index 94b20906..5707f2d5 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DModifiedSolution.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DModifiedSolution.c @@ -19,20 +19,20 @@ http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DModifiedSolution( - double *uC, /*!< The modified solution (same array size and layout as u) */ - double *u, /*!< The solution (conserved variables) */ - int d, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + double *a_uC, /*!< The modified solution (same array size and layout as a_u) */ + double *a_u, /*!< The solution (conserved variables) */ + int a_d, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double waqt /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -46,9 +46,9 @@ int ShallowWater1DModifiedSolution( while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double h,v; - _ShallowWater1DGetFlowVar_((u+_MODEL_NVARS_*p),h,v); - uC[_MODEL_NVARS_*p+0] = h + param->b[p]; - uC[_MODEL_NVARS_*p+1] = h * v; + _ShallowWater1DGetFlowVar_((a_u+_MODEL_NVARS_*p),h,v); + a_uC[_MODEL_NVARS_*p+0] = h + param->m_b[p]; + a_uC[_MODEL_NVARS_*p+1] = h * v; _ArrayIncrementIndex_(ndims,bounds,index,done); } return(0); diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DSource.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DSource.c index f2d705a6..4001f407 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DSource.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DSource.c @@ -23,41 +23,41 @@ static int ShallowWater1DSourceFunction2 (double*,double*,double*,void*,void*,do http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DSource( - double *source, /*!< Computed source terms (array size & layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current solution time */ + double *a_source, /*!< Computed source terms (array size & layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar* ) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; int v, done, p, p1, p2; - double *SourceI = solver->fluxI; /* interace source term */ - double *SourceC = solver->fluxC; /* cell-centered source term */ - double *SourceL = solver->fL; - double *SourceR = solver->fR; - - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *x = solver->x; - double *dxinv = solver->dxinv; + double *SourceI = solver->m_flux_i; /* interace a_source term */ + double *SourceC = solver->m_flux_c; /* cell-centered a_source term */ + double *SourceL = solver->m_f_l; + double *SourceR = solver->m_f_r; + + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *x = solver->m_x; + double *dxinv = solver->m_dxinv; int index[ndims],index1[ndims],index2[ndims],dim_interface[ndims]; /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_XDIR_]++; - /* calculate the first source function */ - IERR ShallowWater1DSourceFunction1(SourceC,u,x,solver,mpi,t); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the first a_source function */ + IERR ShallowWater1DSourceFunction1(SourceC,a_u,x,solver,mpi,a_t); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_XDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -67,18 +67,18 @@ int ShallowWater1DSource( _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse); for (v=0; v<_MODEL_NVARS_; v++) - source[_MODEL_NVARS_*p+v] += (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; + a_source[_MODEL_NVARS_*p+v] += (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; _ArrayIncrementIndex_(ndims,dim,index,done); } - /* calculate the second source function */ - IERR ShallowWater1DSourceFunction2(SourceC,u,x,solver,mpi,t); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the second a_source function */ + IERR ShallowWater1DSourceFunction2(SourceC,a_u,x,solver,mpi,a_t); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_XDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -87,10 +87,10 @@ int ShallowWater1DSource( _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1); _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse); - double h, vel; _ShallowWater1DGetFlowVar_((u+_MODEL_NVARS_*p),h,vel); - double term[_MODEL_NVARS_] = { 0.0, -param->g * (h + param->b[p]) }; + double h, vel; _ShallowWater1DGetFlowVar_((a_u+_MODEL_NVARS_*p),h,vel); + double term[_MODEL_NVARS_] = { 0.0, -param->m_g * (h + param->m_b[p]) }; for (v=0; v<_MODEL_NVARS_; v++) { - source[_MODEL_NVARS_*p+v] += term[v]*(SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; + a_source[_MODEL_NVARS_*p+v] += term[v]*(SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; } vel = h; /* useless statement to avoid compiler warning */ _ArrayIncrementIndex_(ndims,dim,index,done); @@ -109,20 +109,20 @@ int ShallowWater1DSource( http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DSourceFunction1( - double *f, /*!< Computed source function (array size and layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - double *x, /*!< Spatial coordinates */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current solution time */ + double *a_f, /*!< Computed source function (array size and layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + double *a_x, /*!< Spatial coordinates */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar* ) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -135,8 +135,8 @@ int ShallowWater1DSourceFunction1( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = 0.5 * param->g * param->b[p] * param->b[p]; + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = 0.5 * param->m_g * param->m_b[p] * param->m_b[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -153,20 +153,20 @@ int ShallowWater1DSourceFunction1( http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DSourceFunction2( - double *f, /*!< Computed source function (array size and layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - double *x, /*!< Spatial coordinates */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current solution time */ + double *a_f, /*!< Computed source function (array size and layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + double *a_x, /*!< Spatial coordinates */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar* ) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -179,8 +179,8 @@ int ShallowWater1DSourceFunction2( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = param->b[p]; + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = param->m_b[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DSourceUpwind.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DSourceUpwind.c index 977d788a..daf3f8ff 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DSourceUpwind.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DSourceUpwind.c @@ -20,32 +20,32 @@ http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DSourceUpwindLLF( - double *fI, /*!< Computed interface source term ("upwinded") */ - double *fL, /*!< Left-biased interface source term */ - double *fR, /*!< Right-biased interface source term */ - double *u, /*!< Solution (conserved variables) */ - int dir, /*!< Spatial dimension (unused since this is a 1D case) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed interface source term ("upwinded") */ + double *a_fL, /*!< Left-biased interface source term */ + double *a_fR, /*!< Right-biased interface source term */ + double *a_u, /*!< Solution (conserved variables) */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D case) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -62,32 +62,32 @@ int ShallowWater1DSourceUpwindLLF( http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DSourceUpwindRoe( - double *fI, /*!< Computed interface source term ("upwinded") */ - double *fL, /*!< Left-biased interface source term */ - double *fR, /*!< Right-biased interface source term */ - double *u, /*!< Solution (conserved variables) */ - int dir, /*!< Spatial dimension (unused since this is a 1D case) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed interface source term ("upwinded") */ + double *a_fL, /*!< Left-biased interface source term */ + double *a_fR, /*!< Right-biased interface source term */ + double *a_u, /*!< Solution (conserved variables) */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D case) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DTopography.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DTopography.c index aa4aea8e..687997b6 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DTopography.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DTopography.c @@ -18,62 +18,62 @@ data from a file, if available, else sets it to a constant */ int ShallowWater1DTopography( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables*/ - int idx, /*!< Index of this simulation */ - int nsims, /*!< Total number of simulations */ - int *dim_topo /*!< Grid dimensions of the advection field stored in file */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables*/ + int a_idx, /*!< Index of this simulation */ + int a_nsims, /*!< Total number of simulations */ + int *a_dim_topo /*!< Grid dimensions of the advection field stored in file */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; - double *S = param->b; - int d, done, *dim = solver->dim_local, - ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; + double *S = param->m_b; + int d, done, *dim = solver->m_dim_local, + ghosts = solver->m_ghosts; _DECLARE_IERR_; char fname_root[_MAX_STRING_SIZE_] = "topography"; - if (idx >= 0) { - if (nsims > 1) { + if (a_idx >= 0) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(idx, index, (int)log10(nsims)+1); + GetStringFromInteger(a_idx, index, (int)log10(a_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } } /* read topography from provided file, if available */ - if (dim_topo == NULL) { - int ierr = ReadArray( solver->ndims, + if (a_dim_topo == NULL) { + int ierr = ReadArray( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - solver->ghosts, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, solver, mpi, NULL, S, fname_root, - ¶m->topo_flag); + ¶m->m_topo_flag); if (ierr) { fprintf(stderr,"Error in ShallowWater1DTopography()\n"); fprintf(stderr," ReadArray() returned error!\n"); return ierr; } } else { - int ierr = ReadArraywInterp( solver->ndims, + int ierr = ReadArraywInterp( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - dim_topo, - solver->ghosts, + solver->m_dim_global, + solver->m_dim_local, + a_dim_topo, + solver->m_ghosts, solver, mpi, NULL, S, fname_root, - ¶m->topo_flag); + ¶m->m_topo_flag); if (ierr) { fprintf(stderr,"Error in ShallowWater1DTopography()\n"); fprintf(stderr," ReadArraywInterp() returned error!\n"); @@ -81,17 +81,17 @@ int ShallowWater1DTopography( } } - if (!param->topo_flag) { + if (!param->m_topo_flag) { /* if topography file not available, set it to zero */ - _ArraySetValue_(S,solver->npoints_local_wghosts,0.0); + _ArraySetValue_(S,solver->m_npoints_local_wghosts,0.0); } /* if parallel, exchange MPI-boundary ghost point data */ - IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,1,solver->dim_local, - solver->ghosts,mpi,S); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,1,solver->m_dim_local, + solver->m_ghosts,mpi,S); CHECKERR(ierr); - if (param->bt_type) { + if (param->m_bt_type) { /* if topography is periodic, then the overall problem must also be periodic (i.e. boundary conditions will be specified as periodic). Hence, MPIExchangeBoundariesnD() will take care of setting the ghosts points @@ -100,7 +100,7 @@ int ShallowWater1DTopography( int indexb[_MODEL_NDIMS_], indexi[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { - if (mpi->iproc[d] == 1) { + if (mpi->m_iproc[d] == 1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; /* left boundary */ done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -130,7 +130,7 @@ int ShallowWater1DTopography( offset[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { /* left boundary */ - if (!mpi->ip[d]) { + if (!mpi->m_ip[d]) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = -ghosts; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -143,7 +143,7 @@ int ShallowWater1DTopography( } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = dim[d]; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DUpwind.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DUpwind.c index 4e67067d..590d75eb 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DUpwind.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DUpwind.c @@ -29,48 +29,48 @@ */ int ShallowWater1DUpwindRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; int done,k; - int ndims = solver->ndims; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts= solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); - _ShallowWater1DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); + _ShallowWater1DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); _ShallowWater1DEigenvalues_ (uavg,D,param,0); _ShallowWater1DLeftEigenvectors_ (uavg,L,param,0); _ShallowWater1DRightEigenvectors_ (uavg,R,param,0); @@ -84,8 +84,8 @@ int ShallowWater1DUpwindRoe( udiss[0] = modA[0*_MODEL_NVARS_+0]*udiff[0] + modA[0*_MODEL_NVARS_+1]*udiff[1]; udiss[1] = modA[1*_MODEL_NVARS_+0]*udiff[0] + modA[1*_MODEL_NVARS_+1]*udiff[1]; - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -112,36 +112,36 @@ int ShallowWater1DUpwindRoe( http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater1DUpwindLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension (unused since this is a 1D system) */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension (unused since this is a 1D system) */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater1D *param = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater1D *param = (ShallowWater1D*) solver->m_physics; int done,k; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); @@ -150,22 +150,22 @@ int ShallowWater1DUpwindLLF( /* Local Lax-Friedrich upwinding scheme */ - _ShallowWater1DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); + _ShallowWater1DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); _ShallowWater1DEigenvalues_ (uavg,D,param,0); _ShallowWater1DLeftEigenvectors_ (uavg,L,param,0); _ShallowWater1DRightEigenvectors_(uavg,R,param,0); /* calculate characteristic fluxes and variables */ - MatVecMult2(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult2(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult2(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult2(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult2(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult2(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult2(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult2(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); for (k = 0; k < _MODEL_NVARS_; k++) { double eigL,eigC,eigR; - _ShallowWater1DEigenvalues_((u+_MODEL_NVARS_*pL),D,param,0); + _ShallowWater1DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param,0); eigL = D[k*_MODEL_NVARS_+k]; - _ShallowWater1DEigenvalues_((u+_MODEL_NVARS_*pR),D,param,0); + _ShallowWater1DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param,0); eigR = D[k*_MODEL_NVARS_+k]; _ShallowWater1DEigenvalues_(uavg,D,param,0); eigC = D[k*_MODEL_NVARS_+k]; @@ -175,7 +175,7 @@ int ShallowWater1DUpwindLLF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult2(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult2(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/ShallowWater1D/ShallowWater1DWriteTopography.c b/src/PhysicalModels/ShallowWater1D/ShallowWater1DWriteTopography.c index 247e6707..bad4d949 100644 --- a/src/PhysicalModels/ShallowWater1D/ShallowWater1DWriteTopography.c +++ b/src/PhysicalModels/ShallowWater1D/ShallowWater1DWriteTopography.c @@ -14,45 +14,45 @@ #include /*! Write out the topography data to file */ -int ShallowWater1DWriteTopography( void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int ShallowWater1DWriteTopography( void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater1D *params = (ShallowWater1D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater1D *params = (ShallowWater1D*) solver->m_physics; _DECLARE_IERR_; - if (params->topo_flag) { + if (params->m_topo_flag) { char fname_root[_MAX_STRING_SIZE_] = "topography"; - if (solver->nsims > 1) { + if (solver->m_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); strcat(fname_root, "_"); } - WriteArray( solver->ndims, + WriteArray( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - params->b, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + params->m_b, solver, mpi, fname_root ); - if (!strcmp(solver->plot_solution, "yes")) { - PlotArray( solver->ndims, + if (!strcmp(solver->m_plot_solution, "yes")) { + PlotArray( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - params->b, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + params->m_b, a_t, solver,mpi, fname_root ); diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DCleanup.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DCleanup.c index 9b9517ca..91ce2179 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DCleanup.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DCleanup.c @@ -8,10 +8,10 @@ /*! Function to clean up all physics-related allocations for the 2D shallow water equations */ int ShallowWater2DCleanup( - void *s /*!< Solver object of type #HyPar */ + void *a_s /*!< Solver object of type #HyPar */ ) { - ShallowWater2D *param = (ShallowWater2D*) s; - free(param->b); + ShallowWater2D *param = (ShallowWater2D*) a_s; + free(param->m_b); return(0); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DComputeCFL.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DComputeCFL.c index 34088d80..16ddb043 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DComputeCFL.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DComputeCFL.c @@ -15,20 +15,20 @@ is computed over the local domain on this processor only. */ double ShallowWater2DComputeCFL( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; int index[ndims]; - double *u = solver->u; + double *u = solver->m_u; double max_cfl = 0; int done = 0; _ArraySetValue_(index,ndims,0); @@ -37,11 +37,11 @@ double ShallowWater2DComputeCFL( double h, uvel, vvel, c, dxinv, dyinv, local_cfl[_MODEL_NDIMS_]; _ShallowWater2DGetFlowVar_((u+_MODEL_NVARS_*p),h,uvel,vvel); - _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->dxinv,dxinv); /* 1/dx */ - _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->dxinv,dyinv); /* 1/dy */ - c = sqrt(param->g*h); /* speed of gravity waves */ - local_cfl[_XDIR_]=(absolute(uvel)+c)*dt*dxinv;/* local cfl for this grid point (x) */ - local_cfl[_YDIR_]=(absolute(vvel)+c)*dt*dyinv;/* local cfl for this grid point (y) */ + _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,solver->m_dxinv,dxinv); /* 1/dx */ + _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_dxinv,dyinv); /* 1/dy */ + c = sqrt(param->m_g*h); /* speed of gravity waves */ + local_cfl[_XDIR_]=(absolute(uvel)+c)*a_dt*dxinv;/* local cfl for this grid point (x) */ + local_cfl[_YDIR_]=(absolute(vvel)+c)*a_dt*dyinv;/* local cfl for this grid point (y) */ if (local_cfl[_XDIR_] > max_cfl) max_cfl = local_cfl[_XDIR_]; if (local_cfl[_YDIR_] > max_cfl) max_cfl = local_cfl[_YDIR_]; diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DEigen.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DEigen.c index ac1b5547..483139b4 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DEigen.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DEigen.c @@ -17,15 +17,15 @@ to interpolation functions for a characteristic-based reconstruction. */ int ShallowWater2DLeftEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *L, /*!< Array of size nvar^2 = 3^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_L, /*!< Array of size nvar^2 = 3^2 to save the matrix of left eigenvectors in (row-major format). */ - void *p, /*!< Object of type #ShallowWater2D with physics-related variables */ - int dir /*!< Spatial dimension */ + void *a_p, /*!< Object of type #ShallowWater2D with physics-related variables */ + int a_dir /*!< Spatial dimension */ ) { - ShallowWater2D *param = (ShallowWater2D*) p; - _ShallowWater2DLeftEigenvectors_(u,L,param,dir); + ShallowWater2D *param = (ShallowWater2D*) a_p; + _ShallowWater2DLeftEigenvectors_(a_u,a_L,param,a_dir); return(0); } @@ -36,14 +36,14 @@ int ShallowWater2DLeftEigenvectors( to interpolation functions for a characteristic-based reconstruction. */ int ShallowWater2DRightEigenvectors( - double *u, /*!< Conserved solution at a grid point */ - double *R, /*!< Array of size nvar^2 = 3^2 to save the matrix of + double *a_u, /*!< Conserved solution at a grid point */ + double *a_R, /*!< Array of size nvar^2 = 3^2 to save the matrix of right eigenvectors in (row-major format). */ - void *p, /*!< Object of type #ShallowWater2D with physics-related variables */ - int dir /*!< Spatial dimension */ + void *a_p, /*!< Object of type #ShallowWater2D with physics-related variables */ + int a_dir /*!< Spatial dimension */ ) { - ShallowWater2D *param = (ShallowWater2D*) p; - _ShallowWater2DRightEigenvectors_(u,R,param,dir); + ShallowWater2D *param = (ShallowWater2D*) a_p; + _ShallowWater2DRightEigenvectors_(a_u,a_R,param,a_dir); return(0); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DFlux.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DFlux.c index cf18375b..6e797fa3 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DFlux.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DFlux.c @@ -18,17 +18,17 @@ \f} */ int ShallowWater2DFlux( - double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the conserved solution */ - int dir,/*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ + double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the conserved solution */ + int a_dir,/*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; static const int ndims = _MODEL_NDIMS_; static const int nvars = _MODEL_NVARS_; static int index[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; @@ -42,8 +42,8 @@ int ShallowWater2DFlux( while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double h, uvel, vvel; - _ShallowWater2DGetFlowVar_((u+nvars*p),h,uvel,vvel); - _ShallowWater2DSetFlux_((f+nvars*p),h,uvel,vvel,param->g,dir); + _ShallowWater2DGetFlowVar_((a_u+nvars*p),h,uvel,vvel); + _ShallowWater2DSetFlux_((a_f+nvars*p),h,uvel,vvel,param->m_g,a_dir); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DFunctions.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DFunctions.c index a9fc4174..0a50db45 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DFunctions.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DFunctions.c @@ -14,13 +14,13 @@ to interpolation functions for a characteristic-based reconstruction. */ int ShallowWater2DRoeAverage( - double *uavg, /*!< The computed Roe-averaged state */ - double *uL, /*!< Left state (conserved variables)*/ - double *uR, /*!< Right state (conserved variables)*/ - void *p /*!< Object of type #ShallowWater2D with physics-related variables */ + double *a_uavg, /*!< The computed Roe-averaged state */ + double *a_uL, /*!< Left state (conserved variables)*/ + double *a_uR, /*!< Right state (conserved variables)*/ + void *a_p /*!< Object of type #ShallowWater2D with physics-related variables */ ) { - ShallowWater2D *param = (ShallowWater2D*) p; - _ShallowWater2DRoeAverage_(uavg,uL,uR,param); + ShallowWater2D *param = (ShallowWater2D*) a_p; + _ShallowWater2DRoeAverage_(a_uavg,a_uL,a_uR,param); return(0); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DInitialize.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DInitialize.c index 21fe715b..a361c37f 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DInitialize.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DInitialize.c @@ -35,38 +35,38 @@ int ShallowWater2DWriteTopography (void*,void*,double); and set the physics-related function pointers in #HyPar. */ int ShallowWater2DInitialize( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< Object of type #MPIVariables containing MPI-related info */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related info */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater2D *physics = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater2D *physics = (ShallowWater2D*) solver->m_physics; int ferr, d; - static int count = 0; + static int s_count = 0; - if (solver->nvars != _MODEL_NVARS_) { + if (solver->m_nvars != _MODEL_NVARS_) { fprintf(stderr,"Error in ShallowWater2DInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); return(1); } - if (solver->ndims != _MODEL_NDIMS_) { + if (solver->m_ndims != _MODEL_NDIMS_) { fprintf(stderr,"Error in ShallowWater2DInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); return(1); } /* default values */ - physics->g = 1.0; - physics->bt_type = 0; + physics->m_g = 1.0; + physics->m_bt_type = 0; physics->fhat = 0.0; - physics->beta = 0.0; + physics->m_beta = 0.0; physics->D = 0.0; - strcpy(physics->upw_choice,"roe"); + strcpy(physics->m_upw_choice,"roe"); /* reading physical model specific inputs */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; - if (!count) printf("Reading physical model inputs from file \"physics.inp\".\n"); + if (!s_count) printf("Reading physical model inputs from file \"physics.inp\".\n"); in = fopen("physics.inp","r"); if (!in) printf("Warning: File \"physics.inp\" not found. Using default values.\n"); else { @@ -76,22 +76,22 @@ int ShallowWater2DInitialize( while (strcmp(word, "end")){ ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "gravity")) { - ferr = fscanf(in,"%lf",&physics->g); + ferr = fscanf(in,"%lf",&physics->m_g); if (ferr != 1) return(1); } else if (!strcmp(word, "topography_type")) { - ferr = fscanf(in,"%d",&physics->bt_type); + ferr = fscanf(in,"%d",&physics->m_bt_type); if (ferr != 1) return(1); } else if (!strcmp(word, "coriolis_fhat")) { ferr = fscanf(in,"%lf",&physics->fhat); if (ferr != 1) return(1); } else if (!strcmp(word, "coriolis_beta")) { - ferr = fscanf(in,"%lf",&physics->beta); + ferr = fscanf(in,"%lf",&physics->m_beta); if (ferr != 1) return(1); } else if (!strcmp(word, "coriolis_D")) { ferr = fscanf(in,"%lf",&physics->D); if (ferr != 1) return(1); } else if (!strcmp(word,"upwinding")) { - ferr = fscanf(in,"%s",physics->upw_choice); + ferr = fscanf(in,"%s",physics->m_upw_choice); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; @@ -109,12 +109,12 @@ int ShallowWater2DInitialize( } #ifndef serial - IERR MPIBroadcast_double (&physics->g ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&physics->bt_type ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->fhat ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->beta ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (&physics->D ,1,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_character (physics->upw_choice,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_g ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&physics->m_bt_type ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->fhat ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->m_beta ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (&physics->D ,1,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_character (physics->m_upw_choice,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); #endif /* initializing physical model-specific functions */ @@ -123,11 +123,11 @@ int ShallowWater2DInitialize( solver->SFunction = ShallowWater2DSource; solver->UFunction = ShallowWater2DModifiedSolution; solver->JFunction = ShallowWater2DJacobian; - if (!strcmp(physics->upw_choice,_ROE_ )) solver->Upwind = ShallowWater2DUpwindRoe; - else if (!strcmp(physics->upw_choice,_LLF_ )) solver->Upwind = ShallowWater2DUpwindLLF; + if (!strcmp(physics->m_upw_choice,_ROE_ )) solver->Upwind = ShallowWater2DUpwindRoe; + else if (!strcmp(physics->m_upw_choice,_LLF_ )) solver->Upwind = ShallowWater2DUpwindLLF; else { - if (!mpi->rank) fprintf(stderr,"Error in ShallowWater2DInitialize(): %s is not a valid upwinding scheme.\n", - physics->upw_choice); + if (!mpi->m_rank) fprintf(stderr,"Error in ShallowWater2DInitialize(): %s is not a valid upwinding scheme.\n", + physics->m_upw_choice); return(1); } solver->AveragingFunction = ShallowWater2DRoeAverage; @@ -135,13 +135,13 @@ int ShallowWater2DInitialize( solver->GetRightEigenvectors = ShallowWater2DRightEigenvectors; solver->PhysicsOutput = ShallowWater2DWriteTopography; - if (!strcmp(physics->upw_choice,_LLF_ )) physics->SourceUpwind = ShallowWater2DSourceUpwindLLF; - else if (!strcmp(physics->upw_choice,_ROE_ )) physics->SourceUpwind = ShallowWater2DSourceUpwindRoe; + if (!strcmp(physics->m_upw_choice,_LLF_ )) physics->SourceUpwind = ShallowWater2DSourceUpwindLLF; + else if (!strcmp(physics->m_upw_choice,_ROE_ )) physics->SourceUpwind = ShallowWater2DSourceUpwindRoe; /* allocate array to hold the bottom topography field */ - physics->b = (double*) calloc (solver->npoints_local_wghosts, sizeof(double)); + physics->m_b = (double*) calloc (solver->m_npoints_local_wghosts, sizeof(double)); solver->PhysicsInput = ShallowWater2DTopography; - count++; + s_count++; return(0); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DJacobian.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DJacobian.c index 591e56f4..a6deecb9 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DJacobian.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DJacobian.c @@ -12,32 +12,32 @@ is returned as a 1D array (double) of 4 elements in row-major format. */ int ShallowWater2DJacobian( - double *Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 9 */ - double *u, /*!< solution at a grid point (array of size nvar = 3) */ - void *p, /*!< object containing the physics-related parameters */ - int dir, /*!< spatial dimension (x/y) */ - int nvars,/*!< number of vector components */ - int upw /*!< 0 -> send back complete Jacobian, + double *a_Jac, /*!< Jacobian matrix: 1D array of size nvar^2 = 9 */ + double *a_u, /*!< solution at a grid point (array of size nvar = 3) */ + void *a_p, /*!< object containing the physics-related parameters */ + int a_dir, /*!< spatial dimension (x/y) */ + int a_nvars,/*!< number of vector components */ + int a_upw /*!< 0 -> send back complete Jacobian, 1 -> send back Jacobian of right(+)-moving flux, -1 -> send back Jacobian of left(-)-moving flux */ ) { - ShallowWater2D *param = (ShallowWater2D*) p; + ShallowWater2D *param = (ShallowWater2D*) a_p; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_]; /* get the eigenvalues and left,right eigenvectors */ - _ShallowWater2DEigenvalues_ (u,D,param,dir); - _ShallowWater2DLeftEigenvectors_ (u,L,param,dir); - _ShallowWater2DRightEigenvectors_(u,R,param,dir); + _ShallowWater2DEigenvalues_ (a_u,D,param,a_dir); + _ShallowWater2DLeftEigenvectors_ (a_u,L,param,a_dir); + _ShallowWater2DRightEigenvectors_(a_u,R,param,a_dir); - int aupw = absolute(upw), k; - k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 4; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); - k = 8; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+upw)*max(0,D[k]) + 0.5*aupw*(1-upw)*min(0,D[k]) ); + int aupw = absolute(a_upw), k; + k = 0; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 4; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); + k = 8; D[k] = absolute( (1-aupw)*D[k] + 0.5*aupw*(1+a_upw)*max(0,D[k]) + 0.5*aupw*(1-a_upw)*min(0,D[k]) ); MatMult3(_MODEL_NVARS_,DL,D,L); - MatMult3(_MODEL_NVARS_,Jac,R,DL); + MatMult3(_MODEL_NVARS_,a_Jac,R,DL); return(0); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DModifiedSolution.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DModifiedSolution.c index f9da9478..dd0662dd 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DModifiedSolution.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DModifiedSolution.c @@ -19,20 +19,20 @@ http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater2DModifiedSolution( - double *uC, /*!< The modified solution (same array size and layout as u) */ - double *u, /*!< The solution (conserved variables) */ - int d, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ + double *a_uC, /*!< The modified solution (same array size and layout as a_u) */ + double *a_u, /*!< The solution (conserved variables) */ + int a_d, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double waqt /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -46,10 +46,10 @@ int ShallowWater2DModifiedSolution( while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); double h,uvel,vvel; - _ShallowWater2DGetFlowVar_((u+_MODEL_NVARS_*p),h,uvel,vvel); - uC[_MODEL_NVARS_*p+0] = h + param->b[p]; - uC[_MODEL_NVARS_*p+1] = h * uvel; - uC[_MODEL_NVARS_*p+2] = h * vvel; + _ShallowWater2DGetFlowVar_((a_u+_MODEL_NVARS_*p),h,uvel,vvel); + a_uC[_MODEL_NVARS_*p+0] = h + param->m_b[p]; + a_uC[_MODEL_NVARS_*p+1] = h * uvel; + a_uC[_MODEL_NVARS_*p+2] = h * vvel; _ArrayIncrementIndex_(ndims,bounds,index,done); } return(0); diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DSource.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DSource.c index 26429d6a..be6c0565 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DSource.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DSource.c @@ -31,28 +31,28 @@ static int ShallowWater2DSourceFunction2 (double*,double*,double*,void*,void*,d Eqns. (2.1)-(2.3), (2.4) */ int ShallowWater2DSource( - double *source, /*!< Computed source terms (array size & layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current solution time */ + double *a_source, /*!< Computed source terms (array size & layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar* ) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; int v, done, p, p1, p2; - double *SourceI = solver->fluxI; /* interace source term */ - double *SourceC = solver->fluxC; /* cell-centered source term */ - double *SourceL = solver->fL; - double *SourceR = solver->fR; + double *SourceI = solver->m_flux_i; /* interace a_source term */ + double *SourceC = solver->m_flux_c; /* cell-centered a_source term */ + double *SourceL = solver->m_f_l; + double *SourceR = solver->m_f_r; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *x = solver->x; - double *dxinv = solver->dxinv; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *x = solver->m_x; + double *dxinv = solver->m_dxinv; int index[ndims],index1[ndims],index2[ndims],dim_interface[ndims]; /* Along X */ @@ -60,14 +60,14 @@ int ShallowWater2DSource( /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_XDIR_]++; - /* calculate the first source function */ - IERR ShallowWater2DSourceFunction1(SourceC,u,x,solver,mpi,t,_XDIR_); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the first a_source function */ + IERR ShallowWater2DSourceFunction1(SourceC,a_u,x,solver,mpi,a_t,_XDIR_); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_XDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -77,17 +77,17 @@ int ShallowWater2DSource( _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse); for (v=0; v<_MODEL_NVARS_; v++) - source[_MODEL_NVARS_*p+v] += (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; + a_source[_MODEL_NVARS_*p+v] += (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; _ArrayIncrementIndex_(ndims,dim,index,done); } - /* calculate the second source function */ - IERR ShallowWater2DSourceFunction2(SourceC,u,x,solver,mpi,t,_XDIR_); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_XDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the second a_source function */ + IERR ShallowWater2DSourceFunction2(SourceC,a_u,x,solver,mpi,a_t,_XDIR_); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_XDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_XDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -96,10 +96,10 @@ int ShallowWater2DSource( _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1); _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dx_inverse; _GetCoordinate_(_XDIR_,index[_XDIR_],dim,ghosts,dxinv,dx_inverse); - double h, uvel, vvel; _ShallowWater2DGetFlowVar_((u+_MODEL_NVARS_*p),h,uvel,vvel); - double term[_MODEL_NVARS_] = { 0.0, -param->g * (h + param->b[p]), 0.0 }; + double h, uvel, vvel; _ShallowWater2DGetFlowVar_((a_u+_MODEL_NVARS_*p),h,uvel,vvel); + double term[_MODEL_NVARS_] = { 0.0, -param->m_g * (h + param->m_b[p]), 0.0 }; for (v=0; v<_MODEL_NVARS_; v++) - source[_MODEL_NVARS_*p+v] += term[v]*(SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; + a_source[_MODEL_NVARS_*p+v] += term[v]*(SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dx_inverse; uvel = vvel = h; /* useless statement to avoid compiler warning */ _ArrayIncrementIndex_(ndims,dim,index,done); } @@ -109,14 +109,14 @@ int ShallowWater2DSource( /* set interface dimensions */ _ArrayCopy1D_(dim,dim_interface,ndims); dim_interface[_YDIR_]++; - /* calculate the first source function */ - IERR ShallowWater2DSourceFunction1(SourceC,u,x,solver,mpi,t,_YDIR_); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_YDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the first a_source function */ + IERR ShallowWater2DSourceFunction1(SourceC,a_u,x,solver,mpi,a_t,_YDIR_); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_YDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -126,17 +126,17 @@ int ShallowWater2DSource( _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dy_inverse; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,dxinv,dy_inverse); for (v=0; v<_MODEL_NVARS_; v++) - source[_MODEL_NVARS_*p+v] += (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dy_inverse; + a_source[_MODEL_NVARS_*p+v] += (SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dy_inverse; _ArrayIncrementIndex_(ndims,dim,index,done); } - /* calculate the second source function */ - IERR ShallowWater2DSourceFunction2(SourceC,u,x,solver,mpi,t,_YDIR_); CHECKERR(ierr); - /* calculate the left and right interface source terms */ - IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr); - IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr); - /* calculate the final interface source term */ - IERR param->SourceUpwind(SourceI,SourceL,SourceR,u,_YDIR_,solver,t); - /* calculate the final cell-centered source term */ + /* calculate the second a_source function */ + IERR ShallowWater2DSourceFunction2(SourceC,a_u,x,solver,mpi,a_t,_YDIR_); CHECKERR(ierr); + /* calculate the left and right interface a_source terms */ + IERR solver->InterpolateInterfacesHyp(SourceL,SourceC,a_u,x, 1,_YDIR_,solver,mpi,0); CHECKERR(ierr); + IERR solver->InterpolateInterfacesHyp(SourceR,SourceC,a_u,x,-1,_YDIR_,solver,mpi,0); CHECKERR(ierr); + /* calculate the final interface a_source term */ + IERR param->SourceUpwind(SourceI,SourceL,SourceR,a_u,_YDIR_,solver,a_t); + /* calculate the final cell-centered a_source term */ done = 0; _ArraySetValue_(index,ndims,0); while (!done) { _ArrayCopy1D_(index,index1,ndims); @@ -145,10 +145,10 @@ int ShallowWater2DSource( _ArrayIndex1D_(ndims,dim_interface,index1,0 ,p1); _ArrayIndex1D_(ndims,dim_interface,index2,0 ,p2); double dy_inverse; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,dxinv,dy_inverse); - double h, uvel, vvel; _ShallowWater2DGetFlowVar_((u+_MODEL_NVARS_*p),h,uvel,vvel); - double term[_MODEL_NVARS_] = { 0.0, 0.0, -param->g * (h + param->b[p]) }; + double h, uvel, vvel; _ShallowWater2DGetFlowVar_((a_u+_MODEL_NVARS_*p),h,uvel,vvel); + double term[_MODEL_NVARS_] = { 0.0, 0.0, -param->m_g * (h + param->m_b[p]) }; for (v=0; v<_MODEL_NVARS_; v++) - source[_MODEL_NVARS_*p+v] += term[v]*(SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dy_inverse; + a_source[_MODEL_NVARS_*p+v] += term[v]*(SourceI[_MODEL_NVARS_*p2+v]-SourceI[_MODEL_NVARS_*p1+v])*dy_inverse; uvel = vvel = h; /* useless statement to avoid compiler warning */ _ArrayIncrementIndex_(ndims,dim,index,done); } @@ -158,13 +158,13 @@ int ShallowWater2DSource( while (!done) { _ArrayIndex1D_(ndims,dim,index ,ghosts,p); double h, uvel, vvel; - _ShallowWater2DGetFlowVar_((u+_MODEL_NVARS_*p),h,uvel,vvel); - double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->x,ycoord); - double coeff = param->fhat + param->beta * (ycoord - 0.5*param->D); + _ShallowWater2DGetFlowVar_((a_u+_MODEL_NVARS_*p),h,uvel,vvel); + double ycoord; _GetCoordinate_(_YDIR_,index[_YDIR_],dim,ghosts,solver->m_x,ycoord); + double coeff = param->fhat + param->m_beta * (ycoord - 0.5*param->D); double coriolis_x = coeff * vvel, coriolis_y = -coeff * uvel; - source[_MODEL_NVARS_*p+1] += coriolis_x; - source[_MODEL_NVARS_*p+2] += coriolis_y; + a_source[_MODEL_NVARS_*p+1] += coriolis_x; + a_source[_MODEL_NVARS_*p+2] += coriolis_y; _ArrayIncrementIndex_(ndims,dim,index,done); } @@ -192,21 +192,21 @@ int ShallowWater2DSource( \f} */ int ShallowWater2DSourceFunction1( - double *f, /*!< Computed source function (array size and layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - double *x, /*!< Spatial coordinates */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current solution time */ - int dir /*!< Spatial dimension */ + double *a_f, /*!< Computed source function (array size and layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + double *a_x, /*!< Spatial coordinates */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current solution time */ + int a_dir /*!< Spatial dimension */ ) { - HyPar *solver = (HyPar* ) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -219,9 +219,9 @@ int ShallowWater2DSourceFunction1( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = (dir == _XDIR_ ? 0.5 * param->g * param->b[p] * param->b[p] : 0.0 ); - (f+_MODEL_NVARS_*p)[2] = (dir == _YDIR_ ? 0.5 * param->g * param->b[p] * param->b[p] : 0.0 ); + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = (a_dir == _XDIR_ ? 0.5 * param->m_g * param->m_b[p] * param->m_b[p] : 0.0 ); + (a_f+_MODEL_NVARS_*p)[2] = (a_dir == _YDIR_ ? 0.5 * param->m_g * param->m_b[p] * param->m_b[p] : 0.0 ); _ArrayIncrementIndex_(ndims,bounds,index,done); } @@ -249,21 +249,21 @@ int ShallowWater2DSourceFunction1( \f} */ int ShallowWater2DSourceFunction2( - double *f, /*!< Computed source function (array size and layout same as u) */ - double *u, /*!< Solution (conserved variables) */ - double *x, /*!< Spatial coordinates */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t, /*!< Current solution time */ - int dir /*!< Spatial dimension */ + double *a_f, /*!< Computed source function (array size and layout same as a_u) */ + double *a_u, /*!< Solution (conserved variables) */ + double *a_x, /*!< Spatial coordinates */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t, /*!< Current solution time */ + int a_dir /*!< Spatial dimension */ ) { - HyPar *solver = (HyPar* ) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar* ) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - int ndims = solver->ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + int ndims = solver->m_ndims; int index[ndims], bounds[ndims], offset[ndims]; /* set bounds for array index to include ghost points */ @@ -276,9 +276,9 @@ int ShallowWater2DSourceFunction2( int done = 0; _ArraySetValue_(index,ndims,0); while (!done) { int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - (f+_MODEL_NVARS_*p)[0] = 0.0; - (f+_MODEL_NVARS_*p)[1] = (dir == _XDIR_ ? param->b[p] : 0.0 ); - (f+_MODEL_NVARS_*p)[2] = (dir == _YDIR_ ? param->b[p] : 0.0 ); + (a_f+_MODEL_NVARS_*p)[0] = 0.0; + (a_f+_MODEL_NVARS_*p)[1] = (a_dir == _XDIR_ ? param->m_b[p] : 0.0 ); + (a_f+_MODEL_NVARS_*p)[2] = (a_dir == _YDIR_ ? param->m_b[p] : 0.0 ); _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DSourceUpwind.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DSourceUpwind.c index 5428e714..da745d5c 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DSourceUpwind.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DSourceUpwind.c @@ -20,32 +20,32 @@ http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater2DSourceUpwindLLF( - double *fI, /*!< Computed interface source term ("upwinded") */ - double *fL, /*!< Left-biased interface source term */ - double *fR, /*!< Right-biased interface source term */ - double *u, /*!< Solution (conserved variables) */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed interface source term ("upwinded") */ + double *a_fL, /*!< Left-biased interface source term */ + double *a_fR, /*!< Right-biased interface source term */ + double *a_u, /*!< Solution (conserved variables) */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -62,32 +62,32 @@ int ShallowWater2DSourceUpwindLLF( http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater2DSourceUpwindRoe( - double *fI, /*!< Computed interface source term ("upwinded") */ - double *fL, /*!< Left-biased interface source term */ - double *fR, /*!< Right-biased interface source term */ - double *u, /*!< Solution (conserved variables) */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed interface source term ("upwinded") */ + double *a_fL, /*!< Left-biased interface source term */ + double *a_fR, /*!< Right-biased interface source term */ + double *a_u, /*!< Solution (conserved variables) */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int done,k; - int ndims = solver->ndims; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); for (k = 0; k < _MODEL_NVARS_; k++) - (fI+_MODEL_NVARS_*p)[k] = 0.5 * ((fL+_MODEL_NVARS_*p)[k] + (fR+_MODEL_NVARS_*p)[k]); + (a_fI+_MODEL_NVARS_*p)[k] = 0.5 * ((a_fL+_MODEL_NVARS_*p)[k] + (a_fR+_MODEL_NVARS_*p)[k]); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DTopography.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DTopography.c index a1fbef08..fe84047c 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DTopography.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DTopography.c @@ -18,62 +18,62 @@ data from a file, if available, else sets it to a constant */ int ShallowWater2DTopography( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables*/ - int idx, /*!< Index of this simulation */ - int nsims, /*!< Total number of simulations */ - int *dim_topo /*!< Grid dimensions of the advection field stored in file */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables*/ + int a_idx, /*!< Index of this simulation */ + int a_nsims, /*!< Total number of simulations */ + int *a_dim_topo /*!< Grid dimensions of the advection field stored in file */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; - double *S = param->b; - int d, done, *dim = solver->dim_local, - ghosts = solver->ghosts; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; + double *S = param->m_b; + int d, done, *dim = solver->m_dim_local, + ghosts = solver->m_ghosts; _DECLARE_IERR_; char fname_root[_MAX_STRING_SIZE_] = "topography"; - if (idx >= 0) { - if (nsims > 1) { + if (a_idx >= 0) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(idx, index, (int)log10(nsims)+1); + GetStringFromInteger(a_idx, index, (int)log10(a_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } } /* read topography from provided file, if available */ - if (dim_topo == NULL) { - int ierr = ReadArray( solver->ndims, + if (a_dim_topo == NULL) { + int ierr = ReadArray( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - solver->ghosts, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, solver, mpi, NULL, S, fname_root, - ¶m->topo_flag); + ¶m->m_topo_flag); if (ierr) { fprintf(stderr,"Error in ShallowWater2DTopography()\n"); fprintf(stderr," ReadArray() returned error!\n"); return ierr; } } else { - int ierr = ReadArraywInterp( solver->ndims, + int ierr = ReadArraywInterp( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - dim_topo, - solver->ghosts, + solver->m_dim_global, + solver->m_dim_local, + a_dim_topo, + solver->m_ghosts, solver, mpi, NULL, S, fname_root, - ¶m->topo_flag); + ¶m->m_topo_flag); if (ierr) { fprintf(stderr,"Error in ShallowWater2DTopography()\n"); fprintf(stderr," ReadArraywInterp() returned error!\n"); @@ -81,17 +81,17 @@ int ShallowWater2DTopography( } } - if (!param->topo_flag) { + if (!param->m_topo_flag) { /* if topography file not available, set it to zero */ - _ArraySetValue_(S,solver->npoints_local_wghosts,0.0); + _ArraySetValue_(S,solver->m_npoints_local_wghosts,0.0); } /* if parallel, exchange MPI-boundary ghost point data */ - IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,1,solver->dim_local, - solver->ghosts,mpi,S); CHECKERR(ierr); + IERR MPIExchangeBoundariesnD(_MODEL_NDIMS_,1,solver->m_dim_local, + solver->m_ghosts,mpi,S); CHECKERR(ierr); - if (param->bt_type) { + if (param->m_bt_type) { /* if topography is periodic, then the overall problem must also be periodic (i.e. boundary conditions will be specified as periodic). Hence, MPIExchangeBoundariesnD() will take care of setting the ghosts points @@ -100,7 +100,7 @@ int ShallowWater2DTopography( int indexb[_MODEL_NDIMS_], indexi[_MODEL_NDIMS_], bounds[_MODEL_NDIMS_], offset[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { - if (mpi->iproc[d] == 1) { + if (mpi->m_iproc[d] == 1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; /* left boundary */ done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -130,7 +130,7 @@ int ShallowWater2DTopography( offset[_MODEL_NDIMS_]; for (d = 0; d < _MODEL_NDIMS_; d++) { /* left boundary */ - if (!mpi->ip[d]) { + if (!mpi->m_ip[d]) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = -ghosts; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); @@ -143,7 +143,7 @@ int ShallowWater2DTopography( } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { _ArrayCopy1D_(dim,bounds,_MODEL_NDIMS_); bounds[d] = ghosts; _ArraySetValue_(offset,_MODEL_NDIMS_,0); offset[d] = dim[d]; done = 0; _ArraySetValue_(indexb,_MODEL_NDIMS_,0); diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DUpwind.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DUpwind.c index 8b911458..891c059c 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DUpwind.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DUpwind.c @@ -29,52 +29,52 @@ */ int ShallowWater2DUpwindRoe( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; int done,k; - int ndims = solver->ndims; - int ghosts= solver->ghosts; - int *dim = solver->dim_local; + int ndims = solver->m_ndims; + int ghosts= solver->m_ghosts; + int *dim = solver->m_dim_local; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_], DL[_MODEL_NVARS_*_MODEL_NVARS_], modA[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); double udiff[_MODEL_NVARS_], uavg[_MODEL_NVARS_],udiss[_MODEL_NVARS_]; - /* Roe's upwinding scheme */ + /* Roe'a_s upwinding scheme */ - udiff[0] = 0.5 * (uR[_MODEL_NVARS_*p+0] - uL[_MODEL_NVARS_*p+0]); - udiff[1] = 0.5 * (uR[_MODEL_NVARS_*p+1] - uL[_MODEL_NVARS_*p+1]); - udiff[2] = 0.5 * (uR[_MODEL_NVARS_*p+2] - uL[_MODEL_NVARS_*p+2]); + udiff[0] = 0.5 * (a_uR[_MODEL_NVARS_*p+0] - a_uL[_MODEL_NVARS_*p+0]); + udiff[1] = 0.5 * (a_uR[_MODEL_NVARS_*p+1] - a_uL[_MODEL_NVARS_*p+1]); + udiff[2] = 0.5 * (a_uR[_MODEL_NVARS_*p+2] - a_uL[_MODEL_NVARS_*p+2]); - _ShallowWater2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); - _ShallowWater2DEigenvalues_ (uavg,D,param,dir); - _ShallowWater2DLeftEigenvectors_ (uavg,L,param,dir); - _ShallowWater2DRightEigenvectors_ (uavg,R,param,dir); + _ShallowWater2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); + _ShallowWater2DEigenvalues_ (uavg,D,param,a_dir); + _ShallowWater2DLeftEigenvectors_ (uavg,L,param,a_dir); + _ShallowWater2DRightEigenvectors_ (uavg,R,param,a_dir); k = 0; D[k] = absolute(D[k]); k = 4; D[k] = absolute(D[k]); @@ -87,9 +87,9 @@ int ShallowWater2DUpwindRoe( udiss[1] = modA[1*_MODEL_NVARS_+0]*udiff[0] + modA[1*_MODEL_NVARS_+1]*udiff[1] + modA[1*_MODEL_NVARS_+2]*udiff[2]; udiss[2] = modA[2*_MODEL_NVARS_+0]*udiff[0] + modA[2*_MODEL_NVARS_+1]*udiff[1] + modA[2*_MODEL_NVARS_+2]*udiff[2]; - fI[_MODEL_NVARS_*p+0] = 0.5 * (fL[_MODEL_NVARS_*p+0]+fR[_MODEL_NVARS_*p+0]) - udiss[0]; - fI[_MODEL_NVARS_*p+1] = 0.5 * (fL[_MODEL_NVARS_*p+1]+fR[_MODEL_NVARS_*p+1]) - udiss[1]; - fI[_MODEL_NVARS_*p+2] = 0.5 * (fL[_MODEL_NVARS_*p+2]+fR[_MODEL_NVARS_*p+2]) - udiss[2]; + a_fI[_MODEL_NVARS_*p+0] = 0.5 * (a_fL[_MODEL_NVARS_*p+0]+a_fR[_MODEL_NVARS_*p+0]) - udiss[0]; + a_fI[_MODEL_NVARS_*p+1] = 0.5 * (a_fL[_MODEL_NVARS_*p+1]+a_fR[_MODEL_NVARS_*p+1]) - udiss[1]; + a_fI[_MODEL_NVARS_*p+2] = 0.5 * (a_fL[_MODEL_NVARS_*p+2]+a_fR[_MODEL_NVARS_*p+2]) - udiss[2]; } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } @@ -116,36 +116,36 @@ int ShallowWater2DUpwindRoe( http://dx.doi.org/10.1016/j.jcp.2005.02.006 */ int ShallowWater2DUpwindLLF( - double *fI, /*!< Computed upwind interface flux */ - double *fL, /*!< Left-biased reconstructed interface flux */ - double *fR, /*!< Right-biased reconstructed interface flux */ - double *uL, /*!< Left-biased reconstructed interface solution */ - double *uR, /*!< Right-biased reconstructed interface solution */ - double *u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ + double *a_fI, /*!< Computed upwind interface flux */ + double *a_fL, /*!< Left-biased reconstructed interface flux */ + double *a_fR, /*!< Right-biased reconstructed interface flux */ + double *a_uL, /*!< Left-biased reconstructed interface solution */ + double *a_uR, /*!< Right-biased reconstructed interface solution */ + double *a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - ShallowWater2D *param = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + ShallowWater2D *param = (ShallowWater2D*) solver->m_physics; int done,k; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; static double R[_MODEL_NVARS_*_MODEL_NVARS_], D[_MODEL_NVARS_*_MODEL_NVARS_], L[_MODEL_NVARS_*_MODEL_NVARS_]; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int pL; _ArrayIndex1D_(ndims,dim,indexL,ghosts,pL); int pR; _ArrayIndex1D_(ndims,dim,indexR,ghosts,pR); @@ -154,24 +154,24 @@ int ShallowWater2DUpwindLLF( /* Local Lax-Friedrich upwinding scheme */ - _ShallowWater2DRoeAverage_ (uavg,(u+_MODEL_NVARS_*pL),(u+_MODEL_NVARS_*pR),param); - _ShallowWater2DEigenvalues_ (uavg,D,param,dir); - _ShallowWater2DLeftEigenvectors_ (uavg,L,param,dir); - _ShallowWater2DRightEigenvectors_(uavg,R,param,dir); + _ShallowWater2DRoeAverage_ (uavg,(a_u+_MODEL_NVARS_*pL),(a_u+_MODEL_NVARS_*pR),param); + _ShallowWater2DEigenvalues_ (uavg,D,param,a_dir); + _ShallowWater2DLeftEigenvectors_ (uavg,L,param,a_dir); + _ShallowWater2DRightEigenvectors_(uavg,R,param,a_dir); /* calculate characteristic fluxes and variables */ - MatVecMult3(_MODEL_NVARS_,ucL,L,(uL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,ucR,L,(uR+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcL,L,(fL+_MODEL_NVARS_*p)); - MatVecMult3(_MODEL_NVARS_,fcR,L,(fR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucL,L,(a_uL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,ucR,L,(a_uR+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcL,L,(a_fL+_MODEL_NVARS_*p)); + MatVecMult3(_MODEL_NVARS_,fcR,L,(a_fR+_MODEL_NVARS_*p)); for (k = 0; k < _MODEL_NVARS_; k++) { double eigL,eigC,eigR; - _ShallowWater2DEigenvalues_((u+_MODEL_NVARS_*pL),D,param,dir); + _ShallowWater2DEigenvalues_((a_u+_MODEL_NVARS_*pL),D,param,a_dir); eigL = D[k*_MODEL_NVARS_+k]; - _ShallowWater2DEigenvalues_((u+_MODEL_NVARS_*pR),D,param,dir); + _ShallowWater2DEigenvalues_((a_u+_MODEL_NVARS_*pR),D,param,a_dir); eigR = D[k*_MODEL_NVARS_+k]; - _ShallowWater2DEigenvalues_(uavg,D,param,dir); + _ShallowWater2DEigenvalues_(uavg,D,param,a_dir); eigC = D[k*_MODEL_NVARS_+k]; double alpha = max3(absolute(eigL),absolute(eigC),absolute(eigR)); @@ -179,7 +179,7 @@ int ShallowWater2DUpwindLLF( } /* calculate the interface flux from the characteristic flux */ - MatVecMult3(_MODEL_NVARS_,(fI+_MODEL_NVARS_*p),R,fc); + MatVecMult3(_MODEL_NVARS_,(a_fI+_MODEL_NVARS_*p),R,fc); } _ArrayIncrementIndex_(ndims,bounds_outer,index_outer,done); } diff --git a/src/PhysicalModels/ShallowWater2D/ShallowWater2DWriteTopography.c b/src/PhysicalModels/ShallowWater2D/ShallowWater2DWriteTopography.c index 26e35115..5d6f1554 100644 --- a/src/PhysicalModels/ShallowWater2D/ShallowWater2DWriteTopography.c +++ b/src/PhysicalModels/ShallowWater2D/ShallowWater2DWriteTopography.c @@ -14,45 +14,45 @@ #include /*! Write out the topography data to file */ -int ShallowWater2DWriteTopography( void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int ShallowWater2DWriteTopography( void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - ShallowWater2D *params = (ShallowWater2D*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + ShallowWater2D *params = (ShallowWater2D*) solver->m_physics; _DECLARE_IERR_; - if (params->topo_flag) { + if (params->m_topo_flag) { char fname_root[_MAX_STRING_SIZE_] = "topography"; - if (solver->nsims > 1) { + if (solver->m_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); strcat(fname_root, "_"); } - WriteArray( solver->ndims, + WriteArray( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - params->b, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + params->m_b, solver, mpi, fname_root ); - if (!strcmp(solver->plot_solution, "yes")) { - PlotArray( solver->ndims, + if (!strcmp(solver->m_plot_solution, "yes")) { + PlotArray( solver->m_ndims, 1, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - params->b, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + params->m_b, a_t, solver, mpi, diff --git a/src/PhysicalModels/Vlasov/VlasovAdvection.c b/src/PhysicalModels/Vlasov/VlasovAdvection.c index 9fd274ba..02449d74 100644 --- a/src/PhysicalModels/Vlasov/VlasovAdvection.c +++ b/src/PhysicalModels/Vlasov/VlasovAdvection.c @@ -19,20 +19,20 @@ double VlasovAdvectionCoeff(int*, int, void*); where the advection coefficient \f$c\f$ is computed by VlasovAdvectionCoeff(). */ -int VlasovAdvection( double *f, /*!< Array to hold the computed flux (same size and layout as u) */ - double *u, /*!< Array containing the conserved solution */ - int dir, /*!< Spatial dimension */ - void *s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ +int VlasovAdvection( double *a_f, /*!< Array to hold the computed flux (same size and layout as a_u) */ + double *a_u, /*!< Array containing the conserved solution */ + int a_dir, /*!< Spatial dimension */ + void *a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; - int* dim = solver->dim_local; - int ghosts = solver->ghosts; - int ndims = solver->ndims; + int* dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; // set bounds for array index to include ghost points int bounds[ndims]; @@ -50,10 +50,10 @@ int VlasovAdvection( double *f, /*!< Array to hold the computed flux (same si _ArrayCopy1D_(index, index_wog, ndims); for (int i = 0; i < ndims; i++) index_wog[i] -= ghosts; - double adv_coeff = VlasovAdvectionCoeff(index_wog, dir, solver); + double adv_coeff = VlasovAdvectionCoeff(index_wog, a_dir, solver); int p; _ArrayIndex1DWO_(ndims,dim,index,offset,ghosts,p); - f[p] = adv_coeff * u[p]; + a_f[p] = adv_coeff * a_u[p]; _ArrayIncrementIndex_(ndims,bounds,index,done); } diff --git a/src/PhysicalModels/Vlasov/VlasovAdvectionCoeff.c b/src/PhysicalModels/Vlasov/VlasovAdvectionCoeff.c index b9ff37ba..f09e06de 100644 --- a/src/PhysicalModels/Vlasov/VlasovAdvectionCoeff.c +++ b/src/PhysicalModels/Vlasov/VlasovAdvectionCoeff.c @@ -25,34 +25,34 @@ \b Note: this function assumes that the electric field has already been set. */ -double VlasovAdvectionCoeff(int* idx, /*!< grid index */ - int dir, /*!< Spatial dimension */ - void* s /*!< Solver object of type #HyPar */ +double VlasovAdvectionCoeff(int* a_idx, /*!< grid index */ + int a_dir, /*!< Spatial dimension */ + void* a_s /*!< Solver object of type #HyPar */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; - int* dim = solver->dim_local; - int ghosts = solver->ghosts; + int* dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; double retval = DBL_MAX; - if (dir < param->ndims_x) { + if (a_dir < param->m_ndims_x) { - int veldim = dir + param->ndims_x; - _GetCoordinate_(veldim,idx[veldim],dim,ghosts,solver->x,retval); + int veldim = a_dir + param->m_ndims_x; + _GetCoordinate_(veldim,a_idx[veldim],dim,ghosts,solver->m_x,retval); } else { - int ndims_x = param->ndims_x; + int ndims_x = param->m_ndims_x; int dim_x[ndims_x]; _ArrayCopy1D_(dim, dim_x, ndims_x); int idx_x[ndims_x]; - _ArrayCopy1D_(idx, idx_x, ndims_x); + _ArrayCopy1D_(a_idx, idx_x, ndims_x); int p; _ArrayIndex1D_(ndims_x, dim_x, idx_x, ghosts, p); - retval = param->e_field[ndims_x*p+(dir-ndims_x)]; + retval = param->m_e_field[ndims_x*p+(a_dir-ndims_x)]; } diff --git a/src/PhysicalModels/Vlasov/VlasovCleanup.c b/src/PhysicalModels/Vlasov/VlasovCleanup.c index b727c339..5f3d327a 100644 --- a/src/PhysicalModels/Vlasov/VlasovCleanup.c +++ b/src/PhysicalModels/Vlasov/VlasovCleanup.c @@ -7,28 +7,28 @@ #include /*! Function to clean up all physics-related allocations for the Vlasov equations */ -int VlasovCleanup(void *s /*!< Solver object of type #HyPar */) +int VlasovCleanup(void *a_s /*!< Solver object of type #HyPar */) { - Vlasov *physics = (Vlasov*) s; + Vlasov *physics = (Vlasov*) a_s; - free(physics->e_field); - free(physics->potential); + free(physics->m_e_field); + free(physics->m_potential); #ifdef fftw - if(physics->self_consistent_electric_field) { - free(physics->sum_buffer); + if(physics->m_self_consistent_electric_field) { + free(physics->m_sum_buffer); - fftw_destroy_plan(physics->plan_forward_e); - fftw_destroy_plan(physics->plan_backward_e); + fftw_destroy_plan(physics->m_plan_forward_e); + fftw_destroy_plan(physics->m_plan_backward_e); - fftw_free(physics->phys_buffer_e); - fftw_free(physics->fourier_buffer_e); + fftw_free(physics->m_phys_buffer_e); + fftw_free(physics->m_fourier_buffer_e); - fftw_destroy_plan(physics->plan_forward_phi); - fftw_destroy_plan(physics->plan_backward_phi); + fftw_destroy_plan(physics->m_plan_forward_phi); + fftw_destroy_plan(physics->m_plan_backward_phi); - fftw_free(physics->phys_buffer_phi); - fftw_free(physics->fourier_buffer_phi); + fftw_free(physics->m_phys_buffer_phi); + fftw_free(physics->m_fourier_buffer_phi); } #endif diff --git a/src/PhysicalModels/Vlasov/VlasovComputeCFL.c b/src/PhysicalModels/Vlasov/VlasovComputeCFL.c index 8c9c3db0..48abc755 100644 --- a/src/PhysicalModels/Vlasov/VlasovComputeCFL.c +++ b/src/PhysicalModels/Vlasov/VlasovComputeCFL.c @@ -16,19 +16,19 @@ double VlasovAdvectionCoeff(int*, int, void*); /*! Computes the maximum CFL number over the domain. Note that the CFL is computed over the local domain on this processor only. */ -double VlasovComputeCFL( void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double dt, /*!< Time step size for which to compute the CFL */ - double t /*!< Time */ +double VlasovComputeCFL( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_dt, /*!< Time step size for which to compute the CFL */ + double a_t /*!< Time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *params = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *params = (Vlasov*) solver->m_physics; - int ndims = solver->ndims; - int ghosts = solver->ghosts; - int *dim = solver->dim_local; - double *u = solver->u; + int ndims = solver->m_ndims; + int ghosts = solver->m_ghosts; + int *dim = solver->m_dim_local; + double *u = solver->m_u; double max_cfl = 0; int done = 0; @@ -39,9 +39,9 @@ double VlasovComputeCFL( void *s, /*!< Solver object of type #HyPar */ for (int dir=0; dirdxinv,dxinv); + _GetCoordinate_(dir,index[dir],dim,ghosts,solver->m_dxinv,dxinv); double eig = VlasovAdvectionCoeff(index, dir, solver); - double local_cfl = eig*dt*dxinv; + double local_cfl = eig*a_dt*dxinv; if (local_cfl > max_cfl) max_cfl = local_cfl; } diff --git a/src/PhysicalModels/Vlasov/VlasovEField.c b/src/PhysicalModels/Vlasov/VlasovEField.c index a6d4988b..022c19ba 100644 --- a/src/PhysicalModels/Vlasov/VlasovEField.c +++ b/src/PhysicalModels/Vlasov/VlasovEField.c @@ -17,45 +17,45 @@ Calling this routine one bin at a time is not efficient, but we do not care about speed here. */ -static int FFTFreqNum(int bin, /*!< The bin number for the Fourier frequency to be returned */ - int N /*!< The total number of Fourier frequencies */ +static int FFTFreqNum(int a_bin, /*!< The bin number for the Fourier frequency to be returned */ + int a_N /*!< The total number of Fourier frequencies */ ) { double remainder; int last_positive = 0; - remainder = N % 2; + remainder = a_N % 2; // Note that last_positive is an integer if (remainder) { - // N is odd - last_positive = (N-1) / 2; + // a_N is odd + last_positive = (a_N-1) / 2; } else { - // N is even - last_positive = N/2 - 1; + // a_N is even + last_positive = a_N/2 - 1; } - if (bin <= last_positive) { - return bin; + if (a_bin <= last_positive) { + return a_bin; } else { - return -(N - bin); + return -(a_N - a_bin); } } /*! Sets the prescribed electric field. */ -static int SetEFieldPrescribed( double* u,/*!< Conserved solution */ - void* s,/*!< Solver object of type #HyPar */ - double t /*!< Current time */ +static int SetEFieldPrescribed( double* a_u,/*!< Conserved solution */ + void* a_s,/*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; - MPIVariables *mpi = (MPIVariables *) param->m; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; + MPIVariables *mpi = (MPIVariables *) param->m_mpi; - int* dim_local = solver->dim_local; - int ghosts = solver->ghosts; + int* dim_local = solver->m_dim_local; + int ghosts = solver->m_ghosts; - int ndims_x = param->ndims_x; + int ndims_x = param->m_ndims_x; int dim_x[ndims_x]; _ArrayCopy1D_(dim_local,dim_x,ndims_x); @@ -74,12 +74,12 @@ static int SetEFieldPrescribed( double* u,/*!< Conserved solution */ double xvec[ndims_x]; for (int d=0; dx,xvec[d]); + _GetCoordinate_(d,index[d]-ghosts,dim_local,ghosts,solver->m_x,xvec[d]); } int p; _ArrayIndex1DWO_(ndims_x,dim_x,index,offset,ghosts,p); - param->e_field[p*ndims_x+0] = 0.1 * cos(xvec[0]); + param->m_e_field[p*ndims_x+0] = 0.1 * cos(xvec[0]); _ArrayIncrementIndex_(ndims_x,bounds,index,done); } @@ -89,16 +89,16 @@ static int SetEFieldPrescribed( double* u,/*!< Conserved solution */ /*! Compute the self-consistent electric field over the local domain: The field * is solved from the solution values using a Poisson solve in Fourier space. */ -static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ - void* s,/*!< Solver object of type #HyPar */ - double t /*!< Current time */ +static int SetEFieldSelfConsistent(double* a_u,/*!< Conserved solution */ + void* a_s,/*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; - MPIVariables *mpi = (MPIVariables *) param->m; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; + MPIVariables *mpi = (MPIVariables *) param->m_mpi; - if (param->ndims_x > 1) { + if (param->m_ndims_x > 1) { fprintf(stderr,"Error in SetEFieldSelfConsistent():\n"); fprintf(stderr," Implemented for 1 spatial dimension only.\n"); return 1; @@ -112,26 +112,26 @@ static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ #else - int *dim = solver->dim_local; - int N = solver->dim_global[0]; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - - double *sum_buffer = param->sum_buffer; - double *field = param->e_field; - fftw_complex *phys_buffer_e = param->phys_buffer_e; - fftw_complex *fourier_buffer_e = param->fourier_buffer_e; - fftw_plan plan_forward_e = param->plan_forward_e; - fftw_plan plan_backward_e = param->plan_backward_e; - ptrdiff_t local_ni = param->local_ni; - ptrdiff_t local_i_start = param->local_i_start; - ptrdiff_t local_no = param->local_no; - ptrdiff_t local_o_start = param->local_o_start; - - fftw_complex *phys_buffer_phi = param->phys_buffer_phi; - fftw_complex *fourier_buffer_phi = param->fourier_buffer_phi; - fftw_plan plan_forward_phi = param->plan_forward_phi; - fftw_plan plan_backward_phi = param->plan_backward_phi; + int *dim = solver->m_dim_local; + int N = solver->m_dim_global[0]; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + + double *sum_buffer = param->m_sum_buffer; + double *field = param->m_e_field; + fftw_complex *phys_buffer_e = param->m_phys_buffer_e; + fftw_complex *fourier_buffer_e = param->m_fourier_buffer_e; + fftw_plan plan_forward_e = param->m_plan_forward_e; + fftw_plan plan_backward_e = param->m_plan_backward_e; + ptrdiff_t local_ni = param->m_local_ni; + ptrdiff_t local_i_start = param->m_local_i_start; + ptrdiff_t local_no = param->m_local_no; + ptrdiff_t local_o_start = param->m_local_o_start; + + fftw_complex *phys_buffer_phi = param->m_phys_buffer_phi; + fftw_complex *fourier_buffer_phi = param->m_fourier_buffer_phi; + fftw_plan plan_forward_phi = param->m_plan_forward_phi; + fftw_plan plan_backward_phi = param->m_plan_backward_phi; int index[ndims], bounds[ndims], bounds_noghost[ndims], offset[ndims]; @@ -155,18 +155,18 @@ static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ int p; _ArrayIndex1D_(ndims,dim,index,ghosts,p); // accumulate f at this spatial location - double dvinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->dxinv,dvinv); - double x; _GetCoordinate_(0,index[0],dim,ghosts,solver->x,x); - double v; _GetCoordinate_(1,index[1],dim,ghosts,solver->x,v); + double dvinv; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_dxinv,dvinv); + double x; _GetCoordinate_(0,index[0],dim,ghosts,solver->m_x,x); + double v; _GetCoordinate_(1,index[1],dim,ghosts,solver->m_x,v); - sum_buffer[index[0]] += u[p] / dvinv; + sum_buffer[index[0]] += a_u[p] / dvinv; _ArrayIncrementIndex_(ndims,bounds_noghost,index,done); } // Now we can add up globally using MPI reduction for (int i = 0; i < dim[0]; i++) { - MPISum_double(&sum_buffer[i], &sum_buffer[i], 1, &mpi->comm[1]); + MPISum_double(&sum_buffer[i], &sum_buffer[i], 1, &mpi->m_comm[1]); } // Find the average density over all x @@ -174,7 +174,7 @@ static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ for (int i = 0; i < dim[0]; i++) { average_velocity += sum_buffer[i]; } - MPISum_double(&average_velocity, &average_velocity, 1, &mpi->comm[0]); + MPISum_double(&average_velocity, &average_velocity, 1, &mpi->m_comm[0]); average_velocity /= (double) N; // Copy velocity-integrated values into complex-valued FFTW buffer @@ -184,9 +184,9 @@ static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ } // Execute the FFT - MPI_Barrier(mpi->comm[0]); + MPI_Barrier(mpi->m_comm[0]); fftw_execute(plan_forward_e); - MPI_Barrier(mpi->comm[0]); + MPI_Barrier(mpi->m_comm[0]); // Simultaneously do a Poisson solve and take derivative in frequency space int freq_start = 0; @@ -223,30 +223,30 @@ static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ } // Do an inverse Fourier transform to get back physical solved values - MPI_Barrier(mpi->comm[0]); + MPI_Barrier(mpi->m_comm[0]); fftw_execute(plan_backward_e); - MPI_Barrier(mpi->comm[0]); + MPI_Barrier(mpi->m_comm[0]); // Do an inverse Fourier transform to get back physical solved values - MPI_Barrier(mpi->comm[0]); + MPI_Barrier(mpi->m_comm[0]); fftw_execute(plan_backward_phi); - MPI_Barrier(mpi->comm[0]); + MPI_Barrier(mpi->m_comm[0]); // copy the solved electric field into the e buffer for (int i = 0; i < dim[0]; i++) { - param->e_field[i + ghosts] = - phys_buffer_e[i][0] / (double) N; + param->m_e_field[i + ghosts] = - phys_buffer_e[i][0] / (double) N; } // copy the solved potential field into the potential buffer for (int i = 0; i < dim[0]; i++) { - param->potential[i + ghosts] = phys_buffer_phi[i][0] / (double) N; + param->m_potential[i + ghosts] = phys_buffer_phi[i][0] / (double) N; } // Do halo exchange on the e - MPIExchangeBoundaries1D(mpi, param->e_field, dim[0], ghosts, 0, ndims); + MPIExchangeBoundaries1D(mpi, param->m_e_field, dim[0], ghosts, 0, ndims); // Do halo exchange on the potential - MPIExchangeBoundaries1D(mpi, param->potential, dim[0], ghosts, 0, ndims); + MPIExchangeBoundaries1D(mpi, param->m_potential, dim[0], ghosts, 0, ndims); #endif @@ -255,20 +255,20 @@ static int SetEFieldSelfConsistent(double* u,/*!< Conserved solution */ /*! Compute electric field.\n */ -int VlasovEField( double* u, /*!< Conserved solution */ - void* s, /*!< Solver object of type #HyPar */ - double t /*!< Current time */ +int VlasovEField( double* a_u, /*!< Conserved solution */ + void* a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; int ierr; - if (param->self_consistent_electric_field) { - ierr = SetEFieldSelfConsistent(u, s, t); + if (param->m_self_consistent_electric_field) { + ierr = SetEFieldSelfConsistent(a_u, a_s, a_t); } else { - ierr = SetEFieldPrescribed(u, s, t); + ierr = SetEFieldPrescribed(a_u, a_s, a_t); } return ierr; diff --git a/src/PhysicalModels/Vlasov/VlasovFunctions.c b/src/PhysicalModels/Vlasov/VlasovFunctions.c index 7765702c..bf5c7053 100644 --- a/src/PhysicalModels/Vlasov/VlasovFunctions.c +++ b/src/PhysicalModels/Vlasov/VlasovFunctions.c @@ -12,18 +12,18 @@ int VlasovEField(double*, void*, double); /*! Vlasov-specific function called at the beginning of each time-step: Calls the function to set the electric field */ -int VlasovPreStep( double *u, /*!< Solution (conserved variables) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double waqt /*!< Current solution time */ +int VlasovPreStep( double *a_u, /*!< Solution (conserved variables) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_waqt /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; - if (param->use_log_form) takeExp(u,solver->npoints_local_wghosts); - int ierr = VlasovEField(u, solver, waqt); - if (param->use_log_form) takeLog(u,solver->npoints_local_wghosts); + if (param->m_use_log_form) takeExp(a_u,solver->m_npoints_local_wghosts); + int ierr = VlasovEField(a_u, solver, a_waqt); + if (param->m_use_log_form) takeLog(a_u,solver->m_npoints_local_wghosts); if (ierr) return ierr; return 0; @@ -33,18 +33,18 @@ int VlasovPreStep( double *u, /*!< Solution (conserved variables) */ a multistage time integrator: Calls the function to set the electric field */ -int VlasovPostStage( double *u, /*!< Solution (conserved variables) */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double waqt /*!< Current solution time */ +int VlasovPostStage( double *a_u, /*!< Solution (conserved variables) */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_waqt /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; - if (param->use_log_form) takeExp(u,solver->npoints_local_wghosts); - int ierr = VlasovEField(u, solver, waqt); - if (param->use_log_form) takeLog(u,solver->npoints_local_wghosts); + if (param->m_use_log_form) takeExp(a_u,solver->m_npoints_local_wghosts); + int ierr = VlasovEField(a_u, solver, a_waqt); + if (param->m_use_log_form) takeLog(a_u,solver->m_npoints_local_wghosts); if (ierr) return ierr; return 0; diff --git a/src/PhysicalModels/Vlasov/VlasovInitialize.c b/src/PhysicalModels/Vlasov/VlasovInitialize.c index 84ea6911..7f12eac5 100644 --- a/src/PhysicalModels/Vlasov/VlasovInitialize.c +++ b/src/PhysicalModels/Vlasov/VlasovInitialize.c @@ -41,39 +41,39 @@ int VlasovEField(double*, void*, double); allocate and set physics-related parameters, read physics-related inputs from file, and set the physics-related function pointers in #HyPar */ -int VlasovInitialize(void *s, /*!< Solver object of type #HyPar */ - void *m /*!< Object of type #MPIVariables containing MPI-related info */ +int VlasovInitialize(void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< Object of type #MPIVariables containing MPI-related info */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Vlasov *physics = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Vlasov *physics = (Vlasov*) solver->m_physics; - int *dim_global = solver->dim_global; - int *dim_local = solver->dim_local; - int ghosts = solver->ghosts; + int *dim_global = solver->m_dim_global; + int *dim_local = solver->m_dim_local; + int ghosts = solver->m_ghosts; - if (solver->nvars != _MODEL_NVARS_) { - if (!mpi->rank) { + if (solver->m_nvars != _MODEL_NVARS_) { + if (!mpi->m_rank) { fprintf(stderr,"Error in VlasovInitialize(): nvars has to be %d.\n",_MODEL_NVARS_); } return(1); } - if (solver->ndims != _MODEL_NDIMS_) { - if (!mpi->rank) { + if (solver->m_ndims != _MODEL_NDIMS_) { + if (!mpi->m_rank) { fprintf(stderr,"Error in VlasovInitialize(): ndims has to be %d.\n",_MODEL_NDIMS_); } return(1); } /* default is prescribed electric field */ - physics->self_consistent_electric_field = 0; - physics->ndims_x = 1; - physics->ndims_v = 1; - physics->use_log_form = 0; + physics->m_self_consistent_electric_field = 0; + physics->m_ndims_x = 1; + physics->m_ndims_v = 1; + physics->m_use_log_form = 0; /* reading physical model specific inputs - all processes */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; in = fopen("physics.inp","r"); if (in) { @@ -85,19 +85,19 @@ int VlasovInitialize(void *s, /*!< Solver object of type #HyPar */ int ferr = fscanf(in,"%s",word); if (ferr != 1) return(1); if (!strcmp(word, "self_consistent_electric_field")) { /* read whether electric field is self-consistent or prescribed */ - int ferr = fscanf(in,"%d", &physics->self_consistent_electric_field); + int ferr = fscanf(in,"%d", &physics->m_self_consistent_electric_field); if (ferr != 1) return(1); } else if (!strcmp(word, "x_ndims")) { /* read number of spatial dimensions */ - int ferr = fscanf(in,"%d", &physics->ndims_x); + int ferr = fscanf(in,"%d", &physics->m_ndims_x); if (ferr != 1) return(1); } else if (!strcmp(word, "v_ndims")) { /* read number of velocity dimensions */ - int ferr = fscanf(in,"%d", &physics->ndims_v); + int ferr = fscanf(in,"%d", &physics->m_ndims_v); if (ferr != 1) return(1); } else if (!strcmp(word, "use_log_form")) { /* read whether solving in log form */ - int ferr = fscanf(in,"%d", &physics->use_log_form); + int ferr = fscanf(in,"%d", &physics->m_use_log_form); if (ferr != 1) return(1); } else if (strcmp(word,"end")) { char useless[_MAX_STRING_SIZE_]; @@ -115,22 +115,22 @@ int VlasovInitialize(void *s, /*!< Solver object of type #HyPar */ fclose(in); } - if (physics->use_log_form) { - if (!mpi->rank) { + if (physics->m_use_log_form) { + if (!mpi->m_rank) { printf("Vlasov: using the log form of the Vlasov equation.\n"); } } - if ((physics->ndims_x+physics->ndims_v) != solver->ndims) { - if (!mpi->rank) { + if ((physics->m_ndims_x+physics->m_ndims_v) != solver->m_ndims) { + if (!mpi->m_rank) { fprintf(stderr,"Error in VlasovInitialize:\n"); fprintf(stderr, " space + vel dims not equal to ndims!\n"); } return(1); } - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { - if (!mpi->rank) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { + if (!mpi->m_rank) { fprintf(stderr,"Error in VlasovInitialize: This physical model does not have a splitting "); fprintf(stderr,"of the hyperbolic term defined.\n"); } @@ -139,40 +139,40 @@ int VlasovInitialize(void *s, /*!< Solver object of type #HyPar */ #ifndef serial /* Broadcast parsed problem data */ - MPIBroadcast_integer(&physics->ndims_x,1,0,&mpi->world); - MPIBroadcast_integer(&physics->ndims_v,1,0,&mpi->world); - MPIBroadcast_integer((int *) &physics->self_consistent_electric_field, - 1,0,&mpi->world); - MPIBroadcast_integer((int *) &physics->use_log_form, - 1,0,&mpi->world); + MPIBroadcast_integer(&physics->m_ndims_x,1,0,&mpi->m_world); + MPIBroadcast_integer(&physics->m_ndims_v,1,0,&mpi->m_world); + MPIBroadcast_integer((int *) &physics->m_self_consistent_electric_field, + 1,0,&mpi->m_world); + MPIBroadcast_integer((int *) &physics->m_use_log_form, + 1,0,&mpi->m_world); #endif /* compute local number of x-space points with ghosts */ - physics->npts_local_x_wghosts = 1; - physics->npts_local_x = 1; - physics->npts_global_x_wghosts = 1; - physics->npts_global_x = 1; - for (int d=0; dndims_x; d++) { - physics->npts_local_x_wghosts *= (dim_local[d]+2*ghosts); - physics->npts_local_x *= dim_local[d]; - physics->npts_global_x_wghosts *= (dim_global[d]+2*ghosts); - physics->npts_global_x *= dim_global[d]; + physics->m_npts_local_x_wghosts = 1; + physics->m_npts_local_x = 1; + physics->m_npts_global_x_wghosts = 1; + physics->m_npts_global_x = 1; + for (int d=0; dm_ndims_x; d++) { + physics->m_npts_local_x_wghosts *= (dim_local[d]+2*ghosts); + physics->m_npts_local_x *= dim_local[d]; + physics->m_npts_global_x_wghosts *= (dim_global[d]+2*ghosts); + physics->m_npts_global_x *= dim_global[d]; } /* allocate array to hold the electric field (needs to have ghosts); note that number of electric field components is the number of spatial dimensions */ - physics->e_field = (double*) calloc( physics->npts_local_x_wghosts - * physics->ndims_x, + physics->m_e_field = (double*) calloc( physics->m_npts_local_x_wghosts + * physics->m_ndims_x, sizeof(double) ); - physics->potential = (double*) calloc( physics->npts_local_x_wghosts - * physics->ndims_x, + physics->m_potential = (double*) calloc( physics->m_npts_local_x_wghosts + * physics->m_ndims_x, sizeof(double) ); /* Put the mpi object in the params for access in other functions */ - physics->m = m; + physics->m_mpi = a_m; - if (physics->self_consistent_electric_field) { + if (physics->m_self_consistent_electric_field) { #ifdef fftw /* If using FFTW, make sure MPI is enabled Currently we only support the distrubuted memory version @@ -182,60 +182,60 @@ int VlasovInitialize(void *s, /*!< Solver object of type #HyPar */ return(1); #else - if (physics->ndims_x > 1) { + if (physics->m_ndims_x > 1) { fprintf(stderr,"Error in VlasovInitialize():\n"); fprintf(stderr," Self-consistent electric field is implemented for only 1 space dimension.\n"); return 1; } /* Create a scratch buffer for moving between real and complex values */ - physics->sum_buffer = (double*) calloc(dim_local[0], sizeof(double)); + physics->m_sum_buffer = (double*) calloc(dim_local[0], sizeof(double)); /* Initialize FFTW and set up data buffers used for the transforms */ fftw_mpi_init(); - physics->alloc_local = fftw_mpi_local_size_1d(dim_global[0], mpi->comm[0], + physics->m_alloc_local = fftw_mpi_local_size_1d(dim_global[0], mpi->m_comm[0], FFTW_FORWARD, 0, - &physics->local_ni, - &physics->local_i_start, - &physics->local_no, - &physics->local_o_start); - if (dim_local[0] != physics->local_ni) { + &physics->m_local_ni, + &physics->m_local_i_start, + &physics->m_local_no, + &physics->m_local_o_start); + if (dim_local[0] != physics->m_local_ni) { fprintf(stderr,"Error in VlasovInitialize(): The FFTW data distribution is incompatible with the HyPar one.\n"); fprintf(stderr,"Decompose the spatial dimension so that the degrees of freedom are evenly divided.\n"); return(1); } - physics->phys_buffer_e = fftw_alloc_complex(physics->alloc_local); - physics->fourier_buffer_e = fftw_alloc_complex(physics->alloc_local); + physics->m_phys_buffer_e = fftw_alloc_complex(physics->m_alloc_local); + physics->m_fourier_buffer_e = fftw_alloc_complex(physics->m_alloc_local); - physics->plan_forward_e = fftw_mpi_plan_dft_1d(dim_global[0], - physics->phys_buffer_e, - physics->fourier_buffer_e, - mpi->comm[0], + physics->m_plan_forward_e = fftw_mpi_plan_dft_1d(dim_global[0], + physics->m_phys_buffer_e, + physics->m_fourier_buffer_e, + mpi->m_comm[0], FFTW_FORWARD, FFTW_ESTIMATE); - physics->plan_backward_e = fftw_mpi_plan_dft_1d(dim_global[0], - physics->fourier_buffer_e, - physics->phys_buffer_e, - mpi->comm[0], + physics->m_plan_backward_e = fftw_mpi_plan_dft_1d(dim_global[0], + physics->m_fourier_buffer_e, + physics->m_phys_buffer_e, + mpi->m_comm[0], FFTW_BACKWARD, FFTW_ESTIMATE); - physics->phys_buffer_phi = fftw_alloc_complex(physics->alloc_local); - physics->fourier_buffer_phi = fftw_alloc_complex(physics->alloc_local); + physics->m_phys_buffer_phi = fftw_alloc_complex(physics->m_alloc_local); + physics->m_fourier_buffer_phi = fftw_alloc_complex(physics->m_alloc_local); - physics->plan_forward_phi = fftw_mpi_plan_dft_1d(dim_global[0], - physics->phys_buffer_phi, - physics->fourier_buffer_phi, - mpi->comm[0], + physics->m_plan_forward_phi = fftw_mpi_plan_dft_1d(dim_global[0], + physics->m_phys_buffer_phi, + physics->m_fourier_buffer_phi, + mpi->m_comm[0], FFTW_FORWARD, FFTW_ESTIMATE); - physics->plan_backward_phi = fftw_mpi_plan_dft_1d(dim_global[0], - physics->fourier_buffer_phi, - physics->phys_buffer_phi, - mpi->comm[0], + physics->m_plan_backward_phi = fftw_mpi_plan_dft_1d(dim_global[0], + physics->m_fourier_buffer_phi, + physics->m_phys_buffer_phi, + mpi->m_comm[0], FFTW_BACKWARD, FFTW_ESTIMATE); #endif @@ -254,9 +254,9 @@ int VlasovInitialize(void *s, /*!< Solver object of type #HyPar */ solver->PhysicsOutput = VlasovWriteEFieldAndPotential; solver->PostStage = VlasovPostStage; - if (physics->use_log_form) takeExp(solver->u,solver->npoints_local_wghosts); - int ierr = VlasovEField(solver->u, solver, 0.0); - if (physics->use_log_form) takeLog(solver->u,solver->npoints_local_wghosts); + if (physics->m_use_log_form) takeExp(solver->m_u,solver->m_npoints_local_wghosts); + int ierr = VlasovEField(solver->m_u, solver, 0.0); + if (physics->m_use_log_form) takeLog(solver->m_u,solver->m_npoints_local_wghosts); if (ierr) return ierr; return 0; diff --git a/src/PhysicalModels/Vlasov/VlasovPlotSpatialField.c b/src/PhysicalModels/Vlasov/VlasovPlotSpatialField.c index e0e9572d..c81d614c 100644 --- a/src/PhysicalModels/Vlasov/VlasovPlotSpatialField.c +++ b/src/PhysicalModels/Vlasov/VlasovPlotSpatialField.c @@ -23,47 +23,47 @@ #endif /*! Plot out a spatial field or variable to file */ -int VlasovPlotSpatialField( void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int VlasovPlotSpatialField( void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ double* a_field, /*!< Vector field to write */ double a_time, /*!< Current simulation time */ - char* fname_root /*!< Filename root (extension is added automatically). + char* a_fname_root /*!< Filename root (extension is added automatically). For unsteady output, a numerical index is added that is the same as for the solution output files. */) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Vlasov *param = (Vlasov*) solver->m_physics; - if (solver->nsims > 1) { + if (solver->m_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); - strcat(fname_root, "_"); - strcat(fname_root, index); - strcat(fname_root, "_"); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); + strcat(a_fname_root, "_"); + strcat(a_fname_root, index); + strcat(a_fname_root, "_"); } char filename[_MAX_STRING_SIZE_] = ""; - strcat(filename,fname_root); - if (!strcmp(solver->op_overwrite,"no")) { + strcat(filename,a_fname_root); + if (!strcmp(solver->m_op_overwrite,"no")) { strcat(filename,"_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); } strcat(filename,".png"); int d, - ghosts = solver->ghosts, - ndims_x = param->ndims_x; + ghosts = solver->m_ghosts, + ndims_x = param->m_ndims_x; int dim_global_x[ndims_x]; - _ArrayCopy1D_(solver->dim_global, dim_global_x, ndims_x); + _ArrayCopy1D_(solver->m_dim_global, dim_global_x, ndims_x); int dim_local_x[ndims_x]; - _ArrayCopy1D_(solver->dim_local, dim_local_x, ndims_x); + _ArrayCopy1D_(solver->m_dim_local, dim_local_x, ndims_x); /* gather the spatial coordinates into a global array */ double *xg; { - int size_g = param->npts_global_x; + int size_g = param->m_npts_global_x; xg = (double*) calloc (size_g, sizeof(double)); _ArraySetValue_(xg, size_g, 0.0); @@ -71,11 +71,11 @@ int VlasovPlotSpatialField( void* s, /*!< Solver object of type #HyPar offset_global = offset_local = 0; for (d=0; drank?NULL:&xg[offset_global]), - &solver->x[offset_local+ghosts], - mpi->is[d], - mpi->ie[d], - solver->dim_local[d], + (mpi->m_rank?NULL:&xg[offset_global]), + &solver->m_x[offset_local+ghosts], + mpi->m_is[d], + mpi->m_ie[d], + solver->m_dim_local[d], 0); offset_global += dim_global_x[d]; offset_local += dim_local_x [d] + 2*ghosts; @@ -85,27 +85,27 @@ int VlasovPlotSpatialField( void* s, /*!< Solver object of type #HyPar /* gather the field into a global array */ double *field_g; { - int size_g = param->npts_global_x * param->ndims_x; + int size_g = param->m_npts_global_x * param->m_ndims_x; field_g = (double*) calloc (size_g, sizeof(double)); _ArraySetValue_(field_g, size_g, 0.0); - if (param->ndims_x > 1) { - if (!mpi->rank) { + if (param->m_ndims_x > 1) { + if (!mpi->m_rank) { fprintf(stderr,"Warning in VlasovPlotSpatialField():\n"); fprintf(stderr," field plotting not yet supported for >1 spatial dimensions.\n"); } } else { IERR MPIGatherArray1D( mpi, - (mpi->rank ? NULL : field_g), + (mpi->m_rank ? NULL : field_g), (a_field+ghosts), - mpi->is[0], - mpi->ie[0], - solver->dim_local[0], + mpi->m_is[0], + mpi->m_ie[0], + solver->m_dim_local[0], 0); } } - if (!mpi->rank) { + if (!mpi->m_rank) { #ifdef with_python #ifdef with_python_numpy import_array(); @@ -130,17 +130,17 @@ int VlasovPlotSpatialField( void* s, /*!< Solver object of type #HyPar PyTuple_SetItem(py_plt_func_args, 3, py_obj); } { - npy_intp shape[1] = {param->npts_global_x}; + npy_intp shape[1] = {param->m_npts_global_x}; PyObject* x_arr = PyArray_SimpleNewFromData(1,shape,NPY_DOUBLE,xg); PyTuple_SetItem(py_plt_func_args, 4, x_arr); } { - npy_intp shape[1] = {param->npts_global_x * param->ndims_x}; + npy_intp shape[1] = {param->m_npts_global_x * param->m_ndims_x}; PyObject* u_arr = PyArray_SimpleNewFromData(1,shape,NPY_DOUBLE,field_g); PyTuple_SetItem(py_plt_func_args, 5, u_arr); } { - PyObject* py_obj = Py_BuildValue("s", filename); + PyObject* py_obj = Py_BuildValue("a_s", filename); PyTuple_SetItem(py_plt_func_args, 6, py_obj); } if (!py_plt_func) { diff --git a/src/PhysicalModels/Vlasov/VlasovUpwind.c b/src/PhysicalModels/Vlasov/VlasovUpwind.c index 17d3fa68..0f5d13f6 100644 --- a/src/PhysicalModels/Vlasov/VlasovUpwind.c +++ b/src/PhysicalModels/Vlasov/VlasovUpwind.c @@ -14,61 +14,61 @@ double VlasovAdvectionCoeff(int*, int, void*); /*! Upwinding scheme for the Vlasov equations */ -int VlasovUpwind( double* fI, /*!< Computed upwind interface flux */ - double* fL, /*!< Left-biased reconstructed interface flux */ - double* fR, /*!< Right-biased reconstructed interface flux */ - double* uL, /*!< Left-biased reconstructed interface solution */ - double* uR, /*!< Right-biased reconstructed interface solution */ - double* u, /*!< Cell-centered solution */ - int dir, /*!< Spatial dimension */ - void* s, /*!< Solver object of type #HyPar */ - double t /*!< Current solution time */ +int VlasovUpwind( double* a_fI, /*!< Computed upwind interface flux */ + double* a_fL, /*!< Left-biased reconstructed interface flux */ + double* a_fR, /*!< Right-biased reconstructed interface flux */ + double* a_uL, /*!< Left-biased reconstructed interface solution */ + double* a_uR, /*!< Right-biased reconstructed interface solution */ + double* a_u, /*!< Cell-centered solution */ + int a_dir, /*!< Spatial dimension */ + void* a_s, /*!< Solver object of type #HyPar */ + double a_t /*!< Current solution time */ ) { - HyPar *solver = (HyPar*) s; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + Vlasov *param = (Vlasov*) solver->m_physics; int done; - int ndims = solver->ndims; - int *dim = solver->dim_local; - int ghosts = solver->ghosts; + int ndims = solver->m_ndims; + int *dim = solver->m_dim_local; + int ghosts = solver->m_ghosts; int index_outer[ndims], index_inter[ndims], bounds_outer[ndims], bounds_inter[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; - _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[dir] += 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; + _ArrayCopy1D_(dim,bounds_inter,ndims); bounds_inter[a_dir] += 1; done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,index_inter,ndims); - for (index_inter[dir] = 0; index_inter[dir] < bounds_inter[dir]; index_inter[dir]++) { + for (index_inter[a_dir] = 0; index_inter[a_dir] < bounds_inter[a_dir]; index_inter[a_dir]++) { int p; _ArrayIndex1D_(ndims,bounds_inter,index_inter,0,p); - int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[dir]--; + int indexL[ndims]; _ArrayCopy1D_(index_inter,indexL,ndims); indexL[a_dir]--; int indexR[ndims]; _ArrayCopy1D_(index_inter,indexR,ndims); int idxL[ndims], idxR[ndims]; int neig = 2+4*(ndims-1); double eig[neig]; int count = 0; - eig[count] = VlasovAdvectionCoeff(indexL, dir, solver); count++; - eig[count] = VlasovAdvectionCoeff(indexR, dir, solver); count++; + eig[count] = VlasovAdvectionCoeff(indexL, a_dir, solver); count++; + eig[count] = VlasovAdvectionCoeff(indexR, a_dir, solver); count++; for (int tdir = 0; tdir < ndims; tdir++ ) { - if (tdir != dir) { + if (tdir != a_dir) { _ArrayCopy1D_(indexL, idxL, ndims); idxL[tdir]--; _ArrayCopy1D_(indexR, idxR, ndims); idxR[tdir]--; - eig[count] = VlasovAdvectionCoeff(idxL, dir, solver); count++; - eig[count] = VlasovAdvectionCoeff(idxR, dir, solver); count++; + eig[count] = VlasovAdvectionCoeff(idxL, a_dir, solver); count++; + eig[count] = VlasovAdvectionCoeff(idxR, a_dir, solver); count++; _ArrayCopy1D_(indexL, idxL, ndims); idxL[tdir]++; _ArrayCopy1D_(indexR, idxR, ndims); idxR[tdir]++; - eig[count] = VlasovAdvectionCoeff(idxL, dir, solver); count++; - eig[count] = VlasovAdvectionCoeff(idxR, dir, solver); count++; + eig[count] = VlasovAdvectionCoeff(idxL, a_dir, solver); count++; + eig[count] = VlasovAdvectionCoeff(idxR, a_dir, solver); count++; } } if (count != neig) { - fprintf(stderr, "Error in VlasovUpwind(): count != neig for dir=%d\n",dir); + fprintf(stderr, "Error in VlasovUpwind(): count != neig for a_dir=%d\n",a_dir); return 1; } @@ -83,11 +83,11 @@ int VlasovUpwind( double* fI, /*!< Computed upwind interface flux */ } if (all_positive) { - fI[p] = fL[p]; + a_fI[p] = a_fL[p]; } else if (all_negative) { - fI[p] = fR[p]; + a_fI[p] = a_fR[p]; } else { - fI[p] = 0.5 * (fL[p] + fR[p] - maxabs_eig * (uR[p] - uL[p])); + a_fI[p] = 0.5 * (a_fL[p] + a_fR[p] - maxabs_eig * (a_uR[p] - a_uL[p])); } } diff --git a/src/PhysicalModels/Vlasov/VlasovWriteEFieldAndPotential.c b/src/PhysicalModels/Vlasov/VlasovWriteEFieldAndPotential.c index c3841b38..b196aa78 100644 --- a/src/PhysicalModels/Vlasov/VlasovWriteEFieldAndPotential.c +++ b/src/PhysicalModels/Vlasov/VlasovWriteEFieldAndPotential.c @@ -20,27 +20,27 @@ int VlasovWriteSpatialField( void*, void*, double*, char* ); int VlasovPlotSpatialField( void*, void*, double*, double, char* ); /*! Write out the electric field and potential to file */ -int VlasovWriteEFieldAndPotential( void* s, /*!< Solver object of type #HyPar */ - void* m, /*!< MPI object of type #MPIVariables */ +int VlasovWriteEFieldAndPotential( void* a_s, /*!< Solver object of type #HyPar */ + void* a_m, /*!< MPI object of type #MPIVariables */ double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Vlasov *param = (Vlasov*) solver->m_physics; { char fname_root[_MAX_STRING_SIZE_] = "efield"; - VlasovWriteSpatialField( solver, mpi, param->e_field, fname_root ); - if (!strcmp(solver->plot_solution,"yes")) { - VlasovPlotSpatialField( solver, mpi, param->e_field, a_t, fname_root ); + VlasovWriteSpatialField( solver, mpi, param->m_e_field,fname_root); + if (!strcmp(solver->m_plot_solution,"yes")) { + VlasovPlotSpatialField( solver, mpi, param->m_e_field, a_t,fname_root); } } - if (param->self_consistent_electric_field) { + if (param->m_self_consistent_electric_field) { char fname_root[_MAX_STRING_SIZE_] = "potential"; - VlasovWriteSpatialField( solver, mpi, param->potential, fname_root ); - if (!strcmp(solver->plot_solution,"yes")) { - VlasovPlotSpatialField( solver, mpi, param->potential, a_t, fname_root ); + VlasovWriteSpatialField( solver, mpi, param->m_potential,fname_root); + if (!strcmp(solver->m_plot_solution,"yes")) { + VlasovPlotSpatialField( solver, mpi, param->m_potential, a_t,fname_root); } } diff --git a/src/PhysicalModels/Vlasov/VlasovWriteSpatialField.c b/src/PhysicalModels/Vlasov/VlasovWriteSpatialField.c index 8dcc9f7c..134f065a 100644 --- a/src/PhysicalModels/Vlasov/VlasovWriteSpatialField.c +++ b/src/PhysicalModels/Vlasov/VlasovWriteSpatialField.c @@ -15,50 +15,50 @@ #include /*! Write out a spatial field or variable to file */ -int VlasovWriteSpatialField( void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ +int VlasovWriteSpatialField( void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ double *a_field, /*!< Vector field to write */ - char *fname_root /*!< Filename root (extension is added automatically). + char *a_fname_root /*!< Filename root (extension is added automatically). For unsteady output, a numerical index is added that is the same as for the solution output files. */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - Vlasov *param = (Vlasov*) solver->physics; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + Vlasov *param = (Vlasov*) solver->m_physics; if (!solver->WriteOutput) return 0; - if (solver->nsims > 1) { + if (solver->m_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(solver->my_idx, index, (int)log10(solver->nsims)+1); - strcat(fname_root, "_"); - strcat(fname_root, index); - strcat(fname_root, "_"); + GetStringFromInteger(solver->m_my_idx, index, (int)log10(solver->m_nsims)+1); + strcat(a_fname_root, "_"); + strcat(a_fname_root, index); + strcat(a_fname_root, "_"); } char filename[_MAX_STRING_SIZE_] = ""; - strcat(filename,fname_root); - if (!strcmp(solver->op_overwrite,"no")) { + strcat(filename,a_fname_root); + if (!strcmp(solver->m_op_overwrite,"no")) { strcat(filename,"_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); } strcat(filename,".dat"); int d, - ghosts = solver->ghosts, - ndims_x = param->ndims_x; + ghosts = solver->m_ghosts, + ndims_x = param->m_ndims_x; int dim_global_x[ndims_x]; - _ArrayCopy1D_(solver->dim_global, dim_global_x, ndims_x); + _ArrayCopy1D_(solver->m_dim_global, dim_global_x, ndims_x); int dim_local_x[ndims_x]; - _ArrayCopy1D_(solver->dim_local, dim_local_x, ndims_x); + _ArrayCopy1D_(solver->m_dim_local, dim_local_x, ndims_x); /* gather the spatial coordinates into a global array */ double *xg; { - int size_g = param->npts_global_x; + int size_g = param->m_npts_global_x; xg = (double*) calloc (size_g, sizeof(double)); _ArraySetValue_(xg, size_g, 0.0); @@ -66,11 +66,11 @@ int VlasovWriteSpatialField( void *s, /*!< Solver object of type #HyPa offset_global = offset_local = 0; for (d=0; drank?NULL:&xg[offset_global]), - &solver->x[offset_local+ghosts], - mpi->is[d], - mpi->ie[d], - solver->dim_local[d], + (mpi->m_rank?NULL:&xg[offset_global]), + &solver->m_x[offset_local+ghosts], + mpi->m_is[d], + mpi->m_ie[d], + solver->m_dim_local[d], 0); offset_global += dim_global_x[d]; offset_local += dim_local_x [d] + 2*ghosts; @@ -80,27 +80,27 @@ int VlasovWriteSpatialField( void *s, /*!< Solver object of type #HyPa /* gather the field into a global array */ double *field_g; { - int size_g = param->npts_global_x * param->ndims_x; + int size_g = param->m_npts_global_x * param->m_ndims_x; field_g = (double*) calloc (size_g, sizeof(double)); _ArraySetValue_(field_g, size_g, 0.0); - if (param->ndims_x > 1) { - if (!mpi->rank) { + if (param->m_ndims_x > 1) { + if (!mpi->m_rank) { fprintf(stderr,"Warning in VlasovWriteSpatialField():\n"); fprintf(stderr," field writing not yet supported for >1 spatial dimensions.\n"); } } else { IERR MPIGatherArray1D( mpi, - (mpi->rank ? NULL : field_g), + (mpi->m_rank ? NULL : field_g), (a_field+ghosts), - mpi->is[0], - mpi->ie[0], - solver->dim_local[0], + mpi->m_is[0], + mpi->m_ie[0], + solver->m_dim_local[0], 0); } } - if (!mpi->rank) { + if (!mpi->m_rank) { int idx[ndims_x]; WriteText( ndims_x, 1, diff --git a/src/PlottingFunctions/PlotArray.c b/src/PlottingFunctions/PlotArray.c index b99408b0..c97d9a56 100644 --- a/src/PlottingFunctions/PlotArray.c +++ b/src/PlottingFunctions/PlotArray.c @@ -84,7 +84,7 @@ int PlotArraySerial(int a_ndims, /*!< Number of spatial dimensions */ /* root process: allocate global output arrays */ double *ug, *xg; - if (!mpi->rank) { + if (!mpi->m_rank) { size_global_u = 1; for (int d=0; drank?NULL:&xg[offset_global]), + (mpi->m_rank?NULL:&xg[offset_global]), &a_x[offset_local+a_ghosts], - mpi->is[d], - mpi->ie[d], + mpi->m_is[d], + mpi->m_ie[d], a_dim_local[d], 0 ); offset_global += a_dim_global[d]; offset_local += a_dim_local [d] + 2*a_ghosts; } - if (!mpi->rank) { + if (!mpi->m_rank) { char filename[_MAX_STRING_SIZE_] = ""; strcat(filename,a_fname_root); - if (!strcmp(solver->op_overwrite,"no")) { + if (!strcmp(solver->m_op_overwrite,"no")) { strcat(filename,"_"); - strcat(filename,solver->filename_index); + strcat(filename,solver->m_filename_index); } - strcat(filename,solver->plotfilename_extn); + strcat(filename,solver->m_plotfilename_extn); #ifdef with_python #ifdef with_python_numpy @@ -174,7 +174,7 @@ int PlotArraySerial(int a_ndims, /*!< Number of spatial dimensions */ PyTuple_SetItem(py_plt_func_args, 6, py_obj); } if (!py_plt_func) { - fprintf(stderr,"Error in PlotArraySerial(): solver->py_plt_func is NULL!\n"); + fprintf(stderr,"Error in PlotArraySerial(): solver->m_py_plt_func is NULL!\n"); } else { PyObject_CallObject(py_plt_func, py_plt_func_args); } diff --git a/src/ROM/libROMInterface.cpp b/src/ROM/libROMInterface.cpp index 7707b65e..7830f7fe 100644 --- a/src/ROM/libROMInterface.cpp +++ b/src/ROM/libROMInterface.cpp @@ -139,9 +139,9 @@ void libROMInterface::define( void* a_s, /*!< Array of simulation objects of t m_vec_size.resize(m_nsims); for (int ns = 0; ns < m_nsims; ns++) { - m_vec_size[ns] = (sim[ns].solver.npoints_local); + m_vec_size[ns] = (sim[ns].solver.m_npoints_local); if (m_comp_mode == _ROM_COMP_MODE_MONOLITHIC_) { - m_vec_size[ns] *= (sim[ns].solver.nvars); + m_vec_size[ns] *= (sim[ns].solver.m_nvars); } } @@ -161,8 +161,8 @@ void libROMInterface::define( void* a_s, /*!< Array of simulation objects of t } } else if (m_comp_mode == _ROM_COMP_MODE_COMPONENTWISE_) { for (int ns = 0; ns < m_nsims; ns++) { - m_ncomps.push_back(sim[ns].solver.nvars); - for (int v = 0; v < sim[ns].solver.nvars; v++) { + m_ncomps.push_back(sim[ns].solver.m_nvars); + for (int v = 0; v < sim[ns].solver.m_nvars; v++) { if (m_rom_type == _ROM_TYPE_DMD_) { m_rom.push_back(new DMDROMObject( m_vec_size[ns], m_sampling_freq*a_dt, @@ -421,38 +421,38 @@ void libROMInterface::copyFromHyPar( std::vector& a_U, /*!< wo for (int ns = 0; ns < m_nsims; ns++) { double* vec = a_U[ns]->getData(); - const double* u = sim[ns].solver.u; + const double* u = sim[ns].solver.m_u; - std::vector index(sim[ns].solver.ndims); + std::vector index(sim[ns].solver.m_ndims); - ArrayCopynD( sim[ns].solver.ndims, + ArrayCopynD( sim[ns].solver.m_ndims, u, vec, - sim[ns].solver.dim_local, - sim[ns].solver.ghosts, + sim[ns].solver.m_dim_local, + sim[ns].solver.m_ghosts, 0, index.data(), - sim[ns].solver.nvars ); + sim[ns].solver.m_nvars ); } } else if (m_comp_mode == _ROM_COMP_MODE_COMPONENTWISE_) { int count(0); for (int ns = 0; ns < m_nsims; ns++) { - for (int v = 0; v < sim[ns].solver.nvars; v++) { + for (int v = 0; v < sim[ns].solver.m_nvars; v++) { double* vec = a_U[count]->getData(); - const double* u = sim[ns].solver.u; + const double* u = sim[ns].solver.m_u; - std::vector index(sim[ns].solver.ndims); + std::vector index(sim[ns].solver.m_ndims); - ArrayCopynDComponent( sim[ns].solver.ndims, + ArrayCopynDComponent( sim[ns].solver.m_ndims, u, vec, - sim[ns].solver.dim_local, - sim[ns].solver.ghosts, + sim[ns].solver.m_dim_local, + sim[ns].solver.m_ghosts, 0, index.data(), - sim[ns].solver.nvars, + sim[ns].solver.m_nvars, 1, v, 0 ); @@ -481,20 +481,20 @@ void libROMInterface::copyToHyPar( const CAROM::Vector& a_vec, /*!< Work vecto double* u; if (m_mode == _ROM_MODE_TRAIN_) { - u = sim[a_idx].solver.u_rom_predicted; + u = sim[a_idx].solver.m_u_rom_predicted; } else { - u = sim[a_idx].solver.u; + u = sim[a_idx].solver.m_u; } - std::vector index(sim[a_idx].solver.ndims); + std::vector index(sim[a_idx].solver.m_ndims); - ArrayCopynD( sim[a_idx].solver.ndims, + ArrayCopynD( sim[a_idx].solver.m_ndims, a_vec.getData(), u, - sim[a_idx].solver.dim_local, + sim[a_idx].solver.m_dim_local, 0, - sim[a_idx].solver.ghosts, + sim[a_idx].solver.m_ghosts, index.data(), - sim[a_idx].solver.nvars ); + sim[a_idx].solver.m_nvars ); return; } @@ -516,21 +516,21 @@ void libROMInterface::copyToHyPar( const CAROM::Vector& a_vec, /*!< Work vecto double* u; if (m_mode == _ROM_MODE_TRAIN_) { - u = sim[a_idx].solver.u_rom_predicted; + u = sim[a_idx].solver.m_u_rom_predicted; } else { - u = sim[a_idx].solver.u; + u = sim[a_idx].solver.m_u; } - std::vector index(sim[a_idx].solver.ndims); + std::vector index(sim[a_idx].solver.m_ndims); - ArrayCopynDComponent( sim[a_idx].solver.ndims, + ArrayCopynDComponent( sim[a_idx].solver.m_ndims, a_vec.getData(), u, - sim[a_idx].solver.dim_local, + sim[a_idx].solver.m_dim_local, 0, - sim[a_idx].solver.ghosts, + sim[a_idx].solver.m_ghosts, index.data(), 1, - sim[a_idx].solver.nvars, + sim[a_idx].solver.m_nvars, 0, a_var ); diff --git a/src/SecondDerivative/SecondDerivativeFourthOrder.c b/src/SecondDerivative/SecondDerivativeFourthOrder.c index ad0b85dd..2ab9a592 100644 --- a/src/SecondDerivative/SecondDerivativeFourthOrder.c +++ b/src/SecondDerivative/SecondDerivativeFourthOrder.c @@ -32,26 +32,26 @@ through all grid lines along \b dir. */ int SecondDerivativeFourthOrderCentral( - double *D2f, /*!< Array to hold the computed second derivative (with ghost points) - (same size and layout as f) */ - double *f, /*!< Array containing the grid point function values whose first + double *a_D2f, /*!< Array to hold the computed second derivative (with ghost points) + (same size and layout as a_f) */ + double *a_f, /*!< Array containing the grid point function values whose first derivative is to be computed (with ghost points) */ - int dir, /*!< The spatial dimension along which the derivative is computed */ - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + int a_dir, /*!< The spatial dimension along which the derivative is computed */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; + HyPar *solver = (HyPar*) a_s; int i, v; - int ghosts = solver->ghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; - static double one_twelve = 1.0/12.0; + static double s_one_twelve = 1.0/12.0; - if ((!D2f) || (!f)) { + if ((!a_D2f) || (!a_f)) { fprintf(stderr, "Error in SecondDerivativeFourthOrder(): input arrays not allocated.\n"); return(1); } @@ -61,22 +61,22 @@ int SecondDerivativeFourthOrderCentral( } /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along - dimension "dir" */ + dimension "a_dir" */ int indexC[ndims], index_outer[ndims], bounds_outer[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; int done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,indexC,ndims); - for (i = 0; i < dim[dir]; i++) { + for (i = 0; i < dim[a_dir]; i++) { int qm2, qm1, qC, qp1, qp2; - indexC[dir] = i-2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qm2); - indexC[dir] = i-1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qm1); - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC ); - indexC[dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp1); - indexC[dir] = i+2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp2); + indexC[a_dir] = i-2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qm2); + indexC[a_dir] = i-1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qm1); + indexC[a_dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC ); + indexC[a_dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp1); + indexC[a_dir] = i+2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qp2); for (v=0; vghosts; - int ndims = solver->ndims; - int nvars = solver->nvars; - int *dim = solver->dim_local; + int ghosts = solver->m_ghosts; + int ndims = solver->m_ndims; + int nvars = solver->m_nvars; + int *dim = solver->m_dim_local; - if ((!D2f) || (!f)) { + if ((!a_D2f) || (!a_f)) { fprintf(stderr, "Error in SecondDerivativeSecondOrder(): input arrays not allocated.\n"); return(1); } @@ -60,19 +60,19 @@ int SecondDerivativeSecondOrderCentral( } /* create index and bounds for the outer loop, i.e., to loop over all 1D lines along - dimension "dir" */ + dimension "a_dir" */ int indexC[ndims], index_outer[ndims], bounds_outer[ndims]; - _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[dir] = 1; + _ArrayCopy1D_(dim,bounds_outer,ndims); bounds_outer[a_dir] = 1; int done = 0; _ArraySetValue_(index_outer,ndims,0); while (!done) { _ArrayCopy1D_(index_outer,indexC,ndims); - for (i = 0; i < dim[dir]; i++) { + for (i = 0; i < dim[a_dir]; i++) { int qL, qC, qR; - indexC[dir] = i-1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qL); - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC); - indexC[dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR); - for (v=0; vip[dir] == 0) { + if (mpi->m_ip[a_dir] == 0) { /* left physical boundary: overwrite the leftmost value with biased finite-difference */ - int done = 0; _ArraySetValue_(index_outer,ndims,0); + int done = 0; _ArraySetValue_(index_outer,a_ndims,0); while (!done) { - _ArrayCopy1D_(index_outer,indexC,ndims); + _ArrayCopy1D_(index_outer,indexC,a_ndims); i = 0; int qC, qR, qR2, qR3; - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC); - indexC[dir] = i+1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR); - indexC[dir] = i+2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR2); - indexC[dir] = i+3; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qR3); - for (v=0; vip[dir] == (mpi->iproc[dir]-1)) { + if (mpi->m_ip[a_dir] == (mpi->m_iproc[a_dir]-1)) { /* right physical boundary: overwrite the rightmost value with biased finite-difference */ - int done = 0; _ArraySetValue_(index_outer,ndims,0); + int done = 0; _ArraySetValue_(index_outer,a_ndims,0); while (!done) { - _ArrayCopy1D_(index_outer,indexC,ndims); - i = dim[dir]-1; + _ArrayCopy1D_(index_outer,indexC,a_ndims); + i = a_dim[a_dir]-1; int qL3, qL2, qL, qC; - indexC[dir] = i-3; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qL3); - indexC[dir] = i-2; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qL2); - indexC[dir] = i-1; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qL); - indexC[dir] = i ; _ArrayIndex1D_(ndims,dim,indexC,ghosts,qC); - for (v=0; vboundary; + DomainBoundary* boundary = (DomainBoundary*) solver->m_boundary; int i; /* Clean up boundary zones */ - for (i = 0; i < solver->nBoundaryZones; i++) { + for (i = 0; i < solver->m_n_boundary_zones; i++) { #if defined(HAVE_CUDA) - BCCleanup(&boundary[i], solver->use_gpu); + BCCleanup(&boundary[i], solver->m_use_gpu); #else BCCleanup(&boundary[i], 0); #endif } - free(solver->boundary); + free(solver->m_boundary); /* Clean up immersed boundaries */ - if (solver->flag_ib) { - IERR IBCleanup(solver->ib); - free(solver->ib); + if (solver->m_flag_ib) { + IERR IBCleanup(solver->m_ib); + free(solver->m_ib); } /* Clean up any allocations in physical model */ - if (!strcmp(solver->model,_LINEAR_ADVECTION_DIFFUSION_REACTION_)) { - IERR LinearADRCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_DOUBLE_WELL_)) { - IERR FPDoubleWellCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_POWER_SYSTEM_)) { - IERR FPPowerSystemCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_POWER_SYSTEM_1BUS_)) { - IERR FPPowerSystem1BusCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_POWER_SYSTEM_3BUS_)) { - IERR FPPowerSystem3BusCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_EULER_1D_)) { - IERR Euler1DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_EULER_2D_)) { - IERR Euler2DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NAVIER_STOKES_2D_)) { - IERR NavierStokes2DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NAVIER_STOKES_3D_)) { - IERR NavierStokes3DCleanup(solver->physics); CHECKERR(ierr); + if (!strcmp(solver->m_model,_LINEAR_ADVECTION_DIFFUSION_REACTION_)) { + IERR LinearADRCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_FP_DOUBLE_WELL_)) { + IERR FPDoubleWellCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_FP_POWER_SYSTEM_)) { + IERR FPPowerSystemCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_FP_POWER_SYSTEM_1BUS_)) { + IERR FPPowerSystem1BusCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_FP_POWER_SYSTEM_3BUS_)) { + IERR FPPowerSystem3BusCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_EULER_1D_)) { + IERR Euler1DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_EULER_2D_)) { + IERR Euler2DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_NAVIER_STOKES_2D_)) { + IERR NavierStokes2DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_NAVIER_STOKES_3D_)) { + IERR NavierStokes3DCleanup(solver->m_physics); CHECKERR(ierr); #if defined(HAVE_CUDA) - if (solver->use_gpu) { - IERR gpuNavierStokes3DCleanup(solver->physics); CHECKERR(ierr); + if (solver->m_use_gpu) { + IERR gpuNavierStokes3DCleanup(solver->m_physics); CHECKERR(ierr); } #endif - } else if (!strcmp(solver->model,_NUMA2D_)) { - IERR Numa2DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NUMA3D_)) { - IERR Numa3DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_SHALLOW_WATER_1D_)) { - IERR ShallowWater1DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_SHALLOW_WATER_2D_)) { - IERR ShallowWater2DCleanup(solver->physics); CHECKERR(ierr); - } else if (!strcmp(solver->model,_VLASOV_)) { - IERR VlasovCleanup(solver->physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_NUMA2D_)) { + IERR Numa2DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_NUMA3D_)) { + IERR Numa3DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_SHALLOW_WATER_1D_)) { + IERR ShallowWater1DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_SHALLOW_WATER_2D_)) { + IERR ShallowWater2DCleanup(solver->m_physics); CHECKERR(ierr); + } else if (!strcmp(solver->m_model,_VLASOV_)) { + IERR VlasovCleanup(solver->m_physics); CHECKERR(ierr); } - free(solver->physics); + free(solver->m_physics); /* Clean up any allocations from time-integration */ #ifdef with_petsc - if (!solver->use_petscTS) { - if (!strcmp(solver->time_scheme,_RK_)) { - IERR TimeExplicitRKCleanup(solver->msti); CHECKERR(ierr); - free(solver->msti); - } else if (!strcmp(solver->time_scheme,_GLM_GEE_)) { - IERR TimeGLMGEECleanup(solver->msti); CHECKERR(ierr); - free(solver->msti); + if (!solver->m_use_petsc_ts) { + if (!strcmp(solver->m_time_scheme,_RK_)) { + IERR TimeExplicitRKCleanup(solver->m_msti); CHECKERR(ierr); + free(solver->m_msti); + } else if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { + IERR TimeGLMGEECleanup(solver->m_msti); CHECKERR(ierr); + free(solver->m_msti); } } #else - if (!strcmp(solver->time_scheme,_RK_)) { - IERR TimeExplicitRKCleanup(solver->msti); CHECKERR(ierr); - free(solver->msti); - } else if (!strcmp(solver->time_scheme,_GLM_GEE_)) { - IERR TimeGLMGEECleanup(solver->msti); CHECKERR(ierr); - free(solver->msti); + if (!strcmp(solver->m_time_scheme,_RK_)) { + IERR TimeExplicitRKCleanup(solver->m_msti); CHECKERR(ierr); + free(solver->m_msti); + } else if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { + IERR TimeGLMGEECleanup(solver->m_msti); CHECKERR(ierr); + free(solver->m_msti); } #endif /* Clean up any spatial reconstruction related allocations */ - if ( (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_WENO_ )) - || (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) - || (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_HCWENO_)) ) { + if ( (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_WENO_ )) + || (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) + || (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_HCWENO_)) ) { #if defined(HAVE_CUDA) - IERR WENOCleanup(solver->interp, solver->use_gpu); CHECKERR(ierr); + IERR WENOCleanup(solver->m_interp, solver->m_use_gpu); CHECKERR(ierr); #else - IERR WENOCleanup(solver->interp, 0); CHECKERR(ierr); + IERR WENOCleanup(solver->m_interp, 0); CHECKERR(ierr); #endif } - if (solver->interp) free(solver->interp); - if ( (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_COMPACT_UPWIND_ )) - || (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_ )) - || (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_HCWENO_ )) ) { - IERR CompactSchemeCleanup(solver->compact); CHECKERR(ierr); + if (solver->m_interp) free(solver->m_interp); + if ( (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_COMPACT_UPWIND_ )) + || (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_ )) + || (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_HCWENO_ )) ) { + IERR CompactSchemeCleanup(solver->m_compact); CHECKERR(ierr); } - if (solver->compact) free(solver->compact); - if (solver->lusolver) free(solver->lusolver); + if (solver->m_compact) free(solver->m_compact); + if (solver->m_lusolver) free(solver->m_lusolver); /* Free the communicators created */ - IERR MPIFreeCommunicators(solver->ndims,mpi); CHECKERR(ierr); + IERR MPIFreeCommunicators(solver->m_ndims,mpi); CHECKERR(ierr); /* These variables are allocated in Initialize.c */ - free(solver->dim_global); - free(solver->dim_global_ex); - free(solver->dim_local); - free(solver->index); - free(solver->u); + free(solver->m_dim_global); + free(solver->m_dim_global_ex); + free(solver->m_dim_local); + free(solver->m_index); + free(solver->m_u); #ifdef with_petsc - if (solver->u0) free(solver->u0); - if (solver->uref) free(solver->uref); - if (solver->rhsref) free(solver->rhsref); - if (solver->rhs) free(solver->rhs); + if (solver->m_u0) free(solver->m_u0); + if (solver->m_uref) free(solver->m_uref); + if (solver->m_rhsref) free(solver->m_rhsref); + if (solver->m_rhs) free(solver->m_rhs); #endif #ifdef with_librom - free(solver->u_rom_predicted); + free(solver->m_u_rom_predicted); #endif - free(solver->iblank); - free(solver->x); - free(solver->dxinv); - free(solver->isPeriodic); - free(mpi->iproc); - free(mpi->ip); - free(mpi->is); - free(mpi->ie); - free(mpi->bcperiodic); - free(mpi->sendbuf); - free(mpi->recvbuf); - free(solver->VolumeIntegral); - free(solver->VolumeIntegralInitial); - free(solver->TotalBoundaryIntegral); - free(solver->ConservationError); - free(solver->stride_with_ghosts); - free(solver->stride_without_ghosts); + free(solver->m_iblank); + free(solver->m_x); + free(solver->m_dxinv); + free(solver->m_is_periodic); + free(mpi->m_iproc); + free(mpi->m_ip); + free(mpi->m_is); + free(mpi->m_ie); + free(mpi->m_bcperiodic); + free(mpi->m_sendbuf); + free(mpi->m_recvbuf); + free(solver->m_volume_integral); + free(solver->m_volume_integral_initial); + free(solver->m_total_boundary_integral); + free(solver->m_conservation_error); + free(solver->m_stride_with_ghosts); + free(solver->m_stride_without_ghosts); #if defined(HAVE_CUDA) - if (solver->use_gpu) { - gpuFree(solver->hyp); - gpuFree(solver->par); - gpuFree(solver->source); - gpuFree(solver->uC); - gpuFree(solver->fluxC); - gpuFree(solver->Deriv1); - gpuFree(solver->Deriv2); - gpuFree(solver->fluxI); - gpuFree(solver->uL); - gpuFree(solver->uR); - gpuFree(solver->fL); - gpuFree(solver->fR); - gpuFree(solver->StageBoundaryBuffer); - gpuFree(solver->StageBoundaryIntegral); - gpuFree(solver->StepBoundaryIntegral); - - gpuFree(solver->gpu_dim_local); - gpuFree(solver->gpu_iblank); - gpuFree(solver->gpu_x); - gpuFree(solver->gpu_dxinv); - gpuFree(solver->gpu_u); + if (solver->m_use_gpu) { + gpuFree(solver->m_hyp); + gpuFree(solver->m_par); + gpuFree(solver->m_source); + gpuFree(solver->m_u_c); + gpuFree(solver->m_flux_c); + gpuFree(solver->m_deriv1); + gpuFree(solver->m_deriv2); + gpuFree(solver->m_flux_i); + gpuFree(solver->m_u_l); + gpuFree(solver->m_u_r); + gpuFree(solver->m_f_l); + gpuFree(solver->m_f_r); + gpuFree(solver->m_stage_boundary_buffer); + gpuFree(solver->m_stage_boundary_integral); + gpuFree(solver->m_step_boundary_integral); + + gpuFree(solver->m_gpu_dim_local); + gpuFree(solver->m_gpu_iblank); + gpuFree(solver->m_gpu_x); + gpuFree(solver->m_gpu_dxinv); + gpuFree(solver->m_gpu_u); } else { #endif - free(solver->hyp); - free(solver->par); - free(solver->source); - free(solver->uC); - free(solver->fluxC); - free(solver->Deriv1); - free(solver->Deriv2); - free(solver->fluxI); - free(solver->uL); - free(solver->uR); - free(solver->fL); - free(solver->fR); - free(solver->StageBoundaryIntegral); - free(solver->StepBoundaryIntegral); + free(solver->m_hyp); + free(solver->m_par); + free(solver->m_source); + free(solver->m_u_c); + free(solver->m_flux_c); + free(solver->m_deriv1); + free(solver->m_deriv2); + free(solver->m_flux_i); + free(solver->m_u_l); + free(solver->m_u_r); + free(solver->m_f_l); + free(solver->m_f_r); + free(solver->m_stage_boundary_integral); + free(solver->m_step_boundary_integral); #if defined(HAVE_CUDA) } #endif - if (solver->filename_index) free(solver->filename_index); + if (solver->m_filename_index) free(solver->m_filename_index); } diff --git a/src/Simulation/CombineSolutions.c b/src/Simulation/CombineSolutions.c index 20be046f..ec4b7439 100644 --- a/src/Simulation/CombineSolutions.c +++ b/src/Simulation/CombineSolutions.c @@ -27,12 +27,12 @@ void CombineSolutions( SimulationObject* a_sims_src, /*!< Array of simulati HyPar* solver_dst = &(a_sim_dst->solver); MPIVariables* mpi_dst = &(a_sim_dst->mpi); - int ndims = solver_dst->ndims; - int nvars = solver_dst->nvars; - int ghosts = solver_dst->ghosts; + int ndims = solver_dst->m_ndims; + int nvars = solver_dst->m_nvars; + int ghosts = solver_dst->m_ghosts; /* array size */ - int* dim_global_dst = solver_dst->dim_global; + int* dim_global_dst = solver_dst->m_dim_global; int dim_dst_wgpt[ndims]; _ArrayCopy1D_(dim_global_dst, dim_dst_wgpt, ndims); long size_dst_wgpt = nvars; @@ -43,7 +43,7 @@ void CombineSolutions( SimulationObject* a_sims_src, /*!< Array of simulati /* allocate global data array for combined solution */ double *ug_dst_wgpt = NULL; - if (!mpi_dst->rank) { + if (!mpi_dst->m_rank) { ug_dst_wgpt = (double*) calloc (size_dst_wgpt, sizeof(double)); _ArraySetValue_(ug_dst_wgpt, size_dst_wgpt, 0.0); } @@ -52,7 +52,7 @@ void CombineSolutions( SimulationObject* a_sims_src, /*!< Array of simulati * and add to the solution */ for (int n = 0; n < a_nsims; n++) { - int* dim_global_src = a_sims_src[n].solver.dim_global; + int* dim_global_src = a_sims_src[n].solver.m_dim_global; int dim_global_src_wgpt[ndims]; _ArrayCopy1D_(dim_global_src, dim_global_src_wgpt, ndims); long size_src_wgpt = nvars; @@ -62,7 +62,7 @@ void CombineSolutions( SimulationObject* a_sims_src, /*!< Array of simulati } double* ug_src_wgpt = NULL; - if (!a_sims_src[n].mpi.rank) { + if (!a_sims_src[n].mpi.m_rank) { ug_src_wgpt = (double*) calloc (size_src_wgpt, sizeof(double)); _ArraySetValue_(ug_src_wgpt, size_src_wgpt, 0.0); } @@ -71,20 +71,20 @@ void CombineSolutions( SimulationObject* a_sims_src, /*!< Array of simulati ug_src_wgpt, a_u_src[n], dim_global_src, - a_sims_src[n].solver.dim_local, + a_sims_src[n].solver.m_dim_local, ghosts, nvars ); - if (!mpi_dst->rank) { + if (!mpi_dst->m_rank) { double *u_src_interpolated = NULL; InterpolateGlobalnDVar( dim_global_dst, &u_src_interpolated, - a_sims_src[n].solver.dim_global, + a_sims_src[n].solver.m_dim_global, ug_src_wgpt, nvars, ghosts, ndims, - a_sims_src[n].solver.isPeriodic ); + a_sims_src[n].solver.m_is_periodic ); _ArrayAXPY_(u_src_interpolated, a_coeffs[n], ug_dst_wgpt, size_dst_wgpt); free(u_src_interpolated); } @@ -94,15 +94,15 @@ void CombineSolutions( SimulationObject* a_sims_src, /*!< Array of simulati /* now partition the global combined solution to its processor */ MPIPartitionArraynDwGhosts( ndims, mpi_dst, - (mpi_dst->rank ? NULL : ug_dst_wgpt), + (mpi_dst->m_rank ? NULL : ug_dst_wgpt), a_u_dst, - solver_dst->dim_global, - solver_dst->dim_local, + solver_dst->m_dim_global, + solver_dst->m_dim_local, ghosts, nvars ); /* free memory */ - if (!mpi_dst->rank) free(ug_dst_wgpt); + if (!mpi_dst->m_rank) free(ug_dst_wgpt); /* done */ return; diff --git a/src/Simulation/EnsembleSimulationsDefine.cpp b/src/Simulation/EnsembleSimulationsDefine.cpp index de62ffb2..8c28a1c7 100644 --- a/src/Simulation/EnsembleSimulationsDefine.cpp +++ b/src/Simulation/EnsembleSimulationsDefine.cpp @@ -101,10 +101,10 @@ int EnsembleSimulation::define( int a_rank, /*!< MPI rank of this process */ m_sims.resize(m_nsims); for (int ns = 0; ns < m_nsims; ns++) { - m_sims[ns].solver.my_idx = ns; - m_sims[ns].solver.nsims = m_nsims; - m_sims[ns].mpi.rank = m_rank; - m_sims[ns].mpi.nproc = m_nproc; + m_sims[ns].solver.m_my_idx = ns; + m_sims[ns].solver.m_nsims = m_nsims; + m_sims[ns].mpi.m_rank = m_rank; + m_sims[ns].mpi.m_nproc = m_nproc; } if (!m_rank) { diff --git a/src/Simulation/InitialSolution.c b/src/Simulation/InitialSolution.c index 8eb6a6e5..f5975af1 100644 --- a/src/Simulation/InitialSolution.c +++ b/src/Simulation/InitialSolution.c @@ -22,39 +22,39 @@ int VolumeIntegral(double*,double*,void*,void*); /*! Read in initial solution from file, and compute grid spacing and volume integral of the initial solution */ -int InitialSolution ( void *s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims /*!< Number of simulation objects */ +int InitialSolution ( void *a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims /*!< Number of simulation objects */ ) { - SimulationObject* simobj = (SimulationObject*) s; + SimulationObject* simobj = (SimulationObject*) a_s; int n, flag, d, i, offset, ierr; - for (n = 0; n < nsims; n++) { + for (n = 0; n < a_nsims; n++) { - int ghosts = simobj[n].solver.ghosts; + int ghosts = simobj[n].solver.m_ghosts; char fname_root[_MAX_STRING_SIZE_] = "initial"; - if (nsims > 1) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(n, index, (int)log10(nsims)+1); + GetStringFromInteger(n, index, (int)log10(a_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } - ierr = ReadArray( simobj[n].solver.ndims, - simobj[n].solver.nvars, - simobj[n].solver.dim_global, - simobj[n].solver.dim_local, - simobj[n].solver.ghosts, + ierr = ReadArray( simobj[n].solver.m_ndims, + simobj[n].solver.m_nvars, + simobj[n].solver.m_dim_global, + simobj[n].solver.m_dim_local, + simobj[n].solver.m_ghosts, &(simobj[n].solver), &(simobj[n].mpi), - simobj[n].solver.x, - simobj[n].solver.u, + simobj[n].solver.m_x, + simobj[n].solver.m_u, fname_root, &flag ); if (ierr) { fprintf(stderr, "Error in InitialSolution() on rank %d.\n", - simobj[n].mpi.rank); + simobj[n].mpi.m_rank); return ierr; } if (!flag) { @@ -64,50 +64,50 @@ int InitialSolution ( void *s, /*!< Array of simulation objects of type #Simu CHECKERR(ierr); /* exchange MPI-boundary values of u between processors */ - MPIExchangeBoundariesnD( simobj[n].solver.ndims, - simobj[n].solver.nvars, - simobj[n].solver.dim_local, - simobj[n].solver.ghosts, + MPIExchangeBoundariesnD( simobj[n].solver.m_ndims, + simobj[n].solver.m_nvars, + simobj[n].solver.m_dim_local, + simobj[n].solver.m_ghosts, &(simobj[n].mpi), - simobj[n].solver.u ); + simobj[n].solver.m_u ); /* calculate dxinv */ offset = 0; - for (d = 0; d < simobj[n].solver.ndims; d++) { - for (i = 0; i < simobj[n].solver.dim_local[d]; i++) { - simobj[n].solver.dxinv[i+offset+ghosts] - = 2.0 / (simobj[n].solver.x[i+1+offset+ghosts]-simobj[n].solver.x[i-1+offset+ghosts]); + for (d = 0; d < simobj[n].solver.m_ndims; d++) { + for (i = 0; i < simobj[n].solver.m_dim_local[d]; i++) { + simobj[n].solver.m_dxinv[i+offset+ghosts] + = 2.0 / (simobj[n].solver.m_x[i+1+offset+ghosts]-simobj[n].solver.m_x[i-1+offset+ghosts]); } - offset += (simobj[n].solver.dim_local[d] + 2*ghosts); + offset += (simobj[n].solver.m_dim_local[d] + 2*ghosts); } /* exchange MPI-boundary values of dxinv between processors */ offset = 0; - for (d = 0; d < simobj[n].solver.ndims; d++) { + for (d = 0; d < simobj[n].solver.m_ndims; d++) { ierr = MPIExchangeBoundaries1D( &(simobj[n].mpi), - &(simobj[n].solver.dxinv[offset]), - simobj[n].solver.dim_local[d], + &(simobj[n].solver.m_dxinv[offset]), + simobj[n].solver.m_dim_local[d], ghosts, d, - simobj[n].solver.ndims ); CHECKERR(ierr); + simobj[n].solver.m_ndims ); CHECKERR(ierr); if (ierr) { fprintf(stderr, "Error in InitialSolution() on rank %d.\n", - simobj[n].mpi.rank); + simobj[n].mpi.m_rank); return ierr; } - offset += (simobj[n].solver.dim_local[d] + 2*ghosts); + offset += (simobj[n].solver.m_dim_local[d] + 2*ghosts); } /* fill in ghost values of dxinv at physical boundaries by extrapolation */ offset = 0; - for (d = 0; d < simobj[n].solver.ndims; d++) { - double *dxinv = &(simobj[n].solver.dxinv[offset]); - int *dim = simobj[n].solver.dim_local; - if (simobj[n].mpi.ip[d] == 0) { + for (d = 0; d < simobj[n].solver.m_ndims; d++) { + double *dxinv = &(simobj[n].solver.m_dxinv[offset]); + int *dim = simobj[n].solver.m_dim_local; + if (simobj[n].mpi.m_ip[d] == 0) { /* fill left boundary along this dimension */ for (i = 0; i < ghosts; i++) dxinv[i] = dxinv[ghosts]; } - if (simobj[n].mpi.ip[d] == simobj[n].mpi.iproc[d]-1) { + if (simobj[n].mpi.m_ip[d] == simobj[n].mpi.m_iproc[d]-1) { /* fill right boundary along this dimension */ for (i = dim[d]+ghosts; i < dim[d]+2*ghosts; i++) dxinv[i] = dxinv[dim[d]+ghosts-1]; } @@ -115,56 +115,56 @@ int InitialSolution ( void *s, /*!< Array of simulation objects of type #Simu } /* calculate volume integral of the initial solution */ - ierr = VolumeIntegral( simobj[n].solver.VolumeIntegralInitial, - simobj[n].solver.u, + ierr = VolumeIntegral( simobj[n].solver.m_volume_integral_initial, + simobj[n].solver.m_u, &(simobj[n].solver), &(simobj[n].mpi) ); CHECKERR(ierr); if (ierr) { fprintf(stderr, "Error in InitialSolution() on rank %d.\n", - simobj[n].mpi.rank); + simobj[n].mpi.m_rank); return ierr; } - if (!simobj[n].mpi.rank) { - if (nsims > 1) printf("Volume integral of the initial solution on domain %d:\n", n); + if (!simobj[n].mpi.m_rank) { + if (a_nsims > 1) printf("Volume integral of the initial solution on domain %d:\n", n); else printf("Volume integral of the initial solution:\n"); - for (d=0; d= 0)) { - gpuSetDevice(simobj[0].solver.gpu_device_no); + if (simobj[0].solver.m_use_gpu && (simobj[0].solver.m_gpu_device_no >= 0)) { + gpuSetDevice(simobj[0].solver.m_gpu_device_no); } #endif - if (!simobj[0].mpi.rank) printf("Partitioning domain and allocating data arrays.\n"); + if (!simobj[0].mpi.m_rank) printf("Partitioning domain and allocating data arrays.\n"); - for (n = 0; n < nsims; n++) { + for (n = 0; n < a_nsims; n++) { /* this is a full initialization, not a barebones one */ simobj[n].is_barebones = 0; /* allocations */ - simobj[n].mpi.ip = (int*) calloc (simobj[n].solver.ndims,sizeof(int)); - simobj[n].mpi.is = (int*) calloc (simobj[n].solver.ndims,sizeof(int)); - simobj[n].mpi.ie = (int*) calloc (simobj[n].solver.ndims,sizeof(int)); - simobj[n].mpi.bcperiodic = (int*) calloc (simobj[n].solver.ndims,sizeof(int)); - simobj[n].solver.dim_local = (int*) calloc (simobj[n].solver.ndims,sizeof(int)); - simobj[n].solver.isPeriodic= (int*) calloc (simobj[n].solver.ndims,sizeof(int)); + simobj[n].mpi.m_ip = (int*) calloc (simobj[n].solver.m_ndims,sizeof(int)); + simobj[n].mpi.m_is = (int*) calloc (simobj[n].solver.m_ndims,sizeof(int)); + simobj[n].mpi.m_ie = (int*) calloc (simobj[n].solver.m_ndims,sizeof(int)); + simobj[n].mpi.m_bcperiodic = (int*) calloc (simobj[n].solver.m_ndims,sizeof(int)); + simobj[n].solver.m_dim_local = (int*) calloc (simobj[n].solver.m_ndims,sizeof(int)); + simobj[n].solver.m_is_periodic= (int*) calloc (simobj[n].solver.m_ndims,sizeof(int)); #if defined(HAVE_CUDA) - simobj[n].mpi.wctime = 0; - simobj[n].mpi.wctime_total = 0; + simobj[n].mpi.m_wctime = 0; + simobj[n].mpi.m_wctime_total = 0; #endif #ifndef serial @@ -65,293 +65,293 @@ int Initialize( void *s, /*!< Array of simulation objects of type #Simulation /* Domain partitioning */ int total_proc = 1; - for (i=0; i 1) fprintf(stderr,"for domain %d.\n", n); - fprintf(stderr,"mpiexec was called with %d processes, ",simobj[n].mpi.nproc); + if (a_nsims > 1) fprintf(stderr,"for domain %d.\n", n); + fprintf(stderr,"mpiexec was called with %d processes, ",simobj[n].mpi.m_nproc); fprintf(stderr,"total number of processes from \"solver.inp\" is %d.\n", total_proc); return(1); } /* calculate ndims-D rank of each process (ip[]) from rank in MPI_COMM_WORLD */ - IERR MPIRanknD( simobj[n].solver.ndims, - simobj[n].mpi.rank, - simobj[n].mpi.iproc, - simobj[n].mpi.ip); CHECKERR(ierr); + IERR MPIRanknD( simobj[n].solver.m_ndims, + simobj[n].mpi.m_rank, + simobj[n].mpi.m_iproc, + simobj[n].mpi.m_ip); CHECKERR(ierr); /* calculate local domain sizes along each dimension */ - for (i=0; i maxbuf) maxbuf = bufdim[d]; } - maxbuf *= (simobj[n].solver.nvars*simobj[n].solver.ndims); - simobj[n].mpi.maxbuf = maxbuf; - simobj[n].mpi.sendbuf = (double*) calloc (2*simobj[n].solver.ndims*maxbuf,sizeof(double)); - simobj[n].mpi.recvbuf = (double*) calloc (2*simobj[n].solver.ndims*maxbuf,sizeof(double)); + maxbuf *= (simobj[n].solver.m_nvars*simobj[n].solver.m_ndims); + simobj[n].mpi.m_maxbuf = maxbuf; + simobj[n].mpi.m_sendbuf = (double*) calloc (2*simobj[n].solver.m_ndims*maxbuf,sizeof(double)); + simobj[n].mpi.m_recvbuf = (double*) calloc (2*simobj[n].solver.m_ndims*maxbuf,sizeof(double)); #if defined(HAVE_CUDA) - if (simobj[n].solver.use_gpu) { - simobj[n].mpi.cpu_dim = (int *) calloc(simobj[n].solver.ndims, sizeof(int)); - _ArrayCopy1D_(simobj[n].solver.dim_local, simobj[n].mpi.cpu_dim, simobj[n].solver.ndims); - gpuMalloc((void**)&simobj[n].mpi.gpu_sendbuf, 2*simobj[n].solver.ndims*simobj[n].mpi.maxbuf*sizeof(double)); - gpuMalloc((void**)&simobj[n].mpi.gpu_recvbuf, 2*simobj[n].solver.ndims*simobj[n].mpi.maxbuf*sizeof(double)); - gpuMemset(simobj[n].mpi.gpu_sendbuf, 0, 2*simobj[n].solver.ndims*simobj[n].mpi.maxbuf*sizeof(double)); - gpuMemset(simobj[n].mpi.gpu_recvbuf, 0, 2*simobj[n].solver.ndims*simobj[n].mpi.maxbuf*sizeof(double)); + if (simobj[n].solver.m_use_gpu) { + simobj[n].mpi.m_cpu_dim = (int *) calloc(simobj[n].solver.m_ndims, sizeof(int)); + _ArrayCopy1D_(simobj[n].solver.m_dim_local, simobj[n].mpi.m_cpu_dim, simobj[n].solver.m_ndims); + gpuMalloc((void**)&simobj[n].mpi.m_gpu_sendbuf, 2*simobj[n].solver.m_ndims*simobj[n].mpi.m_maxbuf*sizeof(double)); + gpuMalloc((void**)&simobj[n].mpi.m_gpu_recvbuf, 2*simobj[n].solver.m_ndims*simobj[n].mpi.m_maxbuf*sizeof(double)); + gpuMemset(simobj[n].mpi.m_gpu_sendbuf, 0, 2*simobj[n].solver.m_ndims*simobj[n].mpi.m_maxbuf*sizeof(double)); + gpuMemset(simobj[n].mpi.m_gpu_recvbuf, 0, 2*simobj[n].solver.m_ndims*simobj[n].mpi.m_maxbuf*sizeof(double)); } #endif /* allocate the volume and boundary integral arrays */ - simobj[n].solver.VolumeIntegral = (double*) calloc (simobj[n].solver.nvars ,sizeof(double)); - simobj[n].solver.VolumeIntegralInitial = (double*) calloc (simobj[n].solver.nvars ,sizeof(double)); - simobj[n].solver.TotalBoundaryIntegral = (double*) calloc (simobj[n].solver.nvars,sizeof(double)); - simobj[n].solver.ConservationError = (double*) calloc (simobj[n].solver.nvars,sizeof(double)); - for (i=0; irank) { + if (!mpi->m_rank) { char filename[_MAX_STRING_SIZE_] = "boundary"; char filename_backup[_MAX_STRING_SIZE_] = "boundary"; - if (nsims > 1) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(ns, index, (int)log10(nsims)+1); + GetStringFromInteger(ns, index, (int)log10(a_nsims)+1); strcat(filename, "_"); strcat(filename, index); } @@ -71,273 +71,273 @@ int InitializeBoundaries( void *s, /*!< Array of simulation objects of type # filename, filename_backup ); return(1); } else { - if (nsims > 1) printf("Domain %d: ", ns); + if (a_nsims > 1) printf("Domain %d: ", ns); printf("Reading boundary conditions from %s.\n", filename_backup); } } else { - if (nsims > 1) printf("Domain %d: ", ns); + if (a_nsims > 1) printf("Domain %d: ", ns); printf("Reading boundary conditions from %s.\n", filename); } /* read number of boundary conditions and allocate */ - ferr = fscanf(in,"%d",&solver->nBoundaryZones); if (ferr != 1) return(1); - boundary = (DomainBoundary*) calloc (solver->nBoundaryZones,sizeof(DomainBoundary)); - for (nb = 0; nb < solver->nBoundaryZones; nb++) { - boundary[nb].DirichletValue = boundary[nb].SpongeValue - = boundary[nb].FlowVelocity - = boundary[nb].UnsteadyDirichletData + ferr = fscanf(in,"%d",&solver->m_n_boundary_zones); if (ferr != 1) return(1); + boundary = (DomainBoundary*) calloc (solver->m_n_boundary_zones,sizeof(DomainBoundary)); + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { + boundary[nb].m_DirichletValue = boundary[nb].m_SpongeValue + = boundary[nb].m_FlowVelocity + = boundary[nb].m_UnsteadyDirichletData = NULL; - boundary[nb].UnsteadyDirichletSize = NULL; + boundary[nb].m_UnsteadyDirichletSize = NULL; } /* read each boundary condition */ - for (nb = 0; nb < solver->nBoundaryZones; nb++) { + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { int d, v; - boundary[nb].xmin = (double*) calloc (solver->ndims,sizeof(double)); /* deallocated in BCCleanup.c */ - boundary[nb].xmax = (double*) calloc (solver->ndims,sizeof(double)); /* deallocated in BCCleanup.c */ - - ferr = fscanf(in,"%s",boundary[nb].bctype); if (ferr != 1) return(1); - ferr = fscanf(in,"%d",&boundary[nb].dim ); if (ferr != 1) return(1); - ferr = fscanf(in,"%d",&boundary[nb].face ); if (ferr != 1) return(1); - for (d=0; d < solver->ndims; d++) { - ferr = fscanf(in,"%lf %lf", &boundary[nb].xmin[d], &boundary[nb].xmax[d]); + boundary[nb].m_xmin = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ + boundary[nb].m_xmax = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ + + ferr = fscanf(in,"%s",boundary[nb].m_bctype); if (ferr != 1) return(1); + ferr = fscanf(in,"%d",&boundary[nb].m_dim ); if (ferr != 1) return(1); + ferr = fscanf(in,"%d",&boundary[nb].m_face ); if (ferr != 1) return(1); + for (d=0; d < solver->m_ndims; d++) { + ferr = fscanf(in,"%lf %lf", &boundary[nb].m_xmin[d], &boundary[nb].m_xmax[d]); if (ferr != 2) return(1); } /* read in boundary type-specific additional data if required */ - if (!strcmp(boundary[nb].bctype,_DIRICHLET_)) { - boundary[nb].DirichletValue = (double*) calloc (solver->nvars,sizeof(double)); + if (!strcmp(boundary[nb].m_bctype,_DIRICHLET_)) { + boundary[nb].m_DirichletValue = (double*) calloc (solver->m_nvars,sizeof(double)); /* deallocated in BCCleanup.c */ /* read the Dirichlet value for each variable on this boundary */ - for (v = 0; v < solver->nvars; v++) ferr = fscanf(in,"%lf",&boundary[nb].DirichletValue[v]); + for (v = 0; v < solver->m_nvars; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_DirichletValue[v]); } - if (!strcmp(boundary[nb].bctype,_SPONGE_)) { - boundary[nb].SpongeValue = (double*) calloc (solver->nvars,sizeof(double)); + if (!strcmp(boundary[nb].m_bctype,_SPONGE_)) { + boundary[nb].m_SpongeValue = (double*) calloc (solver->m_nvars,sizeof(double)); /* deallocated in BCCleanup.c */ /* read the sponge value for each variable on this boundary */ - for (v = 0; v < solver->nvars; v++) ferr = fscanf(in,"%lf",&boundary[nb].SpongeValue[v]); + for (v = 0; v < solver->m_nvars; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_SpongeValue[v]); } - if ( (!strcmp(boundary[nb].bctype,_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_NOSLIP_WALL_)) ) { - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if ( (!strcmp(boundary[nb].m_bctype,_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_NOSLIP_WALL_)) ) { + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read the wall velocity */ - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); } - if ( (!strcmp(boundary[nb].bctype,_SW_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_SW_NOSLIP_WALL_)) ) { - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if ( (!strcmp(boundary[nb].m_bctype,_SW_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_SW_NOSLIP_WALL_)) ) { + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read the wall velocity */ - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); } - if (!strcmp(boundary[nb].bctype,_SUBSONIC_INFLOW_)) { - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if (!strcmp(boundary[nb].m_bctype,_SUBSONIC_INFLOW_)) { + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read in the inflow density and velocity */ - ferr = fscanf(in,"%lf",&boundary[nb].FlowDensity); - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowDensity); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); } - if (!strcmp(boundary[nb].bctype,_SUBSONIC_OUTFLOW_)) { + if (!strcmp(boundary[nb].m_bctype,_SUBSONIC_OUTFLOW_)) { /* read in the outflow pressure */ - ferr = fscanf(in,"%lf",&boundary[nb].FlowPressure); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowPressure); } - if (!strcmp(boundary[nb].bctype,_SUBSONIC_AMBIVALENT_)) { - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if (!strcmp(boundary[nb].m_bctype,_SUBSONIC_AMBIVALENT_)) { + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read in the inflow density, velocity, and pressure */ - ferr = fscanf(in,"%lf",&boundary[nb].FlowDensity); - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); - ferr = fscanf(in,"%lf",&boundary[nb].FlowPressure); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowDensity); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowPressure); } - if (!strcmp(boundary[nb].bctype,_SUPERSONIC_INFLOW_)) { - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if (!strcmp(boundary[nb].m_bctype,_SUPERSONIC_INFLOW_)) { + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read in the inflow density, velocity and pressure */ - ferr = fscanf(in,"%lf",&boundary[nb].FlowDensity); - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); - ferr = fscanf(in,"%lf",&boundary[nb].FlowPressure); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowDensity); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowPressure); } - if (!strcmp(boundary[nb].bctype,_TURBULENT_SUPERSONIC_INFLOW_)) { - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if (!strcmp(boundary[nb].m_bctype,_TURBULENT_SUPERSONIC_INFLOW_)) { + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read in the inflow density, velocity and pressure */ - ferr = fscanf(in,"%lf",&boundary[nb].FlowDensity); - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); - ferr = fscanf(in,"%lf",&boundary[nb].FlowPressure); - ferr = fscanf(in,"%s" , boundary[nb].UnsteadyDirichletFilename); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowDensity); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); + ferr = fscanf(in,"%lf",&boundary[nb].m_FlowPressure); + ferr = fscanf(in,"%s" , boundary[nb].m_UnsteadyDirichletFilename); } - if ( (!strcmp(boundary[nb].bctype,_THERMAL_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_THERMAL_NOSLIP_WALL_)) ){ - boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); + if ( (!strcmp(boundary[nb].m_bctype,_THERMAL_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_THERMAL_NOSLIP_WALL_)) ){ + boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ /* read the wall velocity */ - for (v = 0; v < solver->ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].FlowVelocity[v]); + for (v = 0; v < solver->m_ndims; v++) ferr = fscanf(in,"%lf",&boundary[nb].m_FlowVelocity[v]); /* read in the filename where temperature data is available */ - ferr = fscanf(in,"%s" , boundary[nb].UnsteadyTemperatureFilename); + ferr = fscanf(in,"%s" , boundary[nb].m_UnsteadyTemperatureFilename); } /* if boundary is periodic, let the MPI and HyPar know */ - if (!strcmp(boundary[nb].bctype,_PERIODIC_)) { - solver->isPeriodic[boundary[nb].dim] = 1; + if (!strcmp(boundary[nb].m_bctype,_PERIODIC_)) { + solver->m_is_periodic[boundary[nb].m_dim] = 1; } /* The MPI function to exchange internal (MPI) boundary information will handle periodic boundaries ONLY IF number of process along that dimension is more than 1. */ - if ((!strcmp(boundary[nb].bctype,_PERIODIC_)) && (mpi->iproc[boundary[nb].dim] > 1)) { - mpi->bcperiodic[boundary[nb].dim] = 1; + if ((!strcmp(boundary[nb].m_bctype,_PERIODIC_)) && (mpi->m_iproc[boundary[nb].m_dim] > 1)) { + mpi->m_bcperiodic[boundary[nb].m_dim] = 1; } /* some checks */ - if (boundary[nb].dim >= solver->ndims) { + if (boundary[nb].m_dim >= solver->m_ndims) { fprintf(stderr,"Error in reading boundary condition %d: dim %d is invalid (ndims = %d).\n", - nb,boundary[nb].dim,solver->ndims); + nb,boundary[nb].m_dim,solver->m_ndims); return(1); } printf(" Boundary %30s: Along dimension %2d and face %+1d\n", - boundary[nb].bctype,boundary[nb].dim,boundary[nb].face); + boundary[nb].m_bctype,boundary[nb].m_dim,boundary[nb].m_face); } fclose(in); - printf("%d boundary condition(s) read.\n",solver->nBoundaryZones); + printf("%d boundary condition(a_s) read.\n",solver->m_n_boundary_zones); } /* tell other processes how many BCs are there and let them allocate */ - IERR MPIBroadcast_integer(&solver->nBoundaryZones,1,0,&mpi->world); CHECKERR(ierr); - if (mpi->rank) { - boundary = (DomainBoundary*) calloc (solver->nBoundaryZones,sizeof(DomainBoundary)); - for (nb = 0; nb < solver->nBoundaryZones; nb++) { - boundary[nb].xmin = (double*) calloc (solver->ndims,sizeof(double)); /* deallocated in BCCleanup.c */ - boundary[nb].xmax = (double*) calloc (solver->ndims,sizeof(double)); /* deallocated in BCCleanup.c */ - boundary[nb].DirichletValue = boundary[nb].SpongeValue - = boundary[nb].FlowVelocity - = boundary[nb].UnsteadyDirichletData + IERR MPIBroadcast_integer(&solver->m_n_boundary_zones,1,0,&mpi->m_world); CHECKERR(ierr); + if (mpi->m_rank) { + boundary = (DomainBoundary*) calloc (solver->m_n_boundary_zones,sizeof(DomainBoundary)); + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { + boundary[nb].m_xmin = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ + boundary[nb].m_xmax = (double*) calloc (solver->m_ndims,sizeof(double)); /* deallocated in BCCleanup.c */ + boundary[nb].m_DirichletValue = boundary[nb].m_SpongeValue + = boundary[nb].m_FlowVelocity + = boundary[nb].m_UnsteadyDirichletData = NULL; - boundary[nb].UnsteadyDirichletSize = NULL; + boundary[nb].m_UnsteadyDirichletSize = NULL; } } /* communicate BC data to other processes */ - for (nb = 0; nb < solver->nBoundaryZones; nb++) { - IERR MPIBroadcast_character(boundary[nb].bctype,_MAX_STRING_SIZE_,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&boundary[nb].dim ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_integer (&boundary[nb].face ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (boundary[nb].xmin ,solver->ndims ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double (boundary[nb].xmax ,solver->ndims ,0,&mpi->world); CHECKERR(ierr); + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { + IERR MPIBroadcast_character(boundary[nb].m_bctype,_MAX_STRING_SIZE_,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&boundary[nb].m_dim ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_integer (&boundary[nb].m_face ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (boundary[nb].m_xmin ,solver->m_ndims ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double (boundary[nb].m_xmax ,solver->m_ndims ,0,&mpi->m_world); CHECKERR(ierr); } - IERR MPIBroadcast_integer(solver->isPeriodic,solver->ndims,0,&mpi->world);CHECKERR(ierr); + IERR MPIBroadcast_integer(solver->m_is_periodic,solver->m_ndims,0,&mpi->m_world);CHECKERR(ierr); /* broadcast periodic boundary info for MPI to all processes */ - IERR MPIBroadcast_integer(mpi->bcperiodic,solver->ndims,0,&mpi->world);CHECKERR(ierr); + IERR MPIBroadcast_integer(mpi->m_bcperiodic,solver->m_ndims,0,&mpi->m_world);CHECKERR(ierr); /* On other processes, if necessary, allocate and receive boundary-type-specific data */ - for (nb = 0; nb < solver->nBoundaryZones; nb++) { - if (!strcmp(boundary[nb].bctype,_DIRICHLET_)) { - if (mpi->rank) boundary[nb].DirichletValue = (double*) calloc (solver->nvars,sizeof(double)); - IERR MPIBroadcast_double(boundary[nb].DirichletValue,solver->nvars,0,&mpi->world); CHECKERR(ierr); + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { + if (!strcmp(boundary[nb].m_bctype,_DIRICHLET_)) { + if (mpi->m_rank) boundary[nb].m_DirichletValue = (double*) calloc (solver->m_nvars,sizeof(double)); + IERR MPIBroadcast_double(boundary[nb].m_DirichletValue,solver->m_nvars,0,&mpi->m_world); CHECKERR(ierr); } - if (!strcmp(boundary[nb].bctype,_SPONGE_)) { - if (mpi->rank) boundary[nb].SpongeValue = (double*) calloc (solver->nvars,sizeof(double)); - IERR MPIBroadcast_double(boundary[nb].SpongeValue,solver->nvars,0,&mpi->world); CHECKERR(ierr); + if (!strcmp(boundary[nb].m_bctype,_SPONGE_)) { + if (mpi->m_rank) boundary[nb].m_SpongeValue = (double*) calloc (solver->m_nvars,sizeof(double)); + IERR MPIBroadcast_double(boundary[nb].m_SpongeValue,solver->m_nvars,0,&mpi->m_world); CHECKERR(ierr); } - if ( (!strcmp(boundary[nb].bctype,_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_NOSLIP_WALL_)) ) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity,solver->ndims,0,&mpi->world); CHECKERR(ierr); + if ( (!strcmp(boundary[nb].m_bctype,_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_NOSLIP_WALL_)) ) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); } - if ( (!strcmp(boundary[nb].bctype,_SW_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_SW_NOSLIP_WALL_)) ) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity,solver->ndims,0,&mpi->world); CHECKERR(ierr); + if ( (!strcmp(boundary[nb].m_bctype,_SW_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_SW_NOSLIP_WALL_)) ) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); } - if (!strcmp(boundary[nb].bctype,_SUBSONIC_INFLOW_)) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(&boundary[nb].FlowDensity,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity,solver->ndims,0,&mpi->world); CHECKERR(ierr); + if (!strcmp(boundary[nb].m_bctype,_SUBSONIC_INFLOW_)) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(&boundary[nb].m_FlowDensity,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); } - if (!strcmp(boundary[nb].bctype,_SUBSONIC_OUTFLOW_)) { - IERR MPIBroadcast_double(&boundary[nb].FlowPressure,1,0,&mpi->world); CHECKERR(ierr); + if (!strcmp(boundary[nb].m_bctype,_SUBSONIC_OUTFLOW_)) { + IERR MPIBroadcast_double(&boundary[nb].m_FlowPressure,1,0,&mpi->m_world); CHECKERR(ierr); } - if (!strcmp(boundary[nb].bctype,_SUBSONIC_AMBIVALENT_)) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(&boundary[nb].FlowDensity,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity,solver->ndims,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&boundary[nb].FlowPressure,1,0,&mpi->world); CHECKERR(ierr); + if (!strcmp(boundary[nb].m_bctype,_SUBSONIC_AMBIVALENT_)) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(&boundary[nb].m_FlowDensity,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&boundary[nb].m_FlowPressure,1,0,&mpi->m_world); CHECKERR(ierr); } - if (!strcmp(boundary[nb].bctype,_SUPERSONIC_INFLOW_)) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(&boundary[nb].FlowDensity ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity ,solver->ndims,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&boundary[nb].FlowPressure,1 ,0,&mpi->world); CHECKERR(ierr); + if (!strcmp(boundary[nb].m_bctype,_SUPERSONIC_INFLOW_)) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(&boundary[nb].m_FlowDensity ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity ,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&boundary[nb].m_FlowPressure,1 ,0,&mpi->m_world); CHECKERR(ierr); } - if (!strcmp(boundary[nb].bctype,_TURBULENT_SUPERSONIC_INFLOW_)) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(&boundary[nb].FlowDensity ,1 ,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity ,solver->ndims,0,&mpi->world); CHECKERR(ierr); - IERR MPIBroadcast_double(&boundary[nb].FlowPressure,1 ,0,&mpi->world); CHECKERR(ierr); + if (!strcmp(boundary[nb].m_bctype,_TURBULENT_SUPERSONIC_INFLOW_)) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(&boundary[nb].m_FlowDensity ,1 ,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity ,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); + IERR MPIBroadcast_double(&boundary[nb].m_FlowPressure,1 ,0,&mpi->m_world); CHECKERR(ierr); /* allocate arrays and read in unsteady boundary data */ - IERR BCReadTurbulentInflowData(&boundary[nb],mpi,solver->ndims,solver->nvars,solver->dim_local); CHECKERR(ierr); + IERR BCReadTurbulentInflowData(&boundary[nb],mpi,solver->m_ndims,solver->m_nvars,solver->m_dim_local); CHECKERR(ierr); } - if ( (!strcmp(boundary[nb].bctype,_THERMAL_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_THERMAL_NOSLIP_WALL_)) ) { - if (mpi->rank) boundary[nb].FlowVelocity = (double*) calloc (solver->ndims,sizeof(double)); - IERR MPIBroadcast_double(boundary[nb].FlowVelocity,solver->ndims,0,&mpi->world); CHECKERR(ierr); + if ( (!strcmp(boundary[nb].m_bctype,_THERMAL_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_THERMAL_NOSLIP_WALL_)) ) { + if (mpi->m_rank) boundary[nb].m_FlowVelocity = (double*) calloc (solver->m_ndims,sizeof(double)); + IERR MPIBroadcast_double(boundary[nb].m_FlowVelocity,solver->m_ndims,0,&mpi->m_world); CHECKERR(ierr); /* allocate arrays and read in boundary temperature data */ - IERR BCReadTemperatureData(&boundary[nb],mpi,solver->ndims,solver->nvars,solver->dim_local); CHECKERR(ierr); + IERR BCReadTemperatureData(&boundary[nb],mpi,solver->m_ndims,solver->m_nvars,solver->m_dim_local); CHECKERR(ierr); } } - solver->boundary = boundary; + solver->m_boundary = boundary; /* each process calculates its own part of these boundaries */ IERR CalculateLocalExtent(solver,mpi); CHECKERR(ierr); #if defined(HAVE_CUDA) int bounds[GPU_MAX_NDIMS]; - if (sim[0].solver.use_gpu) { - for (nb = 0; nb < solver->nBoundaryZones; nb++) { - _ArraySubtract1D_(bounds,boundary[nb].ie,boundary[nb].is,solver->ndims); - - _ArrayProduct1D_(bounds,solver->ndims,boundary[nb].gpu_npoints_bounds); - boundary[nb].gpu_npoints_local_wghosts = solver->npoints_local_wghosts; - - _ArrayProduct1D_(bounds,solver->ndims,boundary[nb].gpu_npoints_bounds); - boundary[nb].gpu_npoints_local_wghosts = solver->npoints_local_wghosts; - - gpuMalloc((void**)&boundary[nb].gpu_is, solver->ndims*sizeof(int)); - gpuMalloc((void**)&boundary[nb].gpu_ie, solver->ndims*sizeof(int)); - gpuMalloc((void**)&boundary[nb].gpu_bounds, solver->ndims*sizeof(int)); - gpuMemcpy(boundary[nb].gpu_is, boundary[nb].is, solver->ndims*sizeof(int), gpuMemcpyHostToDevice); - gpuMemcpy(boundary[nb].gpu_ie, boundary[nb].ie, solver->ndims*sizeof(int), gpuMemcpyHostToDevice); - gpuMemcpy(boundary[nb].gpu_bounds, bounds, solver->ndims*sizeof(int), gpuMemcpyHostToDevice); - if ( (!strcmp(boundary[nb].bctype,_SLIP_WALL_)) - || (!strcmp(boundary[nb].bctype,_NOSLIP_WALL_)) ) { - gpuMalloc((void**)&boundary[nb].gpu_FlowVelocity, solver->ndims*sizeof(double)); - gpuMemcpy( boundary[nb].gpu_FlowVelocity, - boundary[nb].FlowVelocity, - solver->ndims*sizeof(double), + if (sim[0].solver.m_use_gpu) { + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { + _ArraySubtract1D_(bounds,boundary[nb].m_ie,boundary[nb].m_is,solver->m_ndims); + + _ArrayProduct1D_(bounds,solver->m_ndims,boundary[nb].m_gpu_npoints_bounds); + boundary[nb].m_gpu_npoints_local_wghosts = solver->m_npoints_local_wghosts; + + _ArrayProduct1D_(bounds,solver->m_ndims,boundary[nb].m_gpu_npoints_bounds); + boundary[nb].m_gpu_npoints_local_wghosts = solver->m_npoints_local_wghosts; + + gpuMalloc((void**)&boundary[nb].m_gpu_is, solver->m_ndims*sizeof(int)); + gpuMalloc((void**)&boundary[nb].m_gpu_ie, solver->m_ndims*sizeof(int)); + gpuMalloc((void**)&boundary[nb].m_gpu_bounds, solver->m_ndims*sizeof(int)); + gpuMemcpy(boundary[nb].m_gpu_is, boundary[nb].m_is, solver->m_ndims*sizeof(int), gpuMemcpyHostToDevice); + gpuMemcpy(boundary[nb].m_gpu_ie, boundary[nb].m_ie, solver->m_ndims*sizeof(int), gpuMemcpyHostToDevice); + gpuMemcpy(boundary[nb].m_gpu_bounds, bounds, solver->m_ndims*sizeof(int), gpuMemcpyHostToDevice); + if ( (!strcmp(boundary[nb].m_bctype,_SLIP_WALL_)) + || (!strcmp(boundary[nb].m_bctype,_NOSLIP_WALL_)) ) { + gpuMalloc((void**)&boundary[nb].m_gpu_FlowVelocity, solver->m_ndims*sizeof(double)); + gpuMemcpy( boundary[nb].m_gpu_FlowVelocity, + boundary[nb].m_FlowVelocity, + solver->m_ndims*sizeof(double), gpuMemcpyHostToDevice); } } @@ -345,9 +345,9 @@ int InitializeBoundaries( void *s, /*!< Array of simulation objects of type # #endif /* initialize function pointers for each boundary condition */ - for (nb = 0; nb < solver->nBoundaryZones; nb++) { + for (nb = 0; nb < solver->m_n_boundary_zones; nb++) { #if defined(HAVE_CUDA) - BCInitialize(&boundary[nb], solver->use_gpu); + BCInitialize(&boundary[nb], solver->m_use_gpu); #else BCInitialize(&boundary[nb], 0); #endif @@ -363,81 +363,81 @@ int InitializeBoundaries( void *s, /*!< Array of simulation objects of type # that boundary), and accordingly set the bounding grid indices. */ int CalculateLocalExtent( - void *s, /*!< Solver object of type #HyPar */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - DomainBoundary *boundary = solver->boundary; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + DomainBoundary *boundary = solver->m_boundary; int n; - for (n = 0; n < solver->nBoundaryZones; n++) { + for (n = 0; n < solver->m_n_boundary_zones; n++) { /* allocate */ - boundary[n].is = (int*) calloc (solver->ndims,sizeof(int)); /* deallocated in BCCleanup.c */ - boundary[n].ie = (int*) calloc (solver->ndims,sizeof(int)); /* deallocated in BCCleanup.c */ + boundary[n].m_is = (int*) calloc (solver->m_ndims,sizeof(int)); /* deallocated in BCCleanup.c */ + boundary[n].m_ie = (int*) calloc (solver->m_ndims,sizeof(int)); /* deallocated in BCCleanup.c */ - int d,dim = boundary[n].dim; + int d,dim = boundary[n].m_dim; - if (!strcmp(boundary[n].bctype,_SPONGE_)) { + if (!strcmp(boundary[n].m_bctype,_SPONGE_)) { /* Sponge boundary condition */ - boundary[n].on_this_proc = 1; + boundary[n].m_on_this_proc = 1; int offset = 0; - for (d=0; dndims; d++) { + for (d=0; dm_ndims; d++) { int is, ie; - FindInterval(boundary[n].xmin[d],boundary[n].xmax[d], - &solver->x[offset+solver->ghosts], - solver->dim_local[d],&is,&ie); - boundary[n].is[d] = is; - boundary[n].ie[d] = ie; - if ((ie-is) <= 0) boundary[n].on_this_proc = 0; - offset += solver->dim_local[d] + 2*solver->ghosts; + FindInterval(boundary[n].m_xmin[d],boundary[n].m_xmax[d], + &solver->m_x[offset+solver->m_ghosts], + solver->m_dim_local[d],&is,&ie); + boundary[n].m_is[d] = is; + boundary[n].m_ie[d] = ie; + if ((ie-is) <= 0) boundary[n].m_on_this_proc = 0; + offset += solver->m_dim_local[d] + 2*solver->m_ghosts; } } else { /* other boundary conditions */ - if (boundary[n].face == 1) { + if (boundary[n].m_face == 1) { - if (mpi->ip[dim] == 0) { - boundary[n].on_this_proc = 1; + if (mpi->m_ip[dim] == 0) { + boundary[n].m_on_this_proc = 1; int offset = 0; - for (d=0; dndims; d++) { + for (d=0; dm_ndims; d++) { if (d == dim) { - boundary[n].is[d] = -solver->ghosts; - boundary[n].ie[d] = 0; + boundary[n].m_is[d] = -solver->m_ghosts; + boundary[n].m_ie[d] = 0; } else { int is, ie; - FindInterval(boundary[n].xmin[d],boundary[n].xmax[d], - &solver->x[offset+solver->ghosts], - solver->dim_local[d],&is,&ie); - boundary[n].is[d] = is; - boundary[n].ie[d] = ie; - if ((ie-is) <= 0) boundary[n].on_this_proc = 0; + FindInterval(boundary[n].m_xmin[d],boundary[n].m_xmax[d], + &solver->m_x[offset+solver->m_ghosts], + solver->m_dim_local[d],&is,&ie); + boundary[n].m_is[d] = is; + boundary[n].m_ie[d] = ie; + if ((ie-is) <= 0) boundary[n].m_on_this_proc = 0; } - offset += solver->dim_local[d] + 2*solver->ghosts; + offset += solver->m_dim_local[d] + 2*solver->m_ghosts; } - } else boundary[n].on_this_proc = 0; + } else boundary[n].m_on_this_proc = 0; - } else if (boundary[n].face == -1) { + } else if (boundary[n].m_face == -1) { - if (mpi->ip[dim] == mpi->iproc[dim]-1) { - boundary[n].on_this_proc = 1; + if (mpi->m_ip[dim] == mpi->m_iproc[dim]-1) { + boundary[n].m_on_this_proc = 1; int offset = 0; - for (d=0; dndims; d++) { + for (d=0; dm_ndims; d++) { if (d == dim) { - boundary[n].is[d] = solver->dim_local[dim]; - boundary[n].ie[d] = solver->dim_local[dim] + solver->ghosts; + boundary[n].m_is[d] = solver->m_dim_local[dim]; + boundary[n].m_ie[d] = solver->m_dim_local[dim] + solver->m_ghosts; } else { int is, ie; - FindInterval(boundary[n].xmin[d],boundary[n].xmax[d], - &solver->x[offset+solver->ghosts], - solver->dim_local[d],&is,&ie); - boundary[n].is[d] = is; - boundary[n].ie[d] = ie; - if ((ie-is) <= 0) boundary[n].on_this_proc = 0; + FindInterval(boundary[n].m_xmin[d],boundary[n].m_xmax[d], + &solver->m_x[offset+solver->m_ghosts], + solver->m_dim_local[d],&is,&ie); + boundary[n].m_is[d] = is; + boundary[n].m_ie[d] = ie; + if ((ie-is) <= 0) boundary[n].m_on_this_proc = 0; } - offset += solver->dim_local[d] + 2*solver->ghosts; + offset += solver->m_dim_local[d] + 2*solver->m_ghosts; } - } else boundary[n].on_this_proc = 0; + } else boundary[n].m_on_this_proc = 0; } } diff --git a/src/Simulation/InitializeImmersedBoundaries.c b/src/Simulation/InitializeImmersedBoundaries.c index 2ca5d822..d76d0b7d 100644 --- a/src/Simulation/InitializeImmersedBoundaries.c +++ b/src/Simulation/InitializeImmersedBoundaries.c @@ -19,14 +19,14 @@ + Identify and make a list of immersed boundary points on each rank. + For each immersed boundary point, find the "nearest" facet. */ -int InitializeImmersedBoundaries( void *s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims /*!< Number of simulation objects */ +int InitializeImmersedBoundaries( void *a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims /*!< Number of simulation objects */ ) { - SimulationObject* simobj = (SimulationObject*) s; + SimulationObject* simobj = (SimulationObject*) a_s; int n; - for (n = 0; n < nsims; n++) { + for (n = 0; n < a_nsims; n++) { HyPar *solver = &(simobj[n].solver); MPIVariables *mpi = &(simobj[n].mpi); @@ -34,38 +34,38 @@ int InitializeImmersedBoundaries( void *s, /*!< Array of simulation objects o ImmersedBoundary *ib = NULL; Body3D *body = NULL; - int stat, d, ndims = solver->ndims; + int stat, d, ndims = solver->m_ndims; - if ((!solver->flag_ib) || (ndims != _IB_NDIMS_)) { - solver->ib = NULL; + if ((!solver->m_flag_ib) || (ndims != _IB_NDIMS_)) { + solver->m_ib = NULL; continue; } /* Read in immersed body from file */ - IBReadBodySTL(&body,solver->ib_filename,mpi,&stat); + IBReadBodySTL(&body,solver->m_ib_filename,mpi,&stat); if (stat) { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error in InitializeImmersedBoundaries(): Unable to "); - fprintf(stderr,"read immersed body from file %s.\n",solver->ib_filename); + fprintf(stderr,"read immersed body from file %s.\n",solver->m_ib_filename); } - solver->flag_ib = 0; - solver->ib = NULL; + solver->m_flag_ib = 0; + solver->m_ib = NULL; return(1); } IBComputeBoundingBox(body); /* allocate immersed boundary object and set it up */ ib = (ImmersedBoundary*) calloc (1, sizeof(ImmersedBoundary)); - ib->tolerance = 1e-12; - ib->delta = 1e-6; - ib->itr_max = 500; - ib->body = body; - solver->ib = ib; + ib->m_tolerance = 1e-12; + ib->m_delta = 1e-6; + ib->m_itr_max = 500; + ib->m_body = body; + solver->m_ib = ib; int offset_global, offset_local, - *dim_local = solver->dim_local, - *dim_global = solver->dim_global, - ghosts = solver->ghosts, + *dim_local = solver->m_dim_local, + *dim_global = solver->m_dim_global, + ghosts = solver->m_ghosts, size = dim_global[0] + dim_global[1] + dim_global[2], count = 0; double *Xg = (double*) calloc(size,sizeof(double)); @@ -73,22 +73,22 @@ int InitializeImmersedBoundaries( void *s, /*!< Array of simulation objects o /* assemble the global grid on rank 0 */ offset_global = offset_local = 0; for (d=0; drank?NULL:&Xg[offset_global]), - &solver->x[offset_local+ghosts], - mpi->is[d],mpi->ie[d],dim_local[d],0); CHECKERR(ierr); + IERR MPIGatherArray1D(mpi,(mpi->m_rank?NULL:&Xg[offset_global]), + &solver->m_x[offset_local+ghosts], + mpi->m_is[d],mpi->m_ie[d],dim_local[d],0); CHECKERR(ierr); offset_global += dim_global[d]; offset_local += dim_local [d] + 2*ghosts; } /* send the global grid to other ranks */ - MPIBroadcast_double(Xg,size,0,&mpi->world); + MPIBroadcast_double(Xg,size,0,&mpi->m_world); /* identify whether this is a 3D or "pseudo-2D" simulation */ - IBIdentifyMode(Xg,dim_global,solver->ib); + IBIdentifyMode(Xg,dim_global,solver->m_ib); /* identify grid points inside the immersed body */ int count_inside_body = 0; - count = IBIdentifyBody(solver->ib,dim_global,dim_local,ghosts,mpi,Xg,solver->iblank); - MPISum_integer(&count_inside_body,&count,1,&mpi->world); + count = IBIdentifyBody(solver->m_ib,dim_global,dim_local,ghosts,mpi,Xg,solver->m_iblank); + MPISum_integer(&count_inside_body,&count,1,&mpi->m_world); free(Xg); /* At ghost points corresponding to the physical boundary, extrapolate from the interior @@ -98,7 +98,7 @@ int InitializeImmersedBoundaries( void *s, /*!< Array of simulation objects o int indexb[ndims], indexi[ndims], bounds[ndims], offset[ndims]; for (d = 0; d < ndims; d++) { /* left boundary */ - if (!mpi->ip[d]) { + if (!mpi->m_ip[d]) { _ArrayCopy1D_(dim_local,bounds,ndims); bounds[d] = ghosts; _ArraySetValue_(offset,ndims,0); offset[d] = -ghosts; int done = 0; _ArraySetValue_(indexb,ndims,0); @@ -106,12 +106,12 @@ int InitializeImmersedBoundaries( void *s, /*!< Array of simulation objects o _ArrayCopy1D_(indexb,indexi,ndims); indexi[d] = ghosts-1-indexb[d]; int p1; _ArrayIndex1DWO_(ndims,dim_local,indexb,offset,ghosts,p1); int p2; _ArrayIndex1D_ (ndims,dim_local,indexi,ghosts,p2); - solver->iblank[p1] = solver->iblank[p2]; + solver->m_iblank[p1] = solver->m_iblank[p2]; _ArrayIncrementIndex_(ndims,bounds,indexb,done); } } /* right boundary */ - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { _ArrayCopy1D_(dim_local,bounds,ndims); bounds[d] = ghosts; _ArraySetValue_(offset,ndims,0); offset[d] = dim_local[d]; int done = 0; _ArraySetValue_(indexb,ndims,0); @@ -119,69 +119,69 @@ int InitializeImmersedBoundaries( void *s, /*!< Array of simulation objects o _ArrayCopy1D_(indexb,indexi,ndims); indexi[d] = dim_local[d]-1-indexb[d]; int p1; _ArrayIndex1DWO_(ndims,dim_local,indexb,offset,ghosts,p1); int p2; _ArrayIndex1D_ (ndims,dim_local,indexi,ghosts,p2); - solver->iblank[p1] = solver->iblank[p2]; + solver->m_iblank[p1] = solver->m_iblank[p2]; _ArrayIncrementIndex_(ndims,bounds,indexb,done); } } } - MPIExchangeBoundariesnD(ndims,1,dim_local,ghosts,mpi,solver->iblank); + MPIExchangeBoundariesnD(ndims,1,dim_local,ghosts,mpi,solver->m_iblank); /* identify and create a list of immersed boundary points on each rank */ int count_boundary_points = 0; - count = IBIdentifyBoundary(solver->ib,mpi,dim_local,ghosts,solver->iblank); - MPISum_integer(&count_boundary_points,&count,1,&mpi->world); + count = IBIdentifyBoundary(solver->m_ib,mpi,dim_local,ghosts,solver->m_iblank); + MPISum_integer(&count_boundary_points,&count,1,&mpi->m_world); /* find the nearest facet for each immersed boundary point */ double ld = 0, xmin, xmax, ymin, ymax, zmin, zmax; - _GetCoordinate_(0,0 ,dim_local,ghosts,solver->x,xmin); - _GetCoordinate_(0,dim_local[0]-1,dim_local,ghosts,solver->x,xmax); - _GetCoordinate_(1,0 ,dim_local,ghosts,solver->x,ymin); - _GetCoordinate_(1,dim_local[1]-1,dim_local,ghosts,solver->x,ymax); - _GetCoordinate_(2,0 ,dim_local,ghosts,solver->x,zmin); - _GetCoordinate_(2,dim_local[2]-1,dim_local,ghosts,solver->x,zmax); + _GetCoordinate_(0,0 ,dim_local,ghosts,solver->m_x,xmin); + _GetCoordinate_(0,dim_local[0]-1,dim_local,ghosts,solver->m_x,xmax); + _GetCoordinate_(1,0 ,dim_local,ghosts,solver->m_x,ymin); + _GetCoordinate_(1,dim_local[1]-1,dim_local,ghosts,solver->m_x,ymax); + _GetCoordinate_(2,0 ,dim_local,ghosts,solver->m_x,zmin); + _GetCoordinate_(2,dim_local[2]-1,dim_local,ghosts,solver->m_x,zmax); double xlen = xmax - xmin; double ylen = ymax - ymin; double zlen = zmax - zmin; ld = max3(xlen,ylen,zlen); - count = IBNearestFacetNormal(solver->ib,mpi,solver->x,ld,dim_local,ghosts); + count = IBNearestFacetNormal(solver->m_ib,mpi,solver->m_x,ld,dim_local,ghosts); if (count) { fprintf(stderr, "Error in InitializeImmersedBoundaries():\n"); fprintf(stderr, " IBNearestFacetNormal() returned with error code %d on rank %d.\n", - count, mpi->rank); + count, mpi->m_rank); return(count); } /* For the immersed boundary points, find the interior points for extrapolation, and compute their interpolation coefficients */ - count = IBInterpCoeffs(solver->ib,mpi,solver->x,dim_local,ghosts,solver->iblank); + count = IBInterpCoeffs(solver->m_ib,mpi,solver->m_x,dim_local,ghosts,solver->m_iblank); if (count) { fprintf(stderr, "Error in InitializeImmersedBoundaries():\n"); fprintf(stderr, " IBInterpCoeffs() returned with error code %d on rank %d.\n", - count, mpi->rank); + count, mpi->m_rank); return(count); } /* Create facet mapping */; - count = IBCreateFacetMapping(ib,mpi,solver->x,dim_local,ghosts); + count = IBCreateFacetMapping(ib,mpi,solver->m_x,dim_local,ghosts); if (count) { fprintf(stderr, "Error in InitializeImmersedBoundaries():\n"); fprintf(stderr, " IBCreateFacetMapping() returned with error code %d on rank %d.\n", - count, mpi->rank); + count, mpi->m_rank); return(count); } /* Done */ - if (!mpi->rank) { + if (!mpi->m_rank) { double percentage; - printf("Immersed body read from %s:\n",solver->ib_filename); - if (nsims > 1) printf("For domain %d,\n", n); + printf("Immersed body read from %s:\n",solver->m_ib_filename); + if (a_nsims > 1) printf("For domain %d,\n", n); printf(" Number of facets: %d\n Bounding box: [%3.1f,%3.1lf] X [%3.1f,%3.1lf] X [%3.1f,%3.1lf]\n", - body->nfacets,body->xmin,body->xmax,body->ymin,body->ymax,body->zmin,body->zmax); - percentage = ((double)count_inside_body)/((double)solver->npoints_global)*100.0; + body->m_nfacets,body->m_xmin,body->m_xmax,body->m_ymin,body->m_ymax,body->m_zmin,body->m_zmax); + percentage = ((double)count_inside_body)/((double)solver->m_npoints_global)*100.0; printf(" Number of grid points inside immersed body: %d (%4.1f%%).\n",count_inside_body,percentage); - percentage = ((double)count_boundary_points)/((double)solver->npoints_global)*100.0; + percentage = ((double)count_boundary_points)/((double)solver->m_npoints_global)*100.0; printf(" Number of immersed boundary points : %d (%4.1f%%).\n",count_boundary_points,percentage); - printf(" Immersed body simulation mode : %s.\n", ib->mode); + printf(" Immersed body simulation mode : %s.\n", ib->m_mode); } } diff --git a/src/Simulation/InitializePhysics.c b/src/Simulation/InitializePhysics.c index 294dbc15..3805f7b1 100644 --- a/src/Simulation/InitializePhysics.c +++ b/src/Simulation/InitializePhysics.c @@ -35,21 +35,21 @@ setting all the physics-specific functions that are required by the model. */ -int InitializePhysics( void *s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims /*!< number of simulation objects */ +int InitializePhysics( void *a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims /*!< number of simulation objects */ ) { - SimulationObject *sim = (SimulationObject*) s; + SimulationObject *sim = (SimulationObject*) a_s; int ns; _DECLARE_IERR_; - if (nsims == 0) return 0; + if (a_nsims == 0) return 0; - if (!sim[0].mpi.rank) { - printf("Initializing physics. Model = \"%s\"\n",sim[0].solver.model); + if (!sim[0].mpi.m_rank) { + printf("Initializing physics. Model = \"%s\"\n",sim[0].solver.m_model); } - for (ns = 0; ns < nsims; ns++) { + for (ns = 0; ns < a_nsims; ns++) { HyPar *solver = &(sim[ns].solver); MPIVariables *mpi = &(sim[ns].mpi); @@ -81,93 +81,93 @@ int InitializePhysics( void *s, /*!< Array of simulation objects of type #Si solver->GetRightEigenvectors = NULL; solver->IBFunction = NULL; - if (!strcmp(solver->model,_LINEAR_ADVECTION_DIFFUSION_REACTION_)) { + if (!strcmp(solver->m_model,_LINEAR_ADVECTION_DIFFUSION_REACTION_)) { - solver->physics = (LinearADR*) calloc (1,sizeof(LinearADR)); + solver->m_physics = (LinearADR*) calloc (1,sizeof(LinearADR)); IERR LinearADRInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_BURGERS_)) { + } else if (!strcmp(solver->m_model,_BURGERS_)) { - solver->physics = (Burgers*) calloc (1,sizeof(Burgers)); + solver->m_physics = (Burgers*) calloc (1,sizeof(Burgers)); IERR BurgersInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_DOUBLE_WELL_)) { + } else if (!strcmp(solver->m_model,_FP_DOUBLE_WELL_)) { - solver->physics = (FPDoubleWell*) calloc (1,sizeof(FPDoubleWell)); + solver->m_physics = (FPDoubleWell*) calloc (1,sizeof(FPDoubleWell)); IERR FPDoubleWellInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_POWER_SYSTEM_)) { + } else if (!strcmp(solver->m_model,_FP_POWER_SYSTEM_)) { - solver->physics = (FPPowerSystem*) calloc (1,sizeof(FPPowerSystem)); + solver->m_physics = (FPPowerSystem*) calloc (1,sizeof(FPPowerSystem)); IERR FPPowerSystemInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_POWER_SYSTEM_1BUS_)) { + } else if (!strcmp(solver->m_model,_FP_POWER_SYSTEM_1BUS_)) { - solver->physics = (FPPowerSystem1Bus*) calloc (1,sizeof(FPPowerSystem1Bus)); + solver->m_physics = (FPPowerSystem1Bus*) calloc (1,sizeof(FPPowerSystem1Bus)); IERR FPPowerSystem1BusInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_FP_POWER_SYSTEM_3BUS_)) { + } else if (!strcmp(solver->m_model,_FP_POWER_SYSTEM_3BUS_)) { - solver->physics = (FPPowerSystem3Bus*) calloc (1,sizeof(FPPowerSystem3Bus)); + solver->m_physics = (FPPowerSystem3Bus*) calloc (1,sizeof(FPPowerSystem3Bus)); IERR FPPowerSystem3BusInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_EULER_1D_)) { + } else if (!strcmp(solver->m_model,_EULER_1D_)) { - solver->physics = (Euler1D*) calloc (1,sizeof(Euler1D)); + solver->m_physics = (Euler1D*) calloc (1,sizeof(Euler1D)); IERR Euler1DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_EULER_2D_)) { + } else if (!strcmp(solver->m_model,_EULER_2D_)) { - solver->physics = (Euler2D*) calloc (1,sizeof(Euler2D)); + solver->m_physics = (Euler2D*) calloc (1,sizeof(Euler2D)); IERR Euler2DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NAVIER_STOKES_2D_)) { + } else if (!strcmp(solver->m_model,_NAVIER_STOKES_2D_)) { - solver->physics = (NavierStokes2D*) calloc (1,sizeof(NavierStokes2D)); + solver->m_physics = (NavierStokes2D*) calloc (1,sizeof(NavierStokes2D)); IERR NavierStokes2DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NAVIER_STOKES_3D_)) { + } else if (!strcmp(solver->m_model,_NAVIER_STOKES_3D_)) { - solver->physics = (NavierStokes3D*) calloc (1,sizeof(NavierStokes3D)); + solver->m_physics = (NavierStokes3D*) calloc (1,sizeof(NavierStokes3D)); IERR NavierStokes3DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NUMA2D_)) { + } else if (!strcmp(solver->m_model,_NUMA2D_)) { - solver->physics = (Numa2D*) calloc (1,sizeof(Numa2D)); + solver->m_physics = (Numa2D*) calloc (1,sizeof(Numa2D)); IERR Numa2DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_NUMA3D_)) { + } else if (!strcmp(solver->m_model,_NUMA3D_)) { - solver->physics = (Numa3D*) calloc (1,sizeof(Numa3D)); + solver->m_physics = (Numa3D*) calloc (1,sizeof(Numa3D)); IERR Numa3DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_SHALLOW_WATER_1D_)) { + } else if (!strcmp(solver->m_model,_SHALLOW_WATER_1D_)) { - solver->physics = (ShallowWater1D*) calloc (1,sizeof(ShallowWater1D)); + solver->m_physics = (ShallowWater1D*) calloc (1,sizeof(ShallowWater1D)); IERR ShallowWater1DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_SHALLOW_WATER_2D_)) { + } else if (!strcmp(solver->m_model,_SHALLOW_WATER_2D_)) { - solver->physics = (ShallowWater2D*) calloc (1,sizeof(ShallowWater2D)); + solver->m_physics = (ShallowWater2D*) calloc (1,sizeof(ShallowWater2D)); IERR ShallowWater2DInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->model,_VLASOV_)) { + } else if (!strcmp(solver->m_model,_VLASOV_)) { - solver->physics = (Vlasov*) calloc (1,sizeof(Vlasov)); + solver->m_physics = (Vlasov*) calloc (1,sizeof(Vlasov)); IERR VlasovInitialize(solver,mpi); CHECKERR(ierr); }else { fprintf(stderr,"Error (domain %d): %s is not a supported physical model.\n", - ns, solver->model); + ns, solver->m_model); return(1); } /* some checks */ if ( ( (solver->GetLeftEigenvectors == NULL) || (solver->GetRightEigenvectors == NULL) ) - && (!strcmp(solver->interp_type,_CHARACTERISTIC_)) && (solver->nvars > 1) ) { - if (!mpi->rank) { + && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_)) && (solver->m_nvars > 1) ) { + if (!mpi->m_rank) { fprintf(stderr,"Error (domain %d): Interpolation type is defined as characteristic ", ns); fprintf(stderr,"but physics initializations returned NULL pointers for "); fprintf(stderr,"Get(Left,Right)Eigenvectors needed for characteristic-based "); @@ -176,9 +176,9 @@ int InitializePhysics( void *s, /*!< Array of simulation objects of type #Si return(1); } - if (!strcmp(solver->SplitHyperbolicFlux,"yes")) { + if (!strcmp(solver->m_split_hyperbolic_flux,"yes")) { if ((!solver->dFFunction) || (!solver->UpwinddF)) { - if (!mpi->rank) { + if (!mpi->m_rank) { fprintf(stderr,"Error (domain %d): Splitting of hyperbolic flux requires a dFFunction ", ns); fprintf(stderr,"and its upwinding function UpwinddF.\n"); fprintf(stderr,"Error: f(u) = [f(u) - df(u)] + df(u).\n"); @@ -186,14 +186,14 @@ int InitializePhysics( void *s, /*!< Array of simulation objects of type #Si } return(1); } - if (solver->FdFFunction && solver->UpwindFdF) solver->flag_fdf_specified = 1; - else solver->flag_fdf_specified = 0; + if (solver->FdFFunction && solver->UpwindFdF) solver->m_flag_fdf_specified = 1; + else solver->m_flag_fdf_specified = 0; } - if ((solver->IBFunction == NULL) && (solver->flag_ib)) { - if (!mpi->rank) { + if ((solver->IBFunction == NULL) && (solver->m_flag_ib)) { + if (!mpi->m_rank) { fprintf(stderr,"Error in InitializePhysics() (domain %d): Physical model %s does not yet have an immersed boundary treatment.\n", - ns, solver->model); + ns, solver->m_model); } return(1); } diff --git a/src/Simulation/InitializePhysicsData.c b/src/Simulation/InitializePhysicsData.c index 9af5a0a9..342928ac 100644 --- a/src/Simulation/InitializePhysicsData.c +++ b/src/Simulation/InitializePhysicsData.c @@ -9,22 +9,22 @@ /*! For each simulation object, call the physics-specific function to read in any physics data that is not a part of the solution vector. */ -int InitializePhysicsData(void *s, /*!< Simulation object of type #SimulationObject */ - int idx, /*!< Index of this simulation object */ - int nsims, /*!< Total number of simuations */ - int *dim_data /*!< Dimenions of physics-specific data */ +int InitializePhysicsData(void *a_s, /*!< Simulation object of type #SimulationObject */ + int a_idx, /*!< Index of this simulation object */ + int a_nsims, /*!< Total number of simuations */ + int *a_dim_data /*!< Dimenions of physics-specific data */ ) { - SimulationObject *sim = (SimulationObject*) s; + SimulationObject *sim = (SimulationObject*) a_s; HyPar *solver = &(sim->solver); MPIVariables *mpi = &(sim->mpi); if (solver->PhysicsInput) { - int ierr = solver->PhysicsInput(solver, mpi, idx, nsims, dim_data); + int ierr = solver->PhysicsInput(solver, mpi, a_idx, a_nsims, a_dim_data); if (ierr) { fprintf(stderr, "Error in InitializePhysicsData():\n"); fprintf(stderr, " solver->PhysicsInput() returned error %d on rank %d\n", - ierr, mpi->rank); + ierr, mpi->m_rank); return ierr; } } diff --git a/src/Simulation/InitializeSolvers.c b/src/Simulation/InitializeSolvers.c index c38654a8..fcb58b53 100644 --- a/src/Simulation/InitializeSolvers.c +++ b/src/Simulation/InitializeSolvers.c @@ -49,21 +49,21 @@ int gpuHyperbolicFunction (double*,double*,void*,void*,double,int, depending on user input. The specific functions used for spatial discretization, time integration, and solution output are set here. */ -int InitializeSolvers( void *s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims /*!< number of simulation objects */ +int InitializeSolvers( void *a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims /*!< number of simulation objects */ ) { - SimulationObject *sim = (SimulationObject*) s; + SimulationObject *sim = (SimulationObject*) a_s; int ns; _DECLARE_IERR_; - if (nsims == 0) return 0; + if (a_nsims == 0) return 0; - if (!sim[0].mpi.rank) { + if (!sim[0].mpi.m_rank) { printf("Initializing solvers.\n"); } - for (ns = 0; ns < nsims; ns++) { + for (ns = 0; ns < a_nsims; ns++) { HyPar *solver = &(sim[ns].solver); MPIVariables *mpi = &(sim[ns].mpi); @@ -72,7 +72,7 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si solver->ApplyIBConditions = ApplyIBConditions; solver->SourceFunction = SourceFunction; #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { solver->HyperbolicFunction = gpuHyperbolicFunction; } else { #endif @@ -92,17 +92,17 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si solver->InterpolateInterfacesPar = NULL; #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { - if (!strcmp(solver->spatial_type_par,_NC_2STAGE_)) { + if (!strcmp(solver->m_spatial_type_par,_NC_2STAGE_)) { solver->ParabolicFunction = ParabolicFunctionNC2Stage; - if (!strcmp(solver->spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { + if (!strcmp(solver->m_spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { solver->FirstDerivativePar = gpuFirstDerivativeFourthOrderCentral; } else { fprintf(stderr,"ERROR (domain %d): scheme %s is not supported on GPU!", - ns, solver->spatial_scheme_par); + ns, solver->m_spatial_scheme_par); return 1; } @@ -111,73 +111,73 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si } else { #endif - if (!strcmp(solver->spatial_type_par,_NC_1STAGE_)) { + if (!strcmp(solver->m_spatial_type_par,_NC_1STAGE_)) { solver->ParabolicFunction = ParabolicFunctionNC1Stage; - if (!strcmp(solver->spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { + if (!strcmp(solver->m_spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { solver->SecondDerivativePar = SecondDerivativeSecondOrderCentral; - } else if (!strcmp(solver->spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { + } else if (!strcmp(solver->m_spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { solver->SecondDerivativePar = SecondDerivativeFourthOrderCentral; } else { fprintf(stderr,"Error (domain %d): %s is not a supported ", - ns, solver->spatial_scheme_par); + ns, solver->m_spatial_scheme_par); fprintf(stderr,"spatial scheme of type %s for the parabolic terms.\n", - solver->spatial_type_par); + solver->m_spatial_type_par); } - } else if (!strcmp(solver->spatial_type_par,_NC_2STAGE_)) { + } else if (!strcmp(solver->m_spatial_type_par,_NC_2STAGE_)) { solver->ParabolicFunction = ParabolicFunctionNC2Stage; - if (!strcmp(solver->spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { + if (!strcmp(solver->m_spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { solver->FirstDerivativePar = FirstDerivativeFirstOrder; /* why first order? see ParabolicFunctionNC2Stage.c. 2nd order central approximation to the 2nd derivative can be expressed as a conjugation of 1st order approximations to the 1st derivative (one forward and one backward) -- this prevents odd-even decoupling */ - } else if (!strcmp(solver->spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { + } else if (!strcmp(solver->m_spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { solver->FirstDerivativePar = FirstDerivativeFourthOrderCentral; /* why 4th order? I could not derive the decomposition of the 4th order central approximation to the 2nd derivative! Some problems may show odd-even decoupling */ } else { fprintf(stderr,"Error (domain %d): %s is not a supported ", - ns, solver->spatial_scheme_par); + ns, solver->m_spatial_scheme_par); fprintf(stderr,"spatial scheme of type %s for the parabolic terms.\n", - solver->spatial_type_par); + solver->m_spatial_type_par); } - } else if (!strcmp(solver->spatial_type_par,_NC_1_5STAGE_)) { + } else if (!strcmp(solver->m_spatial_type_par,_NC_1_5STAGE_)) { solver->ParabolicFunction = ParabolicFunctionNC1_5Stage; - if (!strcmp(solver->spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { + if (!strcmp(solver->m_spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { solver->FirstDerivativePar = FirstDerivativeSecondOrderCentral; solver->SecondDerivativePar = SecondDerivativeSecondOrderCentral; - } else if (!strcmp(solver->spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { + } else if (!strcmp(solver->m_spatial_scheme_par,_FOURTH_ORDER_CENTRAL_)) { solver->FirstDerivativePar = FirstDerivativeFourthOrderCentral; solver->SecondDerivativePar = SecondDerivativeFourthOrderCentral; } else { fprintf(stderr,"Error (domain %d): %s is not a supported ", - ns, solver->spatial_scheme_par); + ns, solver->m_spatial_scheme_par); fprintf(stderr,"spatial scheme of type %s for the parabolic terms.\n", - solver->spatial_type_par); + solver->m_spatial_type_par); } - } else if (!strcmp(solver->spatial_type_par,_CONS_1STAGE_)) { + } else if (!strcmp(solver->m_spatial_type_par,_CONS_1STAGE_)) { solver->ParabolicFunction = ParabolicFunctionCons1Stage; - if (!strcmp(solver->spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { + if (!strcmp(solver->m_spatial_scheme_par,_SECOND_ORDER_CENTRAL_)) { solver->InterpolateInterfacesPar = Interp2PrimSecondOrder; } else { fprintf(stderr,"Error (domain %d): %s is not a supported ", - ns, solver->spatial_scheme_par); + ns, solver->m_spatial_scheme_par); fprintf(stderr,"spatial scheme of type %s for the parabolic terms.\n", - solver->spatial_type_par); + solver->m_spatial_type_par); } } else { fprintf(stderr,"Error (domain %d): %s is not a supported ", - ns, solver->spatial_type_par); + ns, solver->m_spatial_type_par); fprintf(stderr,"spatial discretization type for the parabolic terms.\n"); return(1); @@ -188,25 +188,25 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si #endif /* Spatial interpolation for hyperbolic term */ - solver->interp = NULL; - solver->compact = NULL; - solver->lusolver = NULL; + solver->m_interp = NULL; + solver->m_compact = NULL; + solver->m_lusolver = NULL; solver->SetInterpLimiterVar = NULL; - solver->flag_nonlinearinterp = 1; - if (strcmp(solver->interp_type,_CHARACTERISTIC_) && strcmp(solver->interp_type,_COMPONENTS_)) { + solver->m_flag_nonlinearinterp = 1; + if (strcmp(solver->m_interp_type,_CHARACTERISTIC_) && strcmp(solver->m_interp_type,_COMPONENTS_)) { fprintf(stderr,"Error in InitializeSolvers() (domain %d): %s is not a ", - ns, solver->interp_type); + ns, solver->m_interp_type); fprintf(stderr,"supported interpolation type.\n"); return(1); } #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { - if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_WENO_)) { + if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_WENO_)) { /* Fifth order WENO scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { fprintf(stderr, "Error (domain %d): characteristic-based WENO5 is not yet implemented on GPUs.\n", ns ); @@ -214,140 +214,140 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si } else { solver->InterpolateInterfacesHyp = gpuInterp1PrimFifthOrderWENO; } - solver->interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); - IERR WENOInitialize(solver,mpi,solver->spatial_scheme_hyp,solver->interp_type); CHECKERR(ierr); - solver->flag_nonlinearinterp = !(((WENOParameters*)solver->interp)->no_limiting); + solver->m_interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); + IERR WENOInitialize(solver,mpi,solver->m_spatial_scheme_hyp,solver->m_interp_type); CHECKERR(ierr); + solver->m_flag_nonlinearinterp = !(((WENOParameters*)solver->m_interp)->m_no_limiting); } else { fprintf(stderr, "Error (domain %d): %s is a not a supported spatial interpolation scheme on GPUs.\n", - ns, solver->spatial_scheme_hyp); + ns, solver->m_spatial_scheme_hyp); return 1; } } else { #endif - if (!strcmp(solver->spatial_scheme_hyp,_FIRST_ORDER_UPWIND_)) { + if (!strcmp(solver->m_spatial_scheme_hyp,_FIRST_ORDER_UPWIND_)) { /* First order upwind scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFirstOrderUpwindChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFirstOrderUpwind; } - } else if (!strcmp(solver->spatial_scheme_hyp,_SECOND_ORDER_CENTRAL_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_SECOND_ORDER_CENTRAL_)) { /* Second order central scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimSecondOrderCentralChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimSecondOrderCentral; } - } else if (!strcmp(solver->spatial_scheme_hyp,_SECOND_ORDER_MUSCL_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_SECOND_ORDER_MUSCL_)) { /* Second order MUSCL scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimSecondOrderMUSCLChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimSecondOrderMUSCL; } - solver->interp = (MUSCLParameters*) calloc(1,sizeof(MUSCLParameters)); + solver->m_interp = (MUSCLParameters*) calloc(1,sizeof(MUSCLParameters)); IERR MUSCLInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->spatial_scheme_hyp,_THIRD_ORDER_MUSCL_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_THIRD_ORDER_MUSCL_)) { /* Third order MUSCL scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimThirdOrderMUSCLChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimThirdOrderMUSCL; } - solver->interp = (MUSCLParameters*) calloc(1,sizeof(MUSCLParameters)); + solver->m_interp = (MUSCLParameters*) calloc(1,sizeof(MUSCLParameters)); IERR MUSCLInitialize(solver,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->spatial_scheme_hyp,_FOURTH_ORDER_CENTRAL_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_FOURTH_ORDER_CENTRAL_)) { /* Fourth order central scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFourthOrderCentralChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFourthOrderCentral; } - } else if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_UPWIND_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_UPWIND_)) { /* Fifth order upwind scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderUpwindChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderUpwind; } - } else if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_COMPACT_UPWIND_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_COMPACT_UPWIND_)) { /* Fifth order compact upwind scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderCompactUpwindChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderCompactUpwind; } - solver->compact = (CompactScheme*) calloc(1,sizeof(CompactScheme)); - IERR CompactSchemeInitialize(solver,mpi,solver->interp_type); - solver->lusolver = (TridiagLU*) calloc (1,sizeof(TridiagLU)); - IERR tridiagLUInit(solver->lusolver,&mpi->world);CHECKERR(ierr); + solver->m_compact = (CompactScheme*) calloc(1,sizeof(CompactScheme)); + IERR CompactSchemeInitialize(solver,mpi,solver->m_interp_type); + solver->m_lusolver = (TridiagLU_Params*) calloc (1,sizeof(TridiagLU)); + IERR TridiagLUInit(solver->m_lusolver,&mpi->m_world);CHECKERR(ierr); - } else if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_WENO_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_WENO_)) { /* Fifth order WENO scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderWENOChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderWENO; } - solver->interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); - IERR WENOInitialize(solver,mpi,solver->spatial_scheme_hyp,solver->interp_type); CHECKERR(ierr); - solver->flag_nonlinearinterp = !(((WENOParameters*)solver->interp)->no_limiting); + solver->m_interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); + IERR WENOInitialize(solver,mpi,solver->m_spatial_scheme_hyp,solver->m_interp_type); CHECKERR(ierr); + solver->m_flag_nonlinearinterp = !(((WENOParameters*)solver->m_interp)->m_no_limiting); - } else if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_CRWENO_)) { /* Fifth order CRWENO scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderCRWENOChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderCRWENO; } - solver->interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); - IERR WENOInitialize(solver,mpi,solver->spatial_scheme_hyp,solver->interp_type); CHECKERR(ierr); - solver->flag_nonlinearinterp = !(((WENOParameters*)solver->interp)->no_limiting); - solver->compact = (CompactScheme*) calloc(1,sizeof(CompactScheme)); - IERR CompactSchemeInitialize(solver,mpi,solver->interp_type); - solver->lusolver = (TridiagLU*) calloc (1,sizeof(TridiagLU)); - IERR tridiagLUInit(solver->lusolver,&mpi->world);CHECKERR(ierr); + solver->m_interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); + IERR WENOInitialize(solver,mpi,solver->m_spatial_scheme_hyp,solver->m_interp_type); CHECKERR(ierr); + solver->m_flag_nonlinearinterp = !(((WENOParameters*)solver->m_interp)->m_no_limiting); + solver->m_compact = (CompactScheme*) calloc(1,sizeof(CompactScheme)); + IERR CompactSchemeInitialize(solver,mpi,solver->m_interp_type); + solver->m_lusolver = (TridiagLU_Params*) calloc (1,sizeof(TridiagLU)); + IERR TridiagLUInit(solver->m_lusolver,&mpi->m_world);CHECKERR(ierr); - } else if (!strcmp(solver->spatial_scheme_hyp,_FIFTH_ORDER_HCWENO_)) { + } else if (!strcmp(solver->m_spatial_scheme_hyp,_FIFTH_ORDER_HCWENO_)) { /* Fifth order HCWENO scheme */ - if ((solver->nvars > 1) && (!strcmp(solver->interp_type,_CHARACTERISTIC_))) { + if ((solver->m_nvars > 1) && (!strcmp(solver->m_interp_type,_CHARACTERISTIC_))) { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderHCWENOChar; } else { solver->InterpolateInterfacesHyp = Interp1PrimFifthOrderHCWENO; } - solver->interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); - IERR WENOInitialize(solver,mpi,solver->spatial_scheme_hyp,solver->interp_type); CHECKERR(ierr); - solver->flag_nonlinearinterp = !(((WENOParameters*)solver->interp)->no_limiting); - solver->compact = (CompactScheme*) calloc(1,sizeof(CompactScheme)); - IERR CompactSchemeInitialize(solver,mpi,solver->interp_type); - solver->lusolver = (TridiagLU*) calloc (1,sizeof(TridiagLU)); - IERR tridiagLUInit(solver->lusolver,&mpi->world);CHECKERR(ierr); + solver->m_interp = (WENOParameters*) calloc(1,sizeof(WENOParameters)); + IERR WENOInitialize(solver,mpi,solver->m_spatial_scheme_hyp,solver->m_interp_type); CHECKERR(ierr); + solver->m_flag_nonlinearinterp = !(((WENOParameters*)solver->m_interp)->m_no_limiting); + solver->m_compact = (CompactScheme*) calloc(1,sizeof(CompactScheme)); + IERR CompactSchemeInitialize(solver,mpi,solver->m_interp_type); + solver->m_lusolver = (TridiagLU_Params*) calloc (1,sizeof(TridiagLU)); + IERR TridiagLUInit(solver->m_lusolver,&mpi->m_world);CHECKERR(ierr); } else { fprintf(stderr,"Error (domain %d): %s is a not a supported spatial interpolation scheme.\n", - ns, solver->spatial_scheme_hyp); + ns, solver->m_spatial_scheme_hyp); return(1); } @@ -356,108 +356,108 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si #endif /* Time integration */ - solver->time_integrator = NULL; + solver->m_time_integrator = NULL; #ifdef with_petsc - if (solver->use_petscTS) { + if (solver->m_use_petsc_ts) { /* dummy -- not used */ solver->TimeIntegrate = TimeForwardEuler; - solver->msti = NULL; + solver->m_msti = NULL; } else { - if (!strcmp(solver->time_scheme,_FORWARD_EULER_)) { + if (!strcmp(solver->m_time_scheme,_FORWARD_EULER_)) { solver->TimeIntegrate = TimeForwardEuler; - solver->msti = NULL; - } else if (!strcmp(solver->time_scheme,_RK_)) { + solver->m_msti = NULL; + } else if (!strcmp(solver->m_time_scheme,_RK_)) { solver->TimeIntegrate = TimeRK; - solver->msti = (ExplicitRKParameters*) calloc (1,sizeof(ExplicitRKParameters)); - IERR TimeExplicitRKInitialize(solver->time_scheme,solver->time_scheme_type, - solver->msti,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->time_scheme,_GLM_GEE_)) { + solver->m_msti = (ExplicitRKParameters*) calloc (1,sizeof(ExplicitRKParameters)); + IERR TimeExplicitRKInitialize(solver->m_time_scheme,solver->m_time_scheme_type, + solver->m_msti,mpi); CHECKERR(ierr); + } else if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { solver->TimeIntegrate = TimeGLMGEE; - solver->msti = (GLMGEEParameters*) calloc (1,sizeof(GLMGEEParameters)); - IERR TimeGLMGEEInitialize(solver->time_scheme,solver->time_scheme_type, - solver->msti,mpi); CHECKERR(ierr); + solver->m_msti = (GLMGEEParameters*) calloc (1,sizeof(GLMGEEParameters)); + IERR TimeGLMGEEInitialize(solver->m_time_scheme,solver->m_time_scheme_type, + solver->m_msti,mpi); CHECKERR(ierr); } else { fprintf(stderr,"Error (domain %d): %s is a not a supported time-integration scheme.\n", - ns, solver->time_scheme); + ns, solver->m_time_scheme); return(1); } } #else - if (!strcmp(solver->time_scheme,_FORWARD_EULER_)) { + if (!strcmp(solver->m_time_scheme,_FORWARD_EULER_)) { solver->TimeIntegrate = TimeForwardEuler; - solver->msti = NULL; - } else if (!strcmp(solver->time_scheme,_RK_)) { + solver->m_msti = NULL; + } else if (!strcmp(solver->m_time_scheme,_RK_)) { solver->TimeIntegrate = TimeRK; - solver->msti = (ExplicitRKParameters*) calloc (1,sizeof(ExplicitRKParameters)); - IERR TimeExplicitRKInitialize(solver->time_scheme,solver->time_scheme_type, - solver->msti,mpi); CHECKERR(ierr); - } else if (!strcmp(solver->time_scheme,_GLM_GEE_)) { + solver->m_msti = (ExplicitRKParameters*) calloc (1,sizeof(ExplicitRKParameters)); + IERR TimeExplicitRKInitialize(solver->m_time_scheme,solver->m_time_scheme_type, + solver->m_msti,mpi); CHECKERR(ierr); + } else if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { solver->TimeIntegrate = TimeGLMGEE; - solver->msti = (GLMGEEParameters*) calloc (1,sizeof(GLMGEEParameters)); - IERR TimeGLMGEEInitialize(solver->time_scheme,solver->time_scheme_type, - solver->msti,mpi); CHECKERR(ierr); + solver->m_msti = (GLMGEEParameters*) calloc (1,sizeof(GLMGEEParameters)); + IERR TimeGLMGEEInitialize(solver->m_time_scheme,solver->m_time_scheme_type, + solver->m_msti,mpi); CHECKERR(ierr); } else { fprintf(stderr,"Error (domain %d): %s is a not a supported time-integration scheme.\n", - ns, solver->time_scheme); + ns, solver->m_time_scheme); return(1); } #endif /* Solution output function */ solver->WriteOutput = NULL; /* default - no output */ - solver->filename_index = NULL; - strcpy(solver->op_fname_root, "op"); + solver->m_filename_index = NULL; + strcpy(solver->m_op_fname_root, "op"); #ifdef with_librom - strcpy(solver->op_rom_fname_root, "op_rom"); + strcpy(solver->m_op_rom_fname_root, "op_rom"); #endif - strcpy(solver->aux_op_fname_root, "ts0"); - if (!strcmp(solver->output_mode,"serial")) { - solver->index_length = 5; - solver->filename_index = (char*) calloc (solver->index_length+1,sizeof(char)); - int i; for (i=0; iindex_length; i++) solver->filename_index[i] = '0'; - solver->filename_index[solver->index_length] = (char) 0; - if (!strcmp(solver->op_file_format,"text")) { + strcpy(solver->m_aux_op_fname_root, "ts0"); + if (!strcmp(solver->m_output_mode,"serial")) { + solver->m_index_length = 5; + solver->m_filename_index = (char*) calloc (solver->m_index_length+1,sizeof(char)); + int i; for (i=0; im_index_length; i++) solver->m_filename_index[i] = '0'; + solver->m_filename_index[solver->m_index_length] = (char) 0; + if (!strcmp(solver->m_op_file_format,"text")) { solver->WriteOutput = WriteText; - strcpy(solver->solnfilename_extn,".dat"); - } else if (!strcmp(solver->op_file_format,"tecplot2d")) { + strcpy(solver->m_solnfilename_extn,".dat"); + } else if (!strcmp(solver->m_op_file_format,"tecplot2d")) { solver->WriteOutput = WriteTecplot2D; - strcpy(solver->solnfilename_extn,".dat"); - } else if (!strcmp(solver->op_file_format,"tecplot3d")) { + strcpy(solver->m_solnfilename_extn,".dat"); + } else if (!strcmp(solver->m_op_file_format,"tecplot3d")) { solver->WriteOutput = WriteTecplot3D; - strcpy(solver->solnfilename_extn,".dat"); - } else if ((!strcmp(solver->op_file_format,"binary")) || (!strcmp(solver->op_file_format,"bin"))) { + strcpy(solver->m_solnfilename_extn,".dat"); + } else if ((!strcmp(solver->m_op_file_format,"binary")) || (!strcmp(solver->m_op_file_format,"bin"))) { solver->WriteOutput = WriteBinary; - strcpy(solver->solnfilename_extn,".bin"); - } else if (!strcmp(solver->op_file_format,"none")) { + strcpy(solver->m_solnfilename_extn,".bin"); + } else if (!strcmp(solver->m_op_file_format,"none")) { solver->WriteOutput = NULL; } else { fprintf(stderr,"Error (domain %d): %s is not a supported file format.\n", - ns, solver->op_file_format); + ns, solver->m_op_file_format); return(1); } - if ((!strcmp(solver->op_overwrite,"no")) && solver->restart_iter) { - /* if it's a restart run, fast-forward the filename */ + if ((!strcmp(solver->m_op_overwrite,"no")) && solver->m_restart_iter) { + /* if it'a_s a restart run, fast-forward the filename */ int t; - for (t=0; trestart_iter; t++) - if ((t+1)%solver->file_op_iter == 0) IncrementFilenameIndex(solver->filename_index,solver->index_length); + for (t=0; tm_restart_iter; t++) + if ((t+1)%solver->m_file_op_iter == 0) IncrementFilenameIndex(solver->m_filename_index,solver->m_index_length); } - } else if (!strcmp(solver->output_mode,"parallel")) { - if (!strcmp(solver->op_file_format,"none")) solver->WriteOutput = NULL; + } else if (!strcmp(solver->m_output_mode,"parallel")) { + if (!strcmp(solver->m_op_file_format,"none")) solver->WriteOutput = NULL; else { /* only binary file writing supported in parallel mode */ /* use post-processing scripts to convert */ solver->WriteOutput = WriteBinary; - strcpy(solver->solnfilename_extn,".bin"); + strcpy(solver->m_solnfilename_extn,".bin"); } } else { fprintf(stderr,"Error (domain %d): %s is not a supported output mode.\n", - ns, solver->output_mode); + ns, solver->m_output_mode); fprintf(stderr,"Should be \"serial\" or \"parallel\". \n"); return(1); } /* Solution plotting function */ - strcpy(solver->plotfilename_extn,".png"); + strcpy(solver->m_plotfilename_extn,".png"); #ifdef with_python solver->py_plt_func = NULL; solver->py_plt_func_args = NULL; @@ -469,17 +469,17 @@ int InitializeSolvers( void *s, /*!< Array of simulation objects of type #Si if (py_plot_module) { solver->py_plt_func = PyObject_GetAttrString(py_plot_module, "plotSolution"); if (!solver->py_plt_func) { - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Unable to load plotSolution function from Python module.\n"); } } else { - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Loaded Python module for plotting.\n"); printf("Loaded plotSolution function from Python module.\n"); } } } else { - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Unable to load Python module for plotting.\n"); } } diff --git a/src/Simulation/OutputROMSolution.cpp b/src/Simulation/OutputROMSolution.cpp index 8e17cc93..2837e539 100644 --- a/src/Simulation/OutputROMSolution.cpp +++ b/src/Simulation/OutputROMSolution.cpp @@ -21,49 +21,49 @@ extern "C" void IncrementFilenameIndex(char*,int); /*! Write out the ROM solution to file */ -int OutputROMSolution( void* s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims, /*!< Number of simulation objects */ +int OutputROMSolution( void* a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims, /*!< Number of simulation objects */ double a_time /*!< Current simulation time */) { - SimulationObject* simobj = (SimulationObject*) s; + SimulationObject* simobj = (SimulationObject*) a_s; int ns; - for (ns = 0; ns < nsims; ns++) { + for (ns = 0; ns < a_nsims; ns++) { HyPar* solver = &(simobj[ns].solver); MPIVariables* mpi = &(simobj[ns].mpi); - if ((!solver->WriteOutput) && (strcmp(solver->plot_solution,"yes"))) continue; + if ((!solver->WriteOutput) && (strcmp(solver->m_plot_solution,"yes"))) continue; char fname_root[_MAX_STRING_SIZE_]; - strcpy(fname_root, solver->op_rom_fname_root); + strcpy(fname_root, solver->m_op_rom_fname_root); - if (nsims > 1) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(ns, index, (int)log10(nsims)+1); + GetStringFromInteger(ns, index, (int)log10(a_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); } - WriteArray( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - solver->u_rom_predicted, + WriteArray( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + solver->m_u_rom_predicted, solver, mpi, fname_root ); - if (!strcmp(solver->plot_solution, "yes")) { - PlotArray( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - solver->u, + if (!strcmp(solver->m_plot_solution, "yes")) { + PlotArray( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + solver->m_u, a_time, solver, mpi, @@ -71,8 +71,8 @@ int OutputROMSolution( void* s, /*!< Array of simulation objects of type } /* increment the index string, if required */ - if ((!strcmp(solver->output_mode,"serial")) && (!strcmp(solver->op_overwrite,"no"))) { - IncrementFilenameIndex(solver->filename_index,solver->index_length); + if ((!strcmp(solver->m_output_mode,"serial")) && (!strcmp(solver->m_op_overwrite,"no"))) { + IncrementFilenameIndex(solver->m_filename_index,solver->m_index_length); } } diff --git a/src/Simulation/OutputSolution.cpp b/src/Simulation/OutputSolution.cpp index 1cb6a75c..bc862c9e 100644 --- a/src/Simulation/OutputSolution.cpp +++ b/src/Simulation/OutputSolution.cpp @@ -24,20 +24,20 @@ extern "C" void IncrementFilenameIndex(char*,int); /*! Write out the solution to file */ -int OutputSolution( void* s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims, /*!< Number of simulation objects */ +int OutputSolution( void* a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims, /*!< Number of simulation objects */ double a_time /*!< Current simulation time */) { - SimulationObject* simobj = (SimulationObject*) s; + SimulationObject* simobj = (SimulationObject*) a_s; int ns; _DECLARE_IERR_; - for (ns = 0; ns < nsims; ns++) { + for (ns = 0; ns < a_nsims; ns++) { HyPar* solver = &(simobj[ns].solver); MPIVariables* mpi = &(simobj[ns].mpi); - if ((!solver->WriteOutput) && (strcmp(solver->plot_solution,"yes"))) continue; + if ((!solver->WriteOutput) && (strcmp(solver->m_plot_solution,"yes"))) continue; /* time integration module may have auxiliary arrays to write out, so get them */ int NSolutions = 0; @@ -47,12 +47,12 @@ int OutputSolution( void* s, /*!< Array of simulation objects of type #Si int nu; char fname_root[_MAX_STRING_SIZE_]; char aux_fname_root[_MAX_STRING_SIZE_]; - strcpy(fname_root, solver->op_fname_root); - strcpy(aux_fname_root, solver->aux_op_fname_root); + strcpy(fname_root, solver->m_op_fname_root); + strcpy(aux_fname_root, solver->m_aux_op_fname_root); - if (nsims > 1) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(ns, index, (int)log10(nsims)+1); + GetStringFromInteger(ns, index, (int)log10(a_nsims)+1); strcat(fname_root, "_"); strcat(fname_root, index); strcat(aux_fname_root, "_"); @@ -64,12 +64,12 @@ int OutputSolution( void* s, /*!< Array of simulation objects of type #Si double *uaux = NULL; IERR TimeGetAuxSolutions(&NSolutions,&uaux,solver,nu,ns); CHECKERR(ierr); - IERR WriteArray( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, + IERR WriteArray( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, uaux, solver, mpi, @@ -79,21 +79,21 @@ int OutputSolution( void* s, /*!< Array of simulation objects of type #Si } #if defined(HAVE_CUDA) - if (solver->use_gpu) { + if (solver->m_use_gpu) { /* Copy values from GPU memory to CPU memory for writing. */ - gpuMemcpy(solver->x, solver->gpu_x, sizeof(double)*solver->size_x, gpuMemcpyDeviceToHost); + gpuMemcpy(solver->m_x, solver->m_gpu_x, sizeof(double)*solver->m_size_x, gpuMemcpyDeviceToHost); #ifdef CUDA_VAR_ORDERDING_AOS - gpuMemcpy( solver->u, - solver->gpu_u, - sizeof(double)*solver->ndof_cells_wghosts, + gpuMemcpy( solver->m_u, + solver->m_gpu_u, + sizeof(double)*solver->m_ndof_cells_wghosts, gpuMemcpyDeviceToHost ); #else - double *h_u = (double *) malloc(sizeof(double)*solver->ndof_cells_wghosts); - gpuMemcpy(h_u, solver->gpu_u, sizeof(double)*solver->ndof_cells_wghosts, gpuMemcpyDeviceToHost); - for (int i=0; inpoints_local_wghosts; i++) { - for (int v=0; vnvars; v++) { - solver->u[i*solver->nvars+v] = h_u[i+v*solver->npoints_local_wghosts]; + double *h_u = (double *) malloc(sizeof(double)*solver->m_ndof_cells_wghosts); + gpuMemcpy(h_u, solver->m_gpu_u, sizeof(double)*solver->m_ndof_cells_wghosts, gpuMemcpyDeviceToHost); + for (int i=0; im_npoints_local_wghosts; i++) { + for (int v=0; vm_nvars; v++) { + solver->m_u[i*solver->m_nvars+v] = h_u[i+v*solver->m_npoints_local_wghosts]; } } free(h_u); @@ -101,25 +101,25 @@ int OutputSolution( void* s, /*!< Array of simulation objects of type #Si } #endif - WriteArray( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - solver->u, + WriteArray( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + solver->m_u, solver, mpi, fname_root ); - if (!strcmp(solver->plot_solution, "yes")) { - PlotArray( solver->ndims, - solver->nvars, - solver->dim_global, - solver->dim_local, - solver->ghosts, - solver->x, - solver->u, + if (!strcmp(solver->m_plot_solution, "yes")) { + PlotArray( solver->m_ndims, + solver->m_nvars, + solver->m_dim_global, + solver->m_dim_local, + solver->m_ghosts, + solver->m_x, + solver->m_u, a_time, solver, mpi, @@ -127,8 +127,8 @@ int OutputSolution( void* s, /*!< Array of simulation objects of type #Si } /* increment the index string, if required */ - if ((!strcmp(solver->output_mode,"serial")) && (!strcmp(solver->op_overwrite,"no"))) { - IncrementFilenameIndex(solver->filename_index,solver->index_length); + if ((!strcmp(solver->m_output_mode,"serial")) && (!strcmp(solver->m_op_overwrite,"no"))) { + IncrementFilenameIndex(solver->m_filename_index,solver->m_index_length); } } diff --git a/src/Simulation/ReadInputs.c b/src/Simulation/ReadInputs.c index 7130ee8b..af687246 100644 --- a/src/Simulation/ReadInputs.c +++ b/src/Simulation/ReadInputs.c @@ -27,35 +27,35 @@ where the list of keywords and their type are:\n 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 + ndims | int | #HyPar::m_ndims | 1 + nvars | int | #HyPar::m_nvars | 1 + size | int[ndims] | #HyPar::m_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 + ghost | int | #HyPar::m_ghosts | 1 + n_iter | int | #HyPar::m_n_iter | 0 + restart_iter | int | #HyPar::m_restart_iter | 0 + time_scheme | char[] | #HyPar::m_time_scheme | euler + time_scheme_type | char[] | #HyPar::m_time_scheme_type | none + hyp_space_scheme | char[] | #HyPar::m_spatial_scheme_hyp | 1 + hyp_flux_split | char[] | #HyPar::m_split_hyperbolic_flux | no + hyp_interp_type | char[] | #HyPar::m_interp_type | characteristic + par_space_type | char[] | #HyPar::m_spatial_type_par | nonconservative-1stage + par_space_scheme | char[] | #HyPar::m_spatial_scheme_par | 2 + dt | double | #HyPar::m_dt | 0.0 + conservation_check | char[] | #HyPar::m_conservation_check | no + screen_op_iter | int | #HyPar::m_screen_op_iter | 1 + file_op_iter | int | #HyPar::m_file_op_iter | 1000 + op_file_format | char[] | #HyPar::m_op_file_format | text + ip_file_type | char[] | #HyPar::m_ip_file_type | ascii + input_mode | char[] | #HyPar::m_input_mode | serial + output_mode | char[] | #HyPar::m_output_mode | serial + op_overwrite | char[] | #HyPar::m_op_overwrite | no + plot_solution | char[] | #HyPar::m_plot_solution | no + model | char[] | #HyPar::m_model | must be specified + immersed_body | char[] | #HyPar::m_ib_filename | "none" + size_exact | int[ndims] | #HyPar::m_dim_global_ex | #HyPar::m_dim_global + use_gpu | char[] | #HyPar::m_use_gpu | no + gpu_device_no | int | #HyPar::m_gpu_device_no | -1 \b Notes: + "ndims" \b must be specified \b before "size". @@ -90,13 +90,13 @@ \b NOTE: However, if it is specified, and a file of that filename does not exist, it will result in an error. */ -int ReadInputs( void *s, /*!< Array of simulation objects of type #SimulationObject +int ReadInputs( void *a_s, /*!< Array of simulation objects of type #SimulationObject of size nsims */ - int nsims, /*!< Number of simulation objects */ - int rank /*!< MPI rank of this process */ + int a_nsims, /*!< Number of simulation objects */ + int a_rank /*!< MPI rank of this process */ ) { - SimulationObject *sim = (SimulationObject*) s; + SimulationObject *sim = (SimulationObject*) a_s; int n, ferr = 0; if (sim == NULL) { @@ -105,45 +105,45 @@ int ReadInputs( void *s, /*!< Array of simulation objects of type #Simulati return(1); } - if (!rank) { + if (!a_rank) { /* set some default values for optional inputs */ - for (n = 0; n < nsims; n++) { - sim[n].solver.ndims = 1; - sim[n].solver.nvars = 1; - sim[n].solver.ghosts = 1; - sim[n].solver.dim_global = NULL; - sim[n].solver.dim_local = NULL; - sim[n].solver.dim_global_ex = NULL; - sim[n].mpi.iproc = NULL; - sim[n].mpi.N_IORanks = 1; - sim[n].solver.dt = 0.0; - sim[n].solver.n_iter = 0; - sim[n].solver.restart_iter = 0; - sim[n].solver.screen_op_iter = 1; - sim[n].solver.file_op_iter = 1000; - sim[n].solver.write_residual = 0; - sim[n].solver.flag_ib = 0; + for (n = 0; n < a_nsims; n++) { + sim[n].solver.m_ndims = 1; + sim[n].solver.m_nvars = 1; + sim[n].solver.m_ghosts = 1; + sim[n].solver.m_dim_global = NULL; + sim[n].solver.m_dim_local = NULL; + sim[n].solver.m_dim_global_ex = NULL; + sim[n].mpi.m_iproc = NULL; + sim[n].mpi.m_N_IORanks = 1; + sim[n].solver.m_dt = 0.0; + sim[n].solver.m_n_iter = 0; + sim[n].solver.m_restart_iter = 0; + sim[n].solver.m_screen_op_iter = 1; + sim[n].solver.m_file_op_iter = 1000; + sim[n].solver.m_write_residual = 0; + sim[n].solver.m_flag_ib = 0; #if defined(HAVE_CUDA) - sim[n].solver.use_gpu = 0; - sim[n].solver.gpu_device_no = -1; + sim[n].solver.m_use_gpu = 0; + sim[n].solver.m_gpu_device_no = -1; #endif - strcpy(sim[n].solver.time_scheme ,"euler" ); - strcpy(sim[n].solver.time_scheme_type ," " ); - strcpy(sim[n].solver.spatial_scheme_hyp ,"1" ); - strcpy(sim[n].solver.spatial_type_par ,_NC_1STAGE_ ); - strcpy(sim[n].solver.spatial_scheme_par ,"2" ); - strcpy(sim[n].solver.interp_type ,"characteristic"); - strcpy(sim[n].solver.ip_file_type ,"ascii" ); - strcpy(sim[n].solver.input_mode ,"serial" ); - strcpy(sim[n].solver.output_mode ,"serial" ); - strcpy(sim[n].solver.op_file_format ,"text" ); - strcpy(sim[n].solver.op_overwrite ,"no" ); - strcpy(sim[n].solver.plot_solution ,"no" ); - strcpy(sim[n].solver.model ,"none" ); - strcpy(sim[n].solver.ConservationCheck ,"no" ); - strcpy(sim[n].solver.SplitHyperbolicFlux,"no" ); - strcpy(sim[n].solver.ib_filename ,"none" ); + strcpy(sim[n].solver.m_time_scheme ,"euler" ); + strcpy(sim[n].solver.m_time_scheme_type ," " ); + strcpy(sim[n].solver.m_spatial_scheme_hyp ,"1" ); + strcpy(sim[n].solver.m_spatial_type_par ,_NC_1STAGE_ ); + strcpy(sim[n].solver.m_spatial_scheme_par ,"2" ); + strcpy(sim[n].solver.m_interp_type ,"characteristic"); + strcpy(sim[n].solver.m_ip_file_type ,"ascii" ); + strcpy(sim[n].solver.m_input_mode ,"serial" ); + strcpy(sim[n].solver.m_output_mode ,"serial" ); + strcpy(sim[n].solver.m_op_file_format ,"text" ); + strcpy(sim[n].solver.m_op_overwrite ,"no" ); + strcpy(sim[n].solver.m_plot_solution ,"no" ); + strcpy(sim[n].solver.m_model ,"none" ); + strcpy(sim[n].solver.m_conservation_check ,"no" ); + strcpy(sim[n].solver.m_split_hyperbolic_flux,"no" ); + strcpy(sim[n].solver.m_ib_filename ,"none" ); } /* open the file */ @@ -168,53 +168,53 @@ int ReadInputs( void *s, /*!< Array of simulation objects of type #Simulati if (!strcmp(word, "ndims")) { - ferr = fscanf(in,"%d",&(sim[0].solver.ndims)); if (ferr != 1) return(1); - sim[0].solver.dim_global = (int*) calloc (sim[0].solver.ndims,sizeof(int)); - sim[0].mpi.iproc = (int*) calloc (sim[0].solver.ndims,sizeof(int)); - sim[0].solver.dim_global_ex = (int*) calloc (sim[0].solver.ndims,sizeof(int)); + ferr = fscanf(in,"%d",&(sim[0].solver.m_ndims)); if (ferr != 1) return(1); + sim[0].solver.m_dim_global = (int*) calloc (sim[0].solver.m_ndims,sizeof(int)); + sim[0].mpi.m_iproc = (int*) calloc (sim[0].solver.m_ndims,sizeof(int)); + sim[0].solver.m_dim_global_ex = (int*) calloc (sim[0].solver.m_ndims,sizeof(int)); int n; - for (n = 1; n < nsims; n++) { - sim[n].solver.ndims = sim[0].solver.ndims; - sim[n].solver.dim_global = (int*) calloc (sim[n].solver.ndims,sizeof(int)); - sim[n].mpi.iproc = (int*) calloc (sim[n].solver.ndims,sizeof(int)); - sim[n].solver.dim_global_ex = (int*) calloc (sim[n].solver.ndims,sizeof(int)); + for (n = 1; n < a_nsims; n++) { + sim[n].solver.m_ndims = sim[0].solver.m_ndims; + sim[n].solver.m_dim_global = (int*) calloc (sim[n].solver.m_ndims,sizeof(int)); + sim[n].mpi.m_iproc = (int*) calloc (sim[n].solver.m_ndims,sizeof(int)); + sim[n].solver.m_dim_global_ex = (int*) calloc (sim[n].solver.m_ndims,sizeof(int)); } } else if (!strcmp(word, "nvars")) { - ferr = fscanf(in,"%d",&(sim[0].solver.nvars)); - for (int n = 1; n < nsims; n++) sim[n].solver.nvars = sim[0].solver.nvars; + ferr = fscanf(in,"%d",&(sim[0].solver.m_nvars)); + for (int n = 1; n < a_nsims; n++) sim[n].solver.m_nvars = sim[0].solver.m_nvars; } else if (!strcmp(word, "size")) { - for (int n = 0; n < nsims; n++) { - if (!sim[n].solver.dim_global) { + for (int n = 0; n < a_nsims; n++) { + if (!sim[n].solver.m_dim_global) { fprintf(stderr,"Error in ReadInputs(): dim_global not allocated for n=%d.\n", n); fprintf(stderr,"Please specify ndims before dimensions.\n" ); return(1); } else { - for (int i=0; i 1) printf("\n"); + if (a_nsims > 1) printf("\n"); - for (n = 0; n < nsims; n++) { + for (n = 0; n < a_nsims; n++) { char err_fname[_MAX_STRING_SIZE_], cons_fname[_MAX_STRING_SIZE_], @@ -43,7 +43,7 @@ void SimWriteErrors(void *s, /*!< Array of simulations of type #S #endif - if (nsims > 1) { + if (a_nsims > 1) { strcat(err_fname,"_"); strcat(cons_fname,"_"); @@ -53,7 +53,7 @@ void SimWriteErrors(void *s, /*!< Array of simulations of type #S #endif char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(n, index, (int)log10(nsims)+1); + GetStringFromInteger(n, index, (int)log10(a_nsims)+1); strcat(err_fname,index); strcat(cons_fname,index); @@ -73,71 +73,71 @@ void SimWriteErrors(void *s, /*!< Array of simulations of type #S FILE *out; /* write out solution errors and wall times to file */ out = fopen(err_fname,"w"); - for (int d=0; d= 0) { + if (sim[n].solver.m_rom_diff_norms[0] >= 0) { out = fopen(rom_diff_fname,"w"); - for (int d=0; d= 0) { + if (sim[n].solver.m_error[0] >= 0) { printf("Computed errors for domain %d:\n", n); - printf(" L1 Error : %1.16E\n",sim[n].solver.error[0]); - printf(" L2 Error : %1.16E\n",sim[n].solver.error[1]); - printf(" Linfinity Error : %1.16E\n",sim[n].solver.error[2]); + printf(" L1 Error : %1.16E\n",sim[n].solver.m_error[0]); + printf(" L2 Error : %1.16E\n",sim[n].solver.m_error[1]); + printf(" Linfinity Error : %1.16E\n",sim[n].solver.m_error[2]); } - if (!strcmp(sim[n].solver.ConservationCheck,"yes")) { + if (!strcmp(sim[n].solver.m_conservation_check,"yes")) { printf("Conservation Errors:\n"); - for (int d=0; d= 0) { + if (sim[n].solver.m_rom_diff_norms[0] >= 0) { printf("Norms of the diff between ROM and PDE solutions for domain %d:\n", n); - printf(" L1 Norm : %1.16E\n",sim[n].solver.rom_diff_norms[0]); - printf(" L2 Norm : %1.16E\n",sim[n].solver.rom_diff_norms[1]); - printf(" Linfinity Norm : %1.16E\n",sim[n].solver.rom_diff_norms[2]); + printf(" L1 Norm : %1.16E\n",sim[n].solver.m_rom_diff_norms[0]); + printf(" L2 Norm : %1.16E\n",sim[n].solver.m_rom_diff_norms[1]); + printf(" Linfinity Norm : %1.16E\n",sim[n].solver.m_rom_diff_norms[2]); } #endif } - printf("Solver runtime (in seconds): %1.16E\n",solver_runtime); - printf("Total runtime (in seconds): %1.16E\n",main_runtime); - if (nsims > 1) printf("\n"); + printf("Solver runtime (in seconds): %1.16E\n",a_solver_runtime); + printf("Total runtime (in seconds): %1.16E\n",a_main_runtime); + if (a_nsims > 1) printf("\n"); } diff --git a/src/Simulation/SingleSimulationDefine.cpp b/src/Simulation/SingleSimulationDefine.cpp index 21556ae3..c679a789 100644 --- a/src/Simulation/SingleSimulationDefine.cpp +++ b/src/Simulation/SingleSimulationDefine.cpp @@ -20,10 +20,10 @@ int SingleSimulation::define( int a_rank, /*!< MPI rank of this process */ m_nproc = a_nproc; m_sim = new SimulationObject; - m_sim->solver.my_idx = 0; - m_sim->solver.nsims = 1; - m_sim->mpi.rank = m_rank; - m_sim->mpi.nproc = m_nproc; + m_sim->solver.m_my_idx = 0; + m_sim->solver.m_nsims = 1; + m_sim->mpi.m_rank = m_rank; + m_sim->mpi.m_nproc = m_nproc; if (!m_rank) { printf("Allocated simulation object(s).\n"); diff --git a/src/Simulation/Solve.cpp b/src/Simulation/Solve.cpp index 1d74c7ab..3497b98f 100644 --- a/src/Simulation/Solve.cpp +++ b/src/Simulation/Solve.cpp @@ -34,43 +34,43 @@ int OutputROMSolution(void*,int,double); /*!< Write ROM solutions to file */ 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. */ -int Solve( void *s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims, /*!< number of simulation objects */ - int rank, /*!< MPI rank of this process */ +int Solve( void *a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims, /*!< number of simulation objects */ + int a_rank, /*!< MPI a_rank of this process */ int nproc /*!< Number of MPI processes */ ) { - SimulationObject* sim = (SimulationObject*) s; + SimulationObject* sim = (SimulationObject*) a_s; /* make sure none of the simulation objects sent in the array * are "barebones" type */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { if (sim[ns].is_barebones == 1) { - fprintf(stderr, "Error in Solve(): simulation object %d on rank %d is barebones!\n", - ns, rank ); + fprintf(stderr, "Error in Solve(): simulation object %d on a_rank %d is barebones!\n", + ns, a_rank ); return 1; } } /* write out iblank to file for visualization */ - for (int ns = 0; ns < nsims; ns++) { - if (sim[ns].solver.flag_ib) { + for (int ns = 0; ns < a_nsims; ns++) { + if (sim[ns].solver.m_flag_ib) { char fname_root[_MAX_STRING_SIZE_] = "iblank"; - if (nsims > 1) { + if (a_nsims > 1) { char index[_MAX_STRING_SIZE_]; - GetStringFromInteger(ns, index, (int)log10((nsims)+1)); + GetStringFromInteger(ns, index, (int)log10((a_nsims)+1)); strcat(fname_root, "_"); strcat(fname_root, index); } - WriteArray( sim[ns].solver.ndims, + WriteArray( sim[ns].solver.m_ndims, 1, - sim[ns].solver.dim_global, - sim[ns].solver.dim_local, - sim[ns].solver.ghosts, - sim[ns].solver.x, - sim[ns].solver.iblank, + sim[ns].solver.m_dim_global, + sim[ns].solver.m_dim_local, + sim[ns].solver.m_ghosts, + sim[ns].solver.m_x, + sim[ns].solver.m_iblank, &(sim[ns].solver), &(sim[ns].mpi), fname_root ); @@ -78,8 +78,8 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb } #ifdef with_librom - if (!rank) printf("Setting up libROM interface.\n"); - libROMInterface rom_interface( sim, nsims, rank, nproc, sim[0].solver.dt ); + if (!a_rank) printf("Setting up libROM interface.\n"); + libROMInterface rom_interface( sim, a_nsims, a_rank, nproc, sim[0].solver.m_dt ); const std::string& rom_mode( rom_interface.mode() ); std::vector op_times_arr(0); #endif @@ -89,31 +89,31 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb #endif /* Define and initialize the time-integration object */ TimeIntegration TS; - if (!rank) printf("Setting up time integration.\n"); - TimeInitialize(sim, nsims, rank, nproc, &TS); + if (!a_rank) printf("Setting up time integration.\n"); + TimeInitialize(sim, a_nsims, a_rank, nproc, &TS); double ti_runtime = 0.0; - if (!rank) printf("Solving in time (from %d to %d iterations)\n",TS.restart_iter,TS.n_iter); - for (TS.iter = TS.restart_iter; TS.iter < TS.n_iter; TS.iter++) { + if (!a_rank) printf("Solving in time (from %d to %d iterations)\n",TS.m_restart_iter,TS.m_n_iter); + for (TS.m_iter = TS.m_restart_iter; TS.m_iter < TS.m_n_iter; TS.m_iter++) { /* Write initial solution to file if this is the first iteration */ - if (!TS.iter) { - for (int ns = 0; ns < nsims; ns++) { + if (!TS.m_iter) { + for (int ns = 0; ns < a_nsims; ns++) { if (sim[ns].solver.PhysicsOutput) { sim[ns].solver.PhysicsOutput( &(sim[ns].solver), &(sim[ns].mpi), - TS.waqt ); + TS.m_waqt ); } } - OutputSolution(sim, nsims, TS.waqt); + OutputSolution(sim, a_nsims, TS.m_waqt); #ifdef with_librom - op_times_arr.push_back(TS.waqt); + op_times_arr.push_back(TS.m_waqt); #endif } #ifdef with_librom - if ((rom_mode == _ROM_MODE_TRAIN_) && (TS.iter%rom_interface.samplingFrequency() == 0)) { - rom_interface.takeSample( sim, TS.waqt ); + if ((rom_mode == _ROM_MODE_TRAIN_) && (TS.m_iter%rom_interface.samplingFrequency() == 0)) { + rom_interface.takeSample( sim, TS.m_waqt ); } #endif @@ -121,8 +121,8 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb TimePreStep (&TS); #ifdef compute_rhs_operators /* compute and write (to file) matrix operators representing the right-hand side */ -// if (((TS.iter+1)%solver->file_op_iter == 0) || (!TS.iter)) -// { ComputeRHSOperators(solver,mpi,TS.waqt); +// if (((TS.m_iter+1)%solver->m_file_op_iter == 0) || (!TS.m_iter)) +// { ComputeRHSOperators(solver,mpi,TS.m_waqt); #endif /* Step in time */ @@ -131,66 +131,66 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb /* Call post-step function */ TimePostStep (&TS); - ti_runtime += TS.iter_wctime; + ti_runtime += TS.m_iter_wctime; /* Print information to screen */ TimePrintStep(&TS); /* Write intermediate solution to file */ - if ( ((TS.iter+1)%sim[0].solver.file_op_iter == 0) - && ((TS.iter+1) < TS.n_iter) ) { - for (int ns = 0; ns < nsims; ns++) { + if ( ((TS.m_iter+1)%sim[0].solver.m_file_op_iter == 0) + && ((TS.m_iter+1) < TS.m_n_iter) ) { + for (int ns = 0; ns < a_nsims; ns++) { if (sim[ns].solver.PhysicsOutput) { sim[ns].solver.PhysicsOutput( &(sim[ns].solver), &(sim[ns].mpi), - TS.waqt ); + TS.m_waqt ); } } - OutputSolution(sim, nsims, TS.waqt); + OutputSolution(sim, a_nsims, TS.m_waqt); #ifdef with_librom - op_times_arr.push_back(TS.waqt); + op_times_arr.push_back(TS.m_waqt); #endif } } - double t_final = TS.waqt; + double t_final = TS.m_waqt; TimeCleanup(&TS); - if (!rank) { + if (!a_rank) { printf( "Completed time integration (Final time: %f), total wctime: %f (seconds).\n", t_final, ti_runtime ); - if (nsims > 1) printf("\n"); + if (a_nsims > 1) printf("\n"); } /* calculate error if exact solution has been provided */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { CalculateError(&(sim[ns].solver), &(sim[ns].mpi) ); } /* write a final solution file */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { if (sim[ns].solver.PhysicsOutput) { sim[ns].solver.PhysicsOutput( &(sim[ns].solver), &(sim[ns].mpi), t_final ); } } - OutputSolution(sim, nsims, t_final); + OutputSolution(sim, a_nsims, t_final); #ifdef with_librom - op_times_arr.push_back(TS.waqt); + op_times_arr.push_back(TS.m_waqt); - for (int ns = 0; ns < nsims; ns++) { - ResetFilenameIndex( sim[ns].solver.filename_index, - sim[ns].solver.index_length ); + for (int ns = 0; ns < a_nsims; ns++) { + ResetFilenameIndex( sim[ns].solver.m_filename_index, + sim[ns].solver.m_index_length ); } if (rom_interface.mode() == _ROM_MODE_TRAIN_) { rom_interface.train(); - if (!rank) printf("libROM: total training wallclock time: %f (seconds).\n", + if (!a_rank) printf("libROM: total training wallclock time: %f (seconds).\n", rom_interface.trainWallclockTime() ); double total_rom_predict_time = 0; @@ -199,24 +199,24 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb double waqt = op_times_arr[iter]; rom_interface.predict(sim, waqt); - if (!rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", + if (!a_rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", waqt, rom_interface.predictWallclockTime() ); total_rom_predict_time += rom_interface.predictWallclockTime(); /* calculate diff between ROM and PDE solutions */ if (iter == (op_times_arr.size()-1)) { - if (!rank) printf("libROM: Calculating diff between PDE and ROM solutions.\n"); - for (int ns = 0; ns < nsims; ns++) { + if (!a_rank) printf("libROM: Calculating diff between PDE and ROM solutions.\n"); + for (int ns = 0; ns < a_nsims; ns++) { CalculateROMDiff( &(sim[ns].solver), &(sim[ns].mpi) ); } } /* write the ROM solution to file */ - OutputROMSolution(sim, nsims,waqt); + OutputROMSolution(sim, a_nsims,waqt); } - if (!rank) { + if (!a_rank) { printf( "libROM: total prediction/query wallclock time: %f (seconds).\n", total_rom_predict_time ); } @@ -225,10 +225,10 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb } else { - for (int ns = 0; ns < nsims; ns++) { - sim[ns].solver.rom_diff_norms[0] - = sim[ns].solver.rom_diff_norms[1] - = sim[ns].solver.rom_diff_norms[2] + for (int ns = 0; ns < a_nsims; ns++) { + sim[ns].solver.m_rom_diff_norms[0] + = sim[ns].solver.m_rom_diff_norms[1] + = sim[ns].solver.m_rom_diff_norms[2] = -1; } @@ -236,28 +236,28 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb } else if (rom_mode == _ROM_MODE_PREDICT_) { - for (int ns = 0; ns < nsims; ns++) { - sim[ns].solver.rom_diff_norms[0] - = sim[ns].solver.rom_diff_norms[1] - = sim[ns].solver.rom_diff_norms[2] + for (int ns = 0; ns < a_nsims; ns++) { + sim[ns].solver.m_rom_diff_norms[0] + = sim[ns].solver.m_rom_diff_norms[1] + = sim[ns].solver.m_rom_diff_norms[2] = -1; - strcpy(sim[ns].solver.ConservationCheck,"no"); + strcpy(sim[ns].solver.m_conservation_check,"no"); } rom_interface.loadROM(); rom_interface.projectInitialSolution(sim); { - int start_iter = sim[0].solver.restart_iter; - int n_iter = sim[0].solver.n_iter; - double dt = sim[0].solver.dt; + int start_iter = sim[0].solver.m_restart_iter; + int n_iter = sim[0].solver.m_n_iter; + double dt = sim[0].solver.m_dt; double cur_time = start_iter * dt; op_times_arr.push_back(cur_time); for (int iter = start_iter; iter < n_iter; iter++) { cur_time += dt; - if ( ( (iter+1)%sim[0].solver.file_op_iter == 0) + if ( ( (iter+1)%sim[0].solver.m_file_op_iter == 0) && ( (iter+1) < n_iter) ) { op_times_arr.push_back(cur_time); } @@ -273,29 +273,29 @@ int Solve( void *s, /*!< Array of simulation objects of type #SimulationOb double waqt = op_times_arr[iter]; rom_interface.predict(sim, waqt); - if (!rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", + if (!a_rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", waqt, rom_interface.predictWallclockTime() ); total_rom_predict_time += rom_interface.predictWallclockTime(); /* write the solution to file */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { if (sim[ns].solver.PhysicsOutput) { sim[ns].solver.PhysicsOutput( &(sim[ns].solver), &(sim[ns].mpi), waqt ); } } - OutputSolution(sim, nsims, waqt); + OutputSolution(sim, a_nsims, waqt); } /* calculate error if exact solution has been provided */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { CalculateError(&(sim[ns].solver), &(sim[ns].mpi) ); } - if (!rank) { + if (!a_rank) { printf( "libROM: total prediction/query wallclock time: %f (seconds).\n", total_rom_predict_time ); } diff --git a/src/Simulation/SolvePETSc.cpp b/src/Simulation/SolvePETSc.cpp index 0cb4801f..7bfd716f 100644 --- a/src/Simulation/SolvePETSc.cpp +++ b/src/Simulation/SolvePETSc.cpp @@ -47,12 +47,12 @@ int OutputROMSolution(void*,int,double); /*!< Write ROM solutions to file */ (usually googling with the function name shows the man page for that function on PETSc's website). */ -int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims, /*!< number of simulation objects */ - int rank, /*!< MPI rank of this process */ - int nproc /*!< Number of MPI processes */ ) +int SolvePETSc( void* a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims, /*!< number of simulation objects */ + int a_rank, /*!< MPI rank of this process */ + int a_nproc /*!< Number of MPI processes */ ) { - SimulationObject* sim = (SimulationObject*) s; + SimulationObject* sim = (SimulationObject*) a_s; DM dm; /* data management object */ TS ts; /* time integration object */ @@ -70,54 +70,54 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj PetscFunctionBegin; /* Register custom time-integration methods, if specified */ - PetscRegisterTIMethods(rank); - if(!rank) printf("Setting up PETSc time integration... \n"); + PetscRegisterTIMethods(a_rank); + if(!a_rank) printf("Setting up PETSc time integration... \n"); /* create and set a PETSc context */ PETScContext context; - context.rank = rank; - context.nproc = nproc; + context.m_rank = a_rank; + context.m_nproc = a_nproc; - context.simobj = sim; - context.nsims = nsims; + context.m_simobj = sim; + context.m_nsims = a_nsims; /* default: everything explicit */ - context.flag_hyperbolic = _EXPLICIT_; - context.flag_hyperbolic_f = _EXPLICIT_; - context.flag_hyperbolic_df = _EXPLICIT_; - context.flag_parabolic = _EXPLICIT_; - context.flag_source = _EXPLICIT_; - - context.tic = 0; - context.flag_is_linear = 0; - context.globalDOF.clear(); - context.points.clear(); - context.ti_runtime = 0.0; - context.waqt = 0.0; - context.dt = sim[0].solver.dt; - context.stage_times.clear(); - context.stage_index = 0; + context.m_flag_hyperbolic = _EXPLICIT_; + context.m_flag_hyperbolic_f = _EXPLICIT_; + context.m_flag_hyperbolic_df = _EXPLICIT_; + context.m_flag_parabolic = _EXPLICIT_; + context.m_flag_source = _EXPLICIT_; + + context.m_tic = 0; + context.m_flag_is_linear = 0; + context.m_globalDOF.clear(); + context.m_points.clear(); + context.m_ti_runtime = 0.0; + context.m_waqt = 0.0; + context.m_dt = sim[0].solver.m_dt; + context.m_stage_times.clear(); + context.m_stage_index = 0; #ifdef with_librom - if (!rank) printf("Setting up libROM interface.\n"); - context.rom_interface = new libROMInterface( sim, - nsims, - rank, - nproc, - sim[0].solver.dt ); - context.rom_mode = ((libROMInterface*)context.rom_interface)->mode(); - context.op_times_arr.clear(); + if (!a_rank) printf("Setting up libROM interface.\n"); + context.m_rom_interface = new libROMInterface( sim, + a_nsims, + a_rank, + a_nproc, + sim[0].solver.m_dt ); + context.m_rom_mode = ((libROMInterface*)context.m_rom_interface)->mode(); + context.m_op_times_arr.clear(); #endif #ifdef with_librom - if ( (context.rom_mode == _ROM_MODE_TRAIN_) - || (context.rom_mode == _ROM_MODE_INITIAL_GUESS_ ) - || (context.rom_mode == _ROM_MODE_NONE_ ) ) { + if ( (context.m_rom_mode == _ROM_MODE_TRAIN_) + || (context.m_rom_mode == _ROM_MODE_INITIAL_GUESS_ ) + || (context.m_rom_mode == _ROM_MODE_NONE_ ) ) { - if (context.rom_mode == _ROM_MODE_INITIAL_GUESS_) { - ((libROMInterface*)context.rom_interface)->loadROM(); - ((libROMInterface*)context.rom_interface)->projectInitialSolution(sim); + if (context.m_rom_mode == _ROM_MODE_INITIAL_GUESS_) { + ((libROMInterface*)context.m_rom_interface)->loadROM(); + ((libROMInterface*)context.m_rom_interface)->projectInitialSolution(sim); } #endif PetscCreatePointList(&context); @@ -125,16 +125,16 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* create and initialize PETSc solution vector and other parameters */ /* PETSc solution vector does not have ghost points */ VecCreate(MPI_COMM_WORLD,&Y); - VecSetSizes(Y,context.ndofs,PETSC_DECIDE); + VecSetSizes(Y,context.m_ndofs,PETSC_DECIDE); VecSetUp(Y); - /* copy initial solution to PETSc's vector */ - for (int ns = 0; ns < nsims; ns++) { - TransferVecToPETSc( sim[ns].solver.u, + /* copy initial solution to PETSc'a_s vector */ + for (int ns = 0; ns < a_nsims; ns++) { + TransferVecToPETSc( sim[ns].solver.m_u, Y, &context, ns, - context.offsets[ns] ); + context.m_offsets[ns] ); } /* Create the global DOF mapping for all the grid points */ @@ -142,10 +142,10 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* Define and initialize the time-integration object */ TSCreate(MPI_COMM_WORLD,&ts); - TSSetMaxSteps(ts,sim[0].solver.n_iter); - TSSetMaxTime(ts,sim[0].solver.dt*sim[0].solver.n_iter); - TSSetTimeStep(ts,sim[0].solver.dt); - TSSetTime(ts,context.waqt); + TSSetMaxSteps(ts,sim[0].solver.m_n_iter); + TSSetMaxTime(ts,sim[0].solver.m_dt*sim[0].solver.m_n_iter); + TSSetTimeStep(ts,sim[0].solver.m_dt); + TSSetTime(ts,context.m_waqt); TSSetExactFinalTime(ts,TS_EXACTFINALTIME_MATCHSTEP); TSSetType(ts,TSBEULER); @@ -166,7 +166,7 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj #ifdef with_librom TSAdaptGetType(adapt,&adapt_type); if (strcmp(adapt_type, TSADAPTNONE)) { - if (!rank) printf("Warning: libROM interface not yet implemented for adaptive timestepping.\n"); + if (!a_rank) printf("Warning: libROM interface not yet implemented for adaptive timestepping.\n"); } #endif @@ -189,15 +189,15 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj SNESGetType(snes,&snestype); #ifdef with_librom - if (context.rom_mode == _ROM_MODE_INITIAL_GUESS_) { + if (context.m_rom_mode == _ROM_MODE_INITIAL_GUESS_) { SNESSetComputeInitialGuess(snes, PetscSetInitialGuessROM, &context); } #endif - context.flag_use_precon = 0; + context.m_flag_use_precon = 0; PetscOptionsGetBool( nullptr,nullptr, "-with_pc", - (PetscBool*)(&context.flag_use_precon), + (PetscBool*)(&context.m_flag_use_precon), nullptr ); char precon_mat_type_c_st[_MAX_STRING_SIZE_] = "default"; @@ -207,38 +207,38 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj precon_mat_type_c_st, _MAX_STRING_SIZE_, nullptr ); - context.precon_matrix_type = std::string(precon_mat_type_c_st); + context.m_precon_matrix_type = std::string(precon_mat_type_c_st); - if (context.flag_use_precon) { + if (context.m_flag_use_precon) { - if (context.precon_matrix_type == "default") { + if (context.m_precon_matrix_type == "default") { /* Matrix-free representation of the Jacobian */ flag_mat_a = 1; MatCreateShell( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, &context, &A); if ((!strcmp(snestype,SNESKSPONLY)) || (ptype == TS_LINEAR)) { /* linear problem */ - context.flag_is_linear = 1; + context.m_flag_is_linear = 1; MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunctionIMEX_Linear); SNESSetType(snes,SNESKSPONLY); } else { /* nonlinear problem */ - context.flag_is_linear = 0; - context.jfnk_eps = 1e-7; - PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.jfnk_eps,NULL); + context.m_flag_is_linear = 0; + context.m_jfnk_eps = 1e-7; + PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.m_jfnk_eps,NULL); MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunctionIMEX_JFNK); } MatSetUp(A); /* check if Jacobian of the physical model is defined */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { if ((!sim[ns].solver.JFunction) && (!sim[ns].solver.KFunction)) { - if (!rank) { + if (!a_rank) { fprintf(stderr,"Error in SolvePETSc(): solver->JFunction or solver->KFunction "); fprintf(stderr,"(point-wise Jacobians for hyperbolic or parabolic terms) must "); fprintf(stderr,"be defined for preconditioning.\n"); @@ -249,35 +249,35 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* Set up preconditioner matrix */ flag_mat_b = 1; MatCreateAIJ( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, - (sim[0].solver.ndims*2+1)*sim[0].solver.nvars, NULL, - 2*sim[0].solver.ndims*sim[0].solver.nvars, NULL, + (sim[0].solver.m_ndims*2+1)*sim[0].solver.m_nvars, NULL, + 2*sim[0].solver.m_ndims*sim[0].solver.m_nvars, NULL, &B ); - MatSetBlockSize(B,sim[0].solver.nvars); + MatSetBlockSize(B,sim[0].solver.m_nvars); /* Set the IJacobian function for TS */ TSSetIJacobian(ts,A,B,PetscIJacobianIMEX,&context); - } else if (context.precon_matrix_type == "fd") { + } else if (context.m_precon_matrix_type == "fd") { flag_mat_a = 1; MatCreateSNESMF(snes,&A); flag_mat_b = 1; MatCreateAIJ( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, - (sim[0].solver.ndims*2+1)*sim[0].solver.nvars, NULL, - 2*sim[0].solver.ndims*sim[0].solver.nvars, NULL, + (sim[0].solver.m_ndims*2+1)*sim[0].solver.m_nvars, NULL, + 2*sim[0].solver.m_ndims*sim[0].solver.m_nvars, NULL, &B); MatSetOption(B, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); /* Set the Jacobian function for SNES */ SNESSetJacobian(snes, A, B, SNESComputeJacobianDefault, NULL); - } else if (context.precon_matrix_type == "colored_fd") { + } else if (context.m_precon_matrix_type == "colored_fd") { int stencil_width = 1; PetscOptionsGetInt( NULL, @@ -290,15 +290,15 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj MatCreateSNESMF(snes,&A); flag_mat_b = 1; MatCreateAIJ( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, - (sim[0].solver.ndims*2+1)*sim[0].solver.nvars, NULL, - 2*sim[0].solver.ndims*sim[0].solver.nvars, NULL, + (sim[0].solver.m_ndims*2+1)*sim[0].solver.m_nvars, NULL, + 2*sim[0].solver.m_ndims*sim[0].solver.m_nvars, NULL, &B); MatSetOption(B, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); - if (!rank) { + if (!a_rank) { printf("PETSc: Setting Jacobian non-zero pattern (stencil width %d).\n", stencil_width ); } @@ -309,9 +309,9 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj } else { - if (!rank) { + if (!a_rank) { fprintf( stderr,"Invalid input for \"-pc_matrix_type\": %s.\n", - context.precon_matrix_type.c_str()); + context.m_precon_matrix_type.c_str()); } PetscFunctionReturn(0); @@ -326,22 +326,22 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* Matrix-free representation of the Jacobian */ flag_mat_a = 1; MatCreateShell( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, &context, &A); if ((!strcmp(snestype,SNESKSPONLY)) || (ptype == TS_LINEAR)) { /* linear problem */ - context.flag_is_linear = 1; + context.m_flag_is_linear = 1; MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunctionIMEX_Linear); SNESSetType(snes,SNESKSPONLY); } else { /* nonlinear problem */ - context.flag_is_linear = 0; - context.jfnk_eps = 1e-7; - PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.jfnk_eps,NULL); + context.m_flag_is_linear = 0; + context.m_jfnk_eps = 1e-7; + PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.m_jfnk_eps,NULL); MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunctionIMEX_JFNK); } MatSetUp(A); @@ -357,78 +357,78 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* default -> hyperbolic - explicit, parabolic and source - implicit */ PetscBool flag = PETSC_FALSE; - context.flag_hyperbolic = _EXPLICIT_; - context.flag_hyperbolic_f = _EXPLICIT_; - context.flag_hyperbolic_df = _IMPLICIT_; - context.flag_parabolic = _IMPLICIT_; - context.flag_source = _IMPLICIT_; + context.m_flag_hyperbolic = _EXPLICIT_; + context.m_flag_hyperbolic_f = _EXPLICIT_; + context.m_flag_hyperbolic_df = _IMPLICIT_; + context.m_flag_parabolic = _IMPLICIT_; + context.m_flag_source = _IMPLICIT_; - if (!strcmp(sim[0].solver.SplitHyperbolicFlux,"yes")) { + if (!strcmp(sim[0].solver.m_split_hyperbolic_flux,"yes")) { flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-hyperbolic_f_explicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_hyperbolic_f = _EXPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_hyperbolic_f = _EXPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-hyperbolic_f_implicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_hyperbolic_f = _IMPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_hyperbolic_f = _IMPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-hyperbolic_df_explicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_hyperbolic_df = _EXPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_hyperbolic_df = _EXPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-hyperbolic_df_implicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_hyperbolic_df = _IMPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_hyperbolic_df = _IMPLICIT_; } else { flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-hyperbolic_explicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_hyperbolic = _EXPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_hyperbolic = _EXPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-hyperbolic_implicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_hyperbolic = _IMPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_hyperbolic = _IMPLICIT_; } flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-parabolic_explicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_parabolic = _EXPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_parabolic = _EXPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-parabolic_implicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_parabolic = _IMPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_parabolic = _IMPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-source_explicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_source = _EXPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_source = _EXPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-source_implicit",&flag,nullptr); - if (flag == PETSC_TRUE) context.flag_source = _IMPLICIT_; + if (flag == PETSC_TRUE) context.m_flag_source = _IMPLICIT_; flag = PETSC_FALSE; PetscOptionsGetBool(nullptr,nullptr,"-ts_arkimex_fully_implicit",&flag,nullptr); if (flag == PETSC_TRUE) { - context.flag_hyperbolic_f = _IMPLICIT_; - context.flag_hyperbolic_df = _IMPLICIT_; - context.flag_hyperbolic = _IMPLICIT_; - context.flag_parabolic = _IMPLICIT_; - context.flag_source = _IMPLICIT_; + context.m_flag_hyperbolic_f = _IMPLICIT_; + context.m_flag_hyperbolic_df = _IMPLICIT_; + context.m_flag_hyperbolic = _IMPLICIT_; + context.m_flag_parabolic = _IMPLICIT_; + context.m_flag_source = _IMPLICIT_; } /* print out a summary of the treatment of each term */ - if (!rank) { + if (!a_rank) { printf("Implicit-Explicit time-integration:-\n"); - if (!strcmp(sim[0].solver.SplitHyperbolicFlux,"yes")) { - if (context.flag_hyperbolic_f == _EXPLICIT_) printf("Hyperbolic (f-df) term: Explicit\n"); + if (!strcmp(sim[0].solver.m_split_hyperbolic_flux,"yes")) { + if (context.m_flag_hyperbolic_f == _EXPLICIT_) printf("Hyperbolic (f-df) term: Explicit\n"); else printf("Hyperbolic (f-df) term: Implicit\n"); - if (context.flag_hyperbolic_df == _EXPLICIT_) printf("Hyperbolic (df) term: Explicit\n"); + if (context.m_flag_hyperbolic_df == _EXPLICIT_) printf("Hyperbolic (df) term: Explicit\n"); else printf("Hyperbolic (df) term: Implicit\n"); } else { - if (context.flag_hyperbolic == _EXPLICIT_) printf("Hyperbolic term: Explicit\n"); + if (context.m_flag_hyperbolic == _EXPLICIT_) printf("Hyperbolic term: Explicit\n"); else printf("Hyperbolic term: Implicit\n"); } - if (context.flag_parabolic == _EXPLICIT_) printf("Parabolic term: Explicit\n"); + if (context.m_flag_parabolic == _EXPLICIT_) printf("Parabolic term: Explicit\n"); else printf("Parabolic term: Implicit\n"); - if (context.flag_source == _EXPLICIT_) printf("Source term: Explicit\n"); + if (context.m_flag_source == _EXPLICIT_) printf("Source term: Explicit\n"); else printf("Source term: Implicit\n"); } @@ -455,16 +455,16 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj SNESGetType(snes,&snestype); #ifdef with_librom - if (context.rom_mode == _ROM_MODE_INITIAL_GUESS_) { + if (context.m_rom_mode == _ROM_MODE_INITIAL_GUESS_) { SNESSetComputeInitialGuess(snes, PetscSetInitialGuessROM, &context); } #endif - context.flag_use_precon = 0; + context.m_flag_use_precon = 0; PetscOptionsGetBool( nullptr, nullptr, "-with_pc", - (PetscBool*)(&context.flag_use_precon), + (PetscBool*)(&context.m_flag_use_precon), nullptr ); char precon_mat_type_c_st[_MAX_STRING_SIZE_] = "default"; @@ -474,38 +474,38 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj precon_mat_type_c_st, _MAX_STRING_SIZE_, nullptr ); - context.precon_matrix_type = std::string(precon_mat_type_c_st); + context.m_precon_matrix_type = std::string(precon_mat_type_c_st); - if (context.flag_use_precon) { + if (context.m_flag_use_precon) { - if (context.precon_matrix_type == "default") { + if (context.m_precon_matrix_type == "default") { /* Matrix-free representation of the Jacobian */ flag_mat_a = 1; MatCreateShell( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, &context, &A); if ((!strcmp(snestype,SNESKSPONLY)) || (ptype == TS_LINEAR)) { /* linear problem */ - context.flag_is_linear = 1; + context.m_flag_is_linear = 1; MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunction_Linear); SNESSetType(snes,SNESKSPONLY); } else { /* nonlinear problem */ - context.flag_is_linear = 0; - context.jfnk_eps = 1e-7; - PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.jfnk_eps,NULL); + context.m_flag_is_linear = 0; + context.m_jfnk_eps = 1e-7; + PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.m_jfnk_eps,NULL); MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunction_JFNK); } MatSetUp(A); /* check if Jacobian of the physical model is defined */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { if ((!sim[ns].solver.JFunction) && (!sim[ns].solver.KFunction)) { - if (!rank) { + if (!a_rank) { fprintf(stderr,"Error in SolvePETSc(): solver->JFunction or solver->KFunction "); fprintf(stderr,"(point-wise Jacobians for hyperbolic or parabolic terms) must "); fprintf(stderr,"be defined for preconditioning.\n"); @@ -516,35 +516,35 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* Set up preconditioner matrix */ flag_mat_b = 1; MatCreateAIJ( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, - (sim[0].solver.ndims*2+1)*sim[0].solver.nvars, NULL, - 2*sim[0].solver.ndims*sim[0].solver.nvars, NULL, + (sim[0].solver.m_ndims*2+1)*sim[0].solver.m_nvars, NULL, + 2*sim[0].solver.m_ndims*sim[0].solver.m_nvars, NULL, &B ); - MatSetBlockSize(B,sim[0].solver.nvars); + MatSetBlockSize(B,sim[0].solver.m_nvars); /* Set the IJacobian function for TS */ TSSetIJacobian(ts,A,B,PetscIJacobian,&context); - } else if (context.precon_matrix_type == "fd") { + } else if (context.m_precon_matrix_type == "fd") { flag_mat_a = 1; MatCreateSNESMF(snes,&A); flag_mat_b = 1; MatCreateAIJ( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, - (sim[0].solver.ndims*2+1)*sim[0].solver.nvars, NULL, - 2*sim[0].solver.ndims*sim[0].solver.nvars, NULL, + (sim[0].solver.m_ndims*2+1)*sim[0].solver.m_nvars, NULL, + 2*sim[0].solver.m_ndims*sim[0].solver.m_nvars, NULL, &B); MatSetOption(B, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); /* Set the Jacobian function for SNES */ SNESSetJacobian(snes, A, B, SNESComputeJacobianDefault, NULL); - } else if (context.precon_matrix_type == "colored_fd") { + } else if (context.m_precon_matrix_type == "colored_fd") { int stencil_width = 1; PetscOptionsGetInt( NULL, @@ -557,15 +557,15 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj MatCreateSNESMF(snes,&A); flag_mat_b = 1; MatCreateAIJ( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, - (sim[0].solver.ndims*2+1)*sim[0].solver.nvars, NULL, - 2*sim[0].solver.ndims*sim[0].solver.nvars, NULL, + (sim[0].solver.m_ndims*2+1)*sim[0].solver.m_nvars, NULL, + 2*sim[0].solver.m_ndims*sim[0].solver.m_nvars, NULL, &B); MatSetOption(B, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE); - if (!rank) { + if (!a_rank) { printf("PETSc: Setting Jacobian non-zero pattern (stencil width %d).\n", stencil_width ); } @@ -576,9 +576,9 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj } else { - if (!rank) { + if (!a_rank) { fprintf( stderr,"Invalid input for \"-pc_matrix_type\": %s.\n", - context.precon_matrix_type.c_str()); + context.m_precon_matrix_type.c_str()); } PetscFunctionReturn(0); @@ -593,22 +593,22 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* Matrix-free representation of the Jacobian */ flag_mat_a = 1; MatCreateShell( MPI_COMM_WORLD, - context.ndofs, - context.ndofs, + context.m_ndofs, + context.m_ndofs, PETSC_DETERMINE, PETSC_DETERMINE, &context, &A); if ((!strcmp(snestype,SNESKSPONLY)) || (ptype == TS_LINEAR)) { /* linear problem */ - context.flag_is_linear = 1; + context.m_flag_is_linear = 1; MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunction_Linear); SNESSetType(snes,SNESKSPONLY); } else { /* nonlinear problem */ - context.flag_is_linear = 0; - context.jfnk_eps = 1e-7; - PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.jfnk_eps,NULL); + context.m_flag_is_linear = 0; + context.m_jfnk_eps = 1e-7; + PetscOptionsGetReal(NULL,NULL,"-jfnk_epsilon",&context.m_jfnk_eps,NULL); MatShellSetOperation(A,MATOP_MULT,(void (*)(void))PetscJacobianFunction_JFNK); } MatSetUp(A); @@ -622,7 +622,7 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj } else { - if (!rank) { + if (!a_rank) { fprintf(stderr, "Time integration type %s is not yet supported.\n", time_scheme); } PetscFunctionReturn(0); @@ -641,22 +641,22 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj /* Set application context */ TSSetApplicationContext(ts,&context); - if (!rank) { - if (context.flag_is_linear) printf("SolvePETSc(): Problem type is linear.\n"); + if (!a_rank) { + if (context.m_flag_is_linear) printf("SolvePETSc(): Problem type is linear.\n"); else printf("SolvePETSc(): Problem type is nonlinear.\n"); } - if (!rank) printf("** Starting PETSc time integration **\n"); - context.ti_runtime = 0.0; + if (!a_rank) printf("** Starting PETSc time integration **\n"); + context.m_ti_runtime = 0.0; TSSolve(ts,Y); - if (!rank) { + if (!a_rank) { printf("** Completed PETSc time integration (Final time: %f), total wctime: %f (seconds) **\n", - context.waqt, context.ti_runtime ); + context.m_waqt, context.m_ti_runtime ); } /* Get the number of time steps */ - for (int ns = 0; ns < nsims; ns++) { - TSGetStepNumber(ts,&(sim[ns].solver.n_iter)); + for (int ns = 0; ns < a_nsims; ns++) { + TSGetStepNumber(ts,&(sim[ns].solver.m_n_iter)); } /* get and write to file any auxiliary solutions */ @@ -664,19 +664,19 @@ int SolvePETSc( void* s, /*!< Array of simulation objects of type #SimulationObj TSGetSolutionComponents(ts,&iAuxSize,NULL); if (iAuxSize) { if (iAuxSize > 10) iAuxSize = 10; - if (!rank) printf("Number of auxiliary solutions from time integration: %d\n",iAuxSize); + if (!a_rank) printf("Number of auxiliary solutions from time integration: %d\n",iAuxSize); VecDuplicate(Y,&Z); for (i=0; iPhysicsOutput) { - solver->PhysicsOutput(solver,mpi, context.waqt); + solver->PhysicsOutput(solver,mpi, context.m_waqt); } CalculateError(solver,mpi); } - OutputSolution(sim, nsims, context.waqt); + OutputSolution(sim, a_nsims, context.m_waqt); } /* calculate error if exact solution has been provided */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { CalculateError(&(sim[ns].solver), &(sim[ns].mpi)); } PetscCleanup(&context); #ifdef with_librom - context.op_times_arr.push_back(context.waqt); + context.m_op_times_arr.push_back(context.m_waqt); - for (int ns = 0; ns < nsims; ns++) { - ResetFilenameIndex( sim[ns].solver.filename_index, - sim[ns].solver.index_length ); + for (int ns = 0; ns < a_nsims; ns++) { + ResetFilenameIndex( sim[ns].solver.m_filename_index, + sim[ns].solver.m_index_length ); } - if (((libROMInterface*)context.rom_interface)->mode() == _ROM_MODE_TRAIN_) { + if (((libROMInterface*)context.m_rom_interface)->mode() == _ROM_MODE_TRAIN_) { - ((libROMInterface*)context.rom_interface)->train(); - if (!rank) printf("libROM: total training wallclock time: %f (seconds).\n", - ((libROMInterface*)context.rom_interface)->trainWallclockTime() ); + ((libROMInterface*)context.m_rom_interface)->train(); + if (!a_rank) printf("libROM: total training wallclock time: %f (seconds).\n", + ((libROMInterface*)context.m_rom_interface)->trainWallclockTime() ); double total_rom_predict_time = 0; - for (int iter = 0; iter < context.op_times_arr.size(); iter++) { + for (int iter = 0; iter < context.m_op_times_arr.size(); iter++) { - double waqt = context.op_times_arr[iter]; + double waqt = context.m_op_times_arr[iter]; - ((libROMInterface*)context.rom_interface)->predict(sim, waqt); - if (!rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", - waqt, ((libROMInterface*)context.rom_interface)->predictWallclockTime() ); - total_rom_predict_time += ((libROMInterface*)context.rom_interface)->predictWallclockTime(); + ((libROMInterface*)context.m_rom_interface)->predict(sim, waqt); + if (!a_rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", + waqt, ((libROMInterface*)context.m_rom_interface)->predictWallclockTime() ); + total_rom_predict_time += ((libROMInterface*)context.m_rom_interface)->predictWallclockTime(); /* calculate diff between ROM and PDE solutions */ - if (iter == (context.op_times_arr.size()-1)) { - if (!rank) printf("libROM: Calculating diff between PDE and ROM solutions.\n"); - for (int ns = 0; ns < nsims; ns++) { + if (iter == (context.m_op_times_arr.size()-1)) { + if (!a_rank) printf("libROM: Calculating diff between PDE and ROM solutions.\n"); + for (int ns = 0; ns < a_nsims; ns++) { CalculateROMDiff( &(sim[ns].solver), &(sim[ns].mpi) ); } } /* write the ROM solution to file */ - OutputROMSolution(sim, nsims, waqt); + OutputROMSolution(sim, a_nsims, waqt); } - if (!rank) { + if (!a_rank) { printf( "libROM: total prediction/query wallclock time: %f (seconds).\n", total_rom_predict_time ); } - ((libROMInterface*)context.rom_interface)->saveROM(); + ((libROMInterface*)context.m_rom_interface)->saveROM(); } else { - for (int ns = 0; ns < nsims; ns++) { - sim[ns].solver.rom_diff_norms[0] - = sim[ns].solver.rom_diff_norms[1] - = sim[ns].solver.rom_diff_norms[2] + for (int ns = 0; ns < a_nsims; ns++) { + sim[ns].solver.m_rom_diff_norms[0] + = sim[ns].solver.m_rom_diff_norms[1] + = sim[ns].solver.m_rom_diff_norms[2] = -1; } } - } else if (context.rom_mode == _ROM_MODE_PREDICT_) { + } else if (context.m_rom_mode == _ROM_MODE_PREDICT_) { - for (int ns = 0; ns < nsims; ns++) { - sim[ns].solver.rom_diff_norms[0] - = sim[ns].solver.rom_diff_norms[1] - = sim[ns].solver.rom_diff_norms[2] + for (int ns = 0; ns < a_nsims; ns++) { + sim[ns].solver.m_rom_diff_norms[0] + = sim[ns].solver.m_rom_diff_norms[1] + = sim[ns].solver.m_rom_diff_norms[2] = -1; - strcpy(sim[ns].solver.ConservationCheck,"no"); + strcpy(sim[ns].solver.m_conservation_check,"no"); } - ((libROMInterface*)context.rom_interface)->loadROM(); - ((libROMInterface*)context.rom_interface)->projectInitialSolution(sim); + ((libROMInterface*)context.m_rom_interface)->loadROM(); + ((libROMInterface*)context.m_rom_interface)->projectInitialSolution(sim); { - int start_iter = sim[0].solver.restart_iter; - int n_iter = sim[0].solver.n_iter; - double dt = sim[0].solver.dt; + int start_iter = sim[0].solver.m_restart_iter; + int n_iter = sim[0].solver.m_n_iter; + double dt = sim[0].solver.m_dt; double cur_time = start_iter * dt; - context.op_times_arr.push_back(cur_time); + context.m_op_times_arr.push_back(cur_time); for (int iter = start_iter; iter < n_iter; iter++) { cur_time += dt; - if ( ( (iter+1)%sim[0].solver.file_op_iter == 0) + if ( ( (iter+1)%sim[0].solver.m_file_op_iter == 0) && ( (iter+1) < n_iter) ) { - context.op_times_arr.push_back(cur_time); + context.m_op_times_arr.push_back(cur_time); } } double t_final = n_iter*dt; - context.op_times_arr.push_back(t_final); + context.m_op_times_arr.push_back(t_final); } double total_rom_predict_time = 0; - for (int iter = 0; iter < context.op_times_arr.size(); iter++) { + for (int iter = 0; iter < context.m_op_times_arr.size(); iter++) { - double waqt = context.op_times_arr[iter]; + double waqt = context.m_op_times_arr[iter]; - ((libROMInterface*)context.rom_interface)->predict(sim, waqt); - if (!rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", - waqt, ((libROMInterface*)context.rom_interface)->predictWallclockTime() ); - total_rom_predict_time += ((libROMInterface*)context.rom_interface)->predictWallclockTime(); + ((libROMInterface*)context.m_rom_interface)->predict(sim, waqt); + if (!a_rank) printf( "libROM: Predicted solution at time %1.4e using ROM, wallclock time: %f.\n", + waqt, ((libROMInterface*)context.m_rom_interface)->predictWallclockTime() ); + total_rom_predict_time += ((libROMInterface*)context.m_rom_interface)->predictWallclockTime(); /* write the solution to file */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { if (sim[ns].solver.PhysicsOutput) { sim[ns].solver.PhysicsOutput( &(sim[ns].solver), &(sim[ns].mpi), waqt ); } } - OutputSolution(sim, nsims, waqt); + OutputSolution(sim, a_nsims, waqt); } /* calculate error if exact solution has been provided */ - for (int ns = 0; ns < nsims; ns++) { + for (int ns = 0; ns < a_nsims; ns++) { CalculateError(&(sim[ns].solver), &(sim[ns].mpi) ); } - if (!rank) { + if (!a_rank) { printf( "libROM: total prediction/query wallclock time: %f (seconds).\n", total_rom_predict_time ); } } - delete ((libROMInterface*)context.rom_interface); + delete ((libROMInterface*)context.m_rom_interface); #endif PetscFunctionReturn(0); diff --git a/src/Simulation/WriteInputs.c b/src/Simulation/WriteInputs.c index ec5f5fdb..d48814c5 100644 --- a/src/Simulation/WriteInputs.c +++ b/src/Simulation/WriteInputs.c @@ -12,100 +12,100 @@ #include /*! Write the simulation inputs read from the file \b solver.inp. */ -int WriteInputs ( void *s, /*!< Array of simulation objects of type #SimulationObject +int WriteInputs ( void *a_s, /*!< Array of simulation objects of type #SimulationObject of size nsims */ - int nsims, /*!< Number of simulation objects */ - int rank /*!< MPI rank of this process */ + int a_nsims, /*!< Number of simulation objects */ + int a_rank /*!< MPI rank of this process */ ) { - SimulationObject *sim = (SimulationObject*) s; + SimulationObject *sim = (SimulationObject*) a_s; int n; if (sim == NULL) return 0; - if (!rank) { + if (!a_rank) { - printf(" No. of dimensions : %d\n",sim[0].solver.ndims); - printf(" No. of variables : %d\n",sim[0].solver.nvars); - if (nsims > 1) { + printf(" No. of dimensions : %d\n",sim[0].solver.m_ndims); + printf(" No. of variables : %d\n",sim[0].solver.m_nvars); + if (a_nsims > 1) { printf(" Domain sizes:\n"); - for (int n = 0; n < nsims; n++) { + for (int n = 0; n < a_nsims; n++) { printf(" domain %3d - ", n); - for (int i=0; isolver); MPIVariables* mpi = &(m_sim_fg->mpi); - long size = solver->nvars * solver->npoints_local_wghosts; + long size = solver->m_nvars * solver->m_npoints_local_wghosts; uex = (double*) calloc (size, sizeof(double)); char fname_root[_MAX_STRING_SIZE_] = "exact"; @@ -44,14 +44,14 @@ void SparseGridsSimulation::CalculateError() /* No exact solution available */ for (int n=0; nsolver.error[0] - = m_sim_fg->solver.error[1] - = m_sim_fg->solver.error[2] + m_sim_fg->solver.m_error[0] + = m_sim_fg->solver.m_error[1] + = m_sim_fg->solver.m_error[2] = -1; } else { @@ -64,8 +64,8 @@ void SparseGridsSimulation::CalculateError() double *uex2 = NULL; if (m_print_sg_errors == 1) { - long size = m_sim_fg->solver.nvars - * m_sim_fg->solver.npoints_local_wghosts; + long size = m_sim_fg->solver.m_nvars + * m_sim_fg->solver.m_npoints_local_wghosts; uex2 = (double*) calloc(size, sizeof(double)); _ArrayCopy1D_(uex, uex2, size); } @@ -78,27 +78,27 @@ void SparseGridsSimulation::CalculateError() for (int n = 0; n < m_nsims_sg; n++) { GridDimensions dim_fg(m_ndims,0); - StdVecOps::copyFrom(dim_fg, m_sim_fg->solver.dim_global, m_ndims); + StdVecOps::copyFrom(dim_fg, m_sim_fg->solver.m_dim_global, m_ndims); GridDimensions dim_sg(m_ndims,0); - StdVecOps::copyFrom(dim_sg, m_sims_sg[n].solver.dim_global, m_ndims); + StdVecOps::copyFrom(dim_sg, m_sims_sg[n].solver.m_dim_global, m_ndims); /* assemble the global exact solution on full grid */ double *uex_global_fg = NULL; if (!m_rank) { allocateDataArrays( dim_fg, - m_sim_fg->solver.nvars, + m_sim_fg->solver.m_nvars, &uex_global_fg, - m_sim_fg->solver.ghosts); + m_sim_fg->solver.m_ghosts); } MPIGatherArraynDwGhosts( m_ndims, (void*) &(m_sim_fg->mpi), uex_global_fg, uex2, - m_sim_fg->solver.dim_global, - m_sim_fg->solver.dim_local, - m_sim_fg->solver.ghosts, - m_sim_fg->solver.nvars ); + m_sim_fg->solver.m_dim_global, + m_sim_fg->solver.m_dim_local, + m_sim_fg->solver.m_ghosts, + m_sim_fg->solver.m_nvars ); /* interpolate to sparse grid - * this will delete the full grid array*/ @@ -108,8 +108,8 @@ void SparseGridsSimulation::CalculateError() &uex_global_sg, dim_fg.data(), uex_global_fg, - m_sims_sg[n].solver.nvars, - m_sims_sg[n].solver.ghosts, + m_sims_sg[n].solver.m_nvars, + m_sims_sg[n].solver.m_ghosts, m_ndims, periodic_arr.data() ); if (ierr) { @@ -119,8 +119,8 @@ void SparseGridsSimulation::CalculateError() } /* allocate local exact solution on this sparse grid */ - long size = m_sims_sg[n].solver.nvars - * m_sims_sg[n].solver.npoints_local_wghosts; + long size = m_sims_sg[n].solver.m_nvars + * m_sims_sg[n].solver.m_npoints_local_wghosts; double* uex_sg = (double*) calloc(size, sizeof(double)); /* partition the global exact solution to local on this sparse grid */ @@ -128,10 +128,10 @@ void SparseGridsSimulation::CalculateError() (void*) &(m_sims_sg[n].mpi), (m_rank ? NULL : uex_global_sg), uex_sg, - m_sims_sg[n].solver.dim_global, - m_sims_sg[n].solver.dim_local, - m_sims_sg[n].solver.ghosts, - m_sims_sg[n].solver.nvars ); + m_sims_sg[n].solver.m_dim_global, + m_sims_sg[n].solver.m_dim_local, + m_sims_sg[n].solver.m_ghosts, + m_sims_sg[n].solver.m_nvars ); /* delete the global exact solution array */ if (!m_rank) free(uex_global_sg); @@ -155,7 +155,7 @@ void SparseGridsSimulation::CalculateError() void SparseGridsSimulation::computeError( SimulationObject& a_sim, /*!< Simulation object */ double* const a_uex /*!< Exact solution */ ) { - static const double tolerance = 1e-15; + static const double s_tolerance = 1e-15; HyPar* solver = &(a_sim.solver); MPIVariables* mpi = &(a_sim.mpi); @@ -170,53 +170,53 @@ void SparseGridsSimulation::computeError( SimulationObject& a_sim, /*!< Simulat double sum, global_sum; double solution_norm[3] = {0.0,0.0,0.0}; /* L1 */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,a_uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solution_norm[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,a_uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solution_norm[0] = global_sum/((double)solver->m_npoints_global); /* L2 */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,a_uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solution_norm[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,a_uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solution_norm[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* Linf */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,a_uex); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,a_uex); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); solution_norm[2] = global_sum; /* compute error = difference between exact and numerical solution */ - long size = solver->nvars*solver->npoints_local_wghosts; - _ArrayAXPY_(solver->u,-1.0,a_uex,size); + long size = solver->m_nvars*solver->m_npoints_local_wghosts; + _ArrayAXPY_(solver->m_u,-1.0,a_uex,size); /* calculate L1 norm of error */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,a_uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solver->error[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,a_uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_error[0] = global_sum/((double)solver->m_npoints_global); /* calculate L2 norm of error */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,a_uex); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - solver->error[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,a_uex); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_error[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* calculate Linf norm of error */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,a_uex); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); - solver->error[2] = global_sum; + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,a_uex); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); + solver->m_error[2] = global_sum; /* decide whether to normalize and report relative errors, or report absolute errors. */ - if ( (solution_norm[0] > tolerance) - && (solution_norm[1] > tolerance) - && (solution_norm[2] > tolerance) ) { - solver->error[0] /= solution_norm[0]; - solver->error[1] /= solution_norm[1]; - solver->error[2] /= solution_norm[2]; + if ( (solution_norm[0] > s_tolerance) + && (solution_norm[1] > s_tolerance) + && (solution_norm[2] > s_tolerance) ) { + solver->m_error[0] /= solution_norm[0]; + solver->m_error[1] /= solution_norm[1]; + solver->m_error[2] /= solution_norm[2]; } return; diff --git a/src/SparseGrids/SparseGridsCombinationTechnique.cpp b/src/SparseGrids/SparseGridsCombinationTechnique.cpp index 748d26c4..a2641ed6 100644 --- a/src/SparseGrids/SparseGridsCombinationTechnique.cpp +++ b/src/SparseGrids/SparseGridsCombinationTechnique.cpp @@ -25,7 +25,7 @@ void SparseGridsSimulation::CombinationTechnique(SimulationObject* const a_sim / double** u_sg = (double**) calloc (m_nsims_sg, sizeof(double*)); std::vector coeffs(m_nsims_sg, 0.0); for (int n=0; nsolver.u, + a_sim->solver.m_u, coeffs.data() ); /* done */ diff --git a/src/SparseGrids/SparseGridsDefine.cpp b/src/SparseGrids/SparseGridsDefine.cpp index d92349b1..be47815c 100644 --- a/src/SparseGrids/SparseGridsDefine.cpp +++ b/src/SparseGrids/SparseGridsDefine.cpp @@ -132,11 +132,11 @@ int SparseGridsSimulation::define( int a_rank, /*!< MPI rank of this process */ m_sim_fg = new SimulationObject; /* the following are deliberately set to junk values * to ensure they are never used */ - m_sim_fg->solver.my_idx = -1; - m_sim_fg->solver.nsims = -1; + m_sim_fg->solver.m_my_idx = -1; + m_sim_fg->solver.m_nsims = -1; /* these are okay */ - m_sim_fg->mpi.rank = m_rank; - m_sim_fg->mpi.nproc = m_nproc; + m_sim_fg->mpi.m_rank = m_rank; + m_sim_fg->mpi.m_nproc = m_nproc; if (!m_rank) { printf("Allocated full grid simulation object(s).\n"); diff --git a/src/SparseGrids/SparseGridsFillGhostCells.cpp b/src/SparseGrids/SparseGridsFillGhostCells.cpp index a4ab1921..ec72fd05 100644 --- a/src/SparseGrids/SparseGridsFillGhostCells.cpp +++ b/src/SparseGrids/SparseGridsFillGhostCells.cpp @@ -15,14 +15,14 @@ from the other side of the domain. Otherwise, the interior data is extrapolated by a 4th order polynomial (assuming uniform grid spacing). */ -void SparseGridsSimulation::fillGhostCells( const GridDimensions& a_dim, /*!< grid dimensions of solution */ +void SparseGridsSimulation::FillGhostCells( const GridDimensions& a_dim, /*!< grid dimensions of solution */ const int a_ngpt, /*!< number of ghost cells */ double* const a_u, /*!< solution array */ const int a_nvars /*!< number of vector components of the solution */ ) { if (m_is_periodic.size() != m_ndims) { - fprintf(stderr, "Error in SparseGridsSimulation::fillGhostCells() -\n"); + fprintf(stderr, "Error in SparseGridsSimulation::FillGhostCells() -\n"); fprintf(stderr, "m_is_periodic.size() != m_ndims \n"); exit(1); } @@ -119,15 +119,15 @@ void SparseGridsSimulation::fillGhostCells( const GridDimensions& a_dim, /*!< gr double alpha = - (double) (a_ngpt - index[d]); double c0 = -((-2.0 + alpha)*(-1.0 + alpha)*alpha)/6.0; - double c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; - double c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; + double s_c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; + double s_c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; double c3 = (alpha*(-1.0 + alpha*alpha))/6.0; for (int v = 0; v < a_nvars; v++) { a_u[p_gpt*a_nvars+v] = c0 * a_u[p_int_0*a_nvars+v] - + c1 * a_u[p_int_1*a_nvars+v] - + c2 * a_u[p_int_2*a_nvars+v] + + s_c1 * a_u[p_int_1*a_nvars+v] + + s_c2 * a_u[p_int_2*a_nvars+v] + c3 * a_u[p_int_3*a_nvars+v]; } @@ -162,15 +162,15 @@ void SparseGridsSimulation::fillGhostCells( const GridDimensions& a_dim, /*!< gr double alpha = - (double) (index[d]+1); double c0 = -((-2.0 + alpha)*(-1.0 + alpha)*alpha)/6.0; - double c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; - double c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; + double s_c1 = ((-2.0 + alpha)*(-1.0 + alpha)*(1.0 + alpha))/2.0; + double s_c2 = (alpha*(2.0 + alpha - alpha*alpha))/2.0; double c3 = (alpha*(-1.0 + alpha*alpha))/6.0; for (int v = 0; v < a_nvars; v++) { a_u[p_gpt*a_nvars+v] = c0 * a_u[p_int_0*a_nvars+v] - + c1 * a_u[p_int_1*a_nvars+v] - + c2 * a_u[p_int_2*a_nvars+v] + + s_c1 * a_u[p_int_1*a_nvars+v] + + s_c2 * a_u[p_int_2*a_nvars+v] + c3 * a_u[p_int_3*a_nvars+v]; } diff --git a/src/SparseGrids/SparseGridsInitialSolution.cpp b/src/SparseGrids/SparseGridsInitialSolution.cpp index 112c9327..79d07863 100644 --- a/src/SparseGrids/SparseGridsInitialSolution.cpp +++ b/src/SparseGrids/SparseGridsInitialSolution.cpp @@ -33,18 +33,18 @@ int SparseGridsSimulation::InitialSolution() HyPar* solver = &(m_sims_sg[n].solver); MPIVariables* mpi = &(m_sims_sg[n].mpi); - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim_local = solver->dim_local; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim_local = solver->m_dim_local; /* calculate dxinv */ { int offset = 0; for (int d = 0; d < m_ndims; d++) { for (int i = 0; i < dim_local[d]; i++) { - solver->dxinv[i+offset+ghosts] - = 2.0 / ( solver->x[i+1+offset+ghosts] - - solver->x[i-1+offset+ghosts] ); + solver->m_dxinv[i+offset+ghosts] + = 2.0 / ( solver->m_x[i+1+offset+ghosts] + - solver->m_x[i-1+offset+ghosts] ); } offset += (dim_local[d] + 2*ghosts); } @@ -55,7 +55,7 @@ int SparseGridsSimulation::InitialSolution() int offset = 0; for (int d = 0; d < m_ndims; d++) { ierr = MPIExchangeBoundaries1D( mpi, - &(solver->dxinv[offset]), + &(solver->m_dxinv[offset]), dim_local[d], ghosts, d, @@ -69,13 +69,13 @@ int SparseGridsSimulation::InitialSolution() { int offset = 0; for (int d = 0; d < m_ndims; d++) { - double *dxinv = &(solver->dxinv[offset]); + double *dxinv = &(solver->m_dxinv[offset]); int *dim = dim_local; - if (mpi->ip[d] == 0) { + if (mpi->m_ip[d] == 0) { /* fill left boundary along this dimension */ for (int i = 0; i < ghosts; i++) dxinv[i] = dxinv[ghosts]; } - if (mpi->ip[d] == mpi->iproc[d]-1) { + if (mpi->m_ip[d] == mpi->m_iproc[d]-1) { /* fill right boundary along this dimension */ for (int i = dim[d]+ghosts; i < dim[d]+2*ghosts; i++) { dxinv[i] = dxinv[dim[d]+ghosts-1]; diff --git a/src/SparseGrids/SparseGridsInitializationWrapup.cpp b/src/SparseGrids/SparseGridsInitializationWrapup.cpp index f4c655bf..911e0315 100644 --- a/src/SparseGrids/SparseGridsInitializationWrapup.cpp +++ b/src/SparseGrids/SparseGridsInitializationWrapup.cpp @@ -26,9 +26,9 @@ int SparseGridsSimulation::InitializationWrapup() HyPar* solver = &(m_sims_sg[n].solver); MPIVariables* mpi = &(m_sims_sg[n].mpi); - int nvars = solver->nvars; - int ghosts = solver->ghosts; - int *dim_local = solver->dim_local; + int nvars = solver->m_nvars; + int ghosts = solver->m_ghosts; + int *dim_local = solver->m_dim_local; /* exchange MPI-boundary values of u between processors */ MPIExchangeBoundariesnD( m_ndims, @@ -36,24 +36,24 @@ int SparseGridsSimulation::InitializationWrapup() dim_local, ghosts, mpi, - solver->u ); + solver->m_u ); /* calculate volume integral of the initial solution */ - ierr = ::VolumeIntegral(solver->VolumeIntegralInitial, - solver->u, + ierr = ::VolumeIntegral(solver->m_volume_integral_initial, + solver->m_u, solver, mpi ); if (ierr) return ierr; - if (!mpi->rank) { + if (!mpi->m_rank) { printf(" Volume integral of the initial solution on sparse grids domain %d:\n", n); for (int d=0; dVolumeIntegralInitial[d]); + printf(" %2d: %1.16E\n",d,solver->m_volume_integral_initial[d]); } } /* Set initial total boundary flux integral to zero */ - _ArraySetValue_( solver->TotalBoundaryIntegral, nvars, 0 ); + _ArraySetValue_( solver->m_total_boundary_integral, nvars, 0 ); } diff --git a/src/SparseGrids/SparseGridsInitialize.cpp b/src/SparseGrids/SparseGridsInitialize.cpp index 6d0edd08..0716dc3e 100644 --- a/src/SparseGrids/SparseGridsInitialize.cpp +++ b/src/SparseGrids/SparseGridsInitialize.cpp @@ -17,7 +17,7 @@ int SparseGridsSimulation::Initialize() int ierr; /* find out the number of spatial dimensions */ - m_ndims = m_sim_fg->solver.ndims; + m_ndims = m_sim_fg->solver.m_ndims; /* make sure full grid simulation object is allocated */ if (m_sim_fg == NULL) { @@ -29,14 +29,14 @@ int SparseGridsSimulation::Initialize() /* set full grid processor distribution based on grid size and * number of MPI ranks */ GridDimensions dim_fg(m_ndims); - for (int d=0; dsolver.dim_global[d]; + for (int d=0; dsolver.m_dim_global[d]; ProcDistribution iproc_fg; ComputeProcessorDistribution(iproc_fg, dim_fg); - for (int d=0; dmpi.iproc[d] = iproc_fg[d]; - MPIBroadcast_integer( m_sim_fg->mpi.iproc, + for (int d=0; dmpi.m_iproc[d] = iproc_fg[d]; + MPIBroadcast_integer( m_sim_fg->mpi.m_iproc, m_ndims, 0, - &(m_sim_fg->mpi.world)); CHECKERR(ierr); + &(m_sim_fg->mpi.m_world)); CHECKERR(ierr); ::WriteInputs( (void*) m_sim_fg, 1, m_rank); if (!m_rank) { @@ -103,7 +103,7 @@ int SparseGridsSimulation::Initialize() /* set the solver parameters for the sparse grids sim objects */ for (int i = 0; i < m_nsims_sg; i++) { #ifndef serial - MPI_Comm_dup(MPI_COMM_WORLD, &(m_sims_sg[i].mpi.world)); + MPI_Comm_dup(MPI_COMM_WORLD, &(m_sims_sg[i].mpi.m_world)); #endif ierr = SetSolverParameters( m_sims_sg[i], m_combination[i]._dim_, @@ -121,9 +121,9 @@ int SparseGridsSimulation::Initialize() /* compute and report total NDOFs for sparse grids */ long ndof_sg = 0; for (int i = 0; i < m_nsims_sg; i++) { - ndof_sg += m_sims_sg[i].solver.npoints_global; + ndof_sg += m_sims_sg[i].solver.m_npoints_global; } - long ndof_fg = m_sim_fg->solver.npoints_global; + long ndof_fg = m_sim_fg->solver.m_npoints_global; if (!m_rank) { printf("Total number of DOFs:-\n"); printf(" using sparse grids: %d\n", (int)ndof_sg); diff --git a/src/SparseGrids/SparseGridsInterpolate.cpp b/src/SparseGrids/SparseGridsInterpolate.cpp index e94d7308..28543bea 100644 --- a/src/SparseGrids/SparseGridsInterpolate.cpp +++ b/src/SparseGrids/SparseGridsInterpolate.cpp @@ -18,11 +18,11 @@ void SparseGridsSimulation::interpolate( SimulationObject* const a_dst, { /* get the destination grid dimensions */ GridDimensions dim_dst; - StdVecOps::copyFrom(dim_dst, a_dst->solver.dim_global, m_ndims); + StdVecOps::copyFrom(dim_dst, a_dst->solver.m_dim_global, m_ndims); /* get number of vector components */ - int nvars = a_src->solver.nvars; - if (nvars != a_dst->solver.nvars) { + int nvars = a_src->solver.m_nvars; + if (nvars != a_dst->solver.m_nvars) { fprintf(stderr, "Error in SparseGridsSimulation::interpolate(): unequal nvars\n"); exit(1); } @@ -33,11 +33,11 @@ void SparseGridsSimulation::interpolate( SimulationObject* const a_dst, /* partition the destination */ MPIPartitionArraynDwGhosts( m_ndims, (void*) &(a_dst->mpi), - (a_dst->mpi.rank ? NULL : ug_dst), - a_dst->solver.u, - a_dst->solver.dim_global, - a_dst->solver.dim_local, - a_dst->solver.ghosts, + (a_dst->mpi.m_rank ? NULL : ug_dst), + a_dst->solver.m_u, + a_dst->solver.m_dim_global, + a_dst->solver.m_dim_local, + a_dst->solver.m_ghosts, nvars); if (!m_rank) { @@ -73,21 +73,21 @@ void SparseGridsSimulation::interpolate(const GridDimensions& a_dim_dst, /*!< gr /* get the source grid dimensions */ GridDimensions dim_src; - StdVecOps::copyFrom(dim_src, a_src->solver.dim_global, m_ndims); + StdVecOps::copyFrom(dim_src, a_src->solver.m_dim_global, m_ndims); /* get number of vector components and number of ghost points*/ - int nvars = a_src->solver.nvars; - int ghosts = a_src->solver.ghosts; + int nvars = a_src->solver.m_nvars; + int ghosts = a_src->solver.m_ghosts; /* gather the source on rank 0 */ double *ug_src = NULL; - if (!m_rank) allocateDataArrays(dim_src, nvars, &ug_src, ghosts); + if (!m_rank) allocateDataArrays(dim_src, nvars, &ug_src,ghosts); MPIGatherArraynDwGhosts( m_ndims, (void*) &(a_src->mpi), ug_src, - a_src->solver.u, - a_src->solver.dim_global, - a_src->solver.dim_local, + a_src->solver.m_u, + a_src->solver.m_dim_global, + a_src->solver.m_dim_local, ghosts, nvars ); diff --git a/src/SparseGrids/SparseGridsInterpolateGrid.cpp b/src/SparseGrids/SparseGridsInterpolateGrid.cpp index 7677a611..19601fa9 100644 --- a/src/SparseGrids/SparseGridsInterpolateGrid.cpp +++ b/src/SparseGrids/SparseGridsInterpolateGrid.cpp @@ -23,8 +23,8 @@ void SparseGridsSimulation::interpolateGrid ( SimulationObject* const a_ds { /* get the source and destination grid dimensions */ GridDimensions dim_src, dim_dst; - StdVecOps::copyFrom(dim_src, a_src->solver.dim_global, m_ndims); - StdVecOps::copyFrom(dim_dst, a_dst->solver.dim_global, m_ndims); + StdVecOps::copyFrom(dim_src, a_src->solver.m_dim_global, m_ndims); + StdVecOps::copyFrom(dim_dst, a_dst->solver.m_dim_global, m_ndims); /* gather the source on rank 0 */ double* xg_src = NULL; @@ -34,14 +34,14 @@ void SparseGridsSimulation::interpolateGrid ( SimulationObject* const a_ds offset_global = offset_local = 0; for (int d=0; dmpi), - (a_src->mpi.rank ? NULL : &xg_src[offset_global]), - &(a_src->solver.x[offset_local+a_src->solver.ghosts]), - a_src->mpi.is[d], - a_src->mpi.ie[d], - a_src->solver.dim_local[d], + (a_src->mpi.m_rank ? NULL : &xg_src[offset_global]), + &(a_src->solver.m_x[offset_local+a_src->solver.m_ghosts]), + a_src->mpi.m_is[d], + a_src->mpi.m_ie[d], + a_src->solver.m_dim_local[d], 0 ); - offset_global += a_src->solver.dim_global[d]; - offset_local += a_src->solver.dim_local [d] + 2*a_src->solver.ghosts; + offset_global += a_src->solver.m_dim_global[d]; + offset_local += a_src->solver.m_dim_local [d] + 2*a_src->solver.m_ghosts; } } @@ -105,14 +105,14 @@ void SparseGridsSimulation::interpolateGrid ( SimulationObject* const a_ds int offset_global = 0, offset_local = 0; for (int d=0; dmpi), - (a_dst->mpi.rank ? NULL : &xg_dst[offset_global]), - &(a_dst->solver.x[offset_local+a_dst->solver.ghosts]), - a_dst->mpi.is[d], - a_dst->mpi.ie[d], - a_dst->solver.dim_local[d], + (a_dst->mpi.m_rank ? NULL : &xg_dst[offset_global]), + &(a_dst->solver.m_x[offset_local+a_dst->solver.m_ghosts]), + a_dst->mpi.m_is[d], + a_dst->mpi.m_ie[d], + a_dst->solver.m_dim_local[d], 0); - offset_global += a_dst->solver.dim_global[d]; - offset_local += a_dst->solver.dim_local [d] + 2*a_dst->solver.ghosts; + offset_global += a_dst->solver.m_dim_global[d]; + offset_local += a_dst->solver.m_dim_local [d] + 2*a_dst->solver.m_ghosts; } if (!m_rank) { @@ -124,29 +124,29 @@ void SparseGridsSimulation::interpolateGrid ( SimulationObject* const a_ds int offset = 0; for (int d = 0; d < m_ndims; d++) { MPIExchangeBoundaries1D( (void*) &(a_dst->mpi), - &(a_dst->solver.x[offset]), - a_dst->solver.dim_local[d], - a_dst->solver.ghosts, + &(a_dst->solver.m_x[offset]), + a_dst->solver.m_dim_local[d], + a_dst->solver.m_ghosts, d, m_ndims); - offset += (a_dst->solver.dim_local[d] + 2*a_dst->solver.ghosts); + offset += (a_dst->solver.m_dim_local[d] + 2*a_dst->solver.m_ghosts); } } /* fill in ghost values of x at physical boundaries by extrapolation */ { int offset = 0; for (int d = 0; d < m_ndims; d++) { - double* X = &(a_dst->solver.x[offset]); - int* dim = a_dst->solver.dim_local; - int ghosts = a_dst->solver.ghosts; - if (a_dst->mpi.ip[d] == 0) { + double* X = &(a_dst->solver.m_x[offset]); + int* dim = a_dst->solver.m_dim_local; + int ghosts = a_dst->solver.m_ghosts; + if (a_dst->mpi.m_ip[d] == 0) { /* fill left boundary along this dimension */ for (int i = 0; i < ghosts; i++) { int delta = ghosts - i; X[i] = X[ghosts] + ((double) delta) * (X[ghosts]-X[ghosts+1]); } } - if (a_dst->mpi.ip[d] == a_dst->mpi.iproc[d]-1) { + if (a_dst->mpi.m_ip[d] == a_dst->mpi.m_iproc[d]-1) { /* fill right boundary along this dimension */ for (int i = dim[d]+ghosts; i < dim[d]+2*ghosts; i++) { int delta = i - (dim[d]+ghosts-1); diff --git a/src/SparseGrids/SparseGridsMiscFuncs.cpp b/src/SparseGrids/SparseGridsMiscFuncs.cpp index 24944a5b..1d96bbea 100644 --- a/src/SparseGrids/SparseGridsMiscFuncs.cpp +++ b/src/SparseGrids/SparseGridsMiscFuncs.cpp @@ -23,14 +23,14 @@ extern "C" void IncrementFilenameIndex(char*,int); */ int SparseGridsSimulation::ComputeSGDimsAndCoeffs() { - m_n_fg = log2(m_sim_fg->solver.dim_global[0]); + m_n_fg = log2(m_sim_fg->solver.m_dim_global[0]); int d = m_ndims; - double c1 = 1; + double s_c1 = 1; m_combination.clear(); for (int s = 1; s <= d; s++) { - double coeff = c1 * cfunc(d-1,s-1); + double coeff = s_c1 * cfunc(d-1,s-1); std::vector dims(0); GetCTGridSizes((m_n_fg+(m_ndims-1)*(m_imin-1))+d-s, dims); @@ -44,7 +44,7 @@ int SparseGridsSimulation::ComputeSGDimsAndCoeffs() m_combination.push_back(std::pair(coeff,dims[i])); } - c1 *= -1; + s_c1 *= -1; } @@ -155,31 +155,31 @@ int SparseGridsSimulation::CleanupBarebones( SimulationObject *sim /*!< simulati MPIVariables* mpi = &(sim->mpi); /* Free the communicators created */ - IERR MPIFreeCommunicators(solver->ndims,mpi); CHECKERR(ierr); + IERR MPIFreeCommunicators(solver->m_ndims,mpi); CHECKERR(ierr); /* These variables are allocated in Initialize.c */ - free(solver->dim_global); - free(solver->dim_global_ex); - free(solver->dim_local); - free(solver->index); - free(solver->isPeriodic); - free(solver->u); - free(solver->x); - free(solver->dxinv); - free(mpi->iproc); - free(mpi->ip); - free(mpi->is); - free(mpi->ie); - free(mpi->bcperiodic); - free(mpi->sendbuf); - free(mpi->recvbuf); - free(solver->VolumeIntegral); - free(solver->VolumeIntegralInitial); - free(solver->TotalBoundaryIntegral); - free(solver->ConservationError); - free(solver->stride_with_ghosts); - free(solver->stride_without_ghosts); - if (solver->filename_index) free(solver->filename_index); + free(solver->m_dim_global); + free(solver->m_dim_global_ex); + free(solver->m_dim_local); + free(solver->m_index); + free(solver->m_is_periodic); + free(solver->m_u); + free(solver->m_x); + free(solver->m_dxinv); + free(mpi->m_iproc); + free(mpi->m_ip); + free(mpi->m_is); + free(mpi->m_ie); + free(mpi->m_bcperiodic); + free(mpi->m_sendbuf); + free(mpi->m_recvbuf); + free(solver->m_volume_integral); + free(solver->m_volume_integral_initial); + free(solver->m_total_boundary_integral); + free(solver->m_conservation_error); + free(solver->m_stride_with_ghosts); + free(solver->m_stride_without_ghosts); + if (solver->m_filename_index) free(solver->m_filename_index); return(0); } @@ -200,38 +200,38 @@ int SparseGridsSimulation::InitializeBarebones( SimulationObject *simobj /*!< si MPIVariables* mpi = &(simobj->mpi); /* allocations */ - mpi->ip = (int*) calloc (m_ndims,sizeof(int)); - mpi->is = (int*) calloc (m_ndims,sizeof(int)); - mpi->ie = (int*) calloc (m_ndims,sizeof(int)); - mpi->bcperiodic = (int*) calloc (m_ndims,sizeof(int)); - solver->dim_local = (int*) calloc (m_ndims,sizeof(int)); - solver->isPeriodic = (int*) calloc (m_ndims,sizeof(int)); + mpi->m_ip = (int*) calloc (m_ndims,sizeof(int)); + mpi->m_is = (int*) calloc (m_ndims,sizeof(int)); + mpi->m_ie = (int*) calloc (m_ndims,sizeof(int)); + mpi->m_bcperiodic = (int*) calloc (m_ndims,sizeof(int)); + solver->m_dim_local = (int*) calloc (m_ndims,sizeof(int)); + solver->m_is_periodic = (int*) calloc (m_ndims,sizeof(int)); #ifndef serial /* Domain partitioning */ int total_proc = 1; - for (int i=0; iiproc[i]; + for (int i=0; im_iproc[i]; /* calculate ndims-D rank of each process (ip[]) from rank in MPI_COMM_WORLD */ IERR MPIRanknD( m_ndims, m_rank, - mpi->iproc, - mpi->ip ); CHECKERR(ierr); + mpi->m_iproc, + mpi->m_ip ); CHECKERR(ierr); /* calculate local domain sizes along each dimension */ for (int i=0; idim_local[i] = MPIPartition1D( solver->dim_global[i], - mpi->iproc[i], - mpi->ip[i] ); + solver->m_dim_local[i] = MPIPartition1D( solver->m_dim_global[i], + mpi->m_iproc[i], + mpi->m_ip[i] ); } /* calculate local domain limits in terms of global domain */ IERR MPILocalDomainLimits( m_ndims, m_rank, &(simobj->mpi), - solver->dim_global, - mpi->is, - mpi->ie ); + solver->m_dim_global, + mpi->m_is, + mpi->m_ie ); CHECKERR(ierr); /* create sub-communicators for parallel computations @@ -239,7 +239,7 @@ int SparseGridsSimulation::InitializeBarebones( SimulationObject *simobj /*!< si IERR MPICreateCommunicators(m_ndims,&(simobj->mpi)); CHECKERR(ierr); /* initialize periodic BC flags to zero */ - for (int i=0; indims; i++) mpi->bcperiodic[i] = 0; + for (int i=0; im_ndims; i++) mpi->m_bcperiodic[i] = 0; /* create communication groups */ IERR MPICreateIOGroups(&(simobj->mpi)); CHECKERR(ierr); @@ -247,73 +247,73 @@ int SparseGridsSimulation::InitializeBarebones( SimulationObject *simobj /*!< si #else for (int i=0; iip[i] = 0; - solver->dim_local[i] = solver->dim_global[i]; - mpi->iproc[i] = 1; - mpi->is[i] = 0; - mpi->ie[i] = solver->dim_local[i]; - mpi->bcperiodic[i] = 0; + mpi->m_ip[i] = 0; + solver->m_dim_local[i] = solver->m_dim_global[i]; + mpi->m_iproc[i] = 1; + mpi->m_is[i] = 0; + mpi->m_ie[i] = solver->m_dim_local[i]; + mpi->m_bcperiodic[i] = 0; } #endif - solver->npoints_global - = solver->npoints_local - = solver->npoints_local_wghosts + solver->m_npoints_global + = solver->m_npoints_local + = solver->m_npoints_local_wghosts = 1; for (int i=0; inpoints_global *= solver->dim_global[i]; - solver->npoints_local *= solver->dim_local [i]; - solver->npoints_local_wghosts *= (solver->dim_local[i]+2*solver->ghosts); + solver->m_npoints_global *= solver->m_dim_global[i]; + solver->m_npoints_local *= solver->m_dim_local [i]; + solver->m_npoints_local_wghosts *= (solver->m_dim_local[i]+2*solver->m_ghosts); } /* Allocations */ if (!m_rank) printf("Allocating data arrays for full grid.\n"); - solver->index = (int*) calloc (m_ndims,sizeof(int)); - solver->stride_with_ghosts = (int*) calloc (solver->ndims,sizeof(int)); - solver->stride_without_ghosts = (int*) calloc (solver->ndims,sizeof(int)); + solver->m_index = (int*) calloc (m_ndims,sizeof(int)); + solver->m_stride_with_ghosts = (int*) calloc (solver->m_ndims,sizeof(int)); + solver->m_stride_without_ghosts = (int*) calloc (solver->m_ndims,sizeof(int)); int accu1 = 1, accu2 = 1; - for (int i=0; indims; i++) { - solver->stride_with_ghosts[i] = accu1; - solver->stride_without_ghosts[i] = accu2; - accu1 *= (solver->dim_local[i]+2*solver->ghosts); - accu2 *= solver->dim_local[i]; + for (int i=0; im_ndims; i++) { + solver->m_stride_with_ghosts[i] = accu1; + solver->m_stride_without_ghosts[i] = accu2; + accu1 *= (solver->m_dim_local[i]+2*solver->m_ghosts); + accu2 *= solver->m_dim_local[i]; } int size; /* state variables */ size = 1; - for (int i=0; idim_local[i]+2*solver->ghosts); - solver->u = (double*) calloc (solver->nvars*size,sizeof(double)); + for (int i=0; im_dim_local[i]+2*solver->m_ghosts); + solver->m_u = (double*) calloc (solver->m_nvars*size,sizeof(double)); /* grid */ size = 0; - for (int i=0; idim_local[i]+2*solver->ghosts); - solver->x = (double*) calloc (size,sizeof(double)); - solver->dxinv = (double*) calloc (size,sizeof(double)); + for (int i=0; im_dim_local[i]+2*solver->m_ghosts); + solver->m_x = (double*) calloc (size,sizeof(double)); + solver->m_dxinv = (double*) calloc (size,sizeof(double)); /* allocate MPI send/receive buffer arrays */ - int bufdim[solver->ndims], maxbuf = 0; - for (int d = 0; d < solver->ndims; d++) { + int bufdim[solver->m_ndims], maxbuf = 0; + for (int d = 0; d < solver->m_ndims; d++) { bufdim[d] = 1; - for (int i = 0; i < solver->ndims; i++) { - if (i == d) bufdim[d] *= solver->ghosts; - else bufdim[d] *= solver->dim_local[i]; + for (int i = 0; i < solver->m_ndims; i++) { + if (i == d) bufdim[d] *= solver->m_ghosts; + else bufdim[d] *= solver->m_dim_local[i]; } if (bufdim[d] > maxbuf) maxbuf = bufdim[d]; } - maxbuf *= solver->nvars; - mpi->maxbuf = maxbuf; - mpi->sendbuf = (double*) calloc (2*solver->ndims*maxbuf,sizeof(double)); - mpi->recvbuf = (double*) calloc (2*solver->ndims*maxbuf,sizeof(double)); + maxbuf *= solver->m_nvars; + mpi->m_maxbuf = maxbuf; + mpi->m_sendbuf = (double*) calloc (2*solver->m_ndims*maxbuf,sizeof(double)); + mpi->m_recvbuf = (double*) calloc (2*solver->m_ndims*maxbuf,sizeof(double)); - solver->VolumeIntegral = (double*) calloc (solver->nvars,sizeof(double)); - solver->VolumeIntegralInitial = (double*) calloc (solver->nvars,sizeof(double)); - solver->TotalBoundaryIntegral = (double*) calloc (solver->nvars,sizeof(double)); - solver->ConservationError = (double*) calloc (solver->nvars,sizeof(double)); + solver->m_volume_integral = (double*) calloc (solver->m_nvars,sizeof(double)); + solver->m_volume_integral_initial = (double*) calloc (solver->m_nvars,sizeof(double)); + solver->m_total_boundary_integral = (double*) calloc (solver->m_nvars,sizeof(double)); + solver->m_conservation_error = (double*) calloc (solver->m_nvars,sizeof(double)); - for (int i=0; invars; i++) solver->ConservationError[i] = -1; + for (int i=0; im_nvars; i++) solver->m_conservation_error[i] = -1; return(0); } @@ -338,66 +338,66 @@ int SparseGridsSimulation::InitializeSolversBarebones( SimulationObject *sim /*! solver->FirstDerivativePar = NULL; solver->InterpolateInterfacesPar = NULL; - solver->interp = NULL; - solver->compact = NULL; - solver->lusolver = NULL; + solver->m_interp = NULL; + solver->m_compact = NULL; + solver->m_lusolver = NULL; solver->SetInterpLimiterVar = NULL; - solver->flag_nonlinearinterp = 0; - solver->time_integrator = NULL; - solver->msti = NULL; + solver->m_flag_nonlinearinterp = 0; + solver->m_time_integrator = NULL; + solver->m_msti = NULL; /* Solution output function */ solver->WriteOutput = NULL; /* default - no output */ - solver->filename_index = NULL; - if (!strcmp(solver->output_mode,"serial")) { - solver->index_length = 5; - solver->filename_index = (char*) calloc (solver->index_length+1,sizeof(char)); - int i; for (i=0; iindex_length; i++) solver->filename_index[i] = '0'; - solver->filename_index[solver->index_length] = (char) 0; - if (!strcmp(solver->op_file_format,"text")) { + solver->m_filename_index = NULL; + if (!strcmp(solver->m_output_mode,"serial")) { + solver->m_index_length = 5; + solver->m_filename_index = (char*) calloc (solver->m_index_length+1,sizeof(char)); + int i; for (i=0; im_index_length; i++) solver->m_filename_index[i] = '0'; + solver->m_filename_index[solver->m_index_length] = (char) 0; + if (!strcmp(solver->m_op_file_format,"text")) { solver->WriteOutput = WriteText; - strcpy(solver->solnfilename_extn,".dat"); - } else if (!strcmp(solver->op_file_format,"tecplot2d")) { + strcpy(solver->m_solnfilename_extn,".dat"); + } else if (!strcmp(solver->m_op_file_format,"tecplot2d")) { solver->WriteOutput = WriteTecplot2D; - strcpy(solver->solnfilename_extn,".dat"); - } else if (!strcmp(solver->op_file_format,"tecplot3d")) { + strcpy(solver->m_solnfilename_extn,".dat"); + } else if (!strcmp(solver->m_op_file_format,"tecplot3d")) { solver->WriteOutput = WriteTecplot3D; - strcpy(solver->solnfilename_extn,".dat"); - } else if ((!strcmp(solver->op_file_format,"binary")) || (!strcmp(solver->op_file_format,"bin"))) { + strcpy(solver->m_solnfilename_extn,".dat"); + } else if ((!strcmp(solver->m_op_file_format,"binary")) || (!strcmp(solver->m_op_file_format,"bin"))) { solver->WriteOutput = WriteBinary; - strcpy(solver->solnfilename_extn,".bin"); - } else if (!strcmp(solver->op_file_format,"none")) { + strcpy(solver->m_solnfilename_extn,".bin"); + } else if (!strcmp(solver->m_op_file_format,"none")) { solver->WriteOutput = NULL; } else { fprintf(stderr,"Error (domain %d): %s is not a supported file format.\n", - ns, solver->op_file_format); + ns, solver->m_op_file_format); return(1); } - if ((!strcmp(solver->op_overwrite,"no")) && solver->restart_iter) { + if ((!strcmp(solver->m_op_overwrite,"no")) && solver->m_restart_iter) { /* if it's a restart run, fast-forward the filename */ int t; - for (t=0; trestart_iter; t++) - if ((t+1)%solver->file_op_iter == 0) IncrementFilenameIndex(solver->filename_index,solver->index_length); + for (t=0; tm_restart_iter; t++) + if ((t+1)%solver->m_file_op_iter == 0) IncrementFilenameIndex(solver->m_filename_index,solver->m_index_length); } - } else if (!strcmp(solver->output_mode,"parallel")) { - if (!strcmp(solver->op_file_format,"none")) solver->WriteOutput = NULL; + } else if (!strcmp(solver->m_output_mode,"parallel")) { + if (!strcmp(solver->m_op_file_format,"none")) solver->WriteOutput = NULL; else { /* only binary file writing supported in parallel mode */ /* use post-processing scripts to convert */ solver->WriteOutput = WriteBinary; - strcpy(solver->solnfilename_extn,".bin"); + strcpy(solver->m_solnfilename_extn,".bin"); } } else { fprintf(stderr,"Error (domain %d): %s is not a supported output mode.\n", - ns, solver->output_mode); + ns, solver->m_output_mode); fprintf(stderr,"Should be \"serial\" or \"parallel\". \n"); return(1); } /* Solution plotting function */ - strcpy(solver->plotfilename_extn,".png"); + strcpy(solver->m_plotfilename_extn,".png"); #ifdef with_python solver->py_plt_func = NULL; solver->py_plt_func_args = NULL; @@ -409,17 +409,17 @@ int SparseGridsSimulation::InitializeSolversBarebones( SimulationObject *sim /*! if (py_plot_module) { solver->py_plt_func = PyObject_GetAttrString(py_plot_module, "plotSolution"); if (!solver->py_plt_func) { - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Unable to load plotSolution function from Python module.\n"); } } else { - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Loaded Python module for plotting.\n"); printf("Loaded plotSolution function from Python module.\n"); } } } else { - if (!mpi->rank) { + if (!mpi->m_rank) { printf("Unable to load Python module for plotting.\n"); } } diff --git a/src/SparseGrids/SparseGridsSanityChecks.cpp b/src/SparseGrids/SparseGridsSanityChecks.cpp index 770899eb..721c9f94 100644 --- a/src/SparseGrids/SparseGridsSanityChecks.cpp +++ b/src/SparseGrids/SparseGridsSanityChecks.cpp @@ -17,8 +17,8 @@ */ int SparseGridsSimulation::SanityChecks() { - int *dim_global_fg = m_sim_fg->solver.dim_global; - int *iproc_fg = m_sim_fg->mpi.iproc; + int *dim_global_fg = m_sim_fg->solver.m_dim_global; + int *iproc_fg = m_sim_fg->mpi.m_iproc; /* check if grid sizes are same along all dimensions */ { diff --git a/src/SparseGrids/SparseGridsSetSolverParameters.cpp b/src/SparseGrids/SparseGridsSetSolverParameters.cpp index 48937d98..5e795f4f 100644 --- a/src/SparseGrids/SparseGridsSetSolverParameters.cpp +++ b/src/SparseGrids/SparseGridsSetSolverParameters.cpp @@ -16,57 +16,57 @@ int SparseGridsSimulation::SetSolverParameters( SimulationObject& a_dst_si const int a_nsims /*!< Total number of simulations */ ) { - a_dst_sim.solver.my_idx = a_idx; - a_dst_sim.solver.nsims = a_nsims; + a_dst_sim.solver.m_my_idx = a_idx; + a_dst_sim.solver.m_nsims = a_nsims; - a_dst_sim.mpi.rank = m_rank; - a_dst_sim.mpi.nproc = m_nproc; + a_dst_sim.mpi.m_rank = m_rank; + a_dst_sim.mpi.m_nproc = m_nproc; - a_dst_sim.solver.ndims = a_src_sim.solver.ndims; - a_dst_sim.solver.nvars = a_src_sim.solver.nvars; - a_dst_sim.solver.ghosts = a_src_sim.solver.ghosts; + a_dst_sim.solver.m_ndims = a_src_sim.solver.m_ndims; + a_dst_sim.solver.m_nvars = a_src_sim.solver.m_nvars; + a_dst_sim.solver.m_ghosts = a_src_sim.solver.m_ghosts; - a_dst_sim.solver.dim_global = (int*) calloc (a_dst_sim.solver.ndims,sizeof(int)); - a_dst_sim.mpi.iproc = (int*) calloc (a_dst_sim.solver.ndims,sizeof(int)); - for (int d = 0; d < a_dst_sim.solver.ndims; d++) { - a_dst_sim.solver.dim_global[d] = a_dim_global[d]; - a_dst_sim.mpi.iproc[d] = a_iproc[d]; + a_dst_sim.solver.m_dim_global = (int*) calloc (a_dst_sim.solver.m_ndims,sizeof(int)); + a_dst_sim.mpi.m_iproc = (int*) calloc (a_dst_sim.solver.m_ndims,sizeof(int)); + for (int d = 0; d < a_dst_sim.solver.m_ndims; d++) { + a_dst_sim.solver.m_dim_global[d] = a_dim_global[d]; + a_dst_sim.mpi.m_iproc[d] = a_iproc[d]; } - a_dst_sim.solver.n_iter = a_src_sim.solver.n_iter; - a_dst_sim.solver.restart_iter = a_src_sim.solver.restart_iter; + a_dst_sim.solver.m_n_iter = a_src_sim.solver.m_n_iter; + a_dst_sim.solver.m_restart_iter = a_src_sim.solver.m_restart_iter; - strcpy(a_dst_sim.solver.time_scheme, a_src_sim.solver.time_scheme); - strcpy(a_dst_sim.solver.time_scheme_type, a_src_sim.solver.time_scheme_type); - strcpy(a_dst_sim.solver.spatial_scheme_hyp, a_src_sim.solver.spatial_scheme_hyp); - strcpy(a_dst_sim.solver.SplitHyperbolicFlux, a_src_sim.solver.SplitHyperbolicFlux); - strcpy(a_dst_sim.solver.interp_type, a_src_sim.solver.interp_type); - strcpy(a_dst_sim.solver.spatial_type_par, a_src_sim.solver.spatial_type_par); - strcpy(a_dst_sim.solver.spatial_scheme_par, a_src_sim.solver.spatial_scheme_par); + strcpy(a_dst_sim.solver.m_time_scheme, a_src_sim.solver.m_time_scheme); + strcpy(a_dst_sim.solver.m_time_scheme_type, a_src_sim.solver.m_time_scheme_type); + strcpy(a_dst_sim.solver.m_spatial_scheme_hyp, a_src_sim.solver.m_spatial_scheme_hyp); + strcpy(a_dst_sim.solver.m_split_hyperbolic_flux, a_src_sim.solver.m_split_hyperbolic_flux); + strcpy(a_dst_sim.solver.m_interp_type, a_src_sim.solver.m_interp_type); + strcpy(a_dst_sim.solver.m_spatial_type_par, a_src_sim.solver.m_spatial_type_par); + strcpy(a_dst_sim.solver.m_spatial_scheme_par, a_src_sim.solver.m_spatial_scheme_par); - a_dst_sim.solver.dt = a_src_sim.solver.dt; + a_dst_sim.solver.m_dt = a_src_sim.solver.m_dt; - strcpy(a_dst_sim.solver.ConservationCheck, a_src_sim.solver.ConservationCheck); + strcpy(a_dst_sim.solver.m_conservation_check, a_src_sim.solver.m_conservation_check); - a_dst_sim.solver.screen_op_iter = a_src_sim.solver.screen_op_iter; - a_dst_sim.solver.file_op_iter = a_src_sim.solver.file_op_iter; + a_dst_sim.solver.m_screen_op_iter = a_src_sim.solver.m_screen_op_iter; + a_dst_sim.solver.m_file_op_iter = a_src_sim.solver.m_file_op_iter; - strcpy(a_dst_sim.solver.op_file_format, a_src_sim.solver.op_file_format); - strcpy(a_dst_sim.solver.ip_file_type, a_src_sim.solver.ip_file_type); + strcpy(a_dst_sim.solver.m_op_file_format, a_src_sim.solver.m_op_file_format); + strcpy(a_dst_sim.solver.m_ip_file_type, a_src_sim.solver.m_ip_file_type); - strcpy(a_dst_sim.solver.input_mode, a_src_sim.solver.input_mode); - strcpy(a_dst_sim.solver.output_mode, a_src_sim.solver.output_mode); - a_dst_sim.mpi.N_IORanks = a_src_sim.mpi.N_IORanks; + strcpy(a_dst_sim.solver.m_input_mode, a_src_sim.solver.m_input_mode); + strcpy(a_dst_sim.solver.m_output_mode, a_src_sim.solver.m_output_mode); + a_dst_sim.mpi.m_N_IORanks = a_src_sim.mpi.m_N_IORanks; - strcpy(a_dst_sim.solver.op_overwrite, a_src_sim.solver.op_overwrite); - strcpy(a_dst_sim.solver.plot_solution, a_src_sim.solver.plot_solution); - strcpy(a_dst_sim.solver.model, a_src_sim.solver.model); - strcpy(a_dst_sim.solver.ib_filename, a_src_sim.solver.ib_filename); + strcpy(a_dst_sim.solver.m_op_overwrite, a_src_sim.solver.m_op_overwrite); + strcpy(a_dst_sim.solver.m_plot_solution, a_src_sim.solver.m_plot_solution); + strcpy(a_dst_sim.solver.m_model, a_src_sim.solver.m_model); + strcpy(a_dst_sim.solver.m_ib_filename, a_src_sim.solver.m_ib_filename); - a_dst_sim.solver.flag_ib = a_src_sim.solver.flag_ib; + a_dst_sim.solver.m_flag_ib = a_src_sim.solver.m_flag_ib; #ifdef with_petsc - a_dst_sim.solver.use_petscTS = a_src_sim.solver.use_petscTS; + a_dst_sim.solver.m_use_petsc_ts = a_src_sim.solver.m_use_petsc_ts; #endif return(0); diff --git a/src/SparseGrids/SparseGridsSolve.cpp b/src/SparseGrids/SparseGridsSolve.cpp index 07a10b4e..4d3c6863 100644 --- a/src/SparseGrids/SparseGridsSolve.cpp +++ b/src/SparseGrids/SparseGridsSolve.cpp @@ -21,7 +21,7 @@ int SparseGridsSimulation::Solve() /* write out iblank to file for visualization */ if (m_write_sg_solutions == 1) { for (int ns = 0; ns < m_nsims_sg; ns++) { - if (m_sims_sg[ns].solver.flag_ib) { + if (m_sims_sg[ns].solver.m_flag_ib) { char fname_root[_MAX_STRING_SIZE_] = "iblank_sg"; if (m_nsims_sg > 1) { @@ -31,29 +31,29 @@ int SparseGridsSimulation::Solve() strcat(fname_root, index); } - WriteArray( m_sims_sg[ns].solver.ndims, + WriteArray( m_sims_sg[ns].solver.m_ndims, 1, - m_sims_sg[ns].solver.dim_global, - m_sims_sg[ns].solver.dim_local, - m_sims_sg[ns].solver.ghosts, - m_sims_sg[ns].solver.x, - m_sims_sg[ns].solver.iblank, + m_sims_sg[ns].solver.m_dim_global, + m_sims_sg[ns].solver.m_dim_local, + m_sims_sg[ns].solver.m_ghosts, + m_sims_sg[ns].solver.m_x, + m_sims_sg[ns].solver.m_iblank, &(m_sims_sg[ns].solver), &(m_sims_sg[ns].mpi), fname_root ); } } } - if (m_sim_fg->solver.flag_ib) { + if (m_sim_fg->solver.m_flag_ib) { char fname_root[_MAX_STRING_SIZE_] = "iblank"; - WriteArray( m_sim_fg->solver.ndims, + WriteArray( m_sim_fg->solver.m_ndims, 1, - m_sim_fg->solver.dim_global, - m_sim_fg->solver.dim_local, - m_sim_fg->solver.ghosts, - m_sim_fg->solver.x, - m_sim_fg->solver.iblank, + m_sim_fg->solver.m_dim_global, + m_sim_fg->solver.m_dim_local, + m_sim_fg->solver.m_ghosts, + m_sim_fg->solver.m_x, + m_sim_fg->solver.m_iblank, &(m_sim_fg->solver), &(m_sim_fg->mpi), fname_root ); @@ -66,13 +66,13 @@ int SparseGridsSimulation::Solve() if (!m_rank) { printf( "Solving in time (from %d to %d iterations)\n", - TS.restart_iter,TS.n_iter); + TS.m_restart_iter,TS.m_n_iter); } - for (TS.iter = TS.restart_iter; TS.iter < TS.n_iter; TS.iter++) { + for (TS.m_iter = TS.m_restart_iter; TS.m_iter < TS.m_n_iter; TS.m_iter++) { /* Write initial solution to file if this is the first iteration */ - if (!TS.iter) OutputSolution(TS.waqt); + if (!TS.m_iter) OutputSolution(TS.m_waqt); /* Call pre-step function */ TimePreStep (&TS); @@ -88,18 +88,18 @@ int SparseGridsSimulation::Solve() tic++; /* Write intermediate solution to file */ - if ((TS.iter+1)%m_sims_sg[0].solver.file_op_iter == 0) { - OutputSolution(TS.waqt); + if ((TS.m_iter+1)%m_sims_sg[0].solver.m_file_op_iter == 0) { + OutputSolution(TS.m_waqt); tic = 0; } } /* write a final solution file, if last iteration did not write one */ - if (tic || (!TS.n_iter)) OutputSolution(TS.waqt); + if (tic || (!TS.m_n_iter)) OutputSolution(TS.m_waqt); if (!m_rank) { - printf("Completed time integration (Final time: %f).\n",TS.waqt); + printf("Completed time integration (Final time: %f).\n",TS.m_waqt); if (m_nsims_sg > 1) printf("\n"); } diff --git a/src/SparseGrids/SparseGridsWriteErrors.cpp b/src/SparseGrids/SparseGridsWriteErrors.cpp index 33e8a6bd..75bddbd8 100644 --- a/src/SparseGrids/SparseGridsWriteErrors.cpp +++ b/src/SparseGrids/SparseGridsWriteErrors.cpp @@ -51,44 +51,44 @@ void SparseGridsSimulation::WriteErrors(double solver_runtime, /*!< Measured ru /* write out solution errors and wall times to file */ int d; out = fopen(err_fname,"w"); - for (d=0; d= 0) { + if (m_sims_sg[n].solver.m_error[0] >= 0) { printf("Computed errors for sparse grids domain %d:\n", n); - printf(" L1 Error: %1.16E\n",m_sims_sg[n].solver.error[0]); - printf(" L2 Error: %1.16E\n",m_sims_sg[n].solver.error[1]); - printf(" Linf Error: %1.16E\n",m_sims_sg[n].solver.error[2]); + printf(" L1 Error: %1.16E\n",m_sims_sg[n].solver.m_error[0]); + printf(" L2 Error: %1.16E\n",m_sims_sg[n].solver.m_error[1]); + printf(" Linf Error: %1.16E\n",m_sims_sg[n].solver.m_error[2]); } - if (!strcmp(m_sims_sg[n].solver.ConservationCheck,"yes")) { + if (!strcmp(m_sims_sg[n].solver.m_conservation_check,"yes")) { printf("Conservation Errors:\n"); - for (d=0; dsolver.ndims; d++) fprintf(out,"%4d ",m_sim_fg->solver.dim_global[d]); - for (d=0; dsolver.ndims; d++) fprintf(out,"%4d ",m_sim_fg->mpi.iproc[d]); - fprintf(out,"%1.16E ",m_sim_fg->solver.dt); - fprintf(out,"%1.16E %1.16E %1.16E ",m_sim_fg->solver.error[0],m_sim_fg->solver.error[1],m_sim_fg->solver.error[2]); + for (d=0; dsolver.m_ndims; d++) fprintf(out,"%4d ",m_sim_fg->solver.m_dim_global[d]); + for (d=0; dsolver.m_ndims; d++) fprintf(out,"%4d ",m_sim_fg->mpi.m_iproc[d]); + fprintf(out,"%1.16E ",m_sim_fg->solver.m_dt); + fprintf(out,"%1.16E %1.16E %1.16E ",m_sim_fg->solver.m_error[0],m_sim_fg->solver.m_error[1],m_sim_fg->solver.m_error[2]); fprintf(out,"%1.16E %1.16E\n",solver_runtime,main_runtime); fclose(out); /* print solution errors, conservation errors, and wall times to screen */ - if (m_sim_fg->solver.error[0] >= 0) { + if (m_sim_fg->solver.m_error[0] >= 0) { printf("Computed errors for full grid solution:\n"); - printf(" L1 Error: %1.16E\n",m_sim_fg->solver.error[0]); - printf(" L2 Error: %1.16E\n",m_sim_fg->solver.error[1]); - printf(" Linf Error: %1.16E\n",m_sim_fg->solver.error[2]); + printf(" L1 Error: %1.16E\n",m_sim_fg->solver.m_error[0]); + printf(" L2 Error: %1.16E\n",m_sim_fg->solver.m_error[1]); + printf(" Linf Error: %1.16E\n",m_sim_fg->solver.m_error[2]); } } diff --git a/src/TimeIntegration/TimeCleanup.c b/src/TimeIntegration/TimeCleanup.c index 33d10dba..5609c325 100644 --- a/src/TimeIntegration/TimeCleanup.c +++ b/src/TimeIntegration/TimeCleanup.c @@ -15,53 +15,53 @@ /*! Clean up all allocations related to time integration */ -int TimeCleanup(void *ts /*!< Object of type #TimeIntegration*/) +int TimeCleanup(void *a_ts /*!< Object of type #TimeIntegration*/) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; - int ns, nsims = TS->nsims; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + int ns, nsims = TS->m_nsims; /* close files opened for writing */ - if (!TS->rank) if (sim[0].solver.write_residual) fclose((FILE*)TS->ResidualFile); + if (!TS->m_rank) if (sim[0].solver.m_write_residual) fclose((FILE*)TS->m_ResidualFile); #if defined(HAVE_CUDA) - if (sim[0].solver.use_gpu) { - if (!strcmp(sim[0].solver.time_scheme,_RK_)) { - gpuFree(TS->gpu_U); - gpuFree(TS->gpu_Udot); - gpuFree(TS->gpu_BoundaryFlux); + if (sim[0].solver.m_use_gpu) { + if (!strcmp(sim[0].solver.m_time_scheme,_RK_)) { + gpuFree(TS->m_gpu_U); + gpuFree(TS->m_gpu_Udot); + gpuFree(TS->m_gpu_BoundaryFlux); } } else { #endif - if (!strcmp(sim[0].solver.time_scheme,_RK_)) { + if (!strcmp(sim[0].solver.m_time_scheme,_RK_)) { int i; - ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.msti; - for (i=0; instages; i++) free(TS->U[i]); free(TS->U); - for (i=0; instages; i++) free(TS->Udot[i]); free(TS->Udot); - for (i=0; instages; i++) free(TS->BoundaryFlux[i]); free(TS->BoundaryFlux); - } else if (!strcmp(sim[0].solver.time_scheme,_FORWARD_EULER_)) { + ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.m_msti; + for (i=0; instages; i++) free(TS->m_U[i]); free(TS->m_U); + for (i=0; instages; i++) free(TS->m_Udot[i]); free(TS->m_Udot); + for (i=0; instages; i++) free(TS->m_BoundaryFlux[i]); free(TS->m_BoundaryFlux); + } else if (!strcmp(sim[0].solver.m_time_scheme,_FORWARD_EULER_)) { int nstages = 1, i; - for (i=0; iBoundaryFlux[i]); free(TS->BoundaryFlux); - } else if (!strcmp(sim[0].solver.time_scheme,_GLM_GEE_)) { + for (i=0; im_BoundaryFlux[i]); free(TS->m_BoundaryFlux); + } else if (!strcmp(sim[0].solver.m_time_scheme,_GLM_GEE_)) { int i; - GLMGEEParameters *params = (GLMGEEParameters*) sim[0].solver.msti; - for (i=0; i<2*params->r-1 ; i++) free(TS->U[i]); free(TS->U); - for (i=0; instages; i++) free(TS->Udot[i]); free(TS->Udot); - for (i=0; instages; i++) free(TS->BoundaryFlux[i]); free(TS->BoundaryFlux); + GLMGEEParameters *params = (GLMGEEParameters*) sim[0].solver.m_msti; + for (i=0; i<2*params->r-1 ; i++) free(TS->m_U[i]); free(TS->m_U); + for (i=0; instages; i++) free(TS->m_Udot[i]); free(TS->m_Udot); + for (i=0; instages; i++) free(TS->m_BoundaryFlux[i]); free(TS->m_BoundaryFlux); } #if defined(HAVE_CUDA) } #endif /* deallocate arrays */ - free(TS->u_offsets); - free(TS->u_sizes); - free(TS->bf_offsets); - free(TS->bf_sizes); - free(TS->u ); - free(TS->rhs); + free(TS->m_u_offsets); + free(TS->m_u_sizes); + free(TS->m_bf_offsets); + free(TS->m_bf_sizes); + free(TS->m_u ); + free(TS->m_rhs); for (ns = 0; ns < nsims; ns++) { - sim[ns].solver.time_integrator = NULL; + sim[ns].solver.m_time_integrator = NULL; } return(0); } diff --git a/src/TimeIntegration/TimeError.c b/src/TimeIntegration/TimeError.c index a78dd934..6c74df77 100644 --- a/src/TimeIntegration/TimeError.c +++ b/src/TimeIntegration/TimeError.c @@ -15,7 +15,7 @@ integration method chosen has a mechanism to compute the error in the numerical integration, it is computed in this function. In addition, if an exact solution is available (see function argument - \a uex, the error of the computed solution (stored in #HyPar::u) + \a uex, the error of the computed solution (stored in #HyPar::m_u) with respect to this exact solution is also computed. These errors are written to a text file whose name depends on the time integration method being used. @@ -25,93 +25,93 @@ (see TimeGLMGEE(), TimeGLMGEEInitialize() ) */ int TimeError( - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double *uex /*!< Exact solution (stored with the same - array layout as #HyPar::u (may be + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double *a_uex /*!< Exact solution (stored with the same + array layout as #HyPar::m_u (may be NULL) */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; - TimeIntegration *TS = (TimeIntegration*) solver->time_integrator; - int size = solver->npoints_local_wghosts * solver->nvars; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; + TimeIntegration *TS = (TimeIntegration*) solver->m_time_integrator; + int size = solver->m_npoints_local_wghosts * solver->m_nvars; double sum = 0.0, global_sum = 0.0; - static const double tolerance = 1e-15; + static const double s_tolerance = 1e-15; if (!TS) return(0); - if (!strcmp(solver->time_scheme,_GLM_GEE_)) { + if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { /* For GLM-GEE methods, calculate the norm of the estimated global error */ - GLMGEEParameters *params = (GLMGEEParameters*) solver->msti; + GLMGEEParameters *params = (GLMGEEParameters*) solver->m_msti; double error[6] = {0,0,0,0,0,0}, *Uerr; - if (!strcmp(params->ee_mode,_GLM_GEE_YEPS_)) Uerr = TS->U[params->r]; + if (!strcmp(params->ee_mode,_GLM_GEE_YEPS_)) Uerr = TS->m_U[params->r]; else { - Uerr = TS->U[0]; - _ArraySubtract1D_(Uerr,solver->u,TS->U[params->r],size); + Uerr = TS->m_U[0]; + _ArraySubtract1D_(Uerr,solver->m_u,TS->m_U[params->r],size); _ArrayScale1D_(Uerr,(1.0/(1.0-params->gamma)),size); } /* calculate solution norm for relative errors */ double sol_norm[3] = {0.0,0.0,0.0}; /* L1 */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - sol_norm[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + sol_norm[0] = global_sum/((double)solver->m_npoints_global); /* L2 */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - sol_norm[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + sol_norm[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* Linf */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,solver->u); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,solver->m_u); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); sol_norm[2] = global_sum; /* calculate L1 norm of error */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,Uerr); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - error[0] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,Uerr); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + error[0] = global_sum/((double)solver->m_npoints_global); /* calculate L2 norm of error */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,Uerr); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - error[1] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,Uerr); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + error[1] = sqrt(global_sum/((double)solver->m_npoints_global)); /* calculate Linf norm of error */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,Uerr); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,Uerr); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); error[2] = global_sum; - if (uex) { - _ArrayAXBY_(TS->Udot[0],1.0,solver->u,-1.0,uex,size); - _ArrayAXPY_(Uerr,-1.0,TS->Udot[0],size); + if (a_uex) { + _ArrayAXBY_(TS->m_Udot[0],1.0,solver->m_u,-1.0,a_uex,size); + _ArrayAXPY_(Uerr,-1.0,TS->m_Udot[0],size); /* calculate L1 norm of error */ - sum = ArraySumAbsnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,TS->Udot[0]); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - error[3] = global_sum/((double)solver->npoints_global); + sum = ArraySumAbsnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,TS->m_Udot[0]); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + error[3] = global_sum/((double)solver->m_npoints_global); /* calculate L2 norm of error */ - sum = ArraySumSquarenD(solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,TS->Udot[0]); - global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->world); - error[4] = sqrt(global_sum/((double)solver->npoints_global)); + sum = ArraySumSquarenD(solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,TS->m_Udot[0]); + global_sum = 0; MPISum_double(&global_sum,&sum,1,&mpi->m_world); + error[4] = sqrt(global_sum/((double)solver->m_npoints_global)); /* calculate Linf norm of error */ - sum = ArrayMaxnD (solver->nvars,solver->ndims,solver->dim_local, - solver->ghosts,solver->index,TS->Udot[0]); - global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->world); + sum = ArrayMaxnD (solver->m_nvars,solver->m_ndims,solver->m_dim_local, + solver->m_ghosts,solver->m_index,TS->m_Udot[0]); + global_sum = 0; MPIMax_double(&global_sum,&sum,1,&mpi->m_world); error[5] = global_sum; } else error[3] = error[4] = error[5] = -1; - if ( (sol_norm[0] > tolerance) - && (sol_norm[1] > tolerance) - && (sol_norm[2] > tolerance) ) { + if ( (sol_norm[0] > s_tolerance) + && (sol_norm[1] > s_tolerance) + && (sol_norm[2] > s_tolerance) ) { error[0] /= sol_norm[0]; error[1] /= sol_norm[1]; error[2] /= sol_norm[2]; - if (uex) { + if (a_uex) { error[3] /= sol_norm[0]; error[4] /= sol_norm[1]; error[5] /= sol_norm[2]; @@ -119,10 +119,10 @@ int TimeError( } /* write to file */ - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *out; out = fopen("glm_err.dat","w"); - fprintf(out,"%1.16E %1.16E %1.16E %1.16E ",TS->dt,error[0],error[1],error[2]); + fprintf(out,"%1.16E %1.16E %1.16E %1.16E ",TS->m_dt,error[0],error[1],error[2]); fprintf(out,"%1.16E %1.16E %1.16E\n",error[3],error[4],error[5]); fclose(out); printf("Estimated time integration errors (GLM-GEE time-integration):-\n"); diff --git a/src/TimeIntegration/TimeExplicitRKCleanup.c b/src/TimeIntegration/TimeExplicitRKCleanup.c index f0ca3b1a..1564c153 100644 --- a/src/TimeIntegration/TimeExplicitRKCleanup.c +++ b/src/TimeIntegration/TimeExplicitRKCleanup.c @@ -9,9 +9,9 @@ /*! Clean up allocations related to explicit Runge-Kutta time integration: This function frees up the arrays for the Butcher tableaux. */ -int TimeExplicitRKCleanup(void *s /*!< Object of type #ExplicitRKParameters*/ ) +int TimeExplicitRKCleanup(void *a_s /*!< Object of type #ExplicitRKParameters*/ ) { - ExplicitRKParameters *params = (ExplicitRKParameters*) s; + ExplicitRKParameters *params = (ExplicitRKParameters*) a_s; if (params->A) free(params->A); if (params->b) free(params->b); if (params->c) free(params->c); diff --git a/src/TimeIntegration/TimeExplicitRKInitialize.c b/src/TimeIntegration/TimeExplicitRKInitialize.c index 902bece0..281c08ce 100644 --- a/src/TimeIntegration/TimeExplicitRKInitialize.c +++ b/src/TimeIntegration/TimeExplicitRKInitialize.c @@ -18,7 +18,7 @@ int TimeExplicitRKInitialize( char *class, /*!< Name of time integrator class; must match #_RK_ */ char *type, /*!< Type of explicit Runge-Kutta method */ void *s, /*!< Object of type #ExplicitRKParameters */ - void *m /*!< Unused argument */ + void *a_m /*!< Unused argument */ ) { ExplicitRKParameters *params = (ExplicitRKParameters*) s; diff --git a/src/TimeIntegration/TimeForwardEuler.c b/src/TimeIntegration/TimeForwardEuler.c index ad271c64..4999ffe2 100644 --- a/src/TimeIntegration/TimeForwardEuler.c +++ b/src/TimeIntegration/TimeForwardEuler.c @@ -13,22 +13,22 @@ \f{equation}{ \frac{d{\bf u}}{dt} = {\bf F} \left({\bf u}\right) \f} - by one time step of size #HyPar::dt using the forward Euler method + by one time step of size #HyPar::m_dt using the forward Euler method given by \f{equation}{ {\bf u}^{n+1} = {\bf u}^n + \Delta t {\bf F}\left( {\bf u}^n \right) \f} where the superscript represents the time level, \f$\Delta t\f$ is the - time step size #HyPar::dt, and \f${\bf F}\left({\bf u}\right)\f$ is + time step size #HyPar::m_dt, and \f${\bf F}\left({\bf u}\right)\f$ is computed by #TimeIntegration::RHSFunction. */ int TimeForwardEuler( - void *ts /*!< Time integrator object of type #TimeIntegration */ + void *a_ts /*!< Time integrator object of type #TimeIntegration */ ) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; - int ns, nsims = TS->nsims; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + int ns, nsims = TS->m_nsims; _DECLARE_IERR_; for (ns = 0; ns < nsims; ns++) { @@ -36,25 +36,25 @@ int TimeForwardEuler( HyPar* solver = &(sim[ns].solver); MPIVariables* mpi = &(sim[ns].mpi); - double* rhs = TS->rhs + TS->u_offsets[ns]; + double* rhs = TS->m_rhs + TS->m_u_offsets[ns]; /* Evaluate right-hand side */ IERR TS->RHSFunction( rhs, - solver->u, + solver->m_u, solver, mpi, - TS->waqt ); CHECKERR(ierr); + TS->m_waqt ); CHECKERR(ierr); /* update solution */ _ArrayAXPY_( rhs, - TS->dt, - solver->u, - TS->u_sizes[ns] ); - - _ArrayScaleCopy1D_( solver->StageBoundaryIntegral, - TS->dt, - solver->StepBoundaryIntegral, - TS->bf_sizes[ns] ); + TS->m_dt, + solver->m_u, + TS->m_u_sizes[ns] ); + + _ArrayScaleCopy1D_( solver->m_stage_boundary_integral, + TS->m_dt, + solver->m_step_boundary_integral, + TS->m_bf_sizes[ns] ); } return(0); diff --git a/src/TimeIntegration/TimeGLMGEE.c b/src/TimeIntegration/TimeGLMGEE.c index d57f5600..691e0ab6 100644 --- a/src/TimeIntegration/TimeGLMGEE.c +++ b/src/TimeIntegration/TimeGLMGEE.c @@ -14,7 +14,7 @@ \f{equation}{ \frac{d{\bf u}}{dt} = {\bf F} \left({\bf u}\right) \f} - by one time step of size #HyPar::dt using the \f$s\f$-stage General Linear Method with + by one time step of size #HyPar::m_dt using the \f$s\f$-stage General Linear Method with Global Error Estimation (GLM-GEE), given by \f{align}{ {\bf U}^{\left(i\right)} &= c_{i0}{\bf u}_n + \sum_{j=1}^{r-1} c_{ij} \tilde{\bf u}_n^j @@ -26,7 +26,7 @@ \f} where the superscripts in parentheses represent stages, the subscripts represent the time level, the superscripts without parentheses represent auxiliary solutions, \f$\Delta t\f$ is the - time step size #HyPar::dt, \f$\tilde{\bf u}^i, i=1,\cdots,r-1\f$ are the auxiliary solutions, + time step size #HyPar::m_dt, \f$\tilde{\bf u}^i, i=1,\cdots,r-1\f$ are the auxiliary solutions, and \f${\bf F}\left({\bf u}\right)\f$ is computed by #TimeIntegration::RHSFunction. The coefficients defining this methods are: + \f$a_{ij}, i=1,\cdots,s, j=1,\cdots,s\f$ (#GLMGEEParameters::A) @@ -42,40 +42,40 @@ References: + Constantinescu, E. M., "Estimating Global Errors in Time Stepping.", Submitted, 2015 (http://arxiv.org/abs/1503.05166). */ -int TimeGLMGEE(void *ts /*!< Object of type #TimeIntegration */) +int TimeGLMGEE(void *a_ts /*!< Object of type #TimeIntegration */) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; - GLMGEEParameters* params = (GLMGEEParameters*) sim[0].solver.msti; - int ns, stage, i, j, nsims = TS->nsims; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + GLMGEEParameters* params = (GLMGEEParameters*) sim[0].solver.m_msti; + int ns, stage, i, j, nsims = TS->m_nsims; _DECLARE_IERR_; int s = params->nstages; int r = params->r; - double dt = TS->dt; + double dt = TS->m_dt; double *A =params->A, *B =params->B, *C=params->C, *D=params->D, *c=params->c, - **U = TS->U, - **Udot = TS->Udot, - **Uaux = &TS->U[r]; + **U = TS->m_U, + **Udot = TS->m_Udot, + **Uaux = &TS->m_U[r]; /* Calculate stage values */ for (j=0; jwaqt + c[j]*dt; + double stagetime = TS->m_waqt + c[j]*dt; for (ns = 0; ns < nsims; ns++) { - _ArrayScaleCopy1D_( sim[ns].solver.u, + _ArrayScaleCopy1D_( sim[ns].solver.m_u, C[j*r+0], - (U[0] + TS->u_offsets[ns]), - (TS->u_sizes[ns]) ); + (U[0] + TS->m_u_offsets[ns]), + (TS->m_u_sizes[ns]) ); } - for (i=1;iu_size_total); - for (i=0;iu_size_total); + for (i=1;im_u_size_total); + for (i=0;im_u_size_total); for (ns = 0; ns < nsims; ns++) { if (sim[ns].solver.PreStage) { @@ -90,8 +90,8 @@ int TimeGLMGEE(void *ts /*!< Object of type #TimeIntegration */) } for (ns = 0; ns < nsims; ns++) { - IERR TS->RHSFunction( (Udot[j] + TS->u_offsets[ns]), - (U[0] + TS->u_offsets[ns]), + IERR TS->RHSFunction( (Udot[j] + TS->m_u_offsets[ns]), + (U[0] + TS->m_u_offsets[ns]), &(sim[ns].solver), &(sim[ns].mpi), stagetime); @@ -99,18 +99,18 @@ int TimeGLMGEE(void *ts /*!< Object of type #TimeIntegration */) for (ns = 0; ns < nsims; ns++) { if (sim[ns].solver.PostStage) { - IERR sim[ns].solver.PostStage( (U[j] + TS->u_offsets[ns]), + IERR sim[ns].solver.PostStage( (U[j] + TS->m_u_offsets[ns]), &(sim[ns].solver), &(sim[ns].mpi), stagetime); CHECKERR(ierr); } } - _ArraySetValue_(TS->BoundaryFlux[j], TS->bf_size_total, 0.0); + _ArraySetValue_(TS->m_BoundaryFlux[j], TS->m_bf_size_total, 0.0); for (ns = 0; ns < nsims; ns++) { - _ArrayCopy1D_( sim[ns].solver.StageBoundaryIntegral, - (TS->BoundaryFlux[j] + TS->bf_offsets[ns]), - TS->bf_sizes[ns] ); + _ArrayCopy1D_( sim[ns].solver.m_stage_boundary_integral, + (TS->m_BoundaryFlux[j] + TS->m_bf_offsets[ns]), + TS->m_bf_sizes[ns] ); } } @@ -119,35 +119,35 @@ int TimeGLMGEE(void *ts /*!< Object of type #TimeIntegration */) for (ns = 0; ns < nsims; ns++) { - _ArrayScaleCopy1D_( sim[ns].solver.u, + _ArrayScaleCopy1D_( sim[ns].solver.m_u, D[j*r+0], - (U[j]+TS->u_offsets[ns]), - (TS->u_sizes[ns]) ); + (U[j]+TS->m_u_offsets[ns]), + (TS->m_u_sizes[ns]) ); } - for (i=1; iu_size_total); - for (i=0; iu_size_total); + for (i=1; im_u_size_total); + for (i=0; im_u_size_total); } for (ns = 0; ns < nsims; ns++) { for (i=0; iBoundaryFlux[i] + TS->bf_offsets[ns]), + _ArrayAXPY_( (TS->m_BoundaryFlux[i] + TS->m_bf_offsets[ns]), dt*B[0*s+i], - sim[ns].solver.StepBoundaryIntegral, - TS->bf_sizes[ns] ); + sim[ns].solver.m_step_boundary_integral, + TS->m_bf_sizes[ns] ); } } for (ns = 0; ns < nsims; ns++) { - _ArrayCopy1D_( (U[0] + TS->u_offsets[ns]), - sim[ns].solver.u, - TS->u_sizes[ns] ); + _ArrayCopy1D_( (U[0] + TS->m_u_offsets[ns]), + sim[ns].solver.m_u, + TS->m_u_sizes[ns] ); } for (i=1; iu_size_total); + _ArrayCopy1D_(U[i],Uaux[i-1],TS->m_u_size_total); } return(0); diff --git a/src/TimeIntegration/TimeGLMGEECleanup.c b/src/TimeIntegration/TimeGLMGEECleanup.c index 06fd5780..f512aa7d 100644 --- a/src/TimeIntegration/TimeGLMGEECleanup.c +++ b/src/TimeIntegration/TimeGLMGEECleanup.c @@ -11,9 +11,9 @@ method: This function frees the arrays used to store the Butcher tableaux */ -int TimeGLMGEECleanup(void *s /*!< Object of type #GLMGEEParameters*/) +int TimeGLMGEECleanup(void *a_s /*!< Object of type #GLMGEEParameters*/) { - GLMGEEParameters *params = (GLMGEEParameters*) s; + GLMGEEParameters *params = (GLMGEEParameters*) a_s; if (params->A_yyt ) free(params->A_yyt); if (params->B_yyt ) free(params->B_yyt); if (params->C_yyt ) free(params->C_yyt); diff --git a/src/TimeIntegration/TimeGLMGEEInitialize.c b/src/TimeIntegration/TimeGLMGEEInitialize.c index 0badb35c..445668e5 100644 --- a/src/TimeIntegration/TimeGLMGEEInitialize.c +++ b/src/TimeIntegration/TimeGLMGEEInitialize.c @@ -25,11 +25,11 @@ int TimeGLMGEEInitialize( char *class, /*!< Class of time integration method; must match #_GLM_GEE_ */ char *type, /*!< Name of the #_GLM_GEE_ method to use */ void *s, /*!< Object of type #GLMGEEParameters */ - void *m /*!< MPI object of type #MPIVariables */ + void *a_m /*!< MPI object of type #MPIVariables */ ) { GLMGEEParameters *params = (GLMGEEParameters*) s; - MPIVariables *mpi = (MPIVariables*) m; + MPIVariables *mpi = (MPIVariables*) a_m; int i,j; if (!strcmp(class,_GLM_GEE_)) { @@ -442,7 +442,7 @@ int TimeGLMGEEInitialize( } } - if (!mpi->rank) { + if (!mpi->m_rank) { FILE *in; int ferr; in = fopen("glm_gee.inp","r"); @@ -477,7 +477,7 @@ int TimeGLMGEEInitialize( } printf("GLM-GEE time integration error estimation mode: %s\n",params->ee_mode); } - IERR MPIBroadcast_character(params->ee_mode,_MAX_STRING_SIZE_,0,&mpi->world); + IERR MPIBroadcast_character(params->ee_mode,_MAX_STRING_SIZE_,0,&mpi->m_world); if (!strcmp(params->ee_mode,_GLM_GEE_YYT_)) { params->A = params->A_yyt; diff --git a/src/TimeIntegration/TimeGetAuxSolutions.c b/src/TimeIntegration/TimeGetAuxSolutions.c index 71494b97..409fbb2e 100644 --- a/src/TimeIntegration/TimeGetAuxSolutions.c +++ b/src/TimeIntegration/TimeGetAuxSolutions.c @@ -9,7 +9,7 @@ /*! Return auxiliary solution: Some time integrators may have the concept of - auxiliary solutions that they evolve along with the main solution #HyPar::u + auxiliary solutions that they evolve along with the main solution #HyPar::m_u (these may be used for error estimation, for example). This function returns a pointer to such an auxiliary solution. Note that the auxiliary solution has the same dimensions and array layout as the main solution. @@ -27,28 +27,28 @@ (see TimeGLMGEE(), TimeGLMGEEInitialize() ). */ int TimeGetAuxSolutions( - int *N, /*!< Number of auxiliary solutions */ - double **uaux, /*!< Pointer to the array holding the auxiliary solution */ - void *s, /*!< Solver object of type #HyPar */ - int nu, /*!< Index of the auxiliary solution to return */ - int ns /*!< Index of the simulation domain of which the auxiliary solution to return */ + int *a_N, /*!< Number of auxiliary solutions */ + double **a_uaux, /*!< Pointer to the array holding the auxiliary solution */ + void *a_s, /*!< Solver object of type #HyPar */ + int a_nu, /*!< Index of the auxiliary solution to return */ + int a_ns /*!< Index of the simulation domain of which the auxiliary solution to return */ ) { - HyPar *solver = (HyPar*) s; - TimeIntegration *TS = (TimeIntegration*) solver->time_integrator; + HyPar *solver = (HyPar*) a_s; + TimeIntegration *TS = (TimeIntegration*) solver->m_time_integrator; - if (nu >= 0) { - if (!strcmp(solver->time_scheme,_GLM_GEE_)) { - GLMGEEParameters *params = (GLMGEEParameters*) solver->msti; - *uaux = (TS->U[params->r+nu] + TS->u_offsets[ns]); + if (a_nu >= 0) { + if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { + GLMGEEParameters *params = (GLMGEEParameters*) solver->m_msti; + *a_uaux = (TS->m_U[params->r+a_nu] + TS->m_u_offsets[a_ns]); } } else { - if (!TS) *N = 0; + if (!TS) *a_N = 0; else { - if (!strcmp(solver->time_scheme,_GLM_GEE_)) { - GLMGEEParameters *params = (GLMGEEParameters*) solver->msti; - *N = params->r - 1; - } else *N = 0; + if (!strcmp(solver->m_time_scheme,_GLM_GEE_)) { + GLMGEEParameters *params = (GLMGEEParameters*) solver->m_msti; + *a_N = params->r - 1; + } else *a_N = 0; } } diff --git a/src/TimeIntegration/TimeInitialize.c b/src/TimeIntegration/TimeInitialize.c index f821822f..806c0e79 100644 --- a/src/TimeIntegration/TimeInitialize.c +++ b/src/TimeIntegration/TimeInitialize.c @@ -25,85 +25,85 @@ int TimeRHSFunctionExplicit(double*,double*,void*,void*,double); by specific time integration methods. + It calls the method-specific initialization functions. */ -int TimeInitialize( void *s, /*!< Array of simulation objects of type #SimulationObject */ - int nsims, /*!< number of simulation objects */ - int rank, /*!< MPI rank of this process */ - int nproc, /*!< number of MPI processes */ - void *ts /*!< Time integration object of type #TimeIntegration */ +int TimeInitialize( void *a_s, /*!< Array of simulation objects of type #SimulationObject */ + int a_nsims, /*!< number of simulation objects */ + int a_rank, /*!< MPI rank of this process */ + int a_nproc, /*!< number of MPI processes */ + void *a_ts /*!< Time integration object of type #TimeIntegration */ ) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) s; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) a_s; int ns, d, i; if (!sim) return(1); - TS->simulation = sim; - TS->nsims = nsims; + TS->m_simulation = sim; + TS->m_nsims = a_nsims; - TS->rank = rank; - TS->nproc = nproc; + TS->m_rank = a_rank; + TS->m_nproc = a_nproc; - TS->n_iter = sim[0].solver.n_iter; - TS->restart_iter = sim[0].solver.restart_iter; - TS->dt = sim[0].solver.dt; + TS->m_n_iter = sim[0].solver.m_n_iter; + TS->m_restart_iter = sim[0].solver.m_restart_iter; + TS->m_dt = sim[0].solver.m_dt; - TS->waqt = (double) TS->restart_iter * TS->dt; - TS->max_cfl = 0.0; - TS->norm = 0.0; + TS->m_waqt = (double) TS->m_restart_iter * TS->m_dt; + TS->m_max_cfl = 0.0; + TS->m_norm = 0.0; TS->TimeIntegrate = sim[0].solver.TimeIntegrate; - TS->iter_wctime_total = 0.0; + TS->m_iter_wctime_total = 0.0; - TS->u_offsets = (long*) calloc (nsims, sizeof(long)); - TS->u_sizes = (long*) calloc (nsims, sizeof(long)); + TS->m_u_offsets = (long*) calloc (a_nsims, sizeof(long)); + TS->m_u_sizes = (long*) calloc (a_nsims, sizeof(long)); - TS->u_size_total = 0; - for (ns = 0; ns < nsims; ns++) { - TS->u_offsets[ns] = TS->u_size_total; - TS->u_sizes[ns] = sim[ns].solver.npoints_local_wghosts * sim[ns].solver.nvars ; - TS->u_size_total += TS->u_sizes[ns]; + TS->m_u_size_total = 0; + for (ns = 0; ns < a_nsims; ns++) { + TS->m_u_offsets[ns] = TS->m_u_size_total; + TS->m_u_sizes[ns] = sim[ns].solver.m_npoints_local_wghosts * sim[ns].solver.m_nvars ; + TS->m_u_size_total += TS->m_u_sizes[ns]; } - TS->u = (double*) calloc (TS->u_size_total,sizeof(double)); - TS->rhs = (double*) calloc (TS->u_size_total,sizeof(double)); - _ArraySetValue_(TS->u ,TS->u_size_total,0.0); - _ArraySetValue_(TS->rhs,TS->u_size_total,0.0); + TS->m_u = (double*) calloc (TS->m_u_size_total,sizeof(double)); + TS->m_rhs = (double*) calloc (TS->m_u_size_total,sizeof(double)); + _ArraySetValue_(TS->m_u ,TS->m_u_size_total,0.0); + _ArraySetValue_(TS->m_rhs,TS->m_u_size_total,0.0); /* initialize arrays to NULL, then allocate as necessary */ - TS->U = NULL; - TS->Udot = NULL; - TS->BoundaryFlux = NULL; - - TS->bf_offsets = (int*) calloc (nsims, sizeof(int)); - TS->bf_sizes = (int*) calloc (nsims, sizeof(int)); - TS->bf_size_total = 0; - for (ns = 0; ns < nsims; ns++) { - TS->bf_offsets[ns] = TS->bf_size_total; - TS->bf_sizes[ns] = 2 * sim[ns].solver.ndims * sim[ns].solver.nvars; - TS->bf_size_total += TS->bf_sizes[ns]; + TS->m_U = NULL; + TS->m_Udot = NULL; + TS->m_BoundaryFlux = NULL; + + TS->m_bf_offsets = (int*) calloc (a_nsims, sizeof(int)); + TS->m_bf_sizes = (int*) calloc (a_nsims, sizeof(int)); + TS->m_bf_size_total = 0; + for (ns = 0; ns < a_nsims; ns++) { + TS->m_bf_offsets[ns] = TS->m_bf_size_total; + TS->m_bf_sizes[ns] = 2 * sim[ns].solver.m_ndims * sim[ns].solver.m_nvars; + TS->m_bf_size_total += TS->m_bf_sizes[ns]; } #if defined(HAVE_CUDA) - if (sim[0].solver.use_gpu) { + if (sim[0].solver.m_use_gpu) { - if (!strcmp(sim[0].solver.time_scheme,_RK_)) { + if (!strcmp(sim[0].solver.m_time_scheme,_RK_)) { /* explicit Runge-Kutta methods */ - ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.msti; + ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.m_msti; int nstages = params->nstages; - gpuMalloc((void**)&TS->gpu_U, TS->u_size_total*nstages*sizeof(double)); - gpuMalloc((void**)&TS->gpu_Udot, TS->u_size_total*nstages*sizeof(double)); - gpuMalloc((void**)&TS->gpu_BoundaryFlux, TS->bf_size_total*nstages*sizeof(double)); - gpuMemset(TS->gpu_U, 0, TS->u_size_total*nstages*sizeof(double)); - gpuMemset(TS->gpu_Udot, 0, TS->u_size_total*nstages*sizeof(double)); - gpuMemset(TS->gpu_BoundaryFlux, 0, TS->bf_size_total*nstages*sizeof(double)); + gpuMalloc((void**)&TS->m_gpu_U, TS->m_u_size_total*nstages*sizeof(double)); + gpuMalloc((void**)&TS->m_gpu_Udot, TS->m_u_size_total*nstages*sizeof(double)); + gpuMalloc((void**)&TS->m_gpu_BoundaryFlux, TS->m_bf_size_total*nstages*sizeof(double)); + gpuMemset(TS->m_gpu_U, 0, TS->m_u_size_total*nstages*sizeof(double)); + gpuMemset(TS->m_gpu_Udot, 0, TS->m_u_size_total*nstages*sizeof(double)); + gpuMemset(TS->m_gpu_BoundaryFlux, 0, TS->m_bf_size_total*nstages*sizeof(double)); } else { fprintf(stderr,"ERROR in TimeInitialize(): %s is not yet implemented on GPUs.\n", - sim[0].solver.time_scheme ); + sim[0].solver.m_time_scheme ); return 1; } @@ -111,59 +111,59 @@ int TimeInitialize( void *s, /*!< Array of simulation objects of type #Simu } else { #endif - if (!strcmp(sim[0].solver.time_scheme,_RK_)) { + if (!strcmp(sim[0].solver.m_time_scheme,_RK_)) { /* explicit Runge-Kutta methods */ - ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.msti; + ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.m_msti; int nstages = params->nstages; - TS->U = (double**) calloc (nstages,sizeof(double*)); - TS->Udot = (double**) calloc (nstages,sizeof(double*)); + TS->m_U = (double**) calloc (nstages,sizeof(double*)); + TS->m_Udot = (double**) calloc (nstages,sizeof(double*)); for (i = 0; i < nstages; i++) { - TS->U[i] = (double*) calloc (TS->u_size_total,sizeof(double)); - TS->Udot[i] = (double*) calloc (TS->u_size_total,sizeof(double)); + TS->m_U[i] = (double*) calloc (TS->m_u_size_total,sizeof(double)); + TS->m_Udot[i] = (double*) calloc (TS->m_u_size_total,sizeof(double)); } - TS->BoundaryFlux = (double**) calloc (nstages,sizeof(double*)); + TS->m_BoundaryFlux = (double**) calloc (nstages,sizeof(double*)); for (i=0; iBoundaryFlux[i] = (double*) calloc (TS->bf_size_total,sizeof(double)); + TS->m_BoundaryFlux[i] = (double*) calloc (TS->m_bf_size_total,sizeof(double)); } - } else if (!strcmp(sim[0].solver.time_scheme,_FORWARD_EULER_)) { + } else if (!strcmp(sim[0].solver.m_time_scheme,_FORWARD_EULER_)) { int nstages = 1; - TS->BoundaryFlux = (double**) calloc (nstages,sizeof(double*)); + TS->m_BoundaryFlux = (double**) calloc (nstages,sizeof(double*)); for (i=0; iBoundaryFlux[i] = (double*) calloc (TS->bf_size_total,sizeof(double)); + TS->m_BoundaryFlux[i] = (double*) calloc (TS->m_bf_size_total,sizeof(double)); } - } else if (!strcmp(sim[0].solver.time_scheme,_GLM_GEE_)) { + } else if (!strcmp(sim[0].solver.m_time_scheme,_GLM_GEE_)) { /* General Linear Methods with Global Error Estimate */ - GLMGEEParameters *params = (GLMGEEParameters*) sim[0].solver.msti; + GLMGEEParameters *params = (GLMGEEParameters*) sim[0].solver.m_msti; int nstages = params->nstages; int r = params->r; - TS->U = (double**) calloc (2*r-1 ,sizeof(double*)); - TS->Udot = (double**) calloc (nstages,sizeof(double*)); - for (i=0; i<2*r-1; i++) TS->U[i] = (double*) calloc (TS->u_size_total,sizeof(double)); - for (i=0; iUdot[i] = (double*) calloc (TS->u_size_total,sizeof(double)); + TS->m_U = (double**) calloc (2*r-1 ,sizeof(double*)); + TS->m_Udot = (double**) calloc (nstages,sizeof(double*)); + for (i=0; i<2*r-1; i++) TS->m_U[i] = (double*) calloc (TS->m_u_size_total,sizeof(double)); + for (i=0; im_Udot[i] = (double*) calloc (TS->m_u_size_total,sizeof(double)); - TS->BoundaryFlux = (double**) calloc (nstages,sizeof(double*)); + TS->m_BoundaryFlux = (double**) calloc (nstages,sizeof(double*)); for (i=0; iBoundaryFlux[i] = (double*) calloc (TS->bf_size_total,sizeof(double)); + TS->m_BoundaryFlux[i] = (double*) calloc (TS->m_bf_size_total,sizeof(double)); } if (!strcmp(params->ee_mode,_GLM_GEE_YYT_)) { - for (ns = 0; ns < nsims; ns++) { + for (ns = 0; ns < a_nsims; ns++) { for (i=0; iU[r+i] + TS->u_offsets[ns]), - (TS->u_sizes[ns]) ); + _ArrayCopy1D_( (sim[ns].solver.m_u), + (TS->m_U[r+i] + TS->m_u_offsets[ns]), + (TS->m_u_sizes[ns]) ); } } } else { for (i=0; iU[r+i],TS->u_size_total,0.0); + _ArraySetValue_(TS->m_U[r+i],TS->m_u_size_total,0.0); } } } @@ -175,13 +175,13 @@ int TimeInitialize( void *s, /*!< Array of simulation objects of type #Simu TS->RHSFunction = TimeRHSFunctionExplicit; /* open files for writing */ - if (!rank) { - if (sim[0].solver.write_residual) TS->ResidualFile = (void*) fopen("residual.out","w"); - else TS->ResidualFile = NULL; - } else TS->ResidualFile = NULL; + if (!a_rank) { + if (sim[0].solver.m_write_residual) TS->m_ResidualFile = (void*) fopen("residual.out","w"); + else TS->m_ResidualFile = NULL; + } else TS->m_ResidualFile = NULL; - for (ns = 0; ns < nsims; ns++) { - sim[ns].solver.time_integrator = TS; + for (ns = 0; ns < a_nsims; ns++) { + sim[ns].solver.m_time_integrator = TS; } return 0; diff --git a/src/TimeIntegration/TimePostStep.c b/src/TimeIntegration/TimePostStep.c index 2562b739..24733882 100644 --- a/src/TimeIntegration/TimePostStep.c +++ b/src/TimeIntegration/TimePostStep.c @@ -25,63 +25,63 @@ + It will also call any physics-specific post-time-step function, if defined. */ -int TimePostStep(void *ts /*!< Object of type #TimeIntegration */) +int TimePostStep(void *a_ts /*!< Object of type #TimeIntegration */) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; - int ns, nsims = TS->nsims; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + int ns, nsims = TS->m_nsims; /* update current time */ - TS->waqt += TS->dt; + TS->m_waqt += TS->m_dt; - if ((TS->iter+1)%sim[0].solver.screen_op_iter == 0) { + if ((TS->m_iter+1)%sim[0].solver.m_screen_op_iter == 0) { #if defined(HAVE_CUDA) - if (sim[0].solver.use_gpu) { - TS->norm = -1; + if (sim[0].solver.m_use_gpu) { + TS->m_norm = -1; } else { #endif /* Calculate norm for this time step */ double sum = 0.0; double npts = 0; for (ns = 0; ns < nsims; ns++) { - _ArrayAXPY_(sim[ns].solver.u,-1.0,(TS->u+TS->u_offsets[ns]),TS->u_sizes[ns]); - sum += ArraySumSquarenD( sim[ns].solver.nvars, - sim[ns].solver.ndims, - sim[ns].solver.dim_local, - sim[ns].solver.ghosts, - sim[ns].solver.index, - (TS->u+TS->u_offsets[ns]) ); - npts += (double)sim[ns].solver.npoints_global; + _ArrayAXPY_(sim[ns].solver.m_u,-1.0,(TS->m_u+TS->m_u_offsets[ns]),TS->m_u_sizes[ns]); + sum += ArraySumSquarenD( sim[ns].solver.m_nvars, + sim[ns].solver.m_ndims, + sim[ns].solver.m_dim_local, + sim[ns].solver.m_ghosts, + sim[ns].solver.m_index, + (TS->m_u+TS->m_u_offsets[ns]) ); + npts += (double)sim[ns].solver.m_npoints_global; } double global_sum = 0; MPISum_double( &global_sum, &sum,1, - &(sim[0].mpi.world) ); + &(sim[0].mpi.m_world) ); - TS->norm = sqrt(global_sum/npts); + TS->m_norm = sqrt(global_sum/npts); #if defined(HAVE_CUDA) } #endif /* write to file */ - if (TS->ResidualFile) { - fprintf((FILE*)TS->ResidualFile,"%10d\t%E\t%E\n",TS->iter+1,TS->waqt,TS->norm); + if (TS->m_ResidualFile) { + fprintf((FILE*)TS->m_ResidualFile,"%10d\t%E\t%E\n",TS->m_iter+1,TS->m_waqt,TS->m_norm); } } #if defined(HAVE_CUDA) - if (!sim[0].solver.use_gpu) { + if (!sim[0].solver.m_use_gpu) { #endif for (ns = 0; ns < nsims; ns++) { - if (!strcmp(sim[ns].solver.ConservationCheck,"yes")) { + if (!strcmp(sim[ns].solver.m_conservation_check,"yes")) { /* calculate volume integral of the solution at this time step */ - IERR sim[ns].solver.VolumeIntegralFunction( sim[ns].solver.VolumeIntegral, - sim[ns].solver.u, + IERR sim[ns].solver.VolumeIntegralFunction( sim[ns].solver.m_volume_integral, + sim[ns].solver.m_u, &(sim[ns].solver), &(sim[ns].mpi) ); CHECKERR(ierr); /* calculate surface integral of the flux at this time step */ @@ -93,7 +93,7 @@ int TimePostStep(void *ts /*!< Object of type #TimeIntegration */) } if (sim[ns].solver.PostStep) { - sim[ns].solver.PostStep(sim[ns].solver.u,&(sim[ns].solver),&(sim[ns].mpi),TS->waqt,TS->iter); + sim[ns].solver.PostStep(sim[ns].solver.m_u,&(sim[ns].solver),&(sim[ns].mpi),TS->m_waqt,TS->m_iter); } } @@ -101,21 +101,21 @@ int TimePostStep(void *ts /*!< Object of type #TimeIntegration */) } #endif - gettimeofday(&TS->iter_end_time,NULL); + gettimeofday(&TS->m_iter_end_time,NULL); long long walltime; - walltime = ( (TS->iter_end_time.tv_sec * 1000000 + TS->iter_end_time.tv_usec) - - (TS->iter_start_time.tv_sec * 1000000 + TS->iter_start_time.tv_usec)); - TS->iter_wctime = (double) walltime / 1000000.0; - TS->iter_wctime_total += TS->iter_wctime; + walltime = ( (TS->m_iter_end_time.tv_sec * 1000000 + TS->m_iter_end_time.tv_usec) + - (TS->m_iter_start_time.tv_sec * 1000000 + TS->m_iter_start_time.tv_usec)); + TS->m_iter_wctime = (double) walltime / 1000000.0; + TS->m_iter_wctime_total += TS->m_iter_wctime; double global_total = 0, global_wctime = 0, global_mpi_total = 0, global_mpi_wctime = 0; - MPIMax_double(&global_wctime, &TS->iter_wctime, 1, &(sim[0].mpi.world)); - MPIMax_double(&global_total, &TS->iter_wctime_total, 1, &(sim[0].mpi.world)); + MPIMax_double(&global_wctime, &TS->m_iter_wctime, 1, &(sim[0].mpi.m_world)); + MPIMax_double(&global_total, &TS->m_iter_wctime_total, 1, &(sim[0].mpi.m_world)); #if defined(HAVE_CUDA) - MPIMax_double(&global_mpi_wctime, &sim[0].mpi.wctime, 1, &(sim[0].mpi.world)); - MPIMax_double(&global_mpi_total, &sim[0].mpi.wctime_total, 1, &(sim[0].mpi.world)); + MPIMax_double(&global_mpi_wctime, &sim[0].mpi.m_wctime, 1, &(sim[0].mpi.m_world)); + MPIMax_double(&global_mpi_total, &sim[0].mpi.m_wctime_total, 1, &(sim[0].mpi.m_world)); #endif return(0); diff --git a/src/TimeIntegration/TimePreStep.c b/src/TimeIntegration/TimePreStep.c index 0120c8e8..c5ee0a49 100644 --- a/src/TimeIntegration/TimePreStep.c +++ b/src/TimeIntegration/TimePreStep.c @@ -19,15 +19,15 @@ + Computes CFL and diffusion numbers. + Call the physics-specific pre-time-step function, if defined. */ -int TimePreStep(void *ts /*!< Object of type #TimeIntegration */ ) +int TimePreStep(void *a_ts /*!< Object of type #TimeIntegration */ ) { - TimeIntegration* TS = (TimeIntegration*) ts; + TimeIntegration* TS = (TimeIntegration*) a_ts; _DECLARE_IERR_; - SimulationObject* sim = (SimulationObject*) TS->simulation; - int ns, nsims = TS->nsims; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + int ns, nsims = TS->m_nsims; - gettimeofday(&TS->iter_start_time,NULL); + gettimeofday(&TS->m_iter_start_time,NULL); for (ns = 0; ns < nsims; ns++) { @@ -36,11 +36,11 @@ int TimePreStep(void *ts /*!< Object of type #TimeIntegration */ ) double *u = NULL; #if defined(HAVE_CUDA) - if (solver->use_gpu) { - u = solver->gpu_u; + if (solver->m_use_gpu) { + u = solver->m_gpu_u; } else{ #endif - u = solver->u; + u = solver->m_u; #if defined(HAVE_CUDA) } #endif @@ -51,41 +51,41 @@ int TimePreStep(void *ts /*!< Object of type #TimeIntegration */ ) mpi, u, NULL, - TS->waqt ); + TS->m_waqt ); solver->ApplyIBConditions( solver, mpi, u, - TS->waqt ); + TS->m_waqt ); #if defined(HAVE_CUDA) - if (solver->use_gpu) { - gpuMPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->gpu_dim_local, - solver->ghosts, + if (solver->m_use_gpu) { + gpuMPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_gpu_dim_local, + solver->m_ghosts, mpi, u ); } else { #endif - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, u ); #if defined(HAVE_CUDA) } #endif - if ((TS->iter+1)%solver->screen_op_iter == 0) { + if ((TS->m_iter+1)%solver->m_screen_op_iter == 0) { #if defined(HAVE_CUDA) - if (!solver->use_gpu) { + if (!solver->m_use_gpu) { #endif - _ArrayCopy1D_( solver->u, - (TS->u + TS->u_offsets[ns]), - (solver->npoints_local_wghosts*solver->nvars) ); + _ArrayCopy1D_( solver->m_u, + (TS->m_u + TS->m_u_offsets[ns]), + (solver->m_npoints_local_wghosts*solver->m_nvars) ); #if defined(HAVE_CUDA) } #endif @@ -93,34 +93,34 @@ int TimePreStep(void *ts /*!< Object of type #TimeIntegration */ ) /* compute max CFL and diffusion number over the domain */ if (solver->ComputeCFL) { double local_max_cfl = -1.0; - local_max_cfl = solver->ComputeCFL (solver,mpi,TS->dt,TS->waqt); - MPIMax_double(&TS->max_cfl ,&local_max_cfl ,1,&mpi->world); + local_max_cfl = solver->ComputeCFL (solver,mpi,TS->m_dt,TS->m_waqt); + MPIMax_double(&TS->m_max_cfl ,&local_max_cfl ,1,&mpi->m_world); } else { - TS->max_cfl = -1; + TS->m_max_cfl = -1; } if (solver->ComputeDiffNumber) { double local_max_diff = -1.0; - local_max_diff = solver->ComputeDiffNumber (solver,mpi,TS->dt,TS->waqt); - MPIMax_double(&TS->max_diff,&local_max_diff,1,&mpi->world); + local_max_diff = solver->ComputeDiffNumber (solver,mpi,TS->m_dt,TS->m_waqt); + MPIMax_double(&TS->m_max_diff,&local_max_diff,1,&mpi->m_world); } else { - TS->max_diff = -1; + TS->m_max_diff = -1; } } /* set the step boundary flux integral value to zero */ #if defined(HAVE_CUDA) - if (solver->use_gpu) { - gpuArraySetValue(solver->StepBoundaryIntegral,2*solver->ndims*solver->nvars,0.0); + if (solver->m_use_gpu) { + gpuArraySetValue(solver->m_step_boundary_integral,2*solver->m_ndims*solver->m_nvars,0.0); } else { #endif - _ArraySetValue_(solver->StepBoundaryIntegral,2*solver->ndims*solver->nvars,0.0); + _ArraySetValue_(solver->m_step_boundary_integral,2*solver->m_ndims*solver->m_nvars,0.0); #if defined(HAVE_CUDA) } #endif if (solver->PreStep) { - solver->PreStep(u,solver,mpi,TS->waqt); + solver->PreStep(u,solver,mpi,TS->m_waqt); } } diff --git a/src/TimeIntegration/TimePrintStep.c b/src/TimeIntegration/TimePrintStep.c index fe54b620..e0ba7e04 100644 --- a/src/TimeIntegration/TimePrintStep.c +++ b/src/TimeIntegration/TimePrintStep.c @@ -13,35 +13,35 @@ Print information to screen (also calls any physics-specific printing function, if defined). */ -int TimePrintStep(void *ts /*!< Object of type #TimeIntegration */) +int TimePrintStep(void *a_ts /*!< Object of type #TimeIntegration */) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; - int ns, nsims = TS->nsims; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + int ns, nsims = TS->m_nsims; - if ((!TS->rank) && ((TS->iter+1)%sim[0].solver.screen_op_iter == 0)) { + if ((!TS->m_rank) && ((TS->m_iter+1)%sim[0].solver.m_screen_op_iter == 0)) { if (nsims > 1) { printf("--\n"); - printf("iter=%7d, t=%1.3e\n", TS->iter+1, TS->waqt); - if (TS->max_cfl >= 0) printf(" CFL=%1.3E\n", TS->max_cfl); - if (TS->norm >= 0) printf(" norm=%1.4E\n", TS->norm); - printf(" wctime=%1.1E (s)\n",TS->iter_wctime); + printf("iter=%7d, t=%1.3e\n", TS->m_iter+1, TS->m_waqt); + if (TS->m_max_cfl >= 0) printf(" CFL=%1.3E\n", TS->m_max_cfl); + if (TS->m_norm >= 0) printf(" norm=%1.4E\n", TS->m_norm); + printf(" wctime=%1.1E (s)\n",TS->m_iter_wctime); } else { - printf("iter=%7d ",TS->iter+1 ); - printf("t=%1.3E ",TS->waqt ); - if (TS->max_cfl >= 0) printf("CFL=%1.3E ",TS->max_cfl ); - if (TS->norm >= 0) printf("norm=%1.4E ",TS->norm ); - printf("wctime: %1.1E (s) ",TS->iter_wctime); + printf("iter=%7d ",TS->m_iter+1 ); + printf("t=%1.3E ",TS->m_waqt ); + if (TS->m_max_cfl >= 0) printf("CFL=%1.3E ",TS->m_max_cfl ); + if (TS->m_norm >= 0) printf("norm=%1.4E ",TS->m_norm ); + printf("wctime: %1.1E (s) ",TS->m_iter_wctime); } /* calculate and print conservation error */ - if (!strcmp(sim[0].solver.ConservationCheck,"yes")) { + if (!strcmp(sim[0].solver.m_conservation_check,"yes")) { double error = 0; for (ns = 0; ns < nsims; ns++) { int v; - for (v=0; v 1) printf("Physics-specific output for domain %d:\n", ns); sim[ns].solver.PrintStep( &(sim[ns].solver), &(sim[ns].mpi), - TS->waqt ); + TS->m_waqt ); } } if (nsims > 1) { diff --git a/src/TimeIntegration/TimeRHSFunctionExplicit.c b/src/TimeIntegration/TimeRHSFunctionExplicit.c index 05e70f84..456d6715 100644 --- a/src/TimeIntegration/TimeRHSFunctionExplicit.c +++ b/src/TimeIntegration/TimeRHSFunctionExplicit.c @@ -28,68 +28,68 @@ given the solution \f${\bf u}\f$ and the current simulation time. */ int TimeRHSFunctionExplicit( - double *rhs, /*!< Array to hold the computed right-hand-side */ - double *u, /*!< Array holding the solution */ - void *s, /*!< Solver object of type #HyPar */ - void *m, /*!< MPI object of type #MPIVariables */ - double t /*!< Current simulation time */ + double *a_rhs, /*!< Array to hold the computed right-hand-side */ + double *a_u, /*!< Array holding the solution */ + void *a_s, /*!< Solver object of type #HyPar */ + void *a_m, /*!< MPI object of type #MPIVariables */ + double a_t /*!< Current simulation time */ ) { - HyPar *solver = (HyPar*) s; - MPIVariables *mpi = (MPIVariables*) m; + HyPar *solver = (HyPar*) a_s; + MPIVariables *mpi = (MPIVariables*) a_m; int d; int size = 1; - for (d=0; dndims; d++) size *= (solver->dim_local[d]+2*solver->ghosts); + for (d=0; dm_ndims; d++) size *= (solver->m_dim_local[d]+2*solver->m_ghosts); /* apply boundary conditions and exchange data over MPI interfaces */ - solver->ApplyBoundaryConditions(solver,mpi,u,NULL,t); - solver->ApplyIBConditions(solver,mpi,u,t); + solver->ApplyBoundaryConditions(solver,mpi,a_u,NULL,a_t); + solver->ApplyIBConditions(solver,mpi,a_u,a_t); /* Evaluate hyperbolic, parabolic and source terms and the RHS */ #if defined(HAVE_CUDA) - if (solver->use_gpu) { - gpuMPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->gpu_dim_local, - solver->ghosts, + if (solver->m_use_gpu) { + gpuMPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_gpu_dim_local, + solver->m_ghosts, mpi, - u ); + a_u ); } else { #endif - MPIExchangeBoundariesnD( solver->ndims, - solver->nvars, - solver->dim_local, - solver->ghosts, + MPIExchangeBoundariesnD( solver->m_ndims, + solver->m_nvars, + solver->m_dim_local, + solver->m_ghosts, mpi, - u); + a_u); #if defined(HAVE_CUDA) } #endif - solver->HyperbolicFunction( solver->hyp, - u, + solver->HyperbolicFunction( solver->m_hyp, + a_u, solver, mpi, - t, + a_t, 1, solver->FFunction, solver->Upwind ); - solver->ParabolicFunction(solver->par,u,solver,mpi,t); - solver->SourceFunction(solver->source,u,solver,mpi,t); + solver->ParabolicFunction(solver->m_par,a_u,solver,mpi,a_t); + solver->SourceFunction(solver->m_source,a_u,solver,mpi,a_t); #if defined(HAVE_CUDA) - if (solver->use_gpu) { - gpuArraySetValue(rhs, size*solver->nvars, 0.0); - gpuArrayAXPY(solver->hyp, -1.0, rhs, size*solver->nvars); - gpuArrayAXPY(solver->par, 1.0, rhs, size*solver->nvars); - gpuArrayAXPY(solver->source, 1.0, rhs, size*solver->nvars); + if (solver->m_use_gpu) { + gpuArraySetValue(a_rhs, size*solver->m_nvars, 0.0); + gpuArrayAXPY(solver->m_hyp, -1.0, a_rhs, size*solver->m_nvars); + gpuArrayAXPY(solver->m_par, 1.0, a_rhs, size*solver->m_nvars); + gpuArrayAXPY(solver->m_source, 1.0, a_rhs, size*solver->m_nvars); } else { #endif - _ArraySetValue_(rhs,size*solver->nvars,0.0); - _ArrayAXPY_(solver->hyp ,-1.0,rhs,size*solver->nvars); - _ArrayAXPY_(solver->par , 1.0,rhs,size*solver->nvars); - _ArrayAXPY_(solver->source, 1.0,rhs,size*solver->nvars); + _ArraySetValue_(a_rhs,size*solver->m_nvars,0.0); + _ArrayAXPY_(solver->m_hyp ,-1.0,a_rhs,size*solver->m_nvars); + _ArrayAXPY_(solver->m_par , 1.0,a_rhs,size*solver->m_nvars); + _ArrayAXPY_(solver->m_source, 1.0,a_rhs,size*solver->m_nvars); #if defined(HAVE_CUDA) } #endif diff --git a/src/TimeIntegration/TimeRK.c b/src/TimeIntegration/TimeRK.c index 43a36dba..e6aed060 100644 --- a/src/TimeIntegration/TimeRK.c +++ b/src/TimeIntegration/TimeRK.c @@ -19,46 +19,46 @@ \f{equation}{ \frac{d{\bf u}}{dt} = {\bf F} \left({\bf u}\right) \f} - by one time step of size #HyPar::dt using the forward Euler method + by one time step of size #HyPar::m_dt using the forward Euler method given by \f{align}{ {\bf U}^{\left(i\right)} &= {\bf u}_n + \Delta t \sum_{j=1}^{i-1} a_{ij} {\bf F}\left({\bf U}^{\left(j\right)}\right), \\ {\bf u}_{n+1} &= {\bf u}_n + \Delta t \sum_{i=1}^s b_{i} {\bf F}\left({\bf U}^{\left(i\right)}\right), \f} where the subscript represents the time level, the superscripts represent the stages, \f$\Delta t\f$ is the - time step size #HyPar::dt, and \f${\bf F}\left({\bf u}\right)\f$ is computed by #TimeIntegration::RHSFunction. + time step size #HyPar::m_dt, and \f${\bf F}\left({\bf u}\right)\f$ is computed by #TimeIntegration::RHSFunction. The Butcher tableaux coefficients are \f$a_{ij}\f$ (#ExplicitRKParameters::A) and \f$b_i\f$ (#ExplicitRKParameters::b). Note: In the code #TimeIntegration::Udot is equivalent to \f${\bf F}\left({\bf u}\right)\f$. */ -int TimeRK(void *ts /*!< Object of type #TimeIntegration */) +int TimeRK(void *a_ts /*!< Object of type #TimeIntegration */) { - TimeIntegration* TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; - ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.msti; - int ns, stage, i, nsims = TS->nsims; + TimeIntegration* TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; + ExplicitRKParameters *params = (ExplicitRKParameters*) sim[0].solver.m_msti; + int ns, stage, i, nsims = TS->m_nsims; #if defined(HAVE_CUDA) - if (sim[0].solver.use_gpu) { + if (sim[0].solver.m_use_gpu) { /* Calculate stage values */ for (stage = 0; stage < params->nstages; stage++) { - double stagetime = TS->waqt + params->c[stage]*TS->dt; + double stagetime = TS->m_waqt + params->c[stage]*TS->m_dt; for (ns = 0; ns < nsims; ns++) { - gpuArrayCopy1D( sim[ns].solver.gpu_u, - (TS->gpu_U + stage*TS->u_size_total + TS->u_offsets[ns]), - (TS->u_sizes[ns]) ); + gpuArrayCopy1D( sim[ns].solver.m_gpu_u, + (TS->m_gpu_U + stage*TS->m_u_size_total + TS->m_u_offsets[ns]), + (TS->m_u_sizes[ns]) ); } for (i = 0; i < stage; i++) { - gpuArrayAXPY( TS->gpu_Udot + i*TS->u_size_total, - (TS->dt * params->A[stage*params->nstages+i]), - TS->gpu_U + stage*TS->u_size_total, - TS->u_size_total ); + gpuArrayAXPY( TS->m_gpu_Udot + i*TS->m_u_size_total, + (TS->m_dt * params->A[stage*params->nstages+i]), + TS->m_gpu_U + stage*TS->m_u_size_total, + TS->m_u_size_total ); } @@ -67,7 +67,7 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) fprintf(stderr,"ERROR in TimeRK(): Call to solver->PreStage() commented out!\n"); return 1; // sim[ns].solver.PreStage( stage, -// (TS->gpu_U), +// (TS->m_gpu_U), // &(sim[ns].solver), // &(sim[ns].mpi), // stagetime ); CHECKERR(ierr); @@ -76,7 +76,7 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) for (ns = 0; ns < nsims; ns++) { if (sim[ns].solver.PostStage) { - sim[ns].solver.PostStage( (TS->gpu_U + stage*TS->u_size_total + TS->u_offsets[ns]), + sim[ns].solver.PostStage( (TS->m_gpu_U + stage*TS->m_u_size_total + TS->m_u_offsets[ns]), &(sim[ns].solver), &(sim[ns].mpi), stagetime); @@ -84,19 +84,19 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) } for (ns = 0; ns < nsims; ns++) { - TS->RHSFunction( (TS->gpu_Udot + stage*TS->u_size_total + TS->u_offsets[ns]), - (TS->gpu_U + stage*TS->u_size_total + TS->u_offsets[ns]), + TS->RHSFunction( (TS->m_gpu_Udot + stage*TS->m_u_size_total + TS->m_u_offsets[ns]), + (TS->m_gpu_U + stage*TS->m_u_size_total + TS->m_u_offsets[ns]), &(sim[ns].solver), &(sim[ns].mpi), stagetime ); } - gpuArraySetValue(TS->gpu_BoundaryFlux + stage*TS->bf_size_total, TS->bf_size_total, 0.0); + gpuArraySetValue(TS->m_gpu_BoundaryFlux + stage*TS->m_bf_size_total, TS->m_bf_size_total, 0.0); for (ns = 0; ns < nsims; ns++) { - gpuArrayCopy1D( sim[ns].solver.StageBoundaryIntegral, - (TS->gpu_BoundaryFlux + stage*TS->bf_size_total + TS->bf_offsets[ns]), - TS->bf_sizes[ns] ); + gpuArrayCopy1D( sim[ns].solver.m_stage_boundary_integral, + (TS->m_gpu_BoundaryFlux + stage*TS->m_bf_size_total + TS->m_bf_offsets[ns]), + TS->m_bf_sizes[ns] ); } @@ -106,14 +106,14 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) for (stage = 0; stage < params->nstages; stage++) { for (ns = 0; ns < nsims; ns++) { - gpuArrayAXPY( (TS->gpu_Udot + stage*TS->u_size_total + TS->u_offsets[ns]), - (TS->dt * params->b[stage]), - (sim[ns].solver.gpu_u), - (TS->u_sizes[ns]) ); - gpuArrayAXPY( (TS->gpu_BoundaryFlux + stage*TS->bf_size_total + TS->bf_offsets[ns]), - (TS->dt * params->b[stage]), - (sim[ns].solver.StepBoundaryIntegral), - (TS->bf_sizes[ns]) ); + gpuArrayAXPY( (TS->m_gpu_Udot + stage*TS->m_u_size_total + TS->m_u_offsets[ns]), + (TS->m_dt * params->b[stage]), + (sim[ns].solver.m_gpu_u), + (TS->m_u_sizes[ns]) ); + gpuArrayAXPY( (TS->m_gpu_BoundaryFlux + stage*TS->m_bf_size_total + TS->m_bf_offsets[ns]), + (TS->m_dt * params->b[stage]), + (sim[ns].solver.m_step_boundary_integral), + (TS->m_bf_sizes[ns]) ); } @@ -125,19 +125,19 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) /* Calculate stage values */ for (stage = 0; stage < params->nstages; stage++) { - double stagetime = TS->waqt + params->c[stage]*TS->dt; + double stagetime = TS->m_waqt + params->c[stage]*TS->m_dt; for (ns = 0; ns < nsims; ns++) { - _ArrayCopy1D_( sim[ns].solver.u, - (TS->U[stage] + TS->u_offsets[ns]), - (TS->u_sizes[ns]) ); + _ArrayCopy1D_( sim[ns].solver.m_u, + (TS->m_U[stage] + TS->m_u_offsets[ns]), + (TS->m_u_sizes[ns]) ); } for (i = 0; i < stage; i++) { - _ArrayAXPY_( TS->Udot[i], - (TS->dt * params->A[stage*params->nstages+i]), - TS->U[stage], - TS->u_size_total ); + _ArrayAXPY_( TS->m_Udot[i], + (TS->m_dt * params->A[stage*params->nstages+i]), + TS->m_U[stage], + TS->m_u_size_total ); } for (ns = 0; ns < nsims; ns++) { @@ -145,7 +145,7 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) fprintf(stderr,"ERROR in TimeRK(): Call to solver->PreStage() commented out!\n"); return 1; // sim[ns].solver.PreStage( stage, - // (TS->U), + // (TS->m_U), // &(sim[ns].solver), // &(sim[ns].mpi), // stagetime ); CHECKERR(ierr); @@ -154,7 +154,7 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) for (ns = 0; ns < nsims; ns++) { if (sim[ns].solver.PostStage) { - sim[ns].solver.PostStage( (TS->U[stage] + TS->u_offsets[ns]), + sim[ns].solver.PostStage( (TS->m_U[stage] + TS->m_u_offsets[ns]), &(sim[ns].solver), &(sim[ns].mpi), stagetime); CHECKERR(ierr); @@ -162,18 +162,18 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) } for (ns = 0; ns < nsims; ns++) { - TS->RHSFunction( (TS->Udot[stage] + TS->u_offsets[ns]), - (TS->U[stage] + TS->u_offsets[ns]), + TS->RHSFunction( (TS->m_Udot[stage] + TS->m_u_offsets[ns]), + (TS->m_U[stage] + TS->m_u_offsets[ns]), &(sim[ns].solver), &(sim[ns].mpi), stagetime); } - _ArraySetValue_(TS->BoundaryFlux[stage], TS->bf_size_total, 0.0); + _ArraySetValue_(TS->m_BoundaryFlux[stage], TS->m_bf_size_total, 0.0); for (ns = 0; ns < nsims; ns++) { - _ArrayCopy1D_( sim[ns].solver.StageBoundaryIntegral, - (TS->BoundaryFlux[stage] + TS->bf_offsets[ns]), - TS->bf_sizes[ns] ); + _ArrayCopy1D_( sim[ns].solver.m_stage_boundary_integral, + (TS->m_BoundaryFlux[stage] + TS->m_bf_offsets[ns]), + TS->m_bf_sizes[ns] ); } } @@ -182,14 +182,14 @@ int TimeRK(void *ts /*!< Object of type #TimeIntegration */) for (stage = 0; stage < params->nstages; stage++) { for (ns = 0; ns < nsims; ns++) { - _ArrayAXPY_( (TS->Udot[stage] + TS->u_offsets[ns]), - (TS->dt * params->b[stage]), - (sim[ns].solver.u), - (TS->u_sizes[ns]) ); - _ArrayAXPY_( (TS->BoundaryFlux[stage] + TS->bf_offsets[ns]), - (TS->dt * params->b[stage]), - (sim[ns].solver.StepBoundaryIntegral), - (TS->bf_sizes[ns]) ); + _ArrayAXPY_( (TS->m_Udot[stage] + TS->m_u_offsets[ns]), + (TS->m_dt * params->b[stage]), + (sim[ns].solver.m_u), + (TS->m_u_sizes[ns]) ); + _ArrayAXPY_( (TS->m_BoundaryFlux[stage] + TS->m_bf_offsets[ns]), + (TS->m_dt * params->b[stage]), + (sim[ns].solver.m_step_boundary_integral), + (TS->m_bf_sizes[ns]) ); } } diff --git a/src/TimeIntegration/TimeStep.c b/src/TimeIntegration/TimeStep.c index aa752510..f99c513e 100644 --- a/src/TimeIntegration/TimeStep.c +++ b/src/TimeIntegration/TimeStep.c @@ -10,10 +10,10 @@ /*! Advance one time step. */ -int TimeStep(void *ts /*!< Object of type #TimeIntegration */) +int TimeStep(void *a_ts /*!< Object of type #TimeIntegration */) { - TimeIntegration *TS = (TimeIntegration*) ts; - SimulationObject* sim = (SimulationObject*) TS->simulation; + TimeIntegration *TS = (TimeIntegration*) a_ts; + SimulationObject* sim = (SimulationObject*) TS->m_simulation; if (TS->TimeIntegrate) { TS->TimeIntegrate(TS); } diff --git a/src/TridiagLU/blocktridiagIterJacobi.c b/src/TridiagLU/blocktridiagIterJacobi.c index 9216d45c..67144e33 100644 --- a/src/TridiagLU/blocktridiagIterJacobi.c +++ b/src/TridiagLU/blocktridiagIterJacobi.c @@ -85,7 +85,7 @@ + The input array \a x contains the right-hand-side on entering the function, and the solution on exiting it. */ -int blocktridiagIterJacobi( +int BlockTridiagIterJacobi( double *a, /*!< Array containing the sub-diagonal elements */ double *b, /*!< Array containing the diagonal elements */ double *c, /*!< Array containing the super-diagonal elements */ @@ -94,16 +94,16 @@ int blocktridiagIterJacobi( multiplied by the block size) */ int ns, /*!< Number of systems to solve */ int bs, /*!< Block size */ - void *r, /*!< Object of type #TridiagLU */ - void *m /*!< MPI communicator */ + void *r, /*!< Object of type #TridiagLU_Params */ + void *a_m /*!< MPI communicator */ ) { - TridiagLU *context = (TridiagLU*) r; + TridiagLU_Params *context = (TridiagLU_Params *) r; int iter,d,i,j,NT,bs2=bs*bs,nsbs=ns*bs; double norm=0,norm0=0,global_norm=0; #ifndef serial - MPI_Comm *comm = (MPI_Comm*) m; + MPI_Comm *comm = (MPI_Comm*) a_m; int rank,nproc; if (comm) { @@ -116,7 +116,7 @@ int blocktridiagIterJacobi( #endif if (!context) { - fprintf(stderr,"Error in tridiagIterJacobi(): NULL pointer passed for parameters!\n"); + fprintf(stderr,"Error in TridiagIterJacobi(): NULL pointer passed for parameters!\n"); return(-1); } @@ -139,26 +139,26 @@ int blocktridiagIterJacobi( /* total number of points */ #ifdef serial - if (context->evaluate_norm) NT = n; + if (context->m_evaluate_norm) NT = n; else NT = 0; #else - if (context->evaluate_norm) MPI_Allreduce(&n,&NT,1,MPI_INT,MPI_SUM,*comm); + if (context->m_evaluate_norm) MPI_Allreduce(&n,&NT,1,MPI_INT,MPI_SUM,*comm); else NT = 0; #endif #ifdef serial - if (context->verbose) printf("\n"); + if (context->m_verbose) printf("\n"); #else - if (context->verbose && (!rank)) printf("\n"); + if (context->m_verbose && (!rank)) printf("\n"); #endif iter = 0; while(1) { /* evaluate break conditions */ - if ( (iter >= context->maxiter) - || (iter && context->evaluate_norm && (global_norm < context->atol)) - || (iter && context->evaluate_norm && (global_norm/norm0 < context->rtol)) ) { + if ( (iter >= context->m_maxiter) + || (iter && context->m_evaluate_norm && (global_norm < context->m_atol)) + || (iter && context->m_evaluate_norm && (global_norm/norm0 < context->m_rtol)) ) { break; } @@ -177,7 +177,7 @@ int blocktridiagIterJacobi( #endif /* calculate error norm - interior */ - if (context->evaluate_norm) { + if (context->m_evaluate_norm) { norm = 0; for (i=1; ievaluate_norm) { + if (context->m_evaluate_norm) { if (n > 1) { for (d=0; dverbose) + if (context->m_verbose) #else - if (context->verbose && (!rank)) + if (context->m_verbose && (!rank)) #endif printf("\t\titer: %d, norm: %1.16E\n",iter,global_norm); @@ -284,8 +284,8 @@ int blocktridiagIterJacobi( } /* save convergence information */ - context->exitnorm = (context->evaluate_norm ? global_norm : -1.0); - context->exititer = iter; + context->m_exitnorm = (context->m_evaluate_norm ? global_norm : -1.0); + context->m_exititer = iter; free(rhs); free(sendbufL); diff --git a/src/TridiagLU/blocktridiagLU.c b/src/TridiagLU/blocktridiagLU.c index bed3e71f..44eff483 100644 --- a/src/TridiagLU/blocktridiagLU.c +++ b/src/TridiagLU/blocktridiagLU.c @@ -24,7 +24,7 @@ + Stage 2: Elimination of the 1st row on each processor (except the 1st processor) using the last row of the previous processor. + Stage 3: Solution of the reduced tridiagonal system that represents the coupling of the - system across the processors, using blocktridiagIterJacobi() in this implementation. + system across the processors, using BlockTridiagIterJacobi() in this implementation. + Stage 4: Backward-solve to obtain the final solution Specific details of the method implemented here are available in: @@ -104,7 +104,7 @@ + The input array \a x contains the right-hand-side on entering the function, and the solution on exiting it. */ -int blocktridiagLU( +int BlockTridiagLU( double *a, /*!< Array containing the sub-diagonal elements */ double *b, /*!< Array containing the diagonal elements */ double *c, /*!< Array containing the super-diagonal elements */ @@ -113,11 +113,11 @@ int blocktridiagLU( multiplied by the block size) */ int ns, /*!< Number of systems to solve */ int bs, /*!< Block size */ - void *r, /*!< Object of type #TridiagLU (contains wall times at exit) */ - void *m /*!< MPI communicator */ + void *r, /*!< Object of type #TridiagLU_Params (contains wall times at exit) */ + void *a_m /*!< MPI communicator */ ) { - TridiagLU *params = (TridiagLU*) r; + TridiagLU_Params *params = (TridiagLU_Params *) r; int d,i,j,istart,iend,size; int rank,nproc,bs2=bs*bs,nsbs=ns*bs; struct timeval start,stage1,stage2,stage3,stage4; @@ -126,7 +126,7 @@ int blocktridiagLU( rank = 0; nproc = 1; #else - MPI_Comm *comm = (MPI_Comm*) m; + MPI_Comm *comm = (MPI_Comm*) a_m; const int nvar = 4; int ierr = 0; @@ -140,7 +140,7 @@ int blocktridiagLU( #endif if (!params) { - fprintf(stderr,"Error in tridiagLU(): NULL pointer passed for parameters.\n"); + fprintf(stderr,"Error in TridiagLU(): NULL pointer passed for parameters.\n"); return(1); } @@ -245,14 +245,14 @@ int blocktridiagLU( for (i=0; ireducedsolvetype,_TRIDIAG_GS_)) { + if (!strcmp(params->m_reducedsolvetype,_TRIDIAG_GS_)) { /* not supported */ - fprintf(stderr,"Error in blocktridiagLU(): Gather-and-solve for reduced system not available.\n"); + fprintf(stderr,"Error in BlockTridiagLU(): Gather-and-solve for reduced system not available.\n"); return(1); - } else if (!strcmp(params->reducedsolvetype,_TRIDIAG_JACOBI_)) { + } else if (!strcmp(params->m_reducedsolvetype,_TRIDIAG_JACOBI_)) { /* Solving the reduced system iteratively with the Jacobi method */ - if (rank) ierr = blocktridiagIterJacobi(a,b,c,x,1,ns,bs,params,comm); - else ierr = blocktridiagIterJacobi(zero,eye,zero,zero,1,ns,bs,params,comm); + if (rank) ierr = BlockTridiagIterJacobi(a,b,c,x,1,ns,bs,params,comm); + else ierr = BlockTridiagIterJacobi(zero,eye,zero,zero,1,ns,bs,params,comm); } free(zero); free(eye); @@ -307,14 +307,14 @@ int blocktridiagLU( /* save runtimes if needed */ long long walltime; walltime = ((stage1.tv_sec * 1000000 + stage1.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec)); - params->stage1_time = (double) walltime / 1000000.0; + params->m_stage1_time = (double) walltime / 1000000.0; walltime = ((stage2.tv_sec * 1000000 + stage2.tv_usec) - (stage1.tv_sec * 1000000 + stage1.tv_usec)); - params->stage2_time = (double) walltime / 1000000.0; + params->m_stage2_time = (double) walltime / 1000000.0; walltime = ((stage3.tv_sec * 1000000 + stage3.tv_usec) - (stage2.tv_sec * 1000000 + stage2.tv_usec)); - params->stage3_time = (double) walltime / 1000000.0; + params->m_stage3_time = (double) walltime / 1000000.0; walltime = ((stage4.tv_sec * 1000000 + stage4.tv_usec) - (stage3.tv_sec * 1000000 + stage3.tv_usec)); - params->stage4_time = (double) walltime / 1000000.0; + params->m_stage4_time = (double) walltime / 1000000.0; walltime = ((stage4.tv_sec * 1000000 + stage4.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec)); - params->total_time = (double) walltime / 1000000.0; + params->m_total_time = (double) walltime / 1000000.0; return(0); } diff --git a/src/TridiagLU/tridiagIterJacobi.c b/src/TridiagLU/tridiagIterJacobi.c index bb01b9f7..4d28f3cb 100644 --- a/src/TridiagLU/tridiagIterJacobi.c +++ b/src/TridiagLU/tridiagIterJacobi.c @@ -61,23 +61,23 @@ + The input array \a x contains the right-hand-side on entering the function, and the solution on exiting it. */ -int tridiagIterJacobi( +int TridiagIterJacobi( double *a, /*!< Array containing the sub-diagonal elements */ double *b, /*!< Array containing the diagonal elements */ double *c, /*!< Array containing the super-diagonal elements */ double *x, /*!< Right-hand side; will contain the solution on exit */ int n, /*!< Local size of the system on this processor */ int ns, /*!< Number of systems to solve */ - void *r, /*!< Object of type #TridiagLU */ - void *m /*!< MPI communicator */ + void *r, /*!< Object of type #TridiagLU_Params */ + void *a_m /*!< MPI communicator */ ) { - TridiagLU *context = (TridiagLU*) r; + TridiagLU_Params *context = (TridiagLU_Params *) r; int iter,d,i,NT; double norm=0,norm0=0,global_norm=0; #ifndef serial - MPI_Comm *comm = (MPI_Comm*) m; + MPI_Comm *comm = (MPI_Comm*) a_m; int rank,nproc; if (comm) { @@ -90,15 +90,15 @@ int tridiagIterJacobi( #endif if (!context) { - fprintf(stderr,"Error in tridiagIterJacobi(): NULL pointer passed for parameters!\n"); + fprintf(stderr,"Error in TridiagIterJacobi(): NULL pointer passed for parameters!\n"); return(-1); } /* check for zero along the diagonal */ for (i=0; iatol*context->atol) { - fprintf(stderr,"Error in tridiagIterJacobi(): Encountered zero on main diagonal!\n"); + if (b[i*ns+d]*b[i*ns+d] < context->m_atol*context->m_atol) { + fprintf(stderr,"Error in TridiagIterJacobi(): Encountered zero on main diagonal!\n"); return(1); } } @@ -120,26 +120,26 @@ int tridiagIterJacobi( /* total number of points */ #ifdef serial - if (context->evaluate_norm) NT = n; + if (context->m_evaluate_norm) NT = n; else NT = 0; #else - if (context->evaluate_norm) MPI_Allreduce(&n,&NT,1,MPI_INT,MPI_SUM,*comm); + if (context->m_evaluate_norm) MPI_Allreduce(&n,&NT,1,MPI_INT,MPI_SUM,*comm); else NT = 0; #endif #ifdef serial - if (context->verbose) printf("\n"); + if (context->m_verbose) printf("\n"); #else - if (context->verbose && (!rank)) printf("\n"); + if (context->m_verbose && (!rank)) printf("\n"); #endif iter = 0; while(1) { /* evaluate break conditions */ - if ( (iter >= context->maxiter) - || (iter && context->evaluate_norm && (global_norm < context->atol)) - || (iter && context->evaluate_norm && (global_norm/norm0 < context->rtol)) ) { + if ( (iter >= context->m_maxiter) + || (iter && context->m_evaluate_norm && (global_norm < context->m_atol)) + || (iter && context->m_evaluate_norm && (global_norm/norm0 < context->m_rtol)) ) { break; } @@ -155,7 +155,7 @@ int tridiagIterJacobi( #endif /* calculate error norm - interior */ - if (context->evaluate_norm) { + if (context->m_evaluate_norm) { norm = 0; for (i=1; ievaluate_norm) { + if (context->m_evaluate_norm) { if (n > 1) { for (d=0; dverbose) + if (context->m_verbose) #else - if (context->verbose && (!rank)) + if (context->m_verbose && (!rank)) #endif printf("\t\titer: %d, norm: %1.16E\n",iter,global_norm); @@ -225,8 +225,8 @@ int tridiagIterJacobi( } /* save convergence information */ - context->exitnorm = (context->evaluate_norm ? global_norm : -1.0); - context->exititer = iter; + context->m_exitnorm = (context->m_evaluate_norm ? global_norm : -1.0); + context->m_exititer = iter; free(rhs); free(sendbufL); diff --git a/src/TridiagLU/tridiagLU.c b/src/TridiagLU/tridiagLU.c index ec33f8c6..69ef2639 100644 --- a/src/TridiagLU/tridiagLU.c +++ b/src/TridiagLU/tridiagLU.c @@ -23,7 +23,7 @@ + Stage 2: Elimination of the 1st row on each processor (except the 1st processor) using the last row of the previous processor. + Stage 3: Solution of the reduced tridiagonal system that represents the coupling of the - system across the processors, using blocktridiagIterJacobi() in this implementation. + system across the processors, using BlockTridiagIterJacobi() in this implementation. + Stage 4: Backward-solve to obtain the final solution Specific details of the method implemented here are available in: @@ -80,18 +80,18 @@ + The input array \a x contains the right-hand-side on entering the function, and the solution on exiting it. */ -int tridiagLU( +int TridiagLU( double *a, /*!< Array containing the sub-diagonal elements */ double *b, /*!< Array containing the diagonal elements */ double *c, /*!< Array containing the super-diagonal elements */ double *x, /*!< Right-hand side; will contain the solution on exit */ int n, /*!< Local size of the system on this processor */ int ns, /*!< Number of systems to solve */ - void *r, /*!< Object of type #TridiagLU */ - void *m /*!< MPI communicator */ + void *r, /*!< Object of type #TridiagLU_Params */ + void *a_m /*!< MPI communicator */ ) { - TridiagLU *params = (TridiagLU*) r; + TridiagLU_Params *params = (TridiagLU_Params *) r; int d,i,istart,iend; int rank,nproc; struct timeval start,stage1,stage2,stage3,stage4; @@ -100,7 +100,7 @@ int tridiagLU( rank = 0; nproc = 1; #else - MPI_Comm *comm = (MPI_Comm*) m; + MPI_Comm *comm = (MPI_Comm*) a_m; int ierr = 0; const int nvar = 4; @@ -114,7 +114,7 @@ int tridiagLU( #endif if (!params) { - fprintf(stderr,"Error in tridiagLU(): NULL pointer passed for parameters.\n"); + fprintf(stderr,"Error in TridiagLU(): NULL pointer passed for parameters.\n"); return(1); } @@ -206,15 +206,15 @@ int tridiagLU( zero[d] = 0.0; one [d] = 1.0; } - if (!strcmp(params->reducedsolvetype,_TRIDIAG_GS_)) { + if (!strcmp(params->m_reducedsolvetype,_TRIDIAG_GS_)) { /* Solving the reduced system by gather-and-solve algorithm */ - if (rank) ierr = tridiagLUGS(a,b,c,x,1,ns,params,comm); - else ierr = tridiagLUGS(zero,one,zero,zero,1,ns,params,comm); + if (rank) ierr = TridiagLUGS(a,b,c,x,1,ns,params,comm); + else ierr = TridiagLUGS(zero,one,zero,zero,1,ns,params,comm); if (ierr) return(ierr); - } else if (!strcmp(params->reducedsolvetype,_TRIDIAG_JACOBI_)) { + } else if (!strcmp(params->m_reducedsolvetype,_TRIDIAG_JACOBI_)) { /* Solving the reduced system iteratively with the Jacobi method */ - if (rank) ierr = tridiagIterJacobi(a,b,c,x,1,ns,params,comm); - else ierr = tridiagIterJacobi(zero,one,zero,zero,1,ns,params,comm); + if (rank) ierr = TridiagIterJacobi(a,b,c,x,1,ns,params,comm); + else ierr = TridiagIterJacobi(zero,one,zero,zero,1,ns,params,comm); } free(zero); free(one); @@ -261,14 +261,14 @@ int tridiagLU( /* save runtimes if needed */ long long walltime; walltime = ((stage1.tv_sec * 1000000 + stage1.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec)); - params->stage1_time = (double) walltime / 1000000.0; + params->m_stage1_time = (double) walltime / 1000000.0; walltime = ((stage2.tv_sec * 1000000 + stage2.tv_usec) - (stage1.tv_sec * 1000000 + stage1.tv_usec)); - params->stage2_time = (double) walltime / 1000000.0; + params->m_stage2_time = (double) walltime / 1000000.0; walltime = ((stage3.tv_sec * 1000000 + stage3.tv_usec) - (stage2.tv_sec * 1000000 + stage2.tv_usec)); - params->stage3_time = (double) walltime / 1000000.0; + params->m_stage3_time = (double) walltime / 1000000.0; walltime = ((stage4.tv_sec * 1000000 + stage4.tv_usec) - (stage3.tv_sec * 1000000 + stage3.tv_usec)); - params->stage4_time = (double) walltime / 1000000.0; + params->m_stage4_time = (double) walltime / 1000000.0; walltime = ((stage4.tv_sec * 1000000 + stage4.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec)); - params->total_time = (double) walltime / 1000000.0; + params->m_total_time = (double) walltime / 1000000.0; return(0); } diff --git a/src/TridiagLU/tridiagLUGS.c b/src/TridiagLU/tridiagLUGS.c index e8059480..442529a9 100644 --- a/src/TridiagLU/tridiagLUGS.c +++ b/src/TridiagLU/tridiagLUGS.c @@ -16,7 +16,7 @@ Solve tridiagonal (non-periodic) systems of equations using the gather-and-solve approach: This function can solve multiple independent systems with one call. The systems need not share the same left- or right-hand-sides. The "gather-and-solve" approach gathers a tridiagonal - system on one processor and solves it using tridiagLU() (sending NULL as the argument for + system on one processor and solves it using TridiagLU() (sending NULL as the argument for MPI communicator to indicate that a serial solution is desired). Given multiple tridiagonal systems (\a ns > 1), this function will gather the systems on different processors in an optimal way, and thus each processor will solve some of the systems. After the system(s) is @@ -61,26 +61,26 @@ + The input array \a x contains the right-hand-side on entering the function, and the solution on exiting it. */ -int tridiagLUGS( +int TridiagLUGS( double *a, /*!< Array containing the sub-diagonal elements */ double *b, /*!< Array containing the diagonal elements */ double *c, /*!< Array containing the super-diagonal elements */ double *x, /*!< Right-hand side; will contain the solution on exit */ int n, /*!< Local size of the system on this processor */ int ns, /*!< Number of systems to solve */ - void *r, /*!< Object of type #TridiagLU */ - void *m /*!< MPI communicator */ + void *r, /*!< Object of type #TridiagLU_Params */ + void *a_m /*!< MPI communicator */ ) { - TridiagLU *context = (TridiagLU*) r; + TridiagLU_Params *context = (TridiagLU_Params *) r; if (!context) { - fprintf(stderr,"Error in tridiagLUGS(): NULL pointer passed for parameters.\n"); + fprintf(stderr,"Error in TridiagLUGS(): NULL pointer passed for parameters.\n"); return(-1); } #ifdef serial /* Serial compilation */ - return(tridiagLU(a,b,c,x,n,ns,context,m)); + return(TridiagLU(a,b,c,x,n,ns,context,a_m)); #else @@ -90,8 +90,8 @@ int tridiagLUGS( int rank,nproc; /* Parallel compilation */ - MPI_Comm *comm = (MPI_Comm*) m; - if (!comm) return(tridiagLU(a,b,c,x,n,ns,context,NULL)); + MPI_Comm *comm = (MPI_Comm*) a_m; + if (!comm) return(TridiagLU(a,b,c,x,n,ns,context,NULL)); MPI_Comm_size(*comm,&nproc); MPI_Comm_rank(*comm,&rank); @@ -175,7 +175,7 @@ int tridiagLUGS( if (recvbuf) free(recvbuf); /* solve the gathered systems in serial */ - ierr = tridiagLU(ra,rb,rc,rx,NT,ns_local[rank],context,NULL); + ierr = TridiagLU(ra,rb,rc,rx,NT,ns_local[rank],context,NULL); if (ierr) return(ierr); /* allocate send buffer and save the data to send */ diff --git a/src/TridiagLU/tridiagLUInit.c b/src/TridiagLU/tridiagLUInit.c index da2c84f4..9d5f4b90 100644 --- a/src/TridiagLU/tridiagLUInit.c +++ b/src/TridiagLU/tridiagLUInit.c @@ -12,7 +12,7 @@ /*! Initialize the tridiagLU solver by setting the various parameters in -#TridiagLU to their default values. If the file \a lusolver.inp is +#TridiagLU_Params to their default values. If the file \a lusolver.inp is available, read it and set the parameters. The file \b lusolver.inp must be in the following format:\n @@ -28,41 +28,41 @@ The file \b lusolver.inp must be in the following format:\n where the list of keywords are:\n Keyword name | Type | Variable | Default value ------------------ | ------------ | ----------------------------- | ------------------------ - evaluate_norm | int | #TridiagLU::evaluate_norm | 1 - maxiter | int | #TridiagLU::maxiter | 10 - atol | double | #TridiagLU::atol | 1e-12 - rtol | double | #TridiagLU::rtol | 1e-10 - verbose | int | #TridiagLU::verbose | 0 - reducedsolvetype | char[] | #TridiagLU::reducedsolvetype | #_TRIDIAG_JACOBI_ + evaluate_norm | int | #TridiagLU_Params::evaluate_norm | 1 + maxiter | int | #TridiagLU_Params::maxiter | 10 + atol | double | #TridiagLU_Params::atol | 1e-12 + rtol | double | #TridiagLU_Params::rtol | 1e-10 + verbose | int | #TridiagLU_Params::verbose | 0 + reducedsolvetype | char[] | #TridiagLU_Params::reducedsolvetype | #_TRIDIAG_JACOBI_ */ -int tridiagLUInit( - void *r, /*!< Object of type TridiagLU */ - void *c /*!< MPI communicator */ +int TridiagLUInit( + void *a_r, /*!< Object of type TridiagLU_Params */ + void *a_c /*!< MPI communicator */ ) { - TridiagLU *t = (TridiagLU*) r; + TridiagLU_Params *t = (TridiagLU_Params *) a_r; int rank,ierr; #ifdef serial rank = 0; #else - MPI_Comm *comm = (MPI_Comm*) c; + MPI_Comm *comm = (MPI_Comm*) a_c; if (!comm) rank = 0; else MPI_Comm_rank(*comm,&rank); #endif /* default values */ - strcpy(t->reducedsolvetype,_TRIDIAG_JACOBI_); - t->evaluate_norm = 1; - t->maxiter = 10; - t->atol = 1e-12; - t->rtol = 1e-10; - t->verbose = 0; + strcpy(t->m_reducedsolvetype,_TRIDIAG_JACOBI_); + t->m_evaluate_norm = 1; + t->m_maxiter = 10; + t->m_atol = 1e-12; + t->m_rtol = 1e-10; + t->m_verbose = 0; /* read from file, if available */ if (!rank) { FILE *in; - in = fopen("lusolver.inp","r"); + in = fopen("lusolver.inp","a_r"); if (!in) { printf("tridiagLUInit: File \"lusolver.inp\" not found. Using default values.\n"); } else { @@ -71,12 +71,12 @@ int tridiagLUInit( if (!strcmp(word, "begin")) { while (strcmp(word, "end")) { ierr = fscanf(in,"%s",word); if (ierr != 1) return(1); - if (!strcmp(word, "evaluate_norm" )) ierr = fscanf(in,"%d" ,&t->evaluate_norm ); - else if (!strcmp(word, "maxiter" )) ierr = fscanf(in,"%d" ,&t->maxiter ); - else if (!strcmp(word, "atol" )) ierr = fscanf(in,"%lf",&t->atol ); - else if (!strcmp(word, "rtol" )) ierr = fscanf(in,"%lf",&t->rtol ); - else if (!strcmp(word, "verbose" )) ierr = fscanf(in,"%d" ,&t->verbose ); - else if (!strcmp(word, "reducedsolvetype")) ierr = fscanf(in,"%s" ,t->reducedsolvetype); + if (!strcmp(word, "evaluate_norm" )) ierr = fscanf(in,"%d" ,&t->m_evaluate_norm ); + else if (!strcmp(word, "maxiter" )) ierr = fscanf(in,"%d" ,&t->m_maxiter ); + else if (!strcmp(word, "atol" )) ierr = fscanf(in,"%lf",&t->m_atol ); + else if (!strcmp(word, "rtol" )) ierr = fscanf(in,"%lf",&t->m_rtol ); + else if (!strcmp(word, "verbose" )) ierr = fscanf(in,"%d" ,&t->m_verbose ); + else if (!strcmp(word, "reducedsolvetype")) ierr = fscanf(in,"%s" ,t->m_reducedsolvetype); else if (strcmp(word,"end")) { char useless[100]; ierr = fscanf(in,"%s",useless); @@ -95,12 +95,12 @@ int tridiagLUInit( /* broadcast to all processes */ #ifndef serial if (comm) { - MPI_Bcast(t->reducedsolvetype,50,MPI_CHAR,0,*comm); - MPI_Bcast(&t->evaluate_norm,1,MPI_INT,0,*comm); - MPI_Bcast(&t->maxiter,1,MPI_INT,0,*comm); - MPI_Bcast(&t->verbose,1,MPI_INT,0,*comm); - MPI_Bcast(&t->atol,1,MPI_DOUBLE,0,*comm); - MPI_Bcast(&t->rtol,1,MPI_DOUBLE,0,*comm); + MPI_Bcast(t->m_reducedsolvetype,50,MPI_CHAR,0,*comm); + MPI_Bcast(&t->m_evaluate_norm,1,MPI_INT,0,*comm); + MPI_Bcast(&t->m_maxiter,1,MPI_INT,0,*comm); + MPI_Bcast(&t->m_verbose,1,MPI_INT,0,*comm); + MPI_Bcast(&t->m_atol,1,MPI_DOUBLE,0,*comm); + MPI_Bcast(&t->m_rtol,1,MPI_DOUBLE,0,*comm); } #endif diff --git a/src/TridiagLU/tridiagScaLPK.c b/src/TridiagLU/tridiagScaLPK.c index 4ffaeb2e..a6af0854 100644 --- a/src/TridiagLU/tridiagScaLPK.c +++ b/src/TridiagLU/tridiagScaLPK.c @@ -68,18 +68,18 @@ extern void pddtsv_(); + The input array \a x contains the right-hand-side on entering the function, and the solution on exiting it. */ -int tridiagScaLPK( +int TridiagScaLPK( double *a, /*!< Array containing the sub-diagonal elements */ double *b, /*!< Array containing the diagonal elements */ double *c, /*!< Array containing the super-diagonal elements */ double *x, /*!< Right-hand side; will contain the solution on exit */ int n, /*!< Local size of the system on this processor */ int ns, /*!< Number of systems to solve */ - void *r, /*!< Object of type #TridiagLU */ - void *m /*!< MPI communicator */ + void *r, /*!< Object of type #TridiagLU_Params */ + void *a_m /*!< MPI communicator */ ) { - TridiagLU *params = (TridiagLU*) r; + TridiagLU_Params *params = (TridiagLU_Params *) r; int rank,nproc,nglobal,nrhs,i,s,ia,ib,desca[9],descb[9],ierr, lwork; double *dl,*d,*du,*rhs,*work; @@ -90,7 +90,7 @@ int tridiagScaLPK( nproc = 1; nglobal=n; #else - MPI_Comm *comm = (MPI_Comm*) m; + MPI_Comm *comm = (MPI_Comm*) a_m; if (comm) { MPI_Comm_size(*comm,&nproc); @@ -112,7 +112,7 @@ int tridiagScaLPK( } if (!params) { - fprintf(stderr,"Error in tridiagLU(): NULL pointer passed for parameters.\n"); + fprintf(stderr,"Error in TridiagLU(): NULL pointer passed for parameters.\n"); return(1); } @@ -124,7 +124,7 @@ int tridiagScaLPK( lwork = (12*nproc+3*n) + ( (8*nproc) > (10*nproc+4*nrhs) ? (8*nproc) : (10*nproc+4*nrhs) ); desca[0] = 501; - desca[1] = params->blacs_ctxt; + desca[1] = params->m_blacs_ctxt; desca[2] = nglobal; desca[3] = n; desca[4] = 0; @@ -134,7 +134,7 @@ int tridiagScaLPK( desca[8] = 0; descb[0] = 502; - descb[1] = params->blacs_ctxt; + descb[1] = params->m_blacs_ctxt; descb[2] = nglobal; descb[3] = n; descb[4] = 0; @@ -149,11 +149,11 @@ int tridiagScaLPK( rhs = (double*) calloc (n,sizeof(double)); work = (double*) calloc(lwork,sizeof(double)); - params->total_time = 0.0; - params->stage1_time = 0.0; - params->stage2_time = 0.0; - params->stage3_time = 0.0; - params->stage4_time = 0.0; + params->m_total_time = 0.0; + params->m_stage1_time = 0.0; + params->m_stage2_time = 0.0; + params->m_stage3_time = 0.0; + params->m_stage4_time = 0.0; for (s=0; stotal_time += (double) walltime / 1000000.0; + params->m_total_time += (double) walltime / 1000000.0; } diff --git a/src/main.cpp b/src/main.cpp index a40f8167..884d2963 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -233,7 +233,7 @@ static void initializePythonPlotting(int); * * The main driver function that calls the initialization, solving, and cleaning up functions. */ -int main(int argc, char **argv) +int main(int a_argc, char **a_argv) { int ierr = 0, d, n; struct timeval main_start, solve_start; @@ -251,7 +251,7 @@ int main(int argc, char **argv) #else MPI_Comm world; int rank, nproc; - MPI_Init(&argc,&argv); + MPI_Init(&a_argc,&a_argv); MPI_Comm_dup(MPI_COMM_WORLD, &world); MPI_Comm_rank(MPI_COMM_WORLD,&rank ); MPI_Comm_size(MPI_COMM_WORLD,&nproc); @@ -259,7 +259,7 @@ int main(int argc, char **argv) #endif #ifdef with_petsc - PetscInitialize(&argc,&argv,(char*)0,help); + PetscInitialize(&a_argc,&a_argv,(char*)0,help); if (!rank) printf("Compiled with PETSc time integration.\n"); #endif diff --git a/tests/FirstDerivative/test_first_derivative.c b/tests/FirstDerivative/test_first_derivative.c index 5c2d71fb..77ff1aad 100644 --- a/tests/FirstDerivative/test_first_derivative.c +++ b/tests/FirstDerivative/test_first_derivative.c @@ -43,11 +43,11 @@ int test_first_derivative_first_order_linear() { int bias = 1; HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; double *f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); double *Df = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); @@ -86,11 +86,11 @@ int test_first_derivative_second_order_quadratic() { int bias = 0; HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; double *f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); double *Df = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); @@ -131,11 +131,11 @@ int test_first_derivative_fourth_order_cubic() { int bias = 0; HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; double *f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); double *Df = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); @@ -180,10 +180,10 @@ int test_first_derivative_2d() { int bias = 0; HyPar solver; - solver.ndims = ndims; - solver.nvars = nvars; - solver.ghosts = ghosts; - solver.dim_local = dim_local; + solver.m_ndims = ndims; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; + solver.m_dim_local = dim_local; int size_with_ghosts = 1; for (int d = 0; d < ndims; d++) { diff --git a/tests/InterpolationFunctions/test_interpolation.c b/tests/InterpolationFunctions/test_interpolation.c index b9a2ed55..c8b7ec0d 100644 --- a/tests/InterpolationFunctions/test_interpolation.c +++ b/tests/InterpolationFunctions/test_interpolation.c @@ -51,16 +51,16 @@ int test_first_order_upwind_constant() { /* Setup HyPar structure */ HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; /* Setup MPIVariables structure (for serial) */ MPIVariables mpi; - mpi.rank = 0; - mpi.nproc = 1; + mpi.m_rank = 0; + mpi.m_nproc = 1; /* Initialize with constant function f(x) = 2.0 */ for (int i = 0; i < (N+2*ghosts)*nvars; i++) { @@ -102,15 +102,15 @@ int test_first_order_upwind_linear() { double *x = (double*) calloc(N+2*ghosts, sizeof(double)); HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; MPIVariables mpi; - mpi.rank = 0; - mpi.nproc = 1; + mpi.m_rank = 0; + mpi.m_nproc = 1; /* Initialize with linear function f(x) = x */ for (int i = 0; i < N+2*ghosts; i++) { @@ -152,15 +152,15 @@ int test_second_order_central_linear() { double *x = (double*) calloc(N+2*ghosts, sizeof(double)); HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; MPIVariables mpi; - mpi.rank = 0; - mpi.nproc = 1; + mpi.m_rank = 0; + mpi.m_nproc = 1; /* Initialize with linear function f(x) = x */ for (int i = 0; i < N+2*ghosts; i++) { @@ -207,15 +207,15 @@ int test_second_order_central_quadratic() { double *x = (double*) calloc(N+2*ghosts, sizeof(double)); HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; MPIVariables mpi; - mpi.rank = 0; - mpi.nproc = 1; + mpi.m_rank = 0; + mpi.m_nproc = 1; /* Initialize with quadratic function f(x) = x^2 */ for (int i = 0; i < N+2*ghosts; i++) { @@ -262,15 +262,15 @@ int test_fourth_order_central_cubic() { double *x = (double*) calloc(N+2*ghosts, sizeof(double)); HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; MPIVariables mpi; - mpi.rank = 0; - mpi.nproc = 1; + mpi.m_rank = 0; + mpi.m_nproc = 1; /* Initialize with cubic function f(x) = x^3 */ for (int i = 0; i < N+2*ghosts; i++) { @@ -320,52 +320,52 @@ int test_weno_smooth_function() { double *x = (double*) calloc(N+2*ghosts, sizeof(double)); HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; int stride_with_ghosts[1] = {1}; - solver.stride_with_ghosts = stride_with_ghosts; + solver.m_stride_with_ghosts = stride_with_ghosts; /* Initialize WENO parameters */ WENOParameters weno; - weno.mapped = 0; - weno.borges = 0; - weno.yc = 0; - weno.no_limiting = 0; - weno.eps = 1e-6; - weno.p = 2.0; - weno.tol = 1e-10; - weno.rc = 0.3; - weno.xi = 0.001; + weno.m_mapped = 0; + weno.m_borges = 0; + weno.m_yc = 0; + weno.m_no_limiting = 0; + weno.m_eps = 1e-6; + weno.m_p = 2.0; + weno.m_tol = 1e-10; + weno.m_rc = 0.3; + weno.m_xi = 0.001; /* Allocate and initialize WENO weights and offset arrays */ - weno.offset = (int*) calloc(solver.ndims, sizeof(int)); - weno.offset[0] = 0; + weno.m_offset = (int*) calloc(solver.m_ndims, sizeof(int)); + weno.m_offset[0] = 0; /* Calculate total size for weight arrays */ int total_size = nvars * (N + 1); /* For 1D: nvars * (dim+1) */ - weno.size = total_size; + weno.m_size = total_size; /* Allocate weight arrays (4*size for upwind/conservative flags) */ - weno.w1 = (double*) calloc(4*total_size, sizeof(double)); - weno.w2 = (double*) calloc(4*total_size, sizeof(double)); - weno.w3 = (double*) calloc(4*total_size, sizeof(double)); + weno.m_w1 = (double*) calloc(4*total_size, sizeof(double)); + weno.m_w2 = (double*) calloc(4*total_size, sizeof(double)); + weno.m_w3 = (double*) calloc(4*total_size, sizeof(double)); /* Initialize weights to optimal values */ for (int i = 0; i < 4*total_size; i++) { - weno.w1[i] = 0.1; /* Optimal weight 1 */ - weno.w2[i] = 0.6; /* Optimal weight 2 */ - weno.w3[i] = 0.3; /* Optimal weight 3 */ + weno.m_w1[i] = 0.1; /* Optimal weight 1 */ + weno.m_w2[i] = 0.6; /* Optimal weight 2 */ + weno.m_w3[i] = 0.3; /* Optimal weight 3 */ } - solver.interp = &weno; + solver.m_interp = &weno; solver.SetInterpLimiterVar = NULL; MPIVariables mpi; - mpi.rank = 0; - mpi.nproc = 1; + mpi.m_rank = 0; + mpi.m_nproc = 1; /* Initialize with smooth sine wave f(x) = sin(2*pi*x/N) */ double pi = 4.0 * atan(1.0); @@ -390,10 +390,10 @@ int test_weno_smooth_function() { } /* Clean up allocated memory */ - free(weno.w1); - free(weno.w2); - free(weno.w3); - free(weno.offset); + free(weno.m_w1); + free(weno.m_w2); + free(weno.m_w3); + free(weno.m_offset); free(fC); free(fI); free(u); diff --git a/tests/MathFunctions/test_math.c b/tests/MathFunctions/test_math.c index 0a03138a..1798e757 100644 --- a/tests/MathFunctions/test_math.c +++ b/tests/MathFunctions/test_math.c @@ -217,7 +217,7 @@ int test_fill_ghost_cells_periodic() { } /* Fill ghost cells */ - fillGhostCells(dim, ghosts, u, nvars, ndims, periodic); + FillGhostCells(dim, ghosts, u, nvars, ndims, periodic); int test_result = TEST_PASS; @@ -285,7 +285,7 @@ int test_fill_ghost_cells_extrapolation() { double u_0 = u[p_0]; /* Fill ghost cells using extrapolation */ - fillGhostCells(dim, ghosts, u, nvars, ndims, periodic); + FillGhostCells(dim, ghosts, u, nvars, ndims, periodic); int test_result = TEST_PASS; diff --git a/tests/QUICKSTART.md b/tests/QUICKSTART.md deleted file mode 100644 index 661aec78..00000000 --- a/tests/QUICKSTART.md +++ /dev/null @@ -1,313 +0,0 @@ -# Quick Start Guide - Running Interpolation Function Tests - -## One-Command Test Run - -```bash -# From HyPar root directory -autoreconf -i && ./configure --enable-serial && make && make check -``` - -## Step-by-Step Instructions - -### 1. Configure the Build System - -```bash -cd /path/to/hypar -autoreconf -i -``` - -This generates the configure script and Makefiles. - -### 2. Configure HyPar - -**Option A: Serial Mode (Faster, No MPI required)** -```bash -./configure --enable-serial -``` - -**Option B: MPI Mode (Requires MPI installation)** -```bash -./configure -``` - -### 3. Build HyPar - -```bash -make -j$(nproc) -``` - -This compiles: -- All HyPar libraries in `src/` -- Test executables in `tests/` - -### 4. Run Tests - -```bash -make check -``` - -This runs all unit tests and displays results. - -## Understanding Test Output - -### Successful Test Run - -``` -======================================== -Interpolation Functions Unit Tests -======================================== - -Testing First Order Upwind Scheme: -[PASS] First Order Upwind - Constant Function -[PASS] First Order Upwind - Linear Function - -Testing Second Order Central Scheme: -[PASS] Second Order Central - Linear Function -[PASS] Second Order Central - Quadratic Function - -Testing Fourth Order Central Scheme: -[PASS] Fourth Order Central - Cubic Function - -Testing WENO Scheme: -[PASS] Fifth Order WENO - Smooth Sine Wave - -======================================== -Test Results: - Passed: 6 - Failed: 0 -======================================== -``` - -Exit code: 0 (success) - -### Failed Test Run - -``` -Testing Second Order Central Scheme: -[PASS] Second Order Central - Linear Function -[FAIL] Second Order Central - Quadratic Function - At interface 3: got 9.500000, expected 9.250000 -... -Test Results: - Passed: 5 - Failed: 1 -======================================== - -Last failed test: Second Order Central - Quadratic Function -``` - -Exit code: 1 (failure) - -## Running Individual Tests - -### Run Specific Test Executable - -```bash -cd tests/InterpolationFunctions -./test_interpolation -``` - -### Debug with GDB - -```bash -cd tests/InterpolationFunctions -gdb ./test_interpolation -(gdb) run -(gdb) bt # if it crashes -``` - -### Check Test Logs - -```bash -cat tests/InterpolationFunctions/test-suite.log -cat tests/InterpolationFunctions/test_interpolation.log -``` - -## Common Issues and Solutions - -### Issue 1: `autoreconf: command not found` - -**Solution:** Install autotools -```bash -# Ubuntu/Debian -sudo apt-get install autoconf automake libtool - -# macOS -brew install autoconf automake libtool -``` - -### Issue 2: `configure: error: cannot find MPI` - -**Solution:** Either install MPI or use serial mode -```bash -# Option A: Install MPI -sudo apt-get install mpich libmpich-dev - -# Option B: Use serial mode -./configure --enable-serial -``` - -### Issue 3: `make: *** No rule to make target 'check'` - -**Cause:** Makefiles not generated properly - -**Solution:** Reconfigure -```bash -make distclean -autoreconf -i -./configure --enable-serial -make -make check -``` - -### Issue 4: Tests fail with "Segmentation fault" - -**Cause:** Array bounds issue or null pointer - -**Solution:** Run with debugger -```bash -cd tests/InterpolationFunctions -gdb ./test_interpolation -(gdb) run -(gdb) backtrace -``` - -### Issue 5: `undefined reference` linker errors - -**Cause:** Missing library dependencies - -**Solution:** Check Makefile.am has all required libraries -```makefile -test_interpolation_LDADD = \ - ../../src/InterpolationFunctions/libInterpolationFunctions.a \ - ../../src/ArrayFunctions/libArrayFunctions.a \ - ../../src/MathFunctions/libMathFunctions.a \ - ../../src/CommonFunctions/libCommonFunctions.a -``` - -## GitHub Actions CI - -Tests automatically run on GitHub for: -- Every push to any branch -- Every pull request - -### Viewing CI Results - -1. Go to repository on GitHub -2. Click "Actions" tab -3. Select latest workflow run -4. View "Unit Tests (Serial)" and "Unit Tests (MPI)" jobs -5. Check test output in job logs - -### CI Configuration - -File: `.github/workflows/unit-tests.yml` - -The workflow: -1. Checks out code -2. Installs dependencies -3. Configures HyPar (both serial and MPI) -4. Builds HyPar -5. Runs `make check` -6. Displays test logs on failure - -## Clean Build - -To start fresh: - -```bash -# Clean build artifacts -make clean - -# Clean everything including configure -make distclean - -# Or manually remove generated files -rm -rf autom4te.cache config.h config.log config.status Makefile -find . -name Makefile.in -delete -find . -name Makefile -delete - -# Then reconfigure -autoreconf -i -./configure --enable-serial -make -make check -``` - -## Test Development Workflow - -### Adding a New Test - -1. Edit `tests/InterpolationFunctions/test_interpolation.c` -2. Add test function: -```c -int test_my_new_feature() { - // Setup - // Execute - // Verify - return TEST_PASS or TEST_FAIL; -} -``` -3. Register in `main()`: -```c -print_test_result(&stats, "My New Feature Test", test_my_new_feature()); -``` -4. Rebuild and test: -```bash -cd tests/InterpolationFunctions -make clean -make -./test_interpolation -``` - -### Testing Your Changes - -Before committing: -```bash -# Run tests locally -make check - -# Verify no memory leaks (if valgrind available) -cd tests/InterpolationFunctions -valgrind --leak-check=full ./test_interpolation - -# Push and check CI results on GitHub -git push -``` - -## Performance Tips - -### Faster Builds - -```bash -# Use parallel compilation -make -j$(nproc) - -# Only rebuild tests (after source change) -cd tests -make clean -make -``` - -### Faster Test Runs - -Tests are already very fast (< 1 second). To run only interpolation tests: - -```bash -cd tests/InterpolationFunctions -make check -``` - -## Getting Help - -1. **Test Documentation**: `tests/README.md` -2. **Test Summary**: `tests/SUMMARY.md` -3. **GitHub Issues**: Open an issue for bugs or questions -4. **Code Comments**: Read `test_interpolation.c` for examples - -## Next Steps - -- Read `tests/README.md` for detailed documentation -- Read `tests/SUMMARY.md` for architecture overview -- Add tests for additional interpolation schemes -- Integrate with your development workflow diff --git a/tests/SUMMARY.md b/tests/SUMMARY.md deleted file mode 100644 index c662fc09..00000000 --- a/tests/SUMMARY.md +++ /dev/null @@ -1,239 +0,0 @@ -# GitHub CI Tests for Interpolation Functions - Summary - -## Overview - -This document summarizes the GitHub CI test infrastructure created for the InterpolationFunctions in HyPar. - -## Files Created - -### 1. Test Source Code -- **`tests/InterpolationFunctions/test_interpolation.c`** (11KB) - - Comprehensive unit test suite for interpolation functions - - Tests 6 different interpolation schemes - - Includes 6 test cases covering various function types - - Simple custom test harness (no external dependencies) - -### 2. Build Configuration -- **`tests/InterpolationFunctions/Makefile.am`** - - Autotools build configuration for tests - - Links against necessary HyPar libraries - - Defines `test_interpolation` as a check program - -- **`tests/Makefile.am`** - - Parent Makefile for tests directory - - Includes InterpolationFunctions subdirectory - -- **Modified: `configure.ac`** - - Added tests/Makefile and tests/InterpolationFunctions/Makefile to AC_CONFIG_FILES - - Enables autotools to generate Makefiles for tests - -- **Modified: `Makefile.am`** (root) - - Added `tests` to SUBDIRS - - Integrates tests into main build system - -### 3. GitHub Actions Workflow -- **`.github/workflows/unit-tests.yml`** (1.9KB) - - Automated CI workflow for unit tests - - Runs on every push and pull request - - Two test configurations: - - Serial mode (--enable-serial) - - MPI mode (default) - - Displays test logs on failure - -### 4. Documentation -- **`tests/README.md`** (3.5KB) - - Comprehensive documentation for the test suite - - Explains test structure and coverage - - Instructions for running and adding tests - - Future test additions roadmap - -- **`tests/SUMMARY.md`** (this file) - - High-level overview of created infrastructure - -### 5. Git Configuration -- **`tests/.gitignore`** - - Excludes test executables, logs, and build artifacts - - Keeps repository clean - -## Test Coverage - -### Current Tests - -| Interpolation Scheme | Test Cases | Tested Functions | -|---------------------|------------|------------------| -| First Order Upwind | 2 | Constant, Linear | -| Second Order Central | 2 | Linear, Quadratic | -| Fourth Order Central | 1 | Cubic | -| Fifth Order WENO | 1 | Smooth Sine Wave | - -### Tested Interpolation Functions - -1. `Interp1PrimFirstOrderUpwind()` - Component-wise 1st order upwind -2. `Interp1PrimSecondOrderCentral()` - Component-wise 2nd order central -3. `Interp1PrimFourthOrderCentral()` - Component-wise 4th order central -4. `Interp1PrimFifthOrderWENO()` - Component-wise 5th order WENO - -### Test Properties Verified - -- **Polynomial Reproduction**: Schemes correctly reproduce polynomials up to their design order -- **Constant Preservation**: All schemes preserve constant functions exactly -- **Stability**: No spurious oscillations for smooth functions -- **Accuracy**: Interface values match analytical expectations within tolerance (1e-10) - -## How to Use - -### Running Tests Locally - -```bash -# From HyPar root directory -autoreconf -i -./configure --enable-serial # or without for MPI -make -make check -``` - -### Viewing Test Results - -Tests output results in a clear format: -``` -[PASS] First Order Upwind - Constant Function -[PASS] Second Order Central - Linear Function -... -Test Results: - Passed: 6 - Failed: 0 -``` - -### CI Integration - -Tests automatically run on GitHub Actions: -1. Push code or create pull request -2. GitHub Actions triggers unit-tests.yml workflow -3. Tests run in both serial and MPI configurations -4. Results visible in Actions tab -5. Failures block merging (if configured) - -## Architecture - -### Test Design Principles - -1. **Self-contained**: No external test frameworks required -2. **Fast**: All tests complete in < 1 second -3. **Deterministic**: Same input always produces same result -4. **Isolated**: Tests don't depend on each other -5. **Clear Output**: Pass/fail clearly indicated - -### Test Structure - -Each test function follows this pattern: -```c -int test_scheme_property() { - // 1. Setup test data (arrays, solver structure) - // 2. Call interpolation function - // 3. Verify results against expected values - // 4. Clean up allocated memory - // 5. Return TEST_PASS or TEST_FAIL -} -``` - -## Future Enhancements - -### Additional Tests to Add - -1. **MUSCL Schemes** - - Second Order MUSCL (with limiters) - - Third Order MUSCL (with Koren limiter) - -2. **High-Order WENO Variants** - - Fifth Order CRWENO (Compact Reconstruction) - - Fifth Order HCWENO (Hybrid Compact) - - Fifth Order Upwind - -3. **Compact Schemes** - - Fifth Order Compact Upwind - -4. **Characteristic-Based** - - All schemes with characteristic decomposition - - Requires defining physics (e.g., Euler equations) - -5. **Edge Cases** - - Discontinuities (shock capturing) - - Multiple variables (nvars > 1) - - Multi-dimensional tests - - Ghost point handling - -6. **Performance Tests** - - Timing benchmarks - - Memory usage verification - -### Integration with Existing Tests - -- Current tests are **unit tests** (test individual functions) -- Complement existing **regression tests** (test complete simulations) -- Both types of tests are valuable: - - Unit tests: Fast, pinpoint failures - - Regression tests: Verify overall correctness - -## Dependencies - -### Build Dependencies -- autoconf -- automake -- libtool -- C compiler (gcc) -- make - -### Runtime Dependencies -- None (tests are self-contained) - -### Optional Dependencies -- MPI (for MPI mode testing) -- MPICH or OpenMPI (GitHub Actions uses MPICH) - -## Maintenance - -### When to Update Tests - -1. **Adding new interpolation schemes**: Add corresponding test cases -2. **Modifying existing schemes**: Update expected values if behavior changes -3. **Bug fixes**: Add regression test for the bug -4. **Performance improvements**: Verify correctness not compromised - -### Test Failure Debugging - -If tests fail: -1. Check test logs: `tests/InterpolationFunctions/test_interpolation.log` -2. Run test manually: `./tests/InterpolationFunctions/test_interpolation` -3. Use debugger: `gdb ./tests/InterpolationFunctions/test_interpolation` -4. Check recent code changes -5. Verify build configuration - -## Integration with HyPar Build System - -The tests are fully integrated into the autotools build system: - -``` -HyPar/ -├── configure.ac ← Modified (added tests) -├── Makefile.am ← Modified (added tests) -├── src/ ← Existing source code -└── tests/ ← New test directory - ├── Makefile.am ← New - └── InterpolationFunctions/ - ├── Makefile.am ← New - └── test_interpolation.c ← New -``` - -Running `make check` will: -1. Build all HyPar libraries -2. Build test executables -3. Run all tests -4. Report pass/fail status -5. Generate test logs - -## Contact - -For questions or issues with the test infrastructure: -- Open an issue on GitHub -- Check existing documentation in `tests/README.md` -- Review test source code for examples diff --git a/tests/SecondDerivative/test_second_derivative.c b/tests/SecondDerivative/test_second_derivative.c index fcd2dbd4..54151371 100644 --- a/tests/SecondDerivative/test_second_derivative.c +++ b/tests/SecondDerivative/test_second_derivative.c @@ -42,11 +42,11 @@ int test_second_derivative_second_order_quadratic() { int dir = 0; HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; double *f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); double *D2f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); @@ -84,11 +84,11 @@ int test_second_derivative_second_order_cubic() { int dir = 0; HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; double *f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); double *D2f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); @@ -129,11 +129,11 @@ int test_second_derivative_fourth_order_quartic() { int dir = 0; HyPar solver; - solver.ndims = 1; - solver.nvars = nvars; - solver.ghosts = ghosts; + solver.m_ndims = 1; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; int dim_local[1] = {N}; - solver.dim_local = dim_local; + solver.m_dim_local = dim_local; double *f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); double *D2f = (double*) calloc((N+2*ghosts)*nvars, sizeof(double)); @@ -177,10 +177,10 @@ int test_second_derivative_2d() { int ghosts = 2; HyPar solver; - solver.ndims = ndims; - solver.nvars = nvars; - solver.ghosts = ghosts; - solver.dim_local = dim_local; + solver.m_ndims = ndims; + solver.m_nvars = nvars; + solver.m_ghosts = ghosts; + solver.m_dim_local = dim_local; int size_with_ghosts = 1; for (int d = 0; d < ndims; d++) { diff --git a/tests/TridiagLU/test_tridiag.c b/tests/TridiagLU/test_tridiag.c index b9da199e..f2093213 100644 --- a/tests/TridiagLU/test_tridiag.c +++ b/tests/TridiagLU/test_tridiag.c @@ -70,15 +70,15 @@ int test_tridiag_lu_simple() { } /* Initialize TridiagLU structure */ - TridiagLU params; - params.evaluate_norm = 0; - params.maxiter = 10; - params.atol = 1e-12; - params.rtol = 1e-10; - strcpy(params.reducedsolvetype, _TRIDIAG_GS_); + TridiagLU_Params params; + params.m_evaluate_norm = 0; + params.m_maxiter = 10; + params.m_atol = 1e-12; + params.m_rtol = 1e-10; + strcpy(params.m_reducedsolvetype, _TRIDIAG_GS_); /* Solve the system (note: tridiagLU modifies a, b, c, and rhs becomes the solution) */ - int ierr = tridiagLU(a, b, c, rhs, n, 1, ¶ms, NULL); + int ierr = TridiagLU(a, b, c, rhs, n, 1, ¶ms, NULL); /* Copy solution from rhs to x */ for (int i = 0; i < n; i++) { @@ -142,14 +142,14 @@ int test_tridiag_lu_diag_dominant() { rhs_orig[i] = rhs[i]; } - TridiagLU params; - params.evaluate_norm = 0; - params.maxiter = 10; - params.atol = 1e-12; - params.rtol = 1e-10; - strcpy(params.reducedsolvetype, _TRIDIAG_GS_); + TridiagLU_Params params; + params.m_evaluate_norm = 0; + params.m_maxiter = 10; + params.m_atol = 1e-12; + params.m_rtol = 1e-10; + strcpy(params.m_reducedsolvetype, _TRIDIAG_GS_); - int ierr = tridiagLU(a, b, c, rhs, n, 1, ¶ms, NULL); + int ierr = TridiagLU(a, b, c, rhs, n, 1, ¶ms, NULL); /* Copy solution from rhs to x */ for (int i = 0; i < n; i++) { @@ -210,14 +210,14 @@ int test_tridiag_lu_known_solution() { } /* Solve the system (tridiagLU modifies inputs) */ - TridiagLU params; - params.evaluate_norm = 0; - params.maxiter = 10; - params.atol = 1e-12; - params.rtol = 1e-10; - strcpy(params.reducedsolvetype, _TRIDIAG_GS_); - - int ierr = tridiagLU(a, b, c, rhs, n, 1, ¶ms, NULL); + TridiagLU_Params params; + params.m_evaluate_norm = 0; + params.m_maxiter = 10; + params.m_atol = 1e-12; + params.m_rtol = 1e-10; + strcpy(params.m_reducedsolvetype, _TRIDIAG_GS_); + + int ierr = TridiagLU(a, b, c, rhs, n, 1, ¶ms, NULL); /* Copy solution from rhs to x */ for (int i = 0; i < n; i++) {