GRINS-0.7.0
physics.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // This class
27 #include "grins/physics.h"
28 
29 // GRINS
30 #include "grins/ic_handling_base.h"
31 
32 // libMesh
33 #include "libmesh/getpot.h"
34 #include "libmesh/elem.h"
35 #include "libmesh/fe_interface.h"
36 
37 namespace GRINS
38 {
39  // Initialize static members
40  bool Physics::_is_steady = false;
41  bool Physics::_is_axisymmetric = false;
42 
43  Physics::Physics( const std::string& physics_name,
44  const GetPot& input )
45  : ParameterUser(physics_name),
46  _physics_name( physics_name ),
47  _ic_handler(new ICHandlingBase(physics_name))
48  {
49  this->parse_enabled_subdomains(input,physics_name);
50 
51  // Check if this is an axisymmetric problem
52  // There will be redundant calls for multiple Physics objects,
53  // but this guarantees we've parsed is_axisymmetric and then
54  // we can check in subclasses and error out if the Physics
55  // doesn't support axisymmetry.
56  Physics::set_is_axisymmetric( input("Physics/is_axisymmetric",false) );
57  }
58 
60  {
61  if( _ic_handler ) delete _ic_handler;
62  }
63 
64  void Physics::parse_enabled_subdomains( const GetPot& input,
65  const std::string& physics_name )
66  {
67  int num_ids = input.vector_variable_size( "Physics/"+physics_name+"/enabled_subdomains" );
68 
69  for( int i = 0; i < num_ids; i++ )
70  {
71  libMesh::subdomain_id_type dumvar = input( "Physics/"+physics_name+"/enabled_subdomains", -1, i );
72  _enabled_subdomains.insert( dumvar );
73  }
74  }
75 
76  bool Physics::enabled_on_elem( const libMesh::Elem* elem )
77  {
78  // Check if enabled_subdomains flag has been set and if we're
79  // looking at a real element (rather than a nonlocal evaluation)
80  if( !elem || _enabled_subdomains.empty() )
81  return true;
82 
83  // Check if current physics is enabled on elem
84  if( _enabled_subdomains.find( elem->subdomain_id() ) == _enabled_subdomains.end() )
85  return false;
86 
87  return true;
88  }
89 
90  void Physics::set_is_steady( bool is_steady )
91  {
93  return;
94  }
95 
96  bool Physics::is_steady() const
97  {
98  return _is_steady;
99  }
100 
101  void Physics::set_time_evolving_vars( libMesh::FEMSystem* /*system*/ )
102  {
103  return;
104  }
105 
107  {
108  return;
109  }
110 
111 
112  void Physics::init_ics( libMesh::FEMSystem* system,
114  {
115  if( _ic_handler )
116  {
117  _ic_handler->init_ic_data( *system, all_ics );
118  }
119 
120  return;
121  }
122 
124  {
125  return;
126  }
127 
128  void Physics::register_postprocessing_vars( const GetPot& /*input*/,
129  PostProcessedQuantities<libMesh::Real>& /*postprocessing*/ )
130  {
131  return;
132  }
133 
135  CachedValues& )
136  {
137  return;
138  }
139 
141  CachedValues& /*cache*/ )
142  {
143  return;
144  }
145 
147  CachedValues& /*cache*/ )
148  {
149  return;
150  }
151 
153  CachedValues& /*cache*/ )
154  {
155  return;
156  }
157 
159  CachedValues& /*cache*/ )
160  {
161  return;
162  }
163 
165  CachedValues& /*cache*/ )
166  {
167  return;
168  }
169 
171  CachedValues& /*cache*/ )
172  {
173  return;
174  }
175 
177  CachedValues& /*cache*/ )
178  {
179  return;
180  }
181 
183  CachedValues& /*cache*/ )
184  {
185  return;
186  }
187 
188  void Physics::element_time_derivative( bool /*compute_jacobian*/,
189  AssemblyContext& /*context*/,
190  CachedValues& /*cache*/ )
191  {
192  return;
193  }
194 
195  void Physics::side_time_derivative( bool /*compute_jacobian*/,
196  AssemblyContext& /*context*/,
197  CachedValues& /*cache*/ )
198  {
199  return;
200  }
201 
202  void Physics::nonlocal_time_derivative( bool /*compute_jacobian*/,
203  AssemblyContext& /*context*/,
204  CachedValues& /*cache*/ )
205  {
206  return;
207  }
208 
209  void Physics::element_constraint( bool /*compute_jacobian*/,
210  AssemblyContext& /*context*/,
211  CachedValues& /*cache*/ )
212  {
213  return;
214  }
215 
216  void Physics::side_constraint( bool /*compute_jacobian*/,
217  AssemblyContext& /*context*/,
218  CachedValues& /*cache*/ )
219  {
220  return;
221  }
222 
223  void Physics::nonlocal_constraint( bool /*compute_jacobian*/,
224  AssemblyContext& /*context*/,
225  CachedValues& /*cache*/ )
226  {
227  return;
228  }
229 
230  void Physics::damping_residual( bool /*compute_jacobian*/,
231  AssemblyContext& /*context*/,
232  CachedValues& /*cache*/ )
233  {
234  return;
235  }
236 
237  void Physics::mass_residual( bool /*compute_jacobian*/,
238  AssemblyContext& /*context*/,
239  CachedValues& /*cache*/ )
240  {
241  return;
242  }
243 
244  void Physics::nonlocal_mass_residual( bool /*compute_jacobian*/,
245  AssemblyContext& /*context*/,
246  CachedValues& /*cache*/ )
247  {
248  return;
249  }
250 
251  void Physics::compute_postprocessed_quantity( unsigned int /*quantity_index*/,
252  const AssemblyContext& /*context*/,
253  const libMesh::Point& /*point*/,
254  libMesh::Real& /*value*/ )
255  {
256  return;
257  }
258 
259  libMesh::UniquePtr<libMesh::FEGenericBase<libMesh::Real> > Physics::build_new_fe( const libMesh::Elem* elem,
260  const libMesh::FEGenericBase<libMesh::Real>* fe,
261  const libMesh::Point p )
262  {
263  using namespace libMesh;
264  FEType fe_type = fe->get_fe_type();
265 
266  // If we don't have an Elem to evaluate on, then the only functions
267  // we can sensibly evaluate are the scalar dofs which are the same
268  // everywhere.
269  libmesh_assert(elem || fe_type.family == SCALAR);
270 
271  unsigned int elem_dim = elem ? elem->dim() : 0;
272 
273  UniquePtr<FEGenericBase<libMesh::Real> >
274  fe_new(FEGenericBase<libMesh::Real>::build(elem_dim, fe_type));
275 
276  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
277  // Build a vector of point co-ordinates to send to reinit
278  Point master_point = elem ?
279  FEInterface::inverse_map(elem_dim, fe_type, elem, p) :
280  Point(0);
281 
282  std::vector<Point> coor(1, master_point);
283 
284  // Reinitialize the element and compute the shape function values at coor
285  fe_new->reinit (elem, &coor);
286 
287  return fe_new;
288  }
289 
290 #ifdef GRINS_USE_GRVY_TIMERS
291  void Physics::attach_grvy_timer( GRVY::GRVY_Timer_Class* grvy_timer )
292  {
293  _timer = grvy_timer;
294  return;
295  }
296 #endif
297 
298 } // namespace GRINS
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
Definition: physics.C:251
GRINS::ICHandlingBase * _ic_handler
Definition: physics.h:269
bool is_steady() const
Returns whether or not this physics is being solved with a steady solver.
Definition: physics.C:96
virtual void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Register name of postprocessed quantity with PostProcessedQuantities.
Definition: physics.C:128
libMesh::UniquePtr< libMesh::FEGenericBase< libMesh::Real > > build_new_fe(const libMesh::Elem *elem, const libMesh::FEGenericBase< libMesh::Real > *fe, const libMesh::Point p)
Definition: physics.C:259
virtual void damping_residual(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Damping matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
Definition: physics.C:230
virtual void nonlocal_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for scalar variables.
Definition: physics.C:202
virtual void compute_mass_residual_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:176
virtual ~Physics()
Definition: physics.C:59
virtual void compute_element_time_derivative_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:134
virtual void element_constraint(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Constraint part(s) of physics for element interiors.
Definition: physics.C:209
virtual void compute_side_constraint_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:158
GRINS namespace.
virtual void compute_element_constraint_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:152
virtual void compute_side_time_derivative_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:140
ParameterUser base class. Utility methods for subclasses.
virtual bool enabled_on_elem(const libMesh::Elem *elem)
Find if current physics is active on supplied element.
Definition: physics.C:76
virtual void side_constraint(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Constraint part(s) of physics for boundaries of elements on the domain boundary.
Definition: physics.C:216
virtual void auxiliary_init(MultiphysicsSystem &system)
Any auxillary initialization a Physics class may need.
Definition: physics.C:106
Base class for reading and handling initial conditions for physics classes.
virtual void nonlocal_mass_residual(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Mass matrix part(s) for scalar variables.
Definition: physics.C:244
static void set_is_axisymmetric(bool is_axisymmetric)
Set whether we should treat the problem as axisymmetric.
Definition: physics.h:130
static bool _is_steady
Caches whether or not the solver that's being used is steady or not.
Definition: physics.h:277
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Set which variables are time evolving.
Definition: physics.C:101
Interface with libMesh for solving Multiphysics problems.
virtual void compute_damping_residual_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:170
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
Definition: physics.C:123
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.
Definition: physics.C:188
void parse_enabled_subdomains(const GetPot &input, const std::string &physics_name)
Definition: physics.C:64
virtual void side_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for boundaries of elements on the domain boundary.
Definition: physics.C:195
virtual void init_ic_data(const libMesh::FEMSystem &system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
Override this method to initialize any system-dependent data.
virtual void compute_nonlocal_mass_residual_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:182
virtual void compute_nonlocal_time_derivative_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:146
virtual void compute_nonlocal_constraint_cache(const AssemblyContext &context, CachedValues &cache)
Definition: physics.C:164
static bool _is_axisymmetric
Caches whether we are solving an axisymmetric problem or not.
Definition: physics.h:280
virtual void nonlocal_constraint(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Constraint part(s) of physics for scalar variables.
Definition: physics.C:223
void init_ics(libMesh::FEMSystem *system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
Definition: physics.C:112
std::set< libMesh::subdomain_id_type > _enabled_subdomains
Subdomains on which the current Physics class is enabled.
Definition: physics.h:272
void set_is_steady(bool is_steady)
Sets whether this physics is to be solved with a steady solver or not.
Definition: physics.C:90
virtual void mass_residual(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part...
Definition: physics.C:237

Generated on Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10