GRINS-0.8.0
neumann_bc_factory_abstract.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 // This class
27 
28 // GRINS
29 #include "grins/string_utils.h"
30 
31 namespace GRINS
32 {
33  libMesh::UniquePtr<NeumannBCContainer> NeumannBCFactoryAbstract::create()
34  {
35  libMesh::UniquePtr<NeumannBCContainer> container;
36 
37  // Only build the container if the Neumann BC is *not* homogeneous
38  // Otherwise, we just return and empty (NULL) UniquePtr.
39  if(!_is_homogeneous)
40  {
41  // Make sure all necessary state has been setup
42  this->check_state();
43 
44  SharedPtr<NeumannBCAbstract>
45  func = this->build_neumann_func( *_input, *_system, *_fe_var, this->_section );
46 
47  libmesh_assert(func);
48 
49  container.reset(new NeumannBCContainer(*_bc_ids,*_fe_var,func));
50 
51  // Reset state for error checking during next construction
52  this->reset_state();
53  }
54 
55  return container;
56  }
57 
58  void NeumannBCFactoryAbstract::check_for_flux( const GetPot& input, const std::string& flux_input,
59  const std::vector<std::string>& var_names )
60  {
61  if( !input.have_variable(flux_input) )
62  libmesh_error_msg("ERROR: Could not find input specification for "+flux_input+"!");
63 
64  unsigned int flux_size = input.vector_variable_size(flux_input);
65  if( flux_size != var_names.size() )
66  {
67  std::string error_msg = "ERROR: Mismatch in size between flux input and variables size!\n";
68  error_msg += " Found flux size = "+StringUtilities::T_to_string<unsigned int>(flux_size)+"\n";
69  error_msg += " Found variables size = "+StringUtilities::T_to_string<unsigned int>(var_names.size())+"\n";
70  libmesh_error_msg(error_msg);
71  }
72  }
73 
74  // Full specialization for the Factory<NeumannBCContainer>
75  template<>
76  std::map<std::string, FactoryAbstract<NeumannBCContainer>*>&
78  {
79  static std::map<std::string, FactoryAbstract<NeumannBCContainer>*> _map;
80  return _map;
81  }
82 
83  // Definition of static members
84  template<>
86 
87  template<>
89 
90  template<>
91  const std::set<BoundaryID>* BCFactoryAbstract<NeumannBCContainer>::_bc_ids = NULL;
92 
93  template<>
95 
96  template<>
97  std::string BCFactoryAbstract<NeumannBCContainer>::_section = std::string("DIE!");
98 
99 } // end namespace GRINS
virtual void reset_state()
Helper function to redue code duplication.
static std::map< std::string, FactoryAbstract< Base > * > & factory_map()
static const std::set< BoundaryID > * _bc_ids
BoundaryID for constructing a particular boundary condition.
GRINS namespace.
bool _is_homogeneous
Track if this is a homogeneous Neumann boundary condition.
virtual libMesh::UniquePtr< NeumannBCContainer > create()
Creates NeumannBCContainer for this Factory object.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual SharedPtr< NeumannBCAbstract > build_neumann_func(const GetPot &input, MultiphysicsSystem &system, const FEVariablesBase &fe_var, const std::string &section)=0
Builds the NeumannBCAbstract object for Neumann boundary conditions.
void check_for_flux(const GetPot &input, const std::string &section, const std::vector< std::string > &var_names)
Checks that the flux variable has been set.
Interface with libMesh for solving Multiphysics problems.
virtual void check_state() const
Helper function to reduce code duplication.
static MultiphysicsSystem * _system
We store only a raw pointer here because we can't make a copy.
Abstract factory that provides availability of GetPot.
static const FEVariablesBase * _fe_var
The FEVariablesBase class associated with the boundary condition being built.

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