37 #include "libmesh/getpot.h"
38 #include "libmesh/mesh_base.h"
39 #include "libmesh/boundary_info.h"
40 #include "libmesh/parallel_mesh.h"
46 std::vector<SharedPtr<NeumannBCContainer> >& neumann_bcs )
48 libMesh::DofMap& dof_map = system.get_dof_map();
51 std::map<std::string,std::set<BoundaryID> > bc_id_map;
62 std::set<std::string> var_sections;
65 for( std::map<std::string,std::set<BoundaryID> >::const_iterator bc_it = bc_id_map.begin();
66 bc_it != bc_id_map.end(); ++bc_it )
68 const std::string& bc_name = bc_it->first;
70 const std::set<BoundaryID>& bc_ids = bc_it->second;
75 std::string type_input = type_input_section+
"/type";
77 if( input.have_variable(type_input) )
80 type_input_section,var_sections,
88 var_sections,neumann_bcs);
95 const std::set<BoundaryID>& bc_ids,
96 libMesh::DofMap& dof_map,
97 const std::string& type_input_section,
98 std::set<std::string>& var_sections,
99 std::vector<SharedPtr<NeumannBCContainer> >& neumann_bcs)
101 std::string type_input = type_input_section+
"/type";
102 std::string bc_type = input( type_input, std::string(
"DIE!") );
108 libmesh_error_msg(
"ERROR: Must specify Physics/is_axisymmetric = true for axisymmetric BC!");
112 bc_type,var_sections,neumann_bcs);
120 std::string error_msg =
"ERROR: Invalid type '"+bc_type+
"' for "+type_input+
"!\n";
123 error_msg +=
" If your boundary condition is not one of these types, then \n";
124 error_msg +=
" you must specify the boundary condition type for each Variable\n";
125 error_msg +=
" section. Please have a look at the examples.\n";
126 libmesh_error_msg(error_msg);
132 const std::set<BoundaryID>& bc_ids,
133 libMesh::DofMap& dof_map,
134 const std::string& bc_type,
135 std::set<std::string>& var_sections,
136 std::vector<SharedPtr<NeumannBCContainer> >& neumann_bcs )
142 for( std::set<std::string>::const_iterator vars = var_sections.begin();
143 vars != var_sections.end(); ++vars )
145 const std::string& var_section = *vars;
155 std::string full_bc_type = var_section+
"_"+bc_type;
164 std::string(
"dummy"),
174 std::string(
"dummy"),
179 libmesh_error_msg(
"ERROR! Invalid axisymmetric type: "+full_bc_type);
185 const std::string& bc_name,
186 const std::set<BoundaryID>& bc_ids,
187 libMesh::DofMap& dof_map,
188 std::set<std::string>& var_sections,
189 std::vector<SharedPtr<NeumannBCContainer> >& neumann_bcs)
191 for( std::set<std::string>::const_iterator vars = var_sections.begin();
192 vars != var_sections.end(); ++vars )
194 const std::string& var_section = *vars;
203 if( !input.have_section(input_section) )
210 libmesh_error_msg(
"ERROR: Could not find boundary condition specification for "+input_section+
"!");
220 std::string bc_type_section = input_section+
"/type";
221 unsigned int n_bc_types = input.vector_variable_size(bc_type_section);
223 for(
unsigned int bc_type_idx = 0; bc_type_idx < n_bc_types; bc_type_idx++ )
225 std::string bc_type = input(bc_type_section, std::string(
"DIE!"), bc_type_idx);
230 fe_var, input_section,
236 fe_var, input_section,
237 bc_type, neumann_bcs );
240 libmesh_error_msg(
"ERROR: Invalid bc_type "+bc_type+
"!");
248 std::map<std::string,std::set<BoundaryID> >& bc_id_map )
256 libmesh_error_msg(error_msg);
263 if( n_ids != n_names )
264 libmesh_error_msg(
"ERROR: Must have matching number of boundary id sets and boundary names!");
269 std::set<BoundaryID> all_bc_ids;
272 for(
unsigned int i = 0; i < n_names; i++ )
278 std::vector<std::string> bc_ids_str;
280 std::set<BoundaryID> bc_ids;
282 for(std::vector<std::string>::const_iterator it = bc_ids_str.begin();
283 it < bc_ids_str.end(); ++it )
285 BoundaryID id = StringUtilities::string_to_T<BoundaryID>(*it);
288 if( (bc_ids.find(
id) != bc_ids.end()) ||
289 (all_bc_ids.find(
id) != all_bc_ids.end()) )
290 libmesh_error_msg(
"ERROR: Can only specify a boundary ID once!");
293 all_bc_ids.insert(
id);
297 bc_id_map.insert( std::make_pair( bc_name, bc_ids ) );
302 const std::map<std::string,std::set<BoundaryID> >& bc_id_map )
const
304 const libMesh::MeshBase& mesh = system.get_mesh();
305 const libMesh::BoundaryInfo& boundary_info = mesh.get_boundary_info();
307 const std::set<BoundaryID> mesh_ids = boundary_info.get_boundary_ids();
310 std::set<BoundaryID> all_ids;
312 for( std::map<std::string,std::set<BoundaryID> >::const_iterator bc_it = bc_id_map.begin();
313 bc_it != bc_id_map.end(); ++bc_it )
314 all_ids.insert( (bc_it->second).begin(), (bc_it->second).end() );
316 if( mesh_ids != all_ids )
318 std::string err_msg =
"ERROR: Mismatch between specified boundary ids and the boundary ids in the mesh!\n";
319 err_msg +=
"User specified ids: ";
321 for( std::set<BoundaryID>::const_iterator it = all_ids.begin();
322 it != all_ids.end(); ++it )
323 err_msg += StringUtilities::T_to_string<BoundaryID>(*it)+
" ";
327 err_msg +=
"Mesh specified ids: ";
329 for( std::set<BoundaryID>::const_iterator it = mesh_ids.begin();
330 it != mesh_ids.end(); ++it )
331 err_msg += StringUtilities::T_to_string<BoundaryID>(*it)+
" ";
335 libmesh_error_msg(err_msg);
340 std::set<std::string>& sections )
348 std::vector<std::string> all_sections = input.get_section_names();
349 for( std::vector<std::string>::const_iterator s = all_sections.begin();
350 s < all_sections.end(); ++s )
356 std::vector<std::string> split_str;
360 if( split_str.size() == 2 )
363 if( sections.find(split_str[1]) != sections.end() )
364 libmesh_error_msg(
"ERROR: Found duplicate Variable section "+split_str[1]+
"!");
366 sections.insert( split_str[1] );
372 if( sections.empty() )
373 libmesh_error_msg(
"ERROR: Did not find any Variable subsections!");
377 libMesh::System& system,
378 const std::set<BoundaryID>& bc_ids,
379 const std::string& section )
383 const libMesh::MeshBase& mesh = system.get_mesh();
384 const libMesh::ParallelMesh* pmesh =
dynamic_cast<const libMesh::ParallelMesh*
>(&mesh);
387 std::stringstream error_msg;
388 error_msg <<
"ERROR: Cannot use ParallelMesh with periodic boundary conditions!"
390 <<
" See https://github.com/libMesh/libmesh/issues/977 for discussion."
392 libmesh_error_msg(error_msg.str());
395 libMesh::boundary_id_type invalid_bid =
396 std::numeric_limits<libMesh::boundary_id_type>::max();
398 libMesh::boundary_id_type slave_id = invalid_bid;
399 libMesh::boundary_id_type master_id = invalid_bid;
403 if( bc_ids.find(slave_id) == bc_ids.end() ||
404 bc_ids.find(master_id) == bc_ids.end() )
405 libmesh_error_msg(
"ERROR: Mismatch between bc_ids and master/slave ids for perioid bcs!");
407 libMesh::RealVectorValue offset_vector =
410 libMesh::DofMap& dof_map = system.get_dof_map();
416 (
const GetPot& input,
const std::string& section,
417 libMesh::boundary_id_type& master_id,
418 libMesh::boundary_id_type& slave_id )
const
420 if( !input.have_variable(section+
"/master_id") )
421 libmesh_error_msg(
"ERROR: Could not find master_id in section "+section);
423 if( !input.have_variable(section+
"/slave_id") )
424 libmesh_error_msg(
"ERROR: Could not find slave_id in section "+section);
426 libMesh::boundary_id_type invalid_bid =
427 std::numeric_limits<libMesh::boundary_id_type>::max();
429 master_id = input(section+
"/master_id", invalid_bid);
430 slave_id = input(section+
"/slave_id", invalid_bid);
434 (
const GetPot& input,
const std::string& section)
const
436 std::string input_section = section+
"/boundary_offset";
437 if( !input.have_variable(input_section) )
438 libmesh_error_msg(
"ERROR: Could not find boundary_offset in section "+section);
440 unsigned int n_comps = input.vector_variable_size(input_section);
443 libmesh_error_msg(
"ERROR: Cannot specify more than 3 components for boundary_offset!");
445 libMesh::RealVectorValue offset;
446 libMesh::Real invalid_real = std::numeric_limits<libMesh::Real>::max();
448 for(
unsigned int i = 0; i < n_comps; i++ )
449 offset(i) = input(input_section, invalid_real, i );
static bool is_axisymmetric()
void parse_and_build_bc_id_map(const GetPot &input, std::map< std::string, std::set< BoundaryID > > &bc_id_map)
void construct_dbc_core(const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, const FEVariablesBase &fe_var, const std::string §ion, 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 §ion, const std::string &bc_type, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
static std::string variables_section()
Helper function to encapsualte the overall [Variables] section name.
libMesh::boundary_id_type BoundaryID
More descriptive name of the type used for boundary ids.
bool is_dirichlet_bc_type(const std::string &bc_type)
void build_periodic_bc(const GetPot &input, libMesh::System &system, const std::set< BoundaryID > &bc_ids, const std::string §ion)
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)
void build_type_based_bcs(const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, libMesh::DofMap &dof_map, const std::string &type_input_section, std::set< std::string > &var_sections, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
Helper function to build boundary conditions specified by a single type.
void parse_var_sections(const GetPot &input, std::set< std::string > §ions)
void parse_periodic_master_slave_ids(const GetPot &input, const std::string §ion, libMesh::boundary_id_type &master_id, libMesh::boundary_id_type &slave_id) const
void verify_bc_ids_with_mesh(const MultiphysicsSystem &system, const std::map< std::string, std::set< BoundaryID > > &bc_id_map) const
libMesh::RealVectorValue parse_periodic_offset(const GetPot &input, const std::string §ion) const
void build_bcs_by_var_section(const GetPot &input, MultiphysicsSystem &system, const std::string &bc_name, const std::set< BoundaryID > &bc_ids, libMesh::DofMap &dof_map, std::set< std::string > &var_sections, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
Helper function to build boundary conditions using Variable sections.
static std::string axisymmetric()
Interface with libMesh for solving Multiphysics problems.
virtual void build_bcs(const GetPot &input, MultiphysicsSystem &system, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
static const FEVariablesBase & get_variable(const std::string &var_name)
bool is_constraint_var() const
static std::string bc_section()
Outer section name for boundary conditions section in input file.
static std::string periodic()
bool is_neumann_bc_type(const std::string &bc_type)
static std::string bc_id_name_map_var()
Names of boundaries to correspond with bc_ids.
static std::string bc_ids_var()
Variable for list boundary ids to correspond with bc_id_name_map.
void build_axisymmetric_bcs(const GetPot &input, MultiphysicsSystem &system, const std::set< BoundaryID > &bc_ids, libMesh::DofMap &dof_map, const std::string &bc_type, std::set< std::string > &var_sections, std::vector< SharedPtr< NeumannBCContainer > > &neumann_bcs)