GRINS-0.8.0
adaptive_time_stepping_options.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 
31 // libMesh
32 #include "libmesh/getpot.h"
33 #include "libmesh/string_to_enum.h"
34 
35 namespace GRINS
36 {
38  : _is_time_adaptive(false),
39  _target_tolerance(0.0),
40  _upper_tolerance(0.0),
41  _max_growth(0.0)
42  {
43  this->check_dup_input_style(input);
44 
45  if( this->is_old_style(input) )
46  this->parse_old_style(input);
47  else
48  this->parse_new_style(input);
49 
50  if( _target_tolerance != 0.0 )
51  _is_time_adaptive = true;
52  }
53 
54  void AdaptiveTimeSteppingOptions::check_dup_input_style( const GetPot& input ) const
55  {
56  if( (input.have_variable("unsteady-solver/target_tolerance") &&
57  input.have_section("Strategies/AdaptiveTimeStepping/target_tolerance")) ||
58  (input.have_variable("unsteady-solver/upper_tolerance") &&
59  input.have_section("Strategies/AdaptiveTimeStepping/upper_tolerance")) ||
60  (input.have_variable("unsteady-solver/max_growth") &&
61  input.have_section("Strategies/AdaptiveTimeStepping/max_growth")) )
62  libmesh_error_msg("ERROR: Cannot use both old and new style of options for AdaptiveTimeSteppingOptions!");
63  }
64 
65  bool AdaptiveTimeSteppingOptions::is_old_style( const GetPot& input ) const
66  {
67  return input.have_variable("unsteady-solver/target_tolerance");
68  }
69 
71  {
72  {
73  std::string warning = "WARNING: Using [MeshAdaptivity/<options>] is a DEPRECATED\n";
74  warning += " style of input for ErrorEstimator options. Please\n";
75  warning += " update to use the [Strategies/ErrorEstimation/<options> style.\n";
76  grins_warning(warning);
77  }
78 
79  std::string section = "unsteady-solver";
80  this->parse_options(input,section);
81  }
82 
84  {
85  std::string section = "Strategies/AdaptiveTimeStepping";
86  this->parse_options(input,section);
87  }
88 
89  void AdaptiveTimeSteppingOptions::parse_options(const GetPot& input, const std::string& section)
90  {
91  // If the user set the target tolerance, for them to set the other values too
92  if( input.have_variable(section+"/target_tolerance") )
93  {
94  if( !input.have_variable(section+"/upper_tolerance") )
95  libmesh_error_msg("ERROR: Must specify "+section+"/upper_tolerance for adaptive time stepping!");
96 
97  if( !input.have_variable(section+"/max_growth") )
98  libmesh_error_msg("ERROR: Must specify "+section+"/max_growth for adaptive time stepping!");
99  }
100 
101  _target_tolerance = input(section+"/target_tolerance", 0.0 );
102  _upper_tolerance = input(section+"/upper_tolerance", 0.0 );
103  _max_growth = input(section+"/max_growth", 0.0 );
104 
105  // parse component_norm
106  const unsigned int n_component_norm =
107  input.vector_variable_size(section+"/component_norm");
108 
109  for (unsigned int i=0; i != n_component_norm; ++i)
110  {
111  const std::string current_norm = input(section+"/component_norm", std::string("L2"), i);
112  _component_norm.set_type(i, libMesh::Utility::string_to_enum<libMesh::FEMNormType>(current_norm) );
113  }
114  }
115 
116 } // end namespace GRINS
#define grins_warning(message)
Definition: common.h:34
void parse_options(const GetPot &input, const std::string &section)
GRINS namespace.
double _target_tolerance
0.0 means there is no adaptive time stepping enabled.
void check_dup_input_style(const GetPot &input) const
bool is_old_style(const GetPot &input) const

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