GRINS-0.6.0
bc_handling_base.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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 #ifndef GRINS_BC_HANDLING_BASE_H
26 #define GRINS_BC_HANDLING_BASE_H
27 
28 //libMesh
29 #include "libmesh/libmesh.h"
30 #include "libmesh/getpot.h"
31 #include "libmesh/point.h"
32 
33 //GRINS
35 #include "grins/var_typedefs.h"
36 #include "grins/bc_types.h"
37 #include "grins/dbc_container.h"
38 #include "grins/pbc_container.h"
39 #include "grins/nbc_container.h"
41 #include "grins/cached_values.h"
42 
43 // libMesh forward declarations
44 namespace libMesh
45 {
46  class FEMSystem;
47  class DofMap;
48 }
49 
50 namespace GRINS
51 {
52  // GRINS forward declarations
53  class AssemblyContext;
54 
57  {
58  public:
59 
60  BCHandlingBase(const std::string& physics_name);
61 
62  virtual ~BCHandlingBase();
63 
65 
66  void attach_dirichlet_bound_func( const GRINS::DBCContainer& dirichlet_bc );
67 
68  virtual void read_bc_data( const GetPot& input, const std::string& id_str,
69  const std::string& bc_str,
70  const std::string& var_str,
71  const std::string& val_str );
72 
74 
77  virtual void init_bc_data( const libMesh::FEMSystem& system );
78 
79  virtual void apply_neumann_bcs( AssemblyContext& context,
80  const GRINS::CachedValues& cache,
81  const bool request_jacobian,
82  const GRINS::BoundaryID bc_id ) const;
83 
84  virtual void user_apply_neumann_bcs( AssemblyContext& context,
85  const GRINS::CachedValues& cache,
86  const bool request_jacobian,
87  const GRINS::BoundaryID bc_id,
88  const GRINS::BCType bc_type ) const;
89 
90  virtual void init_dirichlet_bc_func_objs( libMesh::FEMSystem* system ) const;
91 
92  virtual void init_periodic_bcs( libMesh::FEMSystem* system ) const;
93 
94  void set_dirichlet_bc_type( GRINS::BoundaryID bc_id, int bc_type );
95  void set_neumann_bc_type( GRINS::BoundaryID bc_id, int bc_type );
96  void set_dirichlet_bc_value( GRINS::BoundaryID bc_id, libMesh::Real value, int component = 0 );
97  void set_neumann_bc_value( GRINS::BoundaryID bc_id, const libMesh::Point& q_in );
98  libMesh::Real get_dirichlet_bc_value( GRINS::BoundaryID bc_id, int component = 0 ) const;
99 
100  const libMesh::Point& get_neumann_bc_value( GRINS::BoundaryID bc_id ) const;
101 
102  std::tr1::shared_ptr< GRINS::NeumannFuncObj > get_neumann_bound_func( GRINS::BoundaryID bc_id,
103  GRINS::VariableIndex var_id ) const;
104 
105  std::tr1::shared_ptr< GRINS::NeumannFuncObj > get_neumann_bound_func( GRINS::BoundaryID bc_id,
106  GRINS::VariableIndex var_id );
107 
108  virtual void init_dirichlet_bcs( libMesh::FEMSystem* system ) const;
109 
110  // User will need to implement these functions for BC handling
111  virtual int string_to_int( const std::string& bc_type_in ) const;
112 
113  virtual void init_bc_types( const GRINS::BoundaryID bc_id,
114  const std::string& bc_id_string,
115  const int bc_type,
116  const std::string& bc_vars,
117  const std::string& bc_value,
118  const GetPot& input );
119 
120  virtual void user_init_dirichlet_bcs( libMesh::FEMSystem* system,
121  libMesh::DofMap& dof_map,
122  GRINS::BoundaryID bc_id,
123  GRINS::BCType bc_type ) const;
124 
125 
127 
128  bool is_axisymmetric() const;
129 
130  protected:
131 
133 
137  std::vector<std::pair<BoundaryID,BCType> > _dirichlet_bc_map;
138 
140  std::map< GRINS::BoundaryID, GRINS::BCType> _neumann_bc_map;
141 
143  std::map< GRINS::BoundaryID, libMesh::Point > _dirichlet_values;
144 
146  std::map< GRINS::BoundaryID, libMesh::Point > _q_values;
147 
148 
149  std::map< GRINS::BoundaryID, GRINS::NBCContainer > _neumann_bound_funcs;
150 
151  std::vector< GRINS::DBCContainer > _dirichlet_bound_funcs;
152 
154 
157 
158  std::vector< GRINS::PBCContainer > _periodic_bcs;
159  unsigned int _num_periodic_bcs;
160 
161  std::string _physics_name;
162 
163  enum BC_BASE{ PERIODIC = -5,
168 
170  static bool _axisymmetric;
171 
172  private:
173  BCHandlingBase();
174 
175  };
176 
177  /* ------------------------- Inline Functions -------------------------*/
178  inline
180  {
181  return _axisymmetric;
182  }
183 
184  inline
185  const libMesh::Point& BCHandlingBase::get_neumann_bc_value( GRINS::BoundaryID bc_id ) const
186  {
187  return (_q_values.find(bc_id))->second;
188  }
189 
190  inline
191  std::tr1::shared_ptr< GRINS::NeumannFuncObj >
193  GRINS::VariableIndex var_id ) const
194  {
195  return ((_neumann_bound_funcs.find(bc_id))->second).get_func(var_id);
196  }
197 
198  inline
199  std::tr1::shared_ptr< GRINS::NeumannFuncObj >
201  GRINS::VariableIndex var_id )
202  {
203  return ((_neumann_bound_funcs.find(bc_id))->second).get_func(var_id);
204  }
205 
206  inline
208  {
209  BCType bc_type_out = -100;
210 
211  for( std::vector<std::pair<BoundaryID,BCType> >::const_iterator it = _dirichlet_bc_map.begin();
212  it != _dirichlet_bc_map.end(); it++ )
213  {
214  if( it->first == bc_id ) bc_type_out = it->second;
215  }
216 
217  libmesh_assert_not_equal_to( bc_type_out, -100 );
218 
219  return bc_type_out;
220  }
221 
222 }
223 #endif // GRINS_BC_HANDLING_BASE
unsigned int VariableIndex
More descriptive name of the type used for variable indices.
Definition: var_typedefs.h:40
virtual void read_bc_data(const GetPot &input, const std::string &id_str, const std::string &bc_str, const std::string &var_str, const std::string &val_str)
virtual void user_init_dirichlet_bcs(libMesh::FEMSystem *system, libMesh::DofMap &dof_map, GRINS::BoundaryID bc_id, GRINS::BCType bc_type) const
Simple helper class to setup general Dirichlet boundary conditions.
Definition: dbc_container.h:49
std::vector< GRINS::PBCContainer > _periodic_bcs
libMesh::boundary_id_type BoundaryID
More descriptive name of the type used for boundary ids.
Definition: var_typedefs.h:54
void attach_dirichlet_bound_func(const GRINS::DBCContainer &dirichlet_bc)
std::vector< GRINS::DBCContainer > _dirichlet_bound_funcs
virtual void apply_neumann_bcs(AssemblyContext &context, const GRINS::CachedValues &cache, const bool request_jacobian, const GRINS::BoundaryID bc_id) const
std::tr1::shared_ptr< GRINS::NeumannFuncObj > get_neumann_bound_func(GRINS::BoundaryID bc_id, GRINS::VariableIndex var_id) const
std::map< GRINS::BoundaryID, libMesh::Point > _dirichlet_values
Stash prescribed Dirichlet boundary values.
void attach_neumann_bound_func(GRINS::NBCContainer &neumann_bcs)
void set_dirichlet_bc_value(GRINS::BoundaryID bc_id, libMesh::Real value, int component=0)
void set_neumann_bc_value(GRINS::BoundaryID bc_id, const libMesh::Point &q_in)
GRINS namespace.
unsigned int _num_periodic_bcs
const libMesh::Point & get_neumann_bc_value(GRINS::BoundaryID bc_id) const
Simple helper class to setup general Neumann boundary conditions.
Definition: nbc_container.h:41
virtual void init_bc_types(const GRINS::BoundaryID bc_id, const std::string &bc_id_string, const int bc_type, const std::string &bc_vars, const std::string &bc_value, const GetPot &input)
GRINS::BCType get_dirichlet_bc_type(const GRINS::BoundaryID bc_id) const
std::vector< std::pair< BoundaryID, BCType > > _dirichlet_bc_map
Map between boundary id and Dirichlet boundary condition type.
virtual void init_dirichlet_bcs(libMesh::FEMSystem *system) const
virtual int string_to_int(const std::string &bc_type_in) const
virtual void init_periodic_bcs(libMesh::FEMSystem *system) const
bool is_axisymmetric() const
static bool _axisymmetric
Flag to cache whether or not there is an axisymmetric boundary present.
virtual void init_dirichlet_bc_func_objs(libMesh::FEMSystem *system) const
std::map< GRINS::BoundaryID, GRINS::NBCContainer > _neumann_bound_funcs
GRINS::BoundaryConditions _bound_conds
Object that stashes generic boundary condition types.
Class to hold typical boundary condition methods.
Base class for reading and handling boundary conditions for physics classes.
virtual void init_bc_data(const libMesh::FEMSystem &system)
Override this method to initialize any system-dependent data.
std::map< GRINS::BoundaryID, libMesh::Point > _q_values
Stash prescribed boundary fluxes.
std::map< GRINS::BoundaryID, GRINS::BCType > _neumann_bc_map
Map between boundary id and Neumann boundary condition type.
void set_neumann_bc_type(GRINS::BoundaryID bc_id, int bc_type)
int BCType
Definition: bc_types.h:32
void set_dirichlet_bc_type(GRINS::BoundaryID bc_id, int bc_type)
libMesh::Real get_dirichlet_bc_value(GRINS::BoundaryID bc_id, int component=0) const
virtual void user_apply_neumann_bcs(AssemblyContext &context, const GRINS::CachedValues &cache, const bool request_jacobian, const GRINS::BoundaryID bc_id, const GRINS::BCType bc_type) const

Generated on Mon Jun 22 2015 21:32:19 for GRINS-0.6.0 by  doxygen 1.8.9.1