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

Constructs ConstFunction objects for Dirichlet boundary conditions. More...

#include <constant_function_dirichlet_bc_factory.h>

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

Public Member Functions

 ConstantFunctionDirichletBCFactory (const std::string &bc_type_name)
 
 ~ConstantFunctionDirichletBCFactory ()
 
- Public Member Functions inherited from GRINS::DirichletBCFactoryFunctionBase< libMesh::FunctionBase< libMesh::Number > >
 DirichletBCFactoryFunctionBase (const std::string &bc_type_name)
 
 ~DirichletBCFactoryFunctionBase ()
 
- Public Member Functions inherited from GRINS::DirichletBCFactoryAbstract
 DirichletBCFactoryAbstract (const std::string &bc_type_name)
 
 ~DirichletBCFactoryAbstract ()
 
- Public Member Functions inherited from GRINS::BCFactoryAbstract< libMesh::DirichletBoundary >
 BCFactoryAbstract (const std::string &bc_type_name)
 
 ~BCFactoryAbstract ()
 
- Public Member Functions inherited from GRINS::FactoryWithGetPot< libMesh::DirichletBoundary >
 FactoryWithGetPot (const std::string &name)
 
 ~FactoryWithGetPot ()
 
- Public Member Functions inherited from GRINS::FactoryAbstract< libMesh::DirichletBoundary >
virtual ~FactoryAbstract ()
 
- Public Member Functions inherited from GRINS::ParsedFunctionFactoryHelper< libMesh::FunctionBase< libMesh::Number > >
 ParsedFunctionFactoryHelper ()
 
 ~ParsedFunctionFactoryHelper ()
 

Protected Member Functions

virtual libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > build_func (const GetPot &input, MultiphysicsSystem &system, std::vector< std::string > &var_names, const std::string &section)
 Builds ConstantFunction objects for boundary conditions. More...
 
virtual void add_found_vars (const GetPot &input, MultiphysicsSystem &system, const std::string &section, const std::set< std::string > &vars_found, libMesh::CompositeFunction< libMesh::Number > &composite_func, std::set< std::string > &vars_added) const
 Adds the vars_found to the composite_func. More...
 
virtual void set_vars_to_search_for (const std::string &, const std::vector< std::string > &var_names, std::vector< std::string > &vars_to_search_for) const
 Set the vars_to_search_for, based on var_names. More...
 
- Protected Member Functions inherited from GRINS::DirichletBCFactoryFunctionBase< libMesh::FunctionBase< libMesh::Number > >
libMesh::UniquePtr< libMesh::DirichletBoundary > make_dirichlet_boundary (const std::set< BoundaryID > &bc_ids, const libMesh::System &system, libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > &func, const std::vector< VariableIndex > &var_indices)
 Dispatch, based on FunctionType, to the correct DirchletBoundary construction. More...
 
virtual const std::vector< std::string > & get_var_names () const
 Helper function that can be overridded in subclasses. More...
 
- Protected Member Functions inherited from GRINS::DirichletBCFactoryAbstract
void check_for_vars (const GetPot &input, const std::string &section, const std::vector< std::string > &var_names, std::set< std::string > *vars_found=NULL)
 Helper function. More...
 
- Protected Member Functions inherited from GRINS::BCFactoryAbstract< libMesh::DirichletBoundary >
void check_for_multiple_expressions (const GetPot &input, const std::string &section, const std::string &var_name) const
 Ensure that there is only one expression for the [Section/var_name] variable. More...
 
void build_var_indices (const MultiphysicsSystem &system, const std::vector< std::string > &var_names, std::vector< VariableIndex > &var_indices) const
 
virtual void check_state () const
 Helper function to reduce code duplication. More...
 
virtual void reset_state ()
 Helper function to redue code duplication. More...
 
- Protected Member Functions inherited from GRINS::FactoryAbstract< libMesh::DirichletBoundary >
 FactoryAbstract (const std::string &name)
 Constructor is protected. Use the build() method to construct Base objects. More...
 
- Protected Member Functions inherited from GRINS::ParsedFunctionFactoryHelper< libMesh::FunctionBase< libMesh::Number > >
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > build_parsed_func (const MultiphysicsSystem &system, const std::string &expression)
 
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > build_composite_func ()
 

Additional Inherited Members

- Static Public Member Functions inherited from GRINS::BCFactoryAbstract< libMesh::DirichletBoundary >
static void set_system (MultiphysicsSystem &system)
 
static void set_bc_ids (const std::set< BoundaryID > &bc_ids)
 Boundary id for the current boundary condition section. More...
 
static void set_fe_var (const FEVariablesBase &fe_var)
 Active variable for the current boundary condition. More...
 
static void set_section (const std::string &section)
 Sets the current section of the input file. More...
 
static bool have_bc_type (const std::string &bc_type)
 
- Static Public Member Functions inherited from GRINS::FactoryWithGetPot< libMesh::DirichletBoundary >
static void set_getpot (const GetPot &input)
 
- Static Public Member Functions inherited from GRINS::FactoryAbstract< libMesh::DirichletBoundary >
static libMesh::UniquePtr< libMesh::DirichletBoundary > build (const std::string &name)
 Use this method to build objects of type Base. More...
 
- Static Protected Member Functions inherited from GRINS::FactoryAbstract< libMesh::DirichletBoundary >
static FactoryAbstract< libMesh::DirichletBoundary > & get_factory (const std::string &name)
 Helper method that looks up the factory and returns it if present, or error if it's not. More...
 
static DerivedType & get_factory_subclass (const std::string &name)
 Like get_factory, but will downcast to DerivedType. More...
 
static std::map< std::string, FactoryAbstract< libMesh::DirichletBoundary > * > & factory_map ()
 
- Static Protected Attributes inherited from GRINS::BCFactoryAbstract< libMesh::DirichletBoundary >
static MultiphysicsSystem_system
 We store only a raw pointer here because we can't make a copy. More...
 
static const std::set< BoundaryID > * _bc_ids
 BoundaryID for constructing a particular boundary condition. More...
 
static const FEVariablesBase_fe_var
 The FEVariablesBase class associated with the boundary condition being built. More...
 
static std::string _section
 
- Static Protected Attributes inherited from GRINS::FactoryWithGetPot< libMesh::DirichletBoundary >
static const GetPot * _input
 We store only a raw pointer here because we can't make a copy. More...
 

Detailed Description

Constructs ConstFunction objects for Dirichlet boundary conditions.

Definition at line 41 of file constant_function_dirichlet_bc_factory.h.

Constructor & Destructor Documentation

GRINS::ConstantFunctionDirichletBCFactory::ConstantFunctionDirichletBCFactory ( const std::string &  bc_type_name)
inline

Definition at line 46 of file constant_function_dirichlet_bc_factory.h.

47  : DirichletBCFactoryFunctionBase<libMesh::FunctionBase<libMesh::Number> >(bc_type_name),
48  ParsedFunctionFactoryHelper<libMesh::FunctionBase<libMesh::Number> >()
49  {}
GRINS::ConstantFunctionDirichletBCFactory::~ConstantFunctionDirichletBCFactory ( )
inline

Definition at line 51 of file constant_function_dirichlet_bc_factory.h.

51 {};

Member Function Documentation

void GRINS::ConstantFunctionDirichletBCFactory::add_found_vars ( const GetPot &  input,
MultiphysicsSystem system,
const std::string &  section,
const std::set< std::string > &  vars_found,
libMesh::CompositeFunction< libMesh::Number > &  composite_func,
std::set< std::string > &  vars_added 
) const
protectedvirtual

Adds the vars_found to the composite_func.

It is expected that this function returns the names of the vars actually added in vars_added. While the default implementation will have vars_found = vars_added, subclasses may actually search for different variables and use them to add the actual system variables.

Reimplemented in GRINS::MoleFractionsDirichletBCFactory.

Definition at line 95 of file constant_function_dirichlet_bc_factory.C.

Referenced by build_func().

101  {
102  libMesh::Number invalid_num = std::numeric_limits<libMesh::Number>::max();
103 
104  for( std::set<std::string>::const_iterator var = vars_found.begin();
105  var != vars_found.end(); ++var )
106  {
107  std::vector<VariableIndex> var_idx(1,system.variable_number(*var));
108 
109  libMesh::Number value = input(section+"/"+(*var),invalid_num);
110 
111  libMesh::ConstFunction<libMesh::Number> const_func(value);
112  composite_func.attach_subfunction(const_func,var_idx);
113  }
114 
115  vars_added = vars_found;
116  }
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > GRINS::ConstantFunctionDirichletBCFactory::build_func ( const GetPot &  input,
MultiphysicsSystem system,
std::vector< std::string > &  var_names,
const std::string &  section 
)
protectedvirtual

Builds ConstantFunction objects for boundary conditions.

The variable names passed in will correspond to only a single VariableBase object, e.g. Velocity. The expected behavior is that if the user didn't specify a value for all the variables, then the unspecified variables will be set to zero. However, the user must've set at least one. The section arguments corresponds to the section to parse for the variables in the input file, e.g. input(section+"/"+var_names[0]).

This is really a "composite" function. We'll cast in the helper functions.

Implements GRINS::DirichletBCFactoryFunctionBase< libMesh::FunctionBase< libMesh::Number > >.

Definition at line 50 of file constant_function_dirichlet_bc_factory.C.

References add_found_vars(), GRINS::ParsedFunctionFactoryHelper< libMesh::FunctionBase< libMesh::Number > >::build_composite_func(), GRINS::DirichletBCFactoryAbstract::check_for_vars(), and set_vars_to_search_for().

54  {
55  libmesh_assert( !var_names.empty() );
56 
58  libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> > all_funcs;
59 
60  // We're given the active variables in var_names. Let's first check
61  // which ones the user actually set in the input file.
62  // If there's only one variable in var_names, then check_for_vars will
63  // error if the user didn't set it, so we don't need to consider that
64  // case here.
65  std::set<std::string> vars_found;
66  {
67  std::vector<std::string> vars_to_search_for(var_names.size());
68  this->set_vars_to_search_for(section,var_names,vars_to_search_for);
69  this->check_for_vars(input,section,vars_to_search_for,&vars_found);
70  }
71 
72  all_funcs.reset( this->build_composite_func().release() );
73 
74  // Cast to raw CompositeFunction for convenience
76  libMesh::cast_ref<libMesh::CompositeFunction<libMesh::Number>&>(*(all_funcs.get()));
77 
78  std::set<std::string> vars_added;
79  this->add_found_vars(input, system, section, vars_found, composite_func, vars_added);
80 
81  // Now add all the other vars that weren't added as ZeroFunctions
82  for( std::vector<std::string>::const_iterator var = var_names.begin();
83  var < var_names.end(); ++var )
84  {
85  if( vars_added.find(*var) == vars_added.end() )
86  {
87  std::vector<VariableIndex> var_idx(1,system.variable_number(*var));
88  composite_func.attach_subfunction( libMesh::ZeroFunction<libMesh::Number>(),var_idx);
89  }
90  }
91 
92  return all_funcs;
93  }
virtual void set_vars_to_search_for(const std::string &, const std::vector< std::string > &var_names, std::vector< std::string > &vars_to_search_for) const
Set the vars_to_search_for, based on var_names.
virtual void add_found_vars(const GetPot &input, MultiphysicsSystem &system, const std::string &section, const std::set< std::string > &vars_found, libMesh::CompositeFunction< libMesh::Number > &composite_func, std::set< std::string > &vars_added) const
Adds the vars_found to the composite_func.
libMesh::UniquePtr< libMesh::FunctionBase< libMesh::Number > > build_composite_func()
void check_for_vars(const GetPot &input, const std::string &section, const std::vector< std::string > &var_names, std::set< std::string > *vars_found=NULL)
Helper function.
virtual void GRINS::ConstantFunctionDirichletBCFactory::set_vars_to_search_for ( const std::string &  ,
const std::vector< std::string > &  var_names,
std::vector< std::string > &  vars_to_search_for 
) const
inlineprotectedvirtual

Set the vars_to_search_for, based on var_names.

In the default implementation, vars_to_search_for = var_names, but subclasses may override this behavior. If this function is overridden, then add_found_vars will also need to be overridden. You may assume vars_to_search_for has been sized to match var_names.

Reimplemented in GRINS::MoleFractionsDirichletBCFactory.

Definition at line 85 of file constant_function_dirichlet_bc_factory.h.

Referenced by build_func().

88  { libmesh_assert_equal_to(var_names.size(),vars_to_search_for.size());
89  vars_to_search_for = var_names; }

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

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