GRINS-0.8.0
solver_parsing.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 // These functions
26 #include "grins/solver_names.h"
27 #include "grins/solver_parsing.h"
29 
30 // GRINS
31 #include "grins/common.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 
36 namespace GRINS
37 {
38  std::string SolverParsing::solver_type(const GetPot& input)
39  {
40  std::string solver_type;
41 
42  // If the user set the solver_type, use that
43  if( input.have_variable("SolverOptions/solver_type") )
44  solver_type = input("SolverOptions/solver_type", "DIE!");
45 
46  // Otherwise, they're using grins_steady/unsteady (possibly mesh_adaptive) solver
47  else
48  {
50  MeshAdaptivityOptions mesh_adaptivity_options(input);
51  bool mesh_adaptive = mesh_adaptivity_options.is_mesh_adaptive();
52 
53  bool transient = SolverParsing::is_transient(input);
54 
55  if(transient && !mesh_adaptive)
56  {
57  solver_type = SolverNames::unsteady_solver();
58  }
59  else if( !transient && !mesh_adaptive )
60  {
61  solver_type = SolverNames::steady_solver();
62  }
63  else if( !transient && mesh_adaptive )
64  {
66  }
67  else if( transient && mesh_adaptive )
68  {
70  }
71  else
72  {
73  libmesh_error_msg("Unsupported combination of solver options!");
74  }
75  }
76 
77  return solver_type;
78  }
79 
80  bool SolverParsing::is_transient( const GetPot& input )
81  {
82  // Can't specify both old and new version
84  "unsteady-solver/transient",
85  "SolverOptions/TimeStepping/solver_type");
86 
87  bool transient = false;
88 
89  if( input.have_variable("unsteady-solver/transient") )
90  {
91  transient = input("unsteady-solver/transient",false);
92 
93  std::string warning = "WARNING: unsteady-solver/transient is DEPRECATED!\n";
94  warning += " Please use SolverOptions/TimeStepping/solver_type to specify time stepping solver.\n";
95  grins_warning(warning);
96  }
97 
98  // In the new version, we set the solver type so we just need to
99  // check if the variable is present. Solver class will figure
100  // out the type.
101  if( input.have_variable("SolverOptions/TimeStepping/solver_type") )
102  transient = true;
103 
104  return transient;
105  }
106 
107  void SolverParsing::dup_solver_option_check( const GetPot& input,
108  const std::string& option1,
109  const std::string& option2 )
110  {
111  // Can't specify both old and new version
112  if( input.have_variable(option1) && input.have_variable(option2) )
113  {
114  libmesh_error_msg("ERROR: Cannot specify both "+option1+" and "+option2);
115  }
116  }
117 
118 } // end namespace GRINS
static std::string solver_type(const GetPot &input)
static bool is_transient(const GetPot &input)
#define grins_warning(message)
Definition: common.h:34
GRINS namespace.
static const std::string unsteady_solver()
Definition: solver_names.h:37
Container for mesh adaptivity options.
static const std::string steady_mesh_adaptive_solver()
Definition: solver_names.h:40
static const std::string unsteady_mesh_adaptive_solver()
Definition: solver_names.h:43
static const std::string steady_solver()
Definition: solver_names.h:34
static void dup_solver_option_check(const GetPot &input, const std::string &option1, const std::string &option2)

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