GRINS-0.8.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-2017 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"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 #include "libmesh/elem.h"
36 #include "libmesh/fe_interface.h"
37 
38 namespace GRINS
39 {
40  // Initialize static members
41  bool Physics::_is_steady = false;
42  bool Physics::_is_axisymmetric = false;
43 
44  Physics::Physics( const std::string& physics_name,
45  const GetPot& input )
46  : ParameterUser(physics_name),
47  _physics_name( physics_name ),
48  _ic_handler(new ICHandlingBase(physics_name))
49  {
50  this->parse_enabled_subdomains(input,physics_name);
51 
52  // Check if this is an axisymmetric problem
53  // There will be redundant calls for multiple Physics objects,
54  // but this guarantees we've parsed is_axisymmetric and then
55  // we can check in subclasses and error out if the Physics
56  // doesn't support axisymmetry.
57  Physics::set_is_axisymmetric( input("Physics/is_axisymmetric",false) );
58  }
59 
61  {
62  if( _ic_handler ) delete _ic_handler;
63  }
64 
65  void Physics::parse_enabled_subdomains( const GetPot& input,
66  const std::string& physics_name )
67  {
68  int num_ids = input.vector_variable_size( "Physics/"+physics_name+"/enabled_subdomains" );
69 
70  for( int i = 0; i < num_ids; i++ )
71  {
72  libMesh::subdomain_id_type dumvar = input( "Physics/"+physics_name+"/enabled_subdomains", -1, i );
73  _enabled_subdomains.insert( dumvar );
74  }
75  }
76 
77  bool Physics::enabled_on_elem( const libMesh::Elem* elem )
78  {
79  // Check if enabled_subdomains flag has been set and if we're
80  // looking at a real element (rather than a nonlocal evaluation)
81  if( !elem || _enabled_subdomains.empty() )
82  return true;
83 
84  // Check if current physics is enabled on elem
85  if( _enabled_subdomains.find( elem->subdomain_id() ) == _enabled_subdomains.end() )
86  return false;
87 
88  return true;
89  }
90 
91  void Physics::set_is_steady( bool is_steady )
92  {
94  return;
95  }
96 
97  bool Physics::is_steady() const
98  {
99  return _is_steady;
100  }
101 
102  void Physics::set_time_evolving_vars( libMesh::FEMSystem* /*system*/ )
103  {
104  return;
105  }
106 
108  {
109  return;
110  }
111 
112 
113  void Physics::init_ics( libMesh::FEMSystem* system,
115  {
116  if( _ic_handler )
117  {
118  _ic_handler->init_ic_data( *system, all_ics );
119  }
120 
121  return;
122  }
123 
125  {
126  return;
127  }
128 
129  void Physics::register_postprocessing_vars( const GetPot& /*input*/,
130  PostProcessedQuantities<libMesh::Real>& /*postprocessing*/ )
131  {
132  return;
133  }
134 
135  void Physics::compute_postprocessed_quantity( unsigned int /*quantity_index*/,
136  const AssemblyContext& /*context*/,
137  const libMesh::Point& /*point*/,
138  libMesh::Real& /*value*/ )
139  {
140  return;
141  }
142 
143  libMesh::UniquePtr<libMesh::FEGenericBase<libMesh::Real> > Physics::build_new_fe( const libMesh::Elem* elem,
144  const libMesh::FEGenericBase<libMesh::Real>* fe,
145  const libMesh::Point p )
146  {
147  using namespace libMesh;
148  FEType fe_type = fe->get_fe_type();
149 
150  // If we don't have an Elem to evaluate on, then the only functions
151  // we can sensibly evaluate are the scalar dofs which are the same
152  // everywhere.
153  libmesh_assert(elem || fe_type.family == SCALAR);
154 
155  unsigned int elem_dim = elem ? elem->dim() : 0;
156 
157  UniquePtr<FEGenericBase<libMesh::Real> >
158  fe_new(FEGenericBase<libMesh::Real>::build(elem_dim, fe_type));
159 
160  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
161  // Build a vector of point co-ordinates to send to reinit
162  Point master_point = elem ?
163  FEInterface::inverse_map(elem_dim, fe_type, elem, p) :
164  Point(0);
165 
166  std::vector<Point> coor(1, master_point);
167 
168  // Reinitialize the element and compute the shape function values at coor
169  fe_new->reinit (elem, &coor);
170 
171  return fe_new;
172  }
173 
175  {
176  const std::set<libMesh::subdomain_id_type>& var_subdomains = var.subdomain_ids();
177 
178  // If both are empty or only the var is empty, we don't need to do anything
179  // since the check is automatically satisified. Empty in both cases means
180  // enabled on all subdomains
181 
182  if( _enabled_subdomains.empty() && !var_subdomains.empty() )
183  libmesh_error_msg("ERROR: Physics enabled on all subdomains but variable is not!");
184 
185  if( !_enabled_subdomains.empty() && !var_subdomains.empty() )
186  for( std::set<libMesh::subdomain_id_type>::const_iterator it = _enabled_subdomains.begin(); it != _enabled_subdomains.end(); ++it )
187  if( var_subdomains.find(*it) == var_subdomains.end() )
188  libmesh_error_msg("ERROR: Could not find subdomain " << *it << " in varaible!");
189  }
190 
191 } // namespace GRINS
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
Definition: physics.C:135
GRINS::ICHandlingBase * _ic_handler
Definition: physics.h:258
bool is_steady() const
Returns whether or not this physics is being solved with a steady solver.
Definition: physics.C:97
virtual void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Register name of postprocessed quantity with PostProcessedQuantities.
Definition: physics.C:129
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:143
void check_var_subdomain_consistency(const FEVariablesBase &var) const
Check that var is enabled on at least the subdomains this Physics is.
Definition: physics.C:174
virtual ~Physics()
Definition: physics.C:60
GRINS namespace.
const std::set< libMesh::subdomain_id_type > & subdomain_ids() const
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:77
virtual void auxiliary_init(MultiphysicsSystem &system)
Any auxillary initialization a Physics class may need.
Definition: physics.C:107
Base class for reading and handling initial conditions for physics classes.
static void set_is_axisymmetric(bool is_axisymmetric)
Set whether we should treat the problem as axisymmetric.
Definition: physics.h:129
static bool _is_steady
Caches whether or not the solver that's being used is steady or not.
Definition: physics.h:266
virtual void set_time_evolving_vars(libMesh::FEMSystem *system)
Set which variables are time evolving.
Definition: physics.C:102
Interface with libMesh for solving Multiphysics problems.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
Definition: physics.C:124
void parse_enabled_subdomains(const GetPot &input, const std::string &physics_name)
Definition: physics.C:65
virtual void init_ic_data(const libMesh::FEMSystem &system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
Override this method to initialize any system-dependent data.
static bool _is_axisymmetric
Caches whether we are solving an axisymmetric problem or not.
Definition: physics.h:269
void init_ics(libMesh::FEMSystem *system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
Definition: physics.C:113
std::set< libMesh::subdomain_id_type > _enabled_subdomains
Subdomains on which the current Physics class is enabled.
Definition: physics.h:261
void set_is_steady(bool is_steady)
Sets whether this physics is to be solved with a steady solver or not.
Definition: physics.C:91

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1