GRINS-0.8.0
variable_builder.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
26 #include "grins/variable_builder.h"
27 
28 // GRINS
30 #include "grins/multiphysics_sys.h"
31 #include "grins/variable_factory.h"
33 
34 // libMesh
35 #include "libmesh/getpot.h"
36 #include "libmesh/string_to_enum.h"
37 
38 namespace GRINS
39 {
40  void VariableBuilder::build_variables( const GetPot& input,
41  MultiphysicsSystem& system )
42  {
43  DefaultVariableBuilder var_builder;
44 
45  // Defer the construction to the builder subclass implementation
46  var_builder.build_variables_impl(input,system);
47  }
48 
49  void VariableBuilder::add_variable_to_warehouse( SharedPtr<FEVariablesBase>& fe_var,
50  const std::string& var_name )
51  {
53  }
54 
56  const std::vector<std::string>& var_names,
57  const std::string& fe_family,
58  const std::string& order,
59  std::vector<VariableIndex>& var_indices,
60  const std::set<libMesh::subdomain_id_type>& subdomain_ids )
61  {
62  const unsigned int n_vars = var_names.size();
63 
64  // Setup var_indices
65  libmesh_assert( var_indices.empty() );
66  var_indices.resize(n_vars);
67 
68  if( subdomain_ids.empty() )
69  for( unsigned int v = 0; v < n_vars; v++ )
70  var_indices[v] = system.add_variable( var_names[v],
71  libMesh::Utility::string_to_enum<GRINSEnums::Order>(order),
72  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(fe_family) );
73 
74  else
75  for( unsigned int v = 0; v < n_vars; v++ )
76  var_indices[v] = system.add_variable( var_names[v],
77  libMesh::Utility::string_to_enum<GRINSEnums::Order>(order),
78  libMesh::Utility::string_to_enum<GRINSEnums::FEFamily>(fe_family),
79  &subdomain_ids );
80  }
81 
82  SharedPtr<FEVariablesBase> VariableBuilder::build_fe_var( const std::string& var_type,
83  const std::vector<std::string>& var_names,
84  const std::vector<VariableIndex>& var_indices,
85  const std::set<libMesh::subdomain_id_type>& subdomain_ids )
86  {
87  // Setup VariableFactory
91 
92  libMesh::UniquePtr<FEVariablesBase> var = VariableFactoryAbstract::build(var_type);
93 
94  // Need to return a SharedPtr, so release from the UniquePtr we got back
95  return SharedPtr<FEVariablesBase>( var.release() );
96  }
97 } // end namespace GRINS
static void set_var_indices(const std::vector< VariableIndex > &var_indices)
Set the variable indices before calling create()
static void set_var_names(const std::vector< std::string > &var_names)
Set the variable names before calling create()
static libMesh::UniquePtr< FEVariablesBase > build(const std::string &name)
Use this method to build objects of type Base.
static void set_subdomain_ids(const std::set< libMesh::subdomain_id_type > &subdomain_ids)
void add_variable_to_warehouse(SharedPtr< FEVariablesBase > &fe_var, const std::string &var_name)
Adds/registers the fe_var to VariableWarehouse.
GRINS namespace.
void add_vars_to_system(MultiphysicsSystem &system, const std::vector< std::string > &var_names, const std::string &fe_family, const std::string &order, std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Given the names, family, and order, this adds the variables to the system and populates var_indices...
static void build_variables(const GetPot &input, MultiphysicsSystem &system)
virtual void build_variables_impl(const GetPot &input, MultiphysicsSystem &system)
Implementation of Variable construction done in subclasses.
static void register_variable(const std::string &var_name, SharedPtr< FEVariablesBase > &variable)
Interface with libMesh for solving Multiphysics problems.
SharedPtr< FEVariablesBase > build_fe_var(const std::string &var_type, const std::vector< std::string > &var_names, const std::vector< VariableIndex > &var_indices, const std::set< libMesh::subdomain_id_type > &subdomain_ids)
Sets appropriate data in the VariableFactoryAbstract and calls VariableFactoryAbstract::build() ...

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