PLUTO
AMRLevelPlutoFactory.cpp
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3 * _______ __
4 * / ___/ / ___ __ _ / / ___
5 * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6 * \___/_//_/\___/_/_/_/_.__/\___/
7 * Please refer to Copyright.txt, in Chombo's root directory.
8 */
9 #endif
10 
11 #include "AMRLevelPlutoFactory.H"
12 
13 #include "NamespaceHeader.H"
14 
15 AMRLevelPlutoFactory::AMRLevelPlutoFactory()
16 {
17  m_patchPluto = NULL;
18  m_isDefined = false;
19 }
20 
21 AMRLevelPlutoFactory::~AMRLevelPlutoFactory()
22 {
23  if (m_patchPluto != NULL)
24  {
25  delete m_patchPluto;
26  m_patchPluto = NULL;
27  }
28 
29  m_isDefined = false;
30 }
31 
32 void AMRLevelPlutoFactory::define(const Real& a_cfl,
33  const Real& a_domainLength,
34  const int& a_verbosity,
35  const Real& a_refineThresh,
36  const int& a_tagBufferSize,
37  const Real& a_initialDtMultiplier,
38  const PatchPluto* const a_patchPluto)
39 {
40  // Store the CFL number
41  m_cfl = a_cfl;
42 
43  // Store the physical dimension of the longest side of the domain
44  m_domainLength = a_domainLength;
45 
46  // Store the verbosity of the object
47  m_verbosity = a_verbosity;
48 
49  // Store the refinement threshold for gradient
50  m_refineThresh = a_refineThresh;
51 
52  // Store the tag buffer size
53  m_tagBufferSize = a_tagBufferSize;
54 
55  // Store the initial dt multiplier
56  m_initialDtMultiplier = a_initialDtMultiplier;
57 
58  // Delete any existing physics object
59  if (m_patchPluto != NULL)
60  {
61  delete m_patchPluto;
62  m_patchPluto = NULL;
63  }
64 
65  // Store the object that supplies the physics needed by the integrator
66  // (used as a factory)
67  m_patchPluto = a_patchPluto->new_patchPluto();
68 
69  // The object is defined
70  m_isDefined = true;
71 }
72 
73 AMRLevel* AMRLevelPlutoFactory::new_amrlevel() const
74 {
75  // Make sure everything is defined
76  CH_assert(isDefined());
77 
78  // Create a new AMRLevelPluto
79  AMRLevelPluto* amrGodPtr = new AMRLevelPluto();
80 
81  // Set up new object
82  amrGodPtr->defineParams(m_cfl,
83  m_domainLength,
84  m_verbosity,
85  m_refineThresh,
86  m_tagBufferSize,
87  m_initialDtMultiplier,
88  m_patchPluto);
89 
90  // Return it
91  return (static_cast <AMRLevel*> (amrGodPtr));
92 }
93 
94 // Check that everything is defined
95 bool AMRLevelPlutoFactory::isDefined() const
96 {
97  return m_isDefined;
98 }
99 
100 #include "NamespaceFooter.H"