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");
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");
void GetCTGridSizes(const int, std::vector< GridDimensions > &)
int WriteBinary(int, int, int *, double *, double *, char *, int *)
int(* SecondDerivativePar)(double *, double *, int, void *, void *)
int InitializeBarebones(SimulationObject *)
int WriteTecplot3D(int, int, int *, double *, double *, char *, int *)
Contains function definitions for common mathematical functions.
int(* ParabolicFunction)(double *, double *, void *, void *, double)
Structure defining a simulation.
char plotfilename_extn[_MAX_STRING_SIZE_]
std::vector< int > GridDimensions
long sum(const std::vector< int > &a_iv)
int InitializeSolversBarebones(SimulationObject *)
double * ConservationError
int ComputeSGDimsAndCoeffs()
char output_mode[_MAX_STRING_SIZE_]
int WriteText(int, int, int *, double *, double *, char *, int *)
int(* SetInterpLimiterVar)(double *, double *, double *, int, void *, void *)
void IncrementFilenameIndex(char *, int)
Structure containing all solver-specific variables and functions.
#define _MAX_STRING_SIZE_
int * stride_without_ghosts
void createNormalVector(std::vector< double > &a_normal_vec, const int *a_vec, const int a_size)
#define _MIN_GRID_PTS_PER_PROC_
Function declarations for file I/O functions.
int MPIFreeCommunicators(int, void *)
std::vector< SGCTElem > m_combination
int ComputeProcessorDistribution(ProcDistribution &, const GridDimensions &)
char op_overwrite[_MAX_STRING_SIZE_]
#define _ArrayIncrementIndexWithLBound_(N, imax, imin, i, done)
double compute2Norm(const std::vector< double > &a_a, const std::vector< double > &a_b)
char solnfilename_extn[_MAX_STRING_SIZE_]
Contains some vector ops.
int MPIPartition1D(int, int, int)
#define _ArraySetValue_(x, size, value)
std::vector< int > ProcDistribution
int WriteTecplot2D(int, int, int *, double *, double *, char *, int *)
#define raiseto_int(y, x, a)
int(* FirstDerivativePar)(double *, double *, int, int, void *, void *)
int(* InterpolateInterfacesPar)(double *, double *, int, void *, void *)
int CleanupBarebones(SimulationObject *)
#define _ArraySum1D_(x, a, size)
double * TotalBoundaryIntegral
double cfunc(int a, int b)
int MPILocalDomainLimits(int, int, void *, int *, int *, int *)
int(* WriteOutput)(int, int, int *, double *, double *, char *, int *)
int MPICreateIOGroups(void *)
Structure of MPI-related variables.
int npoints_local_wghosts
char op_file_format[_MAX_STRING_SIZE_]
SimulationObject * m_sim_fg
int MPIRanknD(int, int, int *, int *)
Contains macros and function definitions for common array operations.
#define _ArrayProduct1D_(x, size, p)
int MPICreateCommunicators(int, void *)
double * VolumeIntegralInitial