GRINS-0.8.0
error_estimator_factory_base.h
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 #ifndef GRINS_ERROR_ESTIMATOR_FACTORY_BASE_H
26 #define GRINS_ERROR_ESTIMATOR_FACTORY_BASE_H
27 
28 // GRINS
30 #include "grins/multiphysics_sys.h"
32 
33 // libMesh
34 #include "libmesh/error_estimator.h"
35 
36 namespace GRINS
37 {
38  // According to the standard, we need a declaration of the
39  // specialization which precedes any automatic instantiation.
41 
43 
46  class ErrorEstimatorFactoryBase : public FactoryWithGetPot<libMesh::ErrorEstimator>
47  {
48  public:
49  ErrorEstimatorFactoryBase( const std::string& estimator_name )
50  : FactoryWithGetPot<libMesh::ErrorEstimator>(estimator_name)
51  {}
52 
54 
55  static void set_system( MultiphysicsSystem& system )
56  { _system = &system; }
57 
58  static void set_estimator_options( const ErrorEstimatorOptions& estimator_options )
59  { _estimator_options = &estimator_options; }
60 
61  protected:
62 
64  virtual libMesh::UniquePtr<libMesh::ErrorEstimator> build_error_estimator( const GetPot& input,
65  MultiphysicsSystem& system,
66  const ErrorEstimatorOptions& estimator_options ) =0;
67 
69 
72 
74 
76 
77  private:
78 
79  virtual libMesh::UniquePtr<libMesh::ErrorEstimator> create();
80 
81  };
82 
83  inline
84  libMesh::UniquePtr<libMesh::ErrorEstimator> ErrorEstimatorFactoryBase::create()
85  {
86  if( !_input )
87  libmesh_error_msg("ERROR: must call set_getpot() before building ErrorEstimator!");
88  if( !_system )
89  libmesh_error_msg("ERROR: must call set_system() before building ErrorEstimator!");
90  if( !_estimator_options )
91  libmesh_error_msg("ERROR: must call set_estimator_options() before building ErrorEstimator!");
92 
93  libMesh::UniquePtr<libMesh::ErrorEstimator>
94  new_estimator = this->build_error_estimator( *_input, *_system, *_estimator_options );
95 
96  libmesh_assert(new_estimator);
97 
98  return new_estimator;
99  }
100 
101 } // end namespace GRINS
102 
103 #endif // GRINS_ERROR_ESTIMATOR_FACTORY_BASE_H
static const ErrorEstimatorOptions * _estimator_options
Cache pointer to system.
static void set_estimator_options(const ErrorEstimatorOptions &estimator_options)
virtual libMesh::UniquePtr< libMesh::ErrorEstimator > build_error_estimator(const GetPot &input, MultiphysicsSystem &system, const ErrorEstimatorOptions &estimator_options)=0
Subclasses implement this method for building the ErrorEstimator object.
GRINS namespace.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual libMesh::UniquePtr< libMesh::ErrorEstimator > create()
Subclasses implement the actual construction of the Base object in create().
static void set_system(MultiphysicsSystem &system)
Container for ErrorEstimator options.
Interface with libMesh for solving Multiphysics problems.
ErrorEstimatorFactoryBase(const std::string &estimator_name)
Abstract factory that provides availability of GetPot.
static MultiphysicsSystem * _system
Cache pointer to system.

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