GRINS-0.7.0
parsed_function_dirichlet_bc_factory.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 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 // libMesh
29 #include "libmesh/composite_function.h"
30 #include "libmesh/composite_fem_function.h"
31 #include "libmesh/parsed_function.h"
32 #include "libmesh/parsed_fem_function.h"
33 #include "libmesh/zero_function.h"
34 #include "libmesh/const_fem_function.h"
35 
36 namespace GRINS
37 {
38  template<typename FunctionType>
39  libMesh::UniquePtr<FunctionType>
41  MultiphysicsSystem& system,
42  std::vector<std::string>& var_names,
43  const std::string& section )
44  {
45  libmesh_assert( !var_names.empty() );
46 
48  libMesh::UniquePtr<FunctionType> all_funcs;
49  all_funcs.reset( this->build_composite_func().release() );
50 
51  typedef typename TypeFrom<FunctionType>::to_composite composite_type;
52  composite_type * composite_func =
53  libMesh::libmesh_cast_ptr<composite_type *>(all_funcs.get());
54 
55  // We're given the active variables in var_names. Let's first check
56  // which ones the user actually set in the input file.
57  // If there's only one variable in var_names, then check_for_vars will
58  // error if the user didn't set it, so we don't need to consider that
59  // case here.
60  std::set<std::string> vars_found;
61  this->check_for_vars(input,section,var_names,&vars_found);
62 
63  for( std::vector<std::string>::const_iterator var = var_names.begin();
64  var < var_names.end(); ++var )
65  {
66  std::vector<VariableIndex> var_idx(1,system.variable_number(*var));
67 
68  // If the user set this variable in input, parse the expression and
69  // add it to the composition function
70  if( vars_found.find(*var) != vars_found.end() )
71  {
72  std::string expression = input(section+"/"+(*var),"DIE!");
73 
74  composite_func->attach_subfunction
75  (TypeFrom<FunctionType>::to_parsed(system, expression), var_idx);
76  }
77  // Otherwise, we set this variable to be zero.
78  else
79  {
80  composite_func->attach_subfunction
82  }
83  }
84 
85  return all_funcs;
86  }
87 
88  // Instantiate all the Parsed(FEM)Function factories.
92 
93 } // end namespace GRINS
ParsedFEMDirichletBCFactory grins_factory_parsed_fem_dirichlet("parsed_fem_dirichlet")
GRINS namespace.
Interface with libMesh for solving Multiphysics problems.
ParsedDirichletBCFactory grins_factory_parsed_displacement("parsed_displacement")
ParsedDirichletBCFactory grins_factory_parsed_dirichlet("parsed_dirichlet")
virtual libMesh::UniquePtr< FunctionType > build_func(const GetPot &input, MultiphysicsSystem &system, std::vector< std::string > &var_names, const std::string &section)
Builds the Parsed(FEM)Function objects for boundary conditions.

Generated on Thu Jun 2 2016 21:52:27 for GRINS-0.7.0 by  doxygen 1.8.10