Exemplo n.º 1
0
int main(int argc, char ** argv) {

  if (argc == 1) {
    cerr << "usage: " << string{argv[0]} << " <parameter file>." << endl << endl;
    exit (-1);
  }

  setNbThreads(16);

  ParamParser parser(string{argv[1]});
  GeometryStructure geometry (parser);
  ProblemStructure  problem  (parser, geometry);
  OutputStructure   output   (parser, geometry, problem);

  problem.initializeProblem();
  
  problem.updateForcingTerms();
  problem.solveStokes();

  problem.recalculateTimestep();
  
  do {    
    output.writeHDF5File (problem.getTimestepNumber());
    cout << "<Timestep: " << problem.getTimestepNumber() << "; t=" << problem.getTime() << ">" << endl << endl;
    problem.updateForcingTerms();
    problem.solveStokes();
    problem.recalculateTimestep();
    problem.solveAdvectionDiffusion();

  } while (problem.advanceTimestep());

  output.writeHDF5File (problem.getTimestepNumber());
  cerr << "Timestep: " << problem.getTimestepNumber() << "; t = " << problem.getTime() << endl;

  output.writeHDF5File();
  
  return 0;
}
Exemplo n.º 2
0
int main(int argc, char ** argv) {

// The valid command line usage is "./mc-mini <parameter file>". Otherwise, throw an exception.
  if (argc == 1) {
    throw std::invalid_argument("usage: " + std::string{argv[0]} + " <parameter file>.");
  }

// Initialize the parser with the specified parameter file.
  ParamParser parser(std::string{argv[1]});
// Initialize geometry parameters.
  GeometryStructure geometry (parser);
// Initialize parameters related to the implementation of the employed numerical method.
  ProblemStructure  problem  (parser, geometry);
// Initialize parameters related to output structure.
  OutputStructure   output   (parser, geometry, problem);

// Initialize the initial data for the problem to be solved.
  problem.initializeProblem();

// Main loop where computations are made and data is output for each timestep of the problem.
  do
  {
    // 1. Solve Stokes equations.
    problem.solveStokes();
    // 2. Initialize the right hand side (forcing terms).
    problem.updateForcingTerms();
    // 3. Recalculate time step.
    problem.recalculateTimestep();
    // 4. Output the solution data.
    output.outputData (problem.getTimestepNumber());
    // 5. Solve advection-diffusion equation.
    problem.solveAdvectionDiffusion();
    // 6. Output which time step is being computed.
    std::cout << "<Timestep: " << problem.getTimestepNumber() << "; t=" << problem.getTime() << ">" << std::endl;
  }
  while (problem.advanceTimestep()); // Loop termination criterion: problem.getTimestepNumber() = end_timestep.

  problem.solveStokes(); // Solve Stokes equations.
  output.outputData (problem.getTimestepNumber()); // Output the solution data.

  return 0;
}