www.mooseframework.org
LevelSetReinitializationMultiApp.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
10 
11 #include "Executioner.h"
12 
13 // libMesh
14 #include "libmesh/mesh_tools.h"
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<MultiApp>();
21  params.addClassDescription(
22  "MultiApp capable of performing repeated complete solves for level set reinitialization.");
23  params.addParam<unsigned int>(
24  "interval", 1, "Time step interval when to perform reinitialization.");
25 
26  params.suppressParameter<std::vector<Point>>("positions");
27  params.suppressParameter<std::vector<FileName>>("positions_file");
28  params.suppressParameter<bool>("output_in_position");
29  params.suppressParameter<Real>("reset_time");
30  params.suppressParameter<std::vector<unsigned int>>("reset_apps");
31  params.suppressParameter<Real>("move_time");
32  params.suppressParameter<std::vector<unsigned int>>("move_apps");
33  params.suppressParameter<std::vector<Point>>("move_positions");
34 
35  return params;
36 }
37 
39  const InputParameters & parameters)
40  : MultiApp(parameters), _level_set_problem(NULL), _interval(getParam<unsigned int>("interval"))
41 {
42 }
43 
44 void
46 {
47  MultiApp::initialSetup();
48 
49  if (_has_an_app)
50  {
51  Executioner * ex = _apps[0]->getExecutioner();
52 
53  if (!ex)
54  mooseError("Executioner does not exist!");
55 
56  ex->init();
57 
58  _executioner = ex;
59 
60  _level_set_problem = dynamic_cast<LevelSetReinitializationProblem *>(&appProblemBase(0));
61  if (!_level_set_problem)
62  mooseError("The Problem type must be LevelSetReinitializationProblem.");
63  }
64 }
65 
66 bool
68  Real /*target_time*/,
69  bool /*auto_advance*/)
70 {
71  // Do nothing if not on interval
72  if ((_fe_problem.timeStep() % _interval) != 0)
73  return true;
74 
75  if (!_has_an_app)
76  return true;
77 
78  _console << "Solving Reinitialization problem." << std::endl;
79 
80  int rank;
81  int ierr;
82  ierr = MPI_Comm_rank(_orig_comm, &rank);
83  mooseCheckMPIErr(ierr);
84 
85  bool last_solve_converged = true;
86 
88  _executioner->execute();
89  if (!_executioner->lastSolveConverged())
90  last_solve_converged = false;
91 
92  return last_solve_converged;
93 }
const unsigned int & _interval
The solve interval for reinitialization.
LevelSetReinitializationMultiApp(const InputParameters &parameters)
void resetTime()
Resets the state of the simulation to allow for it to be re-executed.
A Problem object to perform level set equation reinitialization implementation, mainly implementing a...
LevelSetReinitializationProblem * _level_set_problem
Access to the level set specific problem to allow for the resetTime() method to be called...
InputParameters validParams< LevelSetReinitializationMultiApp >()
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
Executioner * _executioner
Access to the Executioner object to call execute()