HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SparseGridsSolve.cpp
Go to the documentation of this file.
1 
6 #include <common_cpp.h>
7 #include <io_cpp.h>
8 #include <timeintegration_cpp.h>
10 
18 {
19  int tic = 0;
20 
21  /* write out iblank to file for visualization */
22  if (m_write_sg_solutions == 1) {
23  for (int ns = 0; ns < m_nsims_sg; ns++) {
24  if (m_sims_sg[ns].solver.flag_ib) {
25 
26  char fname_root[_MAX_STRING_SIZE_] = "iblank_sg";
27  if (m_nsims_sg > 1) {
28  char index[_MAX_STRING_SIZE_];
29  GetStringFromInteger(ns, index, (int)log10((m_nsims_sg)+1));
30  strcat(fname_root, "_");
31  strcat(fname_root, index);
32  }
33 
34  WriteArray( m_sims_sg[ns].solver.ndims,
35  1,
36  m_sims_sg[ns].solver.dim_global,
37  m_sims_sg[ns].solver.dim_local,
38  m_sims_sg[ns].solver.ghosts,
39  m_sims_sg[ns].solver.x,
40  m_sims_sg[ns].solver.iblank,
41  &(m_sims_sg[ns].solver),
42  &(m_sims_sg[ns].mpi),
43  fname_root );
44  }
45  }
46  }
47  if (m_sim_fg->solver.flag_ib) {
48 
49  char fname_root[_MAX_STRING_SIZE_] = "iblank";
51  1,
55  m_sim_fg->solver.x,
57  &(m_sim_fg->solver),
58  &(m_sim_fg->mpi),
59  fname_root );
60  }
61 
62  /* Define and initialize the time-integration object */
63  TimeIntegration TS;
64  if (!m_rank) printf("Setting up time integration.\n");
65  TimeInitialize((void*)m_sims_sg.data(), m_nsims_sg, m_rank, m_nproc, &TS);
66 
67  if (!m_rank) {
68  printf( "Solving in time (from %d to %d iterations)\n",
69  TS.restart_iter,TS.n_iter);
70  }
71 
72  for (TS.iter = TS.restart_iter; TS.iter < TS.n_iter; TS.iter++) {
73 
74  /* Write initial solution to file if this is the first iteration */
75  if (!TS.iter) OutputSolution(TS.waqt);
76 
77  /* Call pre-step function */
78  TimePreStep (&TS);
79 
80  /* Step in time */
81  TimeStep (&TS);
82 
83  /* Call post-step function */
84  TimePostStep (&TS);
85 
86  /* Print information to screen */
87  TimePrintStep(&TS);
88  tic++;
89 
90  /* Write intermediate solution to file */
91  if ((TS.iter+1)%m_sims_sg[0].solver.file_op_iter == 0) {
92  OutputSolution(TS.waqt);
93  tic = 0;
94  }
95 
96  }
97 
98  /* write a final solution file, if last iteration did not write one */
99  if (tic || (!TS.n_iter)) OutputSolution(TS.waqt);
100 
101  if (!m_rank) {
102  printf("Completed time integration (Final time: %f).\n",TS.waqt);
103  if (m_nsims_sg > 1) printf("\n");
104  }
105 
106  /* calculate error if exact solution has been provided */
107  CalculateError();
108 
109  TimeCleanup(&TS);
110 
111  return(0);
112 }
113 
std::vector< SimulationObject > m_sims_sg
int TimePostStep(void *)
Definition: TimePostStep.c:28
int TimePreStep(void *)
Definition: TimePreStep.c:22
int * dim_global
Definition: hypar.h:33
double * iblank
Definition: hypar.h:436
int TimeStep(void *)
Definition: TimeStep.c:13
Function declarations for file I/O functions.
void GetStringFromInteger(int, char *, int)
Structure of variables/parameters and function pointers for time integration.
int flag_ib
Definition: hypar.h:441
int * dim_local
Definition: hypar.h:37
int TimeCleanup(void *)
Definition: TimeCleanup.c:18
Contains C++ function declarations for time integration.
int ghosts
Definition: hypar.h:52
int WriteArray(int, int, int *, int *, int, double *, double *, void *, void *, char *)
Definition: WriteArray.c:27
#define _MAX_STRING_SIZE_
Definition: basic.h:14
Some common functions used here and there (C++ declarations)
int ndims
Definition: hypar.h:26
int TimePrintStep(void *)
Definition: TimePrintStep.c:16
double * x
Definition: hypar.h:107
int TimeInitialize(void *, int, int, int, void *)