GRINS-0.7.0
mesh_adaptivity_options.C
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 //
3 // GRINS - General Reacting Incompressible Navier-Stokes
4 //
5 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
6 // Copyright (C) 2010-2013 The PECOS Development Team
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the Version 2.1 GNU Lesser General
10 // Public License as published by the Free Software Foundation.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
20 // Boston, MA 02110-1301 USA
21 //
22 //-----------------------------------------------------------------------el-
23 
24 // This class
26 
27 // GRINS
28 #include "grins/common.h"
29 
30 // libMesh
31 #include "libmesh/getpot.h"
32 #include "libmesh/string_to_enum.h"
33 
34 namespace GRINS
35 {
37  : _is_mesh_adaptive(false),
38  _refinement_strategy("elem_fraction"),
39  _max_refinement_steps(0),
40  _coarsen_by_parents(true),
41  _absolute_global_tolerance(0),
42  _nelem_target(0),
43  _refine_fraction(0.2),
44  _coarsen_fraction(0.2),
45  _coarsen_threshold(0),
46  _plot_cell_errors(false),
47  _error_plot_prefix("cell_error"),
48  _node_level_mismatch_limit(0),
49  _edge_level_mismatch_limit(0),
50  _face_level_mismatch_limit(1),
51  _enforce_mismatch_limit_prior_to_refinement(false),
52  _max_h_level(libMesh::invalid_uint)
53  {
54  this->check_dup_input_style(input);
55 
56  if( this->is_old_style(input) )
57  this->parse_old_style(input);
58  else
59  this->parse_new_style(input);
60  }
61 
62  void MeshAdaptivityOptions::check_dup_input_style( const GetPot& input ) const
63  {
64  if( input.have_variable("MeshAdaptivity") &&
65  input.have_section("Strategies/MeshAdaptivity") )
66  libmesh_error_msg("ERROR: Cannot use both old and new style of options for MeshAdaptivityOptions!");
67  }
68 
69  bool MeshAdaptivityOptions::is_old_style( const GetPot& input ) const
70  {
71  return input.have_section("MeshAdaptivity");
72  }
73 
74  void MeshAdaptivityOptions::parse_old_style(const GetPot& input)
75  {
76  {
77  std::string warning = "WARNING: Using [MeshAdaptivity/<options>] is a DEPRECATED\n";
78  warning += " style of input for mesh adaptivity options. Please\n";
79  warning += " update to use the [Strategies/MeshAdaptivity/<options> style.\n";
80  grins_warning(warning);
81  }
82 
83  std::string section = "MeshAdaptivity";
84  this->parse_options(input,section);
85  }
86 
87  void MeshAdaptivityOptions::parse_new_style(const GetPot& input)
88  {
89  std::string section = "Strategies/MeshAdaptivity";
90  this->parse_options(input,section);
91  }
92 
93  void MeshAdaptivityOptions::parse_options(const GetPot& input, const std::string& section)
94  {
95  _is_mesh_adaptive = input(section+"/mesh_adaptive", false);
96  _refinement_strategy = input(section+"/refinement_strategy", "elem_fraction" );
97  _max_refinement_steps = input(section+"/max_refinement_steps", 0);
98  _coarsen_by_parents = true;
99  _absolute_global_tolerance = input(section+"/absolute_global_tolerance", 0);
100  _nelem_target = input(section+"/nelem_target", 0);
101  _refine_fraction = input(section+"/refine_percentage", 0.8);
102  _coarsen_fraction = input(section+"/coarsen_percentage", 0.1);
103  _coarsen_threshold = input(section+"/coarsen_threshold", 0);
104  _plot_cell_errors = input(section+"/plot_cell_errors", false);
105  _error_plot_prefix = input(section+"/error_plot_prefix", "cell_error");
106  _node_level_mismatch_limit = input(section+"/node_level_mismatch_limit", 0);
107  _edge_level_mismatch_limit = input(section+"/edge_level_mismatch_limit", 0 );
108  _face_level_mismatch_limit = input(section+"/face_level_mismatch_limit", 1 );
109  _enforce_mismatch_limit_prior_to_refinement = input(section+"/enforce_mismatch_limit_prior_to_refinement", true );
110  _max_h_level = input(section+"/max_h_level",libMesh::invalid_uint);
111  }
112 
113 } // end namespace GRINS
void parse_new_style(const GetPot &input)
#define grins_warning(message)
Definition: common.h:34
void parse_options(const GetPot &input, const std::string &section)
GRINS namespace.
void parse_old_style(const GetPot &input)
bool is_old_style(const GetPot &input) const
void check_dup_input_style(const GetPot &input) const
MeshAdaptivityOptions(const GetPot &input)

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