GRINS-0.7.0
physics_factory_helper.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 // These functions
27 
28 // GRINS
29 #include "grins/common.h"
30 #include "grins/physics_naming.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 
36 namespace GRINS
37 {
39  const std::string& physics,
40  std::string& model )
41  {
42  // Newer, preferred version
43  bool have_material = MaterialsParsing::have_material(input,physics);
44 
45  // Old deprecated version
46  bool have_viscosity_model = input.have_variable("Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/viscosity_model");
47 
49  have_material,
50  input,
51  physics,
52  model );
53 
54  if( have_material )
55  {
56  std::string material = MaterialsParsing::material_name( input, physics );
57  MaterialsParsing::viscosity_model( input, physics, material, model );
58  }
59  }
60 
62  const std::string& physics,
63  std::string& model )
64  {
65  // Newer, preferred version
66  bool have_material = MaterialsParsing::have_material(input,physics);
67 
68  // Old deprecated versions
69  bool have_ht_conductivity_model = input.have_variable("Physics/"+PhysicsNaming::heat_transfer()+"/conductivity_model");
70 
71  bool have_conductivity_model = input.have_variable("Physics/"+physics+"/conductivity_model");
72 
73  if( (have_material && have_conductivity_model) ||
74  (have_material && have_ht_conductivity_model) )
75  {
76  libmesh_error_msg("Error: Cannot specify both conductivity_model and material.");
77  }
78 
79  /* If the user hasn't specified the material or the conductivity_model,
80  we're assuming they're using the old version.
81  This is deprecated.*/
82  if( !have_conductivity_model && !have_material && !have_ht_conductivity_model )
83  {
84  std::string warning = "Warning: Neither conductivity_model nor material were specified.\n";
85  warning += " We are assuming a constant conductivity model.\n";
86  warning += " This case is DEPRECATED.\n";
87  warning += " Please update and specify Physics/"+physics+"/material.\n";
88  grins_warning(warning);
89 
90  model = "constant";
91  }
92 
93  // Deprecated
94  if( have_ht_conductivity_model )
95  {
96  std::string warning = "Warning: Option Physics/"+PhysicsNaming::heat_transfer()+"/conductivity_model is DEPRECATED.\n";
97  warning += " Please update to use Physics/"+physics+"/material.\n";
98  grins_warning(warning);
99 
100  model = input( "Physics/"+PhysicsNaming::heat_transfer()+"/conductivity_model", "constant" );
101  }
102 
103  // Deprecated
104  if( have_conductivity_model )
105  {
106  std::string warning = "Warning: Option Physics/"+physics+"/conductivity_model is DEPRECATED.\n";
107  warning += " Please update to use Physics/"+physics+"/material.\n";
108  grins_warning(warning);
109 
110  model = input( "Physics/"+physics+"/conductivity_model", "constant" );
111  }
112 
113  // Preferred
114  if( have_material )
115  {
116  std::string material = MaterialsParsing::material_name( input, physics );
117  MaterialsParsing::thermal_conductivity_model( input, physics, material, model );
118  }
119 
120  return;
121  }
122 
124  const std::string& physics,
125  std::string& model )
126  {
127  // Newer, preferred version
128  bool have_material = MaterialsParsing::have_material(input,physics);
129 
130  bool have_lmns_specific_heat_model = input.have_variable("Physics/"+PhysicsNaming::low_mach_navier_stokes()+"/specific_heat_model");
131 
132  if( have_material && have_lmns_specific_heat_model )
133  {
134  libmesh_error_msg("ERROR: Cannot specify both a material and Physics/"+PhysicsNaming::low_mach_navier_stokes()+"/specific_heat_model!");
135  }
136 
137  // Deprecated
138  if( have_lmns_specific_heat_model )
139  {
140  std::string warning = "Warning: Option Physics/"+PhysicsNaming::low_mach_navier_stokes()+"/specific_heat_model is DEPRECATED.\n";
141  warning += " Please update to use Physics/"+physics+"/material.\n";
142  grins_warning(warning);
143 
144  model = input( "Physics/"+PhysicsNaming::low_mach_navier_stokes()+"/specific_heat_model", "constant" );
145  }
146 
147  // Preferred
148  if( have_material )
149  {
150  std::string material = MaterialsParsing::material_name( input, physics );
151  MaterialsParsing::specific_heat_model( input, physics, material, model );
152  }
153  }
154 
156  const std::string& physics,
157  std::string& model )
158  {
159  // Newer, preferred version
160  bool have_material = MaterialsParsing::have_material(input,physics);
161 
162  // Old deprecated version
163  bool have_viscosity_model = input.have_variable("Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/viscosity_model");
164 
166  have_material,
167  input,
168  physics,
169  model );
170 
171  // Additionally, we need to check if the turbulence Physics didn't
172  // set the viscosity model, but the *non* turbulent viscosity_model
173  // is set to spallartallmaras. In that case, the physical viscosity
174  // model is 'constant'.
175  if( !have_material &&
176  input.have_variable( "Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/viscosity_model") )
177  {
178  // If we got here, have_viscosity_model is true and might
179  // be set to spallartallmaras
180  if( input("Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/viscosity_model", "DIE!") == std::string("spalartallmaras") )
181  {
182  model = "constant";
183  }
184  }
185 
186  if( have_material )
187  {
188  std::string material = MaterialsParsing::material_name( input, physics );
189  MaterialsParsing::turb_viscosity_model( input, physics, material, model );
190  }
191 
192  return;
193  }
194 
196  const std::string& physics,
197  std::string& model,
198  std::string& strain_energy )
199  {
200  // Newer, preferred version
201  std::string material = MaterialsParsing::material_name( input, physics );
202 
203  // Old deprecated version
204  bool have_elasticity_model = input.have_variable("Physics/"+physics+"/elasticity_model");
205 
206  // It's an error to specify both the old and the new version
207  if( have_elasticity_model &&
208  input.have_variable("Materials/"+material+"/StressStrainLaw/model") )
209  {
210  libmesh_error_msg("ERROR: Cannot specify both Materials/"+material+"/StressStrainLaw/model and Physics/"+physics+"/elasticity_model!");
211  }
212 
213  // It's an error if don't specify at least one of them
214  if( !have_elasticity_model &&
215  !input.have_variable("Materials/"+material+"/StressStrainLaw/model") )
216  {
217  // But since the old is deprecated, we'll just them to supply the new
218  libmesh_error_msg("ERROR: Must specify Materials/"+material+"/StressStrainLaw/model!");
219  }
220 
221  // Deprecated
222  if( have_elasticity_model )
223  {
224  std::string warning = "Warning: Option Physics/"+physics+"/elasticity_model is DEPRECATED.\n";
225  warning += " Please update to use Materials/MATERIAL_NAME/StressStrainLaw/model.\n";
226  grins_warning(warning);
227 
228  model = input( "Physics/"+physics+"/elasticity_model", "DIE!" );
229 
230  if( model == std::string("HookesLaw") )
231  model = "hookes_law";
232  if( model == std::string("MooneyRivlin") )
233  {
234  model = "incompressible_hyperelasticity";
235  strain_energy = "mooney_rivlin";
236  }
237 
238  }
239  // Preferred
240  else if( input.have_variable("Materials/"+material+"/StressStrainLaw/model") )
241  {
242  MaterialsParsing::stress_strain_model( input, physics, material,
243  model, strain_energy );
244  }
245  // Wat?
246  else
247  {
248  libmesh_error();
249  }
250  }
251 
253  const std::string& physics,
254  std::string& model )
255  {
256  // Newer, preferred version
257  std::string material = MaterialsParsing::material_name( input, physics );
258 
259  bool have_thermochem_lib = input.have_variable( "Physics/"+PhysicsNaming::reacting_low_mach_navier_stokes()+"/thermochemistry_library" );
260 
261  // It's an error to specify both the old and the new version
262  if( have_thermochem_lib &&
263  input.have_variable("Materials/"+material+"/GasMixture/thermochemistry_library") )
264  {
265  libmesh_error_msg("ERROR: Cannot specify both Materials/"+material+"/GasMixture/thermochemistry_library and Physics/"+PhysicsNaming::reacting_low_mach_navier_stokes()+"/thermochemistry_library!");
266  }
267 
268  //Deprecated
269  if( have_thermochem_lib )
270  {
271  model = input( "Physics/"+PhysicsNaming::reacting_low_mach_navier_stokes()+"/thermochemistry_library", "DIE!" );
272  }
273  // Preferred
274  else if( input.have_variable("Materials/"+material+"/GasMixture/thermochemistry_library") )
275  {
276  model = input("Materials/"+material+"/GasMixture/thermochemistry_library", "DIE!");
277  }
278  // Fail
279  else
280  {
281  libmesh_error_msg("ERROR! Could not find valid thermochemistry_library input!");
282  }
283 
284  // Make sure we have a valid model
285  if( model != std::string("antioch") &&
286  model != std::string("cantera") )
287  {
288  std::string error = "ERROR! Invalid thermochemistry library value "+model+"!\n";
289  error += " Valid selections are: antioch\n";
290  error += " cantera\n";
291 
292  libmesh_error_msg(error);
293  }
294  }
295 
297  const std::string& physics,
298  std::string& transport_model,
299  std::string& thermo_model,
300  std::string& viscosity_model,
301  std::string& conductivity_model,
302  std::string& diffusivity_model )
303  {
304  // Newer, preferred version
305  std::string material = MaterialsParsing::material_name( input, physics );
306 
307  bool have_transport_model = input.have_variable( "Physics/Antioch/transport_model" );
308 
309  // It's an error to specify both the old and the new version
310  if( have_transport_model &&
311  input.have_variable("Materials/"+material+"/GasMixture/Antioch/transport_model") )
312  {
313  libmesh_error_msg("ERROR: Cannot specify both Materials/"+material+"/GasMixture/Antioch/transport_model and Physics/Antioch/transport_model!");
314  }
315 
316  //Deprecated
317  if( have_transport_model )
318  {
319  std::string warning = "Warning: Option Physics/Antioch/transport_model is DEPRECATED.\n";
320  warning += " Please update to use Use Materials/MATERIAL_NAME/GasMixture/Antioch/transport_model.\n";
321  grins_warning(warning);
322 
323  transport_model = input( "Physics/Antioch/transport_model", "mixture_averaged" );
324  }
325  // mixing_model option is now deprecated in favor of transport_model
326  else if( input.have_variable("Physics/Antioch/mixing_model") )
327  {
328  std::string warning = "Warning: Option Physics/Antioch/mixing_model is DEPRECATED.\n";
329  warning += " Please update to use Use Materials/MATERIAL_NAME/GasMixture/Antioch/transport_model.\n";
330  grins_warning(warning);
331 
332  transport_model = input( "Physics/Antioch/mixing_model" , "mixture_averaged" );
333  }
334  // Preferred
335  else if( input.have_variable("Materials/"+material+"/GasMixture/Antioch/transport_model") )
336  {
337  transport_model = input("Materials/"+material+"/GasMixture/Antioch/transport_model", "DIE!");
338  }
339  // Fail
340  else
341  {
342  libmesh_error_msg("ERROR! Could not find valid transport_model input!");
343  }
344 
345  // transport_model = wilke is deprecated
346  if( transport_model == std::string("wilke") )
347  {
348  libMesh::err << "WARNING: Physics/Antioch/transport_model value of 'wilke' is deprecated!" << std::endl
349  << " Replace Physics/Antioch/transport_model value with 'mixture_averaged'"
350  << std::endl;
351 
352  transport_model = "mixture_averaged";
353  }
354 
355  // Now parse the remaining models
356  //Deprecated
357  if( have_transport_model || input.have_variable("Physics/Antioch/mixing_model") )
358  {
359  // We're tying all the other option specifications to transport_model.
360  thermo_model = input( "Physics/Antioch/thermo_model", "stat_mech");
361  viscosity_model = input( "Physics/Antioch/viscosity_model", "blottner");
362  conductivity_model = input( "Physics/Antioch/conductivity_model", "eucken");
363  diffusivity_model = input( "Physics/Antioch/diffusivity_model", "constant_lewis");
364 
365  // So they'd better not have the other version specified.
366  if( input.have_variable("Materials/"+material+"/GasMixture/Antioch/thermo_model") ||
367  input.have_variable("Materials/"+material+"/GasMixture/Antioch/viscosity_model") ||
368  input.have_variable("Materials/"+material+"/GasMixture/Antioch/thermal_conductivity_model") ||
369  input.have_variable("Materials/"+material+"/GasMixture/Antioch/mass_diffusivity_model") )
370  {
371  libmesh_error_msg("ERROR: Cannot specifiy Physics/Antioch/transport_model and then specify Materials/"+material+"/GasMixture/Antioch/<thermo,viscosity,conductivity,diffusivity>_model!");
372  }
373  }
374  // Preferred
375  else if( input.have_variable("Materials/"+material+"/GasMixture/Antioch/transport_model") )
376  {
377  // We're tying all the other option specifications to transport_model.
378  // For the newer cases, we don't support a default, the user must specify
379  // We're tying all the other option specifications to transport_model.
380  MaterialsParsing::check_for_input_option(input,"Materials/"+material+"/GasMixture/Antioch/thermo_model");
381  MaterialsParsing::check_for_input_option(input,"Materials/"+material+"/GasMixture/Antioch/viscosity_model");
382  MaterialsParsing::check_for_input_option(input,"Materials/"+material+"/GasMixture/Antioch/thermal_conductivity_model");
383  MaterialsParsing::check_for_input_option(input,"Materials/"+material+"/GasMixture/Antioch/mass_diffusivity_model");
384 
385  thermo_model = input( "Materials/"+material+"/GasMixture/Antioch/thermo_model", "DIE!");
386  viscosity_model = input( "Materials/"+material+"/GasMixture/Antioch/viscosity_model", "DIE!");
387  conductivity_model = input( "Materials/"+material+"/GasMixture/Antioch/thermal_conductivity_model", "DIE!");
388  diffusivity_model = input( "Materials/"+material+"/GasMixture/Antioch/mass_diffusivity_model", "DIE!");
389 
390  // So they'd better not have the other version specified.
391  if( input.have_variable("Physics/Antioch/thermo_model") ||
392  input.have_variable("Physics/Antioch/viscosity_model") ||
393  input.have_variable("Physics/Antioch/conductivity_model") ||
394  input.have_variable("Physics/Antioch/diffusivity_model") )
395  {
396  libmesh_error_msg("ERROR: Cannot specifiy Materials/"+material+"/GasMixture/Antioch/transport_model and then specify Physics/Antioch/<thermo,viscosity,conductivity,diffusivity>_model!");
397  }
398  }
399  // Fail
400  else
401  {
402  libmesh_error_msg("ERROR! Could not find valid transport_model input!");
403  }
404 
405  }
406 
407  void PhysicsFactoryHelper::deprecated_visc_model_parsing( bool have_ins_viscosity_model,
408  bool have_material,
409  const GetPot& input,
410  const std::string& physics,
411  std::string& model)
412  {
413  bool have_viscosity_model = input.have_variable( "Physics/"+physics+"/viscosity_model");
414 
415  if( (have_material && have_ins_viscosity_model) ||
416  (have_material && have_viscosity_model) )
417  {
418  libmesh_error_msg("Error: Cannot specify both viscosity_model and material.");
419  }
420 
421  /* If the user hasn't specified the material or the viscosity_model,
422  we're assuming they're using the old version. */
423  if( !have_ins_viscosity_model && !have_material && !have_viscosity_model )
424  {
425  std::string warning = "Warning: Neither viscosity_model nor material were specified.\n";
426  warning += " We are assuming a constant viscosity model.\n";
427  warning += " This case is DEPRECATED.\n";
428  warning += " Please update and specify Physics/"+physics+"/material.\n";
429  grins_warning(warning);
430 
431  model = "constant";
432  }
433 
434  if( have_ins_viscosity_model )
435  {
436  std::string warning = "Warning: Option Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/viscosity_model is DEPRECATED.\n";
437  warning += " Please update to use Physics/"+physics+"/material.\n";
438  grins_warning(warning);
439 
440  model = input( "Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/viscosity_model", "constant" );
441  }
442 
443  if( have_viscosity_model )
444  {
445  std::string warning = "Warning: Option Physics/"+physics+"/viscosity_model is DEPRECATED.\n";
446  warning += " Please update to use Physics/"+physics+"/material.\n";
447  grins_warning(warning);
448 
449  model = input( "Physics/"+physics+"/viscosity_model", "constant" );
450  }
451  }
452 
453 } // end namespace GRINS
static void parse_viscosity_model(const GetPot &input, const std::string &physics, std::string &model)
Determine viscosity model based on given physics name.
static PhysicsName heat_transfer()
static void parse_thermochemistry_model(const GetPot &input, const std::string &physics, std::string &model)
Determine thermochemistry model type.
static PhysicsName reacting_low_mach_navier_stokes()
static PhysicsName low_mach_navier_stokes()
#define grins_warning(message)
Definition: common.h:34
static void parse_antioch_models(const GetPot &input, const std::string &physics, std::string &transport_model, std::string &thermo_model, std::string &viscosity_model, std::string &conductivity_model, std::string &diffusivity_model)
static void check_for_input_option(const GetPot &input, const std::string &option)
Helper function to check for option and error out if it's not found.
static void viscosity_model(const GetPot &input, const std::string &physics, const std::string &material, std::string &model)
Parse the viscosity model for the given material.
static void stress_strain_model(const GetPot &input, const std::string &, const std::string &material, std::string &model, std::string &strain_energy)
Parse the stress-strain model for the given material.
GRINS namespace.
static void parse_conductivity_model(const GetPot &input, const std::string &physics, std::string &model)
Determine conductivity model based on given physics name.
static void turb_viscosity_model(const GetPot &input, const std::string &physics, const std::string &material, std::string &model)
Parse the turbulence viscosity model for the given material.
static void specific_heat_model(const GetPot &input, const std::string &physics, const std::string &material, std::string &model)
Parse the specific heat model for the given material.
static PhysicsName incompressible_navier_stokes()
static void deprecated_visc_model_parsing(bool have_viscosity_model, bool have_material, const GetPot &input, const std::string &physics, std::string &model)
static std::string material_name(const GetPot &input, const std::string &physics)
Get the name of the material in the Physics/physics section.
static void parse_stress_strain_model(const GetPot &input, const std::string &physics, std::string &model, std::string &strain_energy)
Determine stress-strain law used by solid mechanics classes.
static bool have_material(const GetPot &input, const std::string &physics)
Check if Physics/physics section has a material variable.
static void parse_specific_heat_model(const GetPot &input, const std::string &physics, std::string &model)
Determine specific heat model based on given physics name.
static void thermal_conductivity_model(const GetPot &input, const std::string &physics, const std::string &material, std::string &model)
Parse the conductivity model for the given material.
static void parse_turb_viscosity_model(const GetPot &input, const std::string &physics, std::string &model)
Determine viscosity model used by turblence classes.

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