GRINS-0.6.0
Public Member Functions | Protected Types | Protected Member Functions | List of all members
GRINS::ErrorEstimatorFactory Class Reference

#include <error_estimation_factory.h>

Public Member Functions

 ErrorEstimatorFactory ()
 
virtual ~ErrorEstimatorFactory ()
 
virtual std::tr1::shared_ptr< libMesh::ErrorEstimator > build (const GetPot &input, const libMesh::QoISet &qoi_set)
 

Protected Types

enum  ErrorEstimatorEnum {
  ADJOINT_RESIDUAL = 0, ADJOINT_REFINEMENT, KELLY, PATCH_RECOVERY,
  WEIGHTED_PATCH_RECOVERY, UNIFORM_REFINEMENT
}
 

Protected Member Functions

ErrorEstimatorEnum string_to_enum (const std::string &estimator_type) const
 

Detailed Description

Definition at line 39 of file error_estimation_factory.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

GRINS::ErrorEstimatorFactory::ErrorEstimatorFactory ( )

Definition at line 39 of file error_estimation_factory.C.

40  {
41  return;
42  }
GRINS::ErrorEstimatorFactory::~ErrorEstimatorFactory ( )
virtual

Definition at line 44 of file error_estimation_factory.C.

45  {
46  return;
47  }

Member Function Documentation

std::tr1::shared_ptr< libMesh::ErrorEstimator > GRINS::ErrorEstimatorFactory::build ( const GetPot &  input,
const libMesh::QoISet &  qoi_set 
)
virtual

Definition at line 49 of file error_estimation_factory.C.

References ADJOINT_REFINEMENT, ADJOINT_RESIDUAL, KELLY, PATCH_RECOVERY, string_to_enum(), UNIFORM_REFINEMENT, and WEIGHTED_PATCH_RECOVERY.

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  }
ErrorEstimatorEnum string_to_enum(const std::string &estimator_type) const
ErrorEstimatorFactory::ErrorEstimatorEnum GRINS::ErrorEstimatorFactory::string_to_enum ( const std::string &  estimator_type) const
protected

Definition at line 134 of file error_estimation_factory.C.

References ADJOINT_REFINEMENT, ADJOINT_RESIDUAL, KELLY, PATCH_RECOVERY, UNIFORM_REFINEMENT, and WEIGHTED_PATCH_RECOVERY.

Referenced by build().

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  }

The documentation for this class was generated from the following files:

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