GRINS-0.8.0
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions
GRINS::OldStyleBCBuilder Class Reference

Manages runtime construction of Dirichlet boundary conditions. More...

#include <old_style_bc_builder.h>

Inheritance diagram for GRINS::OldStyleBCBuilder:
Inheritance graph
[legend]
Collaboration diagram for GRINS::OldStyleBCBuilder:
Collaboration graph
[legend]

Public Member Functions

 OldStyleBCBuilder ()
 
 ~OldStyleBCBuilder ()
 
- Public Member Functions inherited from GRINS::BCBuilder
 BCBuilder ()
 
virtual ~BCBuilder ()
 

Protected Member Functions

virtual void build_bcs (const GetPot &input, MultiphysicsSystem &system, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
 
- Protected Member Functions inherited from GRINS::BCBuilder
void construct_dbc_core (const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, const FEVariablesBase &fe_var, const std::string &section, const std::string &bc_type, libMesh::DofMap &dof_map)
 
void construct_nbc_core (const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, const FEVariablesBase &fe_var, const std::string &section, const std::string &bc_type, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
 
bool is_dirichlet_bc_type (const std::string &bc_type)
 
bool is_neumann_bc_type (const std::string &bc_type)
 
void add_periodic_bc_to_dofmap (libMesh::boundary_id_type master_id, libMesh::boundary_id_type slave_id, const libMesh::RealVectorValue &offset_vector, libMesh::DofMap &dof_map)
 

Private Member Functions

const FEVariablesBasedetermine_variable_group (const std::string &raw_physics_name, const std::string &bc_type_str, std::string &var_section)
 Determine the FEVariable type from the raw_physics_name. More...
 
void construct_bcs_old_style (const GetPot &input, MultiphysicsSystem &system, const std::string &raw_physics_name, const std::string &section_name, const std::string &bc_id_str, const std::string &bc_type_str, const std::string &bc_value_str, const std::string &bc_var_str, libMesh::DofMap &dof_map, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
 
void build_basic_physics (std::set< std::string > &physics_names)
 
void build_vel_and_temp_physics (std::set< std::string > &physics_names)
 
void build_reacting_physics (std::set< std::string > &physics_names)
 
template<typename FunctionType >
void set_dirichlet_bc_factory_old_style_quantities (const std::string &bc_value_str, unsigned int value_idx, const std::vector< std::string > &var_names)
 
template<typename FunctionType >
void set_neumann_bc_factory_old_style_quantities (const std::string &bc_value_str, unsigned int value_idx, const std::vector< std::string > &var_names)
 
void build_periodic_bc (const GetPot &input, const std::string &section_name, BoundaryID bc_id, libMesh::DofMap &dof_map)
 

Additional Inherited Members

- Static Public Member Functions inherited from GRINS::BCBuilder
static void build_boundary_conditions (const GetPot &input, MultiphysicsSystem &system, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
 
- Static Protected Member Functions inherited from GRINS::BCBuilder
static bool is_new_bc_input_style (const GetPot &input)
 
static libMesh::UniquePtr< BCBuilderbuild_builder (const GetPot &input)
 

Detailed Description

Manages runtime construction of Dirichlet boundary conditions.

This will parse the input for the request Dirichlet boundary conditions and manage their construction. Actual construction of the DirichletBoundary objects is delegated to factory classes. This builder classes merely manages tasks around the factories as needed. To add new Dirichlet boundary conditions, the user should instantiate an appropriate factory sub class.

Definition at line 40 of file old_style_bc_builder.h.

Constructor & Destructor Documentation

GRINS::OldStyleBCBuilder::OldStyleBCBuilder ( )
inline

Definition at line 44 of file old_style_bc_builder.h.

45  : BCBuilder()
46  {};
GRINS::OldStyleBCBuilder::~OldStyleBCBuilder ( )
inline

Definition at line 48 of file old_style_bc_builder.h.

48 {};

Member Function Documentation

void GRINS::OldStyleBCBuilder::build_basic_physics ( std::set< std::string > &  physics_names)
private

Definition at line 273 of file old_style_bc_builder.C.

References GRINS::PhysicsNaming::axisymmetric_heat_transfer(), GRINS::PhysicsNaming::convection_diffusion(), GRINS::PhysicsNaming::elastic_cable(), GRINS::PhysicsNaming::elastic_membrane(), GRINS::PhysicsNaming::heat_conduction(), GRINS::PhysicsNaming::heat_transfer(), GRINS::PhysicsNaming::incompressible_navier_stokes(), GRINS::PhysicsNaming::spalart_allmaras(), and GRINS::PhysicsNaming::stokes().

Referenced by build_bcs().

274  {
275  physics_names.insert(PhysicsNaming::incompressible_navier_stokes());
276  physics_names.insert(PhysicsNaming::stokes());
277  physics_names.insert(PhysicsNaming::elastic_membrane());
278  physics_names.insert(PhysicsNaming::elastic_cable());
279  physics_names.insert(PhysicsNaming::convection_diffusion());
280  physics_names.insert(PhysicsNaming::spalart_allmaras());
281  physics_names.insert(PhysicsNaming::axisymmetric_heat_transfer());
282  physics_names.insert(PhysicsNaming::heat_conduction());
283  physics_names.insert(PhysicsNaming::heat_transfer());
284  }
static PhysicsName heat_transfer()
static PhysicsName spalart_allmaras()
static PhysicsName elastic_cable()
static PhysicsName elastic_membrane()
static PhysicsName convection_diffusion()
static PhysicsName incompressible_navier_stokes()
static PhysicsName stokes()
static PhysicsName axisymmetric_heat_transfer()
static PhysicsName heat_conduction()
void GRINS::OldStyleBCBuilder::build_bcs ( const GetPot &  input,
MultiphysicsSystem system,
std::vector< SharedPtr< NeumannBCContainer > > &  neumann_bcs 
)
protectedvirtual

Implements GRINS::BCBuilder.

Definition at line 49 of file old_style_bc_builder.C.

References build_basic_physics(), build_reacting_physics(), build_vel_and_temp_physics(), construct_bcs_old_style(), GRINS::PhysicsNaming::extract_physics(), GRINS::MultiphysicsSystem::get_physics_list(), and grins_warning.

51  {
52  // Warn about deprecation of this horrid style
53  {
54  std::string warning = "WARNING: Specifying boundary conditions in the\n";
55  warning += " Physics sections is DEPRECATED! Please\n";
56  warning += " update your input file to new the newer\n";
57  warning += " style. See the examples for an illustration.\n";
58 
59  grins_warning(warning);
60  }
61 
62  libMesh::DofMap& dof_map = system.get_dof_map();
63 
64  const PhysicsList& physics_list = system.get_physics_list();
65 
66  std::set<std::string> basic_physics;
67  this->build_basic_physics(basic_physics);
68 
69  std::set<std::string> vel_and_temp_physics;
70  this->build_vel_and_temp_physics(vel_and_temp_physics);
71 
72  std::set<std::string> reacting_physics;
73  this->build_reacting_physics(reacting_physics);
74 
75  for( PhysicsListIter physics_iter = physics_list.begin();
76  physics_iter != physics_list.end();
77  physics_iter++ )
78  {
79  std::string physics_name = physics_iter->first;
80  std::string raw_physics_name = PhysicsNaming::extract_physics(physics_name);
81 
82  std::string section_name = "Physics/"+physics_name;
83 
84  if( basic_physics.find( raw_physics_name ) != basic_physics.end() )
85  {
86  this->construct_bcs_old_style(input,
87  system,
88  raw_physics_name,
89  section_name,
90  "bc_ids",
91  "bc_types",
92  "bc_values",
93  "bc_variables",
94  dof_map,
95  neumann_bcs);
96  }
97 
98  if( (vel_and_temp_physics.find( raw_physics_name ) != vel_and_temp_physics.end()) ||
99  (reacting_physics.find( raw_physics_name ) != reacting_physics.end()) )
100  {
101  this->construct_bcs_old_style(input,
102  system,
103  raw_physics_name,
104  section_name,
105  "vel_bc_ids",
106  "vel_bc_types",
107  "vel_bc_values",
108  "vel_bc_variables",
109  dof_map,
110  neumann_bcs);
111 
112  this->construct_bcs_old_style(input,
113  system,
114  raw_physics_name,
115  section_name,
116  "temp_bc_ids",
117  "temp_bc_types",
118  "temp_bc_values",
119  "temp_bc_variables",
120  dof_map,
121  neumann_bcs);
122  }
123 
124  if( reacting_physics.find( raw_physics_name ) != reacting_physics.end() )
125  {
126  this->construct_bcs_old_style(input,
127  system,
128  raw_physics_name,
129  section_name,
130  "species_bc_ids",
131  "species_bc_types",
132  "species_bc_values",
133  "species_bc_variables",
134  dof_map,
135  neumann_bcs);
136  }
137  }
138  }
void build_vel_and_temp_physics(std::set< std::string > &physics_names)
#define grins_warning(message)
Definition: common.h:34
void construct_bcs_old_style(const GetPot &input, MultiphysicsSystem &system, const std::string &raw_physics_name, const std::string &section_name, const std::string &bc_id_str, const std::string &bc_type_str, const std::string &bc_value_str, const std::string &bc_var_str, libMesh::DofMap &dof_map, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
static std::string extract_physics(const std::string &full_name)
Extract the physics name from the full_name.
void build_reacting_physics(std::set< std::string > &physics_names)
std::map< std::string, SharedPtr< GRINS::Physics > > PhysicsList
Container for GRINS::Physics object pointers.
Definition: var_typedefs.h:59
void build_basic_physics(std::set< std::string > &physics_names)
std::map< std::string, SharedPtr< GRINS::Physics > >::const_iterator PhysicsListIter
Iterator for PhysicsList.
Definition: var_typedefs.h:62
void GRINS::OldStyleBCBuilder::build_periodic_bc ( const GetPot &  input,
const std::string &  section_name,
BoundaryID  bc_id,
libMesh::DofMap &  dof_map 
)
private

Definition at line 296 of file old_style_bc_builder.C.

References GRINS::BCBuilder::add_periodic_bc_to_dofmap().

Referenced by construct_bcs_old_style().

300  {
301  std::string wall_input = section+"/periodic_wall_";
302  wall_input += StringUtilities::T_to_string<BoundaryID>(bc_id);
303 
304  if( input.have_variable(wall_input) )
305  {
306  libMesh::boundary_id_type invalid_bid =
307  std::numeric_limits<libMesh::boundary_id_type>::max();
308 
309  libMesh::boundary_id_type slave_id = invalid_bid;
310  libMesh::boundary_id_type master_id = invalid_bid;
311 
312  if( input.vector_variable_size(wall_input) != 2 )
313  libmesh_error_msg("ERROR: "+wall_input+" must have only 2 components!");
314 
315  master_id = bc_id;
316 
317  if( input(wall_input,invalid_bid,0) == bc_id )
318  slave_id = input(wall_input,invalid_bid,1);
319  else
320  slave_id = input(wall_input,invalid_bid,0);
321 
322  std::string offset_input = section+"/periodic_offset_";
323  offset_input += StringUtilities::T_to_string<BoundaryID>(bc_id);
324 
325  if( !input.have_variable(offset_input) )
326  libmesh_error_msg("ERROR: Could not find "+offset_input+"!");
327 
328  unsigned int n_comps = input.vector_variable_size(offset_input);
329 
330  libMesh::Real invalid_real = std::numeric_limits<libMesh::Real>::max();
331 
332  libMesh::RealVectorValue offset_vector;
333  for( unsigned int i = 0; i < n_comps; i++ )
334  offset_vector(i) = input(offset_input,invalid_real,i);
335 
336  this->add_periodic_bc_to_dofmap( master_id, slave_id,
337  offset_vector, dof_map );
338  }
339  }
void add_periodic_bc_to_dofmap(libMesh::boundary_id_type master_id, libMesh::boundary_id_type slave_id, const libMesh::RealVectorValue &offset_vector, libMesh::DofMap &dof_map)
Definition: bc_builder.C:151
void GRINS::OldStyleBCBuilder::build_reacting_physics ( std::set< std::string > &  physics_names)
private

Definition at line 291 of file old_style_bc_builder.C.

References GRINS::PhysicsNaming::reacting_low_mach_navier_stokes().

Referenced by build_bcs().

292  {
293  physics_names.insert(PhysicsNaming::reacting_low_mach_navier_stokes());
294  }
static PhysicsName reacting_low_mach_navier_stokes()
void GRINS::OldStyleBCBuilder::build_vel_and_temp_physics ( std::set< std::string > &  physics_names)
private

Definition at line 286 of file old_style_bc_builder.C.

References GRINS::PhysicsNaming::low_mach_navier_stokes().

Referenced by build_bcs().

287  {
288  physics_names.insert(PhysicsNaming::low_mach_navier_stokes());
289  }
static PhysicsName low_mach_navier_stokes()
void GRINS::OldStyleBCBuilder::construct_bcs_old_style ( const GetPot &  input,
MultiphysicsSystem system,
const std::string &  raw_physics_name,
const std::string &  section_name,
const std::string &  bc_id_str,
const std::string &  bc_type_str,
const std::string &  bc_value_str,
const std::string &  bc_var_str,
libMesh::DofMap &  dof_map,
std::vector< SharedPtr< NeumannBCContainer > > &  neumann_bcs 
)
private

Definition at line 178 of file old_style_bc_builder.C.

References GRINS::FEVariablesBase::active_var_names(), build_periodic_bc(), GRINS::BCBuilder::construct_dbc_core(), GRINS::BCBuilder::construct_nbc_core(), determine_variable_group(), GRINS::BCBuilder::is_dirichlet_bc_type(), and GRINS::BCBuilder::is_neumann_bc_type().

Referenced by build_bcs().

188  {
189  unsigned int num_ids = input.vector_variable_size(section_name+"/"+bc_id_str);
190  unsigned int num_types = input.vector_variable_size(section_name+"/"+bc_type_str);
191 
192  if( num_ids != num_types )
193  libmesh_error_msg("Error: Must specify equal number of boundary ids and boundary conditions");
194 
195  for( unsigned int i = 0; i < num_ids; i++ )
196  {
197  // Parse the bc type, add "_old_style" at the end to distinguish for deprecated construction
198  std::string bc_type = input(section_name+"/"+bc_type_str, std::string("DIE!"), i );
199  bc_type += "_old_style";
200 
201  BoundaryID bc_id = input(section_name+"/"+bc_id_str, -1, i );
202 
203  // If this is a periodic boundary condition, we can immediately
204  // apply and move to the next one
205  if( bc_type == std::string("periodic_old_style") )
206  {
207  this->build_periodic_bc( input, section_name, bc_id, dof_map );
208  continue;
209  }
210 
211  // We use the set for compatibility with the BCFactories
212  std::set<BoundaryID> bc_ids;
213  bc_ids.insert(bc_id);
214 
215  std::string variable_group_name;
216 
217  const FEVariablesBase* fe_var_ptr = this->determine_variable_group( raw_physics_name,
218  bc_type_str,
219  variable_group_name );
220 
221  libmesh_assert(fe_var_ptr);
222 
223  // We need the var_names for the old style parsing
224  std::vector<std::string> var_names;
225  var_names = fe_var_ptr->active_var_names();
226 
227  // Axisymmetric is special. It depends on the variable type.
228  // So, we prepend the type with the variable name in that
229  // case.
230  if( bc_type == "axisymmetric_old_style" )
231  bc_type = variable_group_name+"_"+bc_type;
232 
233 
234  // For these types of boundary conditions, we need to treat one
235  // variable at a time, so extract the relevant one.
236  if( bc_type == std::string("parsed_dirichlet_old_style") ||
237  bc_type == std::string("constant_dirichlet_old_style") ||
238  bc_type == std::string("parsed_fem_dirichlet_old_style") ||
239  bc_type == std::string("parsed_neumann_old_style") )
240  {
241  var_names.clear();
242  var_names.resize(1, input(section_name+"/"+bc_var_str, std::string("DIE!"), i ) );
243  }
244 
245  if( this->is_dirichlet_bc_type(bc_type) )
246  {
247  // Tell the old style DirichletBCFactory where to parse the value of the BC
248  this->set_dirichlet_bc_factory_old_style_quantities<libMesh::FunctionBase<libMesh::Number> >
249  ( bc_value_str, i, var_names );
250  this->set_dirichlet_bc_factory_old_style_quantities<libMesh::FEMFunctionBase<libMesh::Number> >
251  ( bc_value_str, i, var_names );
252 
253  this->construct_dbc_core( input, system, bc_ids, *fe_var_ptr,
254  section_name, bc_type, dof_map );
255  }
256  else if( this->is_neumann_bc_type(bc_type) )
257  {
258  // Tell the old style NeumannBCFactory where to parse the value of the BC
259  this->set_neumann_bc_factory_old_style_quantities<libMesh::FunctionBase<libMesh::Number> >
260  ( bc_value_str, i, var_names );
261  this->set_neumann_bc_factory_old_style_quantities<libMesh::FEMFunctionBase<libMesh::Number> >
262  ( bc_value_str, i, var_names );
263 
264  this->construct_nbc_core( input, system, bc_ids, *fe_var_ptr,
265  section_name, bc_type, neumann_bcs );
266  }
267  else
268  libmesh_error_msg("ERROR: Invalid bc_type "+bc_type+"!");
269 
270  }
271  }
void construct_dbc_core(const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, const FEVariablesBase &fe_var, const std::string &section, const std::string &bc_type, libMesh::DofMap &dof_map)
Definition: bc_builder.C:76
void construct_nbc_core(const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, const FEVariablesBase &fe_var, const std::string &section, const std::string &bc_type, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
Definition: bc_builder.C:106
libMesh::boundary_id_type BoundaryID
More descriptive name of the type used for boundary ids.
Definition: var_typedefs.h:56
bool is_dirichlet_bc_type(const std::string &bc_type)
Definition: bc_builder.C:139
void build_periodic_bc(const GetPot &input, const std::string &section_name, BoundaryID bc_id, libMesh::DofMap &dof_map)
const FEVariablesBase * determine_variable_group(const std::string &raw_physics_name, const std::string &bc_type_str, std::string &var_section)
Determine the FEVariable type from the raw_physics_name.
bool is_neumann_bc_type(const std::string &bc_type)
Definition: bc_builder.C:145
const FEVariablesBase * GRINS::OldStyleBCBuilder::determine_variable_group ( const std::string &  raw_physics_name,
const std::string &  bc_type_str,
std::string &  var_section 
)
private

Determine the FEVariable type from the raw_physics_name.

This will set var_section and return the FEVariablesBase pointer. We do it this way, instead of a void function, to avoid a [-Wunused-but-set-parameter] warning on setting the FEVariablesBase pointer.

Definition at line 140 of file old_style_bc_builder.C.

References GRINS::PhysicsNaming::axisymmetric_heat_transfer(), GRINS::PhysicsNaming::convection_diffusion(), GRINS::VariablesParsing::displacement_section(), GRINS::PhysicsNaming::elastic_cable(), GRINS::PhysicsNaming::elastic_membrane(), GRINS::GRINSPrivate::VariableWarehouse::get_variable(), GRINS::PhysicsNaming::heat_conduction(), GRINS::PhysicsNaming::heat_transfer(), GRINS::PhysicsNaming::incompressible_navier_stokes(), GRINS::VariablesParsing::single_var_section(), GRINS::PhysicsNaming::spalart_allmaras(), GRINS::VariablesParsing::species_mass_fractions_section(), GRINS::PhysicsNaming::stokes(), GRINS::VariablesParsing::temperature_section(), GRINS::VariablesParsing::turbulence_section(), and GRINS::VariablesParsing::velocity_section().

Referenced by construct_bcs_old_style().

143  {
144  if( bc_type_str == std::string("bc_types") )
145  {
146  if( raw_physics_name == PhysicsNaming::incompressible_navier_stokes() ||
147  raw_physics_name == PhysicsNaming::stokes() )
148  var_section = VariablesParsing::velocity_section();
149  else if( raw_physics_name == PhysicsNaming::heat_conduction() ||
150  raw_physics_name == PhysicsNaming::heat_transfer() ||
151  raw_physics_name == PhysicsNaming::axisymmetric_heat_transfer() )
153  else if( raw_physics_name == PhysicsNaming::spalart_allmaras() )
154  var_section = VariablesParsing::turbulence_section();
155  else if( raw_physics_name == PhysicsNaming::elastic_membrane() ||
156  raw_physics_name == PhysicsNaming::elastic_cable() )
158  else if( raw_physics_name == PhysicsNaming::convection_diffusion() )
159  var_section = VariablesParsing::single_var_section()+":"+raw_physics_name;
160  else
161  libmesh_error();
162  }
163  else if( bc_type_str == std::string("vel_bc_types") )
164  var_section = VariablesParsing::velocity_section();
165 
166  else if( bc_type_str == std::string("temp_bc_types") )
168 
169  else if( bc_type_str == std::string("species_bc_types") )
171 
172  else
173  libmesh_error();
174 
176  }
static PhysicsName heat_transfer()
static std::string temperature_section()
static PhysicsName spalart_allmaras()
static std::string displacement_section()
static PhysicsName elastic_cable()
static PhysicsName elastic_membrane()
static std::string velocity_section()
static FEVariablesBase & get_variable(const std::string &var_name)
static std::string species_mass_fractions_section()
static PhysicsName convection_diffusion()
static PhysicsName incompressible_navier_stokes()
static PhysicsName stokes()
static std::string single_var_section()
static PhysicsName axisymmetric_heat_transfer()
static std::string turbulence_section()
static PhysicsName heat_conduction()
template<typename FunctionType >
void GRINS::OldStyleBCBuilder::set_dirichlet_bc_factory_old_style_quantities ( const std::string &  bc_value_str,
unsigned int  value_idx,
const std::vector< std::string > &  var_names 
)
private
template<typename FunctionType >
void GRINS::OldStyleBCBuilder::set_neumann_bc_factory_old_style_quantities ( const std::string &  bc_value_str,
unsigned int  value_idx,
const std::vector< std::string > &  var_names 
)
private

Definition at line 352 of file old_style_bc_builder.C.

References GRINS::NeumannBCOldStyleFactoryAbstract::set_value_index_old_style(), and GRINS::NeumannBCOldStyleFactoryAbstract::set_value_var_old_style().

355  {
358  //ParsedFunctionNeumannOldStyleBCFactory<FunctionType>::set_var_names_old_style( var_names );
359  }
static void set_value_var_old_style(const std::string &value_var)
Input variable for parsing old style.
static void set_value_index_old_style(unsigned int idx)
Input variable index for parsing old style.

The documentation for this class was generated from the following files:

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