GRINS-0.6.0
error_estimation_factory.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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 // libMesh
29 #include "libmesh/adjoint_residual_error_estimator.h"
30 #include "libmesh/adjoint_refinement_estimator.h"
31 #include "libmesh/getpot.h"
32 #include "libmesh/patch_recovery_error_estimator.h"
33 #include "libmesh/qoi_set.h"
34 #include "libmesh/kelly_error_estimator.h"
35 
36 namespace GRINS
37 {
38 
40  {
41  return;
42  }
43 
45  {
46  return;
47  }
48 
49  std::tr1::shared_ptr<libMesh::ErrorEstimator> ErrorEstimatorFactory::build( const GetPot& input,
50  const libMesh::QoISet& qoi_set )
51  {
52  std::string estimator_type = input("MeshAdaptivity/estimator_type", "patch_recovery");
53 
54  ErrorEstimatorEnum estimator_enum = this->string_to_enum( estimator_type );
55 
56  std::tr1::shared_ptr<libMesh::ErrorEstimator> error_estimator;
57 
58  switch( estimator_enum )
59  {
60  case(ADJOINT_RESIDUAL):
61  {
62  error_estimator.reset( new libMesh::AdjointResidualErrorEstimator );
63 
64  libMesh::AdjointResidualErrorEstimator*
65  adjoint_error_estimator =
66  libMesh::libmesh_cast_ptr<libMesh::AdjointResidualErrorEstimator*>
67  ( error_estimator.get() );
68 
69  adjoint_error_estimator->qoi_set() = qoi_set;
70 
71  libMesh::PatchRecoveryErrorEstimator *p1 = new libMesh::PatchRecoveryErrorEstimator;
72  adjoint_error_estimator->primal_error_estimator().reset( p1 );
73 
74  libMesh::PatchRecoveryErrorEstimator *p2 = new libMesh::PatchRecoveryErrorEstimator;
75  adjoint_error_estimator->dual_error_estimator().reset( p2 );
76 
77  bool patch_reuse = input( "MeshAdaptivity/patch_reuse", false );
78  adjoint_error_estimator->primal_error_estimator()->error_norm.set_type
79  ( 0, libMesh::H1_SEMINORM );
80  p1->set_patch_reuse( patch_reuse );
81 
82  adjoint_error_estimator->dual_error_estimator()->error_norm.set_type
83  ( 0, libMesh::H1_SEMINORM );
84  p2->set_patch_reuse( patch_reuse );
85  }
86  break;
87 
88  case(KELLY):
89  {
90  error_estimator.reset( new libMesh::KellyErrorEstimator );
91  }
92  break;
93 
94  case(PATCH_RECOVERY):
95  {
96  error_estimator.reset( new libMesh::PatchRecoveryErrorEstimator );
97  }
98  break;
99 
100  case(ADJOINT_REFINEMENT):
101  {
102  error_estimator.reset( new libMesh::AdjointRefinementEstimator );
103 
104  libMesh::AdjointRefinementEstimator*
105  adjoint_error_estimator =
106  libMesh::libmesh_cast_ptr<libMesh::AdjointRefinementEstimator*>
107  ( error_estimator.get() );
108 
109  adjoint_error_estimator->qoi_set() = qoi_set;
110 
111  adjoint_error_estimator->number_h_refinements = 1;
112  adjoint_error_estimator->number_p_refinements = 0;
113  }
114  break;
115 
117  case(UNIFORM_REFINEMENT):
118  {
119  libmesh_not_implemented();
120  }
121  break;
122 
123  // wat?!
124  default:
125  {
126  libmesh_error();
127  }
128 
129  } // switch( estimator_enum )
130 
131  return error_estimator;
132  }
133 
135  {
136  ErrorEstimatorEnum value;
137 
138  if( estimator_type == std::string("adjoint_residual") )
139  {
140  value = ADJOINT_RESIDUAL;
141  }
142  else if( estimator_type == std::string("adjoint_refinement") )
143  {
144  value = ADJOINT_REFINEMENT;
145  }
146  else if( estimator_type == std::string("kelly") )
147  {
148  value = KELLY;
149  }
150  else if( estimator_type == std::string("patch_recovery") )
151  {
152  value = PATCH_RECOVERY;
153  }
154  else if( estimator_type == std::string("weighted_patch_recovery") )
155  {
156  value = WEIGHTED_PATCH_RECOVERY;
157  }
158  else if( estimator_type == std::string("uniform_refinement") )
159  {
160  value = UNIFORM_REFINEMENT;
161  }
162  else
163  {
164  std::cerr << "Error: Invalid error estimator type " << estimator_type << std::endl
165  << "Valid error estimator types are: adjoint_residual" << std::endl
166  << " adjoint_refinement" << std::endl
167  << " kelly" << std::endl
168  << " patch_recovery" << std::endl
169  << " weighted_patch_recovery" << std::endl
170  << " uniform_refinement" << std::endl;
171  libmesh_error();
172  }
173 
174  return value;
175  }
176 
177 } // namespace GRINS
virtual std::tr1::shared_ptr< libMesh::ErrorEstimator > build(const GetPot &input, const libMesh::QoISet &qoi_set)
GRINS namespace.
ErrorEstimatorEnum string_to_enum(const std::string &estimator_type) const

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1