GRINS-0.8.0
parsed_conductivity.C
Go to the documentation of this file.
1 // Public License as published by the Free Software Foundation.
2 //
3 // This library is distributed in the hope that it will be useful,
4 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6 // Lesser General Public License for more details.
7 //
8 // You should have received a copy of the GNU Lesser General Public
9 // License along with this library; if not, write to the Free Software
10 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
11 // Boston, MA 02110-1301 USA
12 //
13 //-----------------------------------------------------------------------el-
14 
15 
16 // This class
18 
19 //GRINS
20 #include "grins/common.h"
21 #include "grins/physics_naming.h"
23 
24 // libMesh
25 #include "libmesh/getpot.h"
26 
27 namespace GRINS
28 {
29 
32  ParameterUser("ParsedConductivity")
33  {
34  // Warning about this constructor being deprecated
35  {
36  std::string warning = "WARNING: Use of this constructor is DEPRECATED.\n";
37  warning += " Please update to use constructor with input material name.\n";
38  grins_warning(warning);
39  }
40 
41  this->set_parameter(this->_func, input,
42  "Materials/Conductivity/k",
43  "DIE!");
44 
45  std::string conductivity_function = input("Materials/Conductivity/k",std::string("0"));
46 
47  if( !this->check_func_nonzero(conductivity_function) )
48  {
49  libmesh_error_msg("ERROR: Detected '0' function for ParsedConductivity!");
50  }
51  }
52 
53  ParsedConductivity::ParsedConductivity( const GetPot& input, const std::string& material )
55  ParameterUser("ParsedConductivity")
56  {
58  "Materials/"+material+"/ThermalConductivity/value",
59  "Materials/Conductivity/k");
60 
61  std::string conductivity_function;
62 
63  // If we have the new version, we parse that
64  if( input.have_variable("Materials/"+material+"/ThermalConductivity/value") )
65  {
66  this->set_parameter(this->_func, input,
67  "Materials/"+material+"/ThermalConductivity/value",
68  "DIE!");
69 
70  conductivity_function = input("Materials/"+material+"/ThermalConductivity/value",std::string("0"));
71  }
72  // If we have the old DEPRECATED version, use that
73  else if( input.have_variable("Materials/Conductivity/k") )
74  {
75  MaterialsParsing::dep_input_warning( "Materials/Conductivity/k",
76  "ThermalConductivity/value" );
77 
78  this->set_parameter(this->_func, input,
79  "Materials/Conductivity/k",
80  "DIE!");
81 
82  conductivity_function = input("Materials/Conductivity/k",std::string("0"));
83  }
84  // If we don't have either, that's an error
85  else
86  {
87  libmesh_error_msg("Error: Could not find either Materials/"+material+"/ThermalConductivity/value or Materials/Conductivity/k");
88  }
89 
90  if( !this->check_func_nonzero(conductivity_function) )
91  {
92  libmesh_error_msg("ERROR: Detected '0' function for ParsedConductivity!");
93  }
94  }
95 
97  {
98  return;
99  }
100 
101 } // namespace GRINS
libMesh::ParsedFunction< libMesh::Number > _func
virtual void set_parameter(libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from.
#define grins_warning(message)
Definition: common.h:34
bool check_func_nonzero(const std::string &function) const
Returns true if function string is nonzero.
GRINS namespace.
ParameterUser base class. Utility methods for subclasses.
Base class for material properties based on ParsedFunction.
static void dep_input_warning(const std::string &old_option, const std::string &property)
Helper function for parsing/maintaing backward compatibility.
static void duplicate_input_test(const GetPot &input, const std::string &option1, const std::string &option2)
Helper function for parsing/maintaing backward compatibility.

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