GRINS-0.6.0
heat_transfer_bc_handling.C
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 
26 // This class
28 
29 // libMesh
30 #include "libmesh/const_function.h"
31 #include "libmesh/dirichlet_boundaries.h"
32 #include "libmesh/dof_map.h"
33 #include "libmesh/fem_system.h"
34 
35 namespace GRINS
36 {
37 
38  HeatTransferBCHandling::HeatTransferBCHandling(const std::string& physics_name,
39  const GetPot& input)
40  : BCHandlingBase(physics_name),
41  _temp_vars(input)
42  {
43  std::string id_str = "Physics/"+_physics_name+"/bc_ids";
44  std::string bc_str = "Physics/"+_physics_name+"/bc_types";
45  std::string var_str = "Physics/"+_physics_name+"/bc_variables";
46  std::string val_str = "Physics/"+_physics_name+"/bc_values";
47 
48  this->read_bc_data( input, id_str, bc_str, var_str, val_str );
49 
50  return;
51  }
52 
54  {
55  return;
56  }
57 
58  int HeatTransferBCHandling::string_to_int( const std::string& bc_type ) const
59  {
60  int bc_type_out;
61 
62  if( bc_type == "isothermal_wall" )
63  bc_type_out = ISOTHERMAL_WALL;
64 
65  else if( bc_type == "adiabatic_wall" )
66  bc_type_out = ADIABATIC_WALL;
67 
68  else if( bc_type == "prescribed_heat_flux" )
69  bc_type_out = PRESCRIBED_HEAT_FLUX;
70 
71  else if( bc_type == "general_heat_flux" )
72  bc_type_out = GENERAL_HEAT_FLUX;
73 
74  else
75  {
76  // Call base class to detect any physics-common boundary conditions
77  bc_type_out = BCHandlingBase::string_to_int( bc_type );
78  }
79 
80  return bc_type_out;
81  }
82 
83  void HeatTransferBCHandling::init_bc_data( const libMesh::FEMSystem& system )
84  {
85  _temp_vars.init(const_cast<libMesh::FEMSystem*>(&system));
86 
87  return;
88  }
89 
91  const std::string& bc_id_string,
92  const int bc_type,
93  const std::string& bc_vars,
94  const std::string& bc_value,
95  const GetPot& input )
96  {
97  switch(bc_type)
98  {
99  case(ISOTHERMAL_WALL):
100  {
101  this->set_dirichlet_bc_type( bc_id, bc_type );
102 
103  this->set_dirichlet_bc_value( bc_id, input("Physics/"+_physics_name+"/T_wall_"+bc_id_string, 0.0 ) );
104  }
105  break;
106 
107  case(ADIABATIC_WALL):
108  {
109  this->set_neumann_bc_type( bc_id, bc_type );
110  }
111  break;
112 
113  case(PRESCRIBED_HEAT_FLUX):
114  {
115  this->set_neumann_bc_type( bc_id, bc_type );
116 
117  libMesh::RealGradient q_in;
118 
119  int num_q_components = input.vector_variable_size("Physics/"+_physics_name+"/q_wall_"+bc_id_string);
120 
121  for( int i = 0; i < num_q_components; i++ )
122  {
123  q_in(i) = input("Physics/"+_physics_name+"/q_wall_"+bc_id_string, 0.0, i );
124  }
125 
126  this->set_neumann_bc_value( bc_id, q_in );
127  }
128  break;
129  case(GENERAL_HEAT_FLUX):
130  {
131  this->set_neumann_bc_type( bc_id, bc_type );
132  }
133  break;
134  default:
135  {
136  // Call base class to detect any physics-common boundary conditions
137  BCHandlingBase::init_bc_types( bc_id, bc_id_string, bc_type,
138  bc_vars, bc_value, input );
139  }
140 
141  }// End switch(bc_type)
142 
143  return;
144  }
145 
146  void HeatTransferBCHandling::user_init_dirichlet_bcs( libMesh::FEMSystem* /*system*/,
147  libMesh::DofMap& dof_map,
148  BoundaryID bc_id,
149  BCType bc_type ) const
150  {
151  switch( bc_type )
152  {
153  case(ISOTHERMAL_WALL):
154  {
155  std::set<BoundaryID> dbc_ids;
156  dbc_ids.insert(bc_id);
157 
158  std::vector<VariableIndex> dbc_vars;
159  dbc_vars.push_back(_temp_vars.T_var());
160 
161  libMesh::ConstFunction<libMesh::Number>
162  t_func(this->get_dirichlet_bc_value(bc_id));
163 
164  libMesh::DirichletBoundary t_dbc( dbc_ids, dbc_vars, &t_func );
165 
166  dof_map.add_dirichlet_boundary( t_dbc );
167  }
168  break;
169  default:
170  {
171  std::cerr << "Error: Invalid Dirichlet BC type for " << _physics_name
172  << std::endl;
173  libmesh_error();
174  }
175  }// end switch
176 
177  return;
178  }
179 
181  const GRINS::CachedValues& cache,
182  const bool request_jacobian,
183  const BoundaryID bc_id,
184  const BCType bc_type ) const
185  {
186  switch( bc_type )
187  {
188  // Zero heat flux
189  case(ADIABATIC_WALL):
190  // Don't need to do anything: q = 0 in this case
191  break;
192 
193  // Prescribed constant heat flux
194  case(PRESCRIBED_HEAT_FLUX):
195  {
196  if( this->is_axisymmetric() )
197  {
199  this->get_neumann_bc_value(bc_id) );
200  }
201  else
202  {
203  _bound_conds.apply_neumann( context, _temp_vars.T_var(), -1.0,
204  this->get_neumann_bc_value(bc_id) );
205  }
206  }
207  break;
208  // General heat flux from user specified function
209  case(GENERAL_HEAT_FLUX):
210  {
211  if( this->is_axisymmetric() )
212  {
213  _bound_conds.apply_neumann_axisymmetric( context, cache, request_jacobian, _temp_vars.T_var(), -1.0,
214  this->get_neumann_bound_func( bc_id, _temp_vars.T_var() ) );
215  }
216  else
217  {
218  _bound_conds.apply_neumann( context, cache, request_jacobian, _temp_vars.T_var(), -1.0,
219  this->get_neumann_bound_func( bc_id, _temp_vars.T_var() ) );
220  }
221  }
222  break;
223  default:
224  {
225  std::cerr << "Error: Invalid Neumann BC type for " << _physics_name
226  << std::endl;
227  libmesh_error();
228  }
229  } // End switch
230 
231  return;
232  }
233 
234 } // namespace GRINS
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 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)
libMesh::boundary_id_type BoundaryID
More descriptive name of the type used for boundary ids.
Definition: var_typedefs.h:54
std::tr1::shared_ptr< GRINS::NeumannFuncObj > get_neumann_bound_func(GRINS::BoundaryID bc_id, GRINS::VariableIndex var_id) const
void apply_neumann_axisymmetric(AssemblyContext &context, const VariableIndex var, const libMesh::Real sign, const typename libMesh::TensorTools::IncrementRank< FEShape >::type &value) const
Applies Neumann boundary conditions for the constant case.
void set_dirichlet_bc_value(GRINS::BoundaryID bc_id, libMesh::Real value, int component=0)
void apply_neumann(AssemblyContext &context, const VariableIndex var, const libMesh::Real sign, const typename libMesh::TensorTools::IncrementRank< FEShape >::type &value) const
Applies Neumann boundary conditions for the constant case.
void set_neumann_bc_value(GRINS::BoundaryID bc_id, const libMesh::Point &q_in)
GRINS namespace.
virtual void init(libMesh::FEMSystem *system)
const libMesh::Point & get_neumann_bc_value(GRINS::BoundaryID bc_id) const
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)
virtual int string_to_int(const std::string &bc_type_in) const
virtual void init_bc_data(const libMesh::FEMSystem &system)
Override this method to initialize any system-dependent data.
virtual int string_to_int(const std::string &bc_type_in) const
bool is_axisymmetric() 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
GRINS::BoundaryConditions _bound_conds
Object that stashes generic boundary condition types.
Base class for reading and handling boundary conditions for physics classes.
virtual void user_init_dirichlet_bcs(libMesh::FEMSystem *system, libMesh::DofMap &dof_map, GRINS::BoundaryID bc_id, GRINS::BCType bc_type) const
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

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