GRINS-0.8.0
variable_warehouse.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 namespace GRINS
29 {
30  namespace GRINSPrivate
31  {
32  std::map<std::string,SharedPtr<FEVariablesBase> >& VariableWarehouse::var_map()
33  {
34  static std::map<std::string,SharedPtr<FEVariablesBase> > _var_map;
35  return _var_map;
36  }
37 
38  SharedPtr<FEVariablesBase> VariableWarehouse::get_variable_ptr( const std::string& var_name )
39  {
40  if( !VariableWarehouse::is_registered(var_name) )
41  {
42  const std::map<std::string,SharedPtr<FEVariablesBase> >& map = var_map();
43 
44  std::stringstream error_msg;
45  error_msg << "ERROR: Could not find Variable "+var_name+" in the VariableWarehouse!"
46  << std::endl
47  << " Variables currently the VariableWarehouse are: "
48  << (map.begin())->first << std::endl;
49 
50  std::map<std::string,SharedPtr<FEVariablesBase> >::const_iterator it = map.begin();
51  it++;
52  for( ; it != map.end(); ++it )
53  error_msg << std::string(54,' ') << it->first << std::endl;
54 
55  libmesh_error_msg(error_msg.str());
56  }
57 
58  SharedPtr<FEVariablesBase> var_ptr = var_map()[var_name];
59 
60  if( !var_ptr )
61  libmesh_error_msg("ERROR: Variable "+var_name+" is an invalid pointer!");
62 
63  return var_ptr;
64  }
65 
66  } // end namespace GRINSPrivate
67 } // end namespace GRINS
static SharedPtr< FEVariablesBase > get_variable_ptr(const std::string &var_name)
GRINS namespace.
static std::map< std::string, SharedPtr< FEVariablesBase > > & var_map()
static bool is_registered(const std::string &var_name)
Check if variable is registered.

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