GRINS-0.8.0
time_stepping_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 // This class
27 
28 // GRINS
29 #include "grins/common.h"
30 #include "grins/solver_names.h"
31 #include "grins/solver_parsing.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 
36 namespace GRINS
37 {
38  unsigned int TimeSteppingParsing::parse_n_timesteps( const GetPot& input )
39  {
41  "unsteady-solver/n_timesteps",
42  "SolverOptions/TimeStepping/n_timesteps");
43 
44  unsigned int n_timesteps = 0;
45 
46  if( input.have_variable("unsteady-solver/n_timesteps") )
47  {
48  n_timesteps = input("unsteady-solver/n_timesteps",0);
49 
50  std::string warning = "WARNING: unsteady-solver/n_timesteps is DEPRECATED!\n";
51  warning += " Please use SolverOptions/TimeStepping/n_timesteps to specify # of timesteps.\n";
52  grins_warning(warning);
53  }
54  else if( input.have_variable("SolverOptions/TimeStepping/n_timesteps") )
55  n_timesteps = input("SolverOptions/TimeStepping/n_timesteps",0);
56  else
57  libmesh_error_msg("ERROR: Could not find valid entry for n_timesteps!");
58 
59  return n_timesteps;
60  }
61 
62  unsigned int TimeSteppingParsing::parse_backtrack_deltat( const GetPot& input )
63  {
65  "unsteady-solver/backtrack_deltat",
66  "SolverOptions/TimeStepping/backtrack_deltat");
67 
68  unsigned int backtrack_deltat = 0;
69 
70  if( input.have_variable("unsteady-solver/backtrack_deltat") )
71  {
72  backtrack_deltat = input("unsteady-solver/backtrack_deltat",0);
73 
74  std::string warning = "WARNING: unsteady-solver/backtrack_deltat is DEPRECATED!\n";
75  warning += " Please use SolverOptions/TimeStepping/backtrack_deltat to set backtrack_deltat.\n";
76  grins_warning(warning);
77  }
78  else
79  backtrack_deltat = input("SolverOptions/TimeStepping/backtrack_deltat",0);
80 
81  return backtrack_deltat;
82  }
83 
84  double TimeSteppingParsing::parse_theta( const GetPot& input )
85  {
86  double theta = 0.0;
87 
88  if( input.have_variable("unsteady-solver/theta") )
89  {
90  theta = input("unsteady-solver/theta",0.5);
91 
92  std::string warning = "WARNING: unsteady-solver/theta is DEPRECATED!\n";
93  warning += " Please use SolverOptions/TimeStepping/theta to set theta.\n";
94  grins_warning(warning);
95  }
96  else
97  theta = input("SolverOptions/TimeStepping/theta",0.5);
98 
99  if( theta < 0.0 || theta > 1.0 )
100  {
101  std::stringstream ts;
102  ts << theta;
103  libmesh_error_msg("ERROR: theta must be between 0.0 and 1.0. Found: "+ts.str());
104  }
105 
106  return theta;
107  }
108 
109  double TimeSteppingParsing::parse_deltat( const GetPot& input )
110  {
111  double delta_t = 0.0;
112 
113  if( input.have_variable("unsteady-solver/deltat") )
114  {
115  delta_t = input("unsteady-solver/deltat",0.0);
116 
117  std::string warning = "WARNING: unsteady-solver/deltat is DEPRECATED!\n";
118  warning += " Please use SolverOptions/TimeStepping/delta_t to set delta_t.\n";
119  grins_warning(warning);
120  }
121  else if( input.have_variable("SolverOptions/TimeStepping/delta_t") )
122  delta_t = input("SolverOptions/TimeStepping/delta_t",0.0);
123  else
124  libmesh_error_msg("ERROR: Could not find valid entry for delta_t!");
125 
126  return delta_t;
127  }
128 
129  std::string TimeSteppingParsing::parse_time_stepper_name( const GetPot& input )
130  {
131  std::string default_stepper = SolverNames::libmesh_euler_solver();
132  std::string time_stepper = default_stepper;
133 
134  // Before, we didn't actually set the solver name, we just set whether we
135  // were transient or not. So, if we see this option was set to true, then
136  // we were time stepping with the only option available then (EulerSolver)
137  if( input("unsteady-solver/transient", false) )
138  {
139  std::string warning = "WARNING: using unsteady-solver options is DEPRECATED!\n";
140  warning += " Please use SolverOptions/TimeStepping/solver_type to set the time\n";
141  warning += " stepping algorithm.\n";
142  grins_warning(warning);
143  }
144  else
145  time_stepper = input("SolverOptions/TimeStepping/solver_type", default_stepper);
146 
147  return time_stepper;
148  }
149 
150 } // end namespace GRINS
static unsigned int parse_n_timesteps(const GetPot &input)
#define grins_warning(message)
Definition: common.h:34
static unsigned int parse_backtrack_deltat(const GetPot &input)
Parse option to retry failed time steps with smaller .
GRINS namespace.
static std::string parse_time_stepper_name(const GetPot &input)
static double parse_theta(const GetPot &input)
Parse value of for theta method time stepping.
static double parse_deltat(const GetPot &input)
static const std::string libmesh_euler_solver()
Definition: solver_names.h:46
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