31 for (
int s = 1; s <= d; s++) {
33 double coeff = c1 *
cfunc(d-1,s-1);
35 std::vector<GridDimensions> dims(0);
37 if (dims.size() == 0) {
38 fprintf(stderr,
"Error in SparseGridsSimulation::ComputeSGDimsAndCoeffs()\n");
39 fprintf(stderr,
" GetCTGridSize() returned empty vector!\n");
43 for (
int i=0; i<dims.size(); i++) {
44 m_combination.push_back(std::pair<double,GridDimensions>(coeff,dims[i]));
57 std::vector<GridDimensions>& a_dims
75 a_dims.push_back(tmp);
90 std::vector<double> dvec;
101 fprintf(stderr,
"Error in SparseGridsSimulation::ComputeProcessorDistribution() - rank %d\n",
m_rank);
102 fprintf(stderr,
" Number of MPI ranks greater than the maximum number of MPI ranks that can be used.\n");
103 fprintf(stderr,
" Please re-run with %d MPI ranks.\n", max_nproc);
109 std::vector<ProcDistribution> iproc_candidates(0);
111 for (
int d=0; d<
m_ndims; d++) ubound[d] = max_procs[d]+1;
117 for (
int d = 0; d <
m_ndims; d++) iproc_vec[d] = iproc[d];
118 iproc_candidates.push_back(iproc_vec);
122 if (iproc_candidates.size() == 0) {
123 fprintf(stderr,
"Error in SparseGridsSimulation::ComputeProcessorDistribution() - rank %d\n",
m_rank);
124 fprintf(stderr,
" Unable to fine candidate iprocs!\n");
129 double min_norm = DBL_MAX;
130 for (
int i = 0; i<iproc_candidates.size(); i++) {
131 std::vector<double> pvec;
134 if (norm < min_norm) {
136 a_iprocs = iproc_candidates[i];
149 fprintf(stderr,
"Error in SparseGridsSimulation::CleanupBarebones()\n");
150 fprintf(stderr,
" Simulation object is not a barebones one.\n");
203 mpi->
ip = (
int*) calloc (
m_ndims,
sizeof(
int));
204 mpi->
is = (
int*) calloc (
m_ndims,
sizeof(
int));
205 mpi->
ie = (
int*) calloc (
m_ndims,
sizeof(
int));
213 for (
int i=0; i<
m_ndims; i++) total_proc *= mpi->
iproc[i];
222 for (
int i=0; i<
m_ndims; i++) {
249 for (
int i=0; i<
m_ndims; i++) {
264 for (
int i=0; i<
m_ndims; i++) {
271 if (!
m_rank) printf(
"Allocating data arrays for full grid.\n");
272 solver->
index = (
int*) calloc (m_ndims,
sizeof(
int));
275 int accu1 = 1, accu2 = 1;
276 for (
int i=0; i<solver->
ndims; i++) {
288 solver->
u = (
double*) calloc (solver->
nvars*size,
sizeof(
double));
293 solver->
x = (
double*) calloc (size,
sizeof(
double));
294 solver->
dxinv = (
double*) calloc (size,
sizeof(
double));
297 int bufdim[solver->
ndims], maxbuf = 0;
298 for (
int d = 0; d < solver->
ndims; d++) {
300 for (
int i = 0; i < solver->
ndims; i++) {
301 if (i == d) bufdim[d] *= solver->
ghosts;
304 if (bufdim[d] > maxbuf) maxbuf = bufdim[d];
306 maxbuf *= solver->
nvars;
308 mpi->
sendbuf = (
double*) calloc (2*solver->
ndims*maxbuf,
sizeof(
double));
309 mpi->
recvbuf = (
double*) calloc (2*solver->
ndims*maxbuf,
sizeof(
double));
327 fprintf(stderr,
"Error in SparseGridsSimulation::InitializeSolversBarebones() - \n");
328 fprintf(stderr,
" simulation object is not barebones type.\n");
372 fprintf(stderr,
"Error (domain %d): %s is not a supported file format.\n",
382 }
else if (!strcmp(solver->
output_mode,
"parallel")) {
392 fprintf(stderr,
"Error (domain %d): %s is not a supported output mode.\n",
394 fprintf(stderr,
"Should be \"serial\" or \"parallel\". \n");
406 PyObject* py_plot_name = PyUnicode_DecodeFSDefault(python_plotting_fname);
407 PyObject* py_plot_module = PyImport_Import(py_plot_name);
408 Py_DECREF(py_plot_name);
409 if (py_plot_module) {
410 solver->
py_plt_func = PyObject_GetAttrString(py_plot_module,
"plotSolution");
413 printf(
"Unable to load plotSolution function from Python module.\n");
417 printf(
"Loaded Python module for plotting.\n");
418 printf(
"Loaded plotSolution function from Python module.\n");
423 printf(
"Unable to load Python module for plotting.\n");
int npoints_local_wghosts
#define _ArraySetValue_(x, size, value)
#define raiseto_int(y, x, a)
Contains some vector ops.
int * stride_without_ghosts
int InitializeBarebones(SimulationObject *)
int ComputeSGDimsAndCoeffs()
Function declarations for file I/O functions.
double compute2Norm(const std::vector< double > &a_a, const std::vector< double > &a_b)
#define _MIN_GRID_PTS_PER_PROC_
char op_file_format[_MAX_STRING_SIZE_]
void GetCTGridSizes(const int, std::vector< GridDimensions > &)
int ComputeProcessorDistribution(ProcDistribution &, const GridDimensions &)
int(* ParabolicFunction)(double *, double *, void *, void *, double)
int InitializeSolversBarebones(SimulationObject *)
int MPICreateIOGroups(void *)
int(* SetInterpLimiterVar)(double *, double *, double *, int, void *, void *)
#define _MAX_STRING_SIZE_
SimulationObject * m_sim_fg
#define _ArraySum1D_(x, a, size)
char plotfilename_extn[_MAX_STRING_SIZE_]
char op_overwrite[_MAX_STRING_SIZE_]
double * TotalBoundaryIntegral
Contains function definitions for common mathematical functions.
int(* InterpolateInterfacesPar)(double *, double *, int, void *, void *)
int MPIRanknD(int, int, int *, int *)
double cfunc(int a, int b)
int MPIPartition1D(int, int, int)
int(* FirstDerivativePar)(double *, double *, int, int, void *, void *)
int WriteTecplot3D(int, int, int *, double *, double *, char *, int *)
long sum(const std::vector< int > &a_iv)
int MPIFreeCommunicators(int, void *)
void createNormalVector(std::vector< double > &a_normal_vec, const int *a_vec, const int a_size)
std::vector< int > ProcDistribution
int CleanupBarebones(SimulationObject *)
int MPILocalDomainLimits(int, int, void *, int *, int *, int *)
double * VolumeIntegralInitial
Structure defining a simulation.
int WriteText(int, int, int *, double *, double *, char *, int *)
std::vector< SGCTElem > m_combination
Contains macros and function definitions for common array operations.
int(* SecondDerivativePar)(double *, double *, int, void *, void *)
double * ConservationError
int WriteTecplot2D(int, int, int *, double *, double *, char *, int *)
char solnfilename_extn[_MAX_STRING_SIZE_]
#define _ArrayProduct1D_(x, size, p)
int WriteBinary(int, int, int *, double *, double *, char *, int *)
Structure of MPI-related variables.
std::vector< int > GridDimensions
char output_mode[_MAX_STRING_SIZE_]
Structure containing all solver-specific variables and functions.
void IncrementFilenameIndex(char *f, int len)
int MPICreateCommunicators(int, void *)
#define _ArrayIncrementIndexWithLBound_(N, imax, imin, i, done)
int(* WriteOutput)(int, int, int *, double *, double *, char *, int *)