GRINS-0.7.0
catalycity_factory_abstract.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 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_CATALYCITY_FACTORY_ABSTRACT_H
26 #define GRINS_CATALYCITY_FACTORY_ABSTRACT_H
27 
28 // GRINS
30 #include "grins/catalycity_base.h"
31 
32 namespace GRINS
33 {
34  class CatalycityFactoryAbstract : public FactoryWithGetPot<CatalycityBase>
35  {
36  public:
37  CatalycityFactoryAbstract( const std::string& physics_name )
38  : FactoryWithGetPot<CatalycityBase>(physics_name)
39  {}
40 
42 
43  static void set_section( const std::string& section )
44  { _section = section; }
45 
46  protected:
47 
48  virtual libMesh::UniquePtr<CatalycityBase> build_catalycity( const GetPot& input,
49  const std::string& section ) =0;
50 
52  virtual void check_state() const;
53 
55  virtual void reset_state();
56 
57  static std::string _section;
58 
59  private:
60 
61  virtual libMesh::UniquePtr<CatalycityBase> create();
62  };
63 
64  inline
65  libMesh::UniquePtr<CatalycityBase> CatalycityFactoryAbstract::create()
66  {
67  this->check_state();
68 
69  libMesh::UniquePtr<CatalycityBase> new_catalycity = this->build_catalycity( *_input, _section );
70 
71  this->reset_state();
72 
73  return new_catalycity;
74  }
75 
76  inline
78  {
79  if( !_input )
80  libmesh_error_msg("ERROR: must call set_getpot() before building Catalycity!");
81 
82  if( _section == std::string("DIE!") )
83  libmesh_error_msg("ERROR: must call set_section() before building Catalycity!");
84  }
85 
86  inline
88  {
89  // Reset for error checking
90  _section = std::string("DIE!");
91  }
92 
93 } // end namespace GRINS
94 
95 #endif // GRINS_CATALYCITY_FACTORY_ABSTRACT_H
virtual libMesh::UniquePtr< CatalycityBase > build_catalycity(const GetPot &input, const std::string &section)=0
CatalycityFactoryAbstract(const std::string &physics_name)
static void set_section(const std::string &section)
GRINS namespace.
virtual void check_state() const
Helper function to reduce code duplication.
virtual void reset_state()
Helper function to reduce code duplication.
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual libMesh::UniquePtr< CatalycityBase > create()
Abstract factory that provides availability of GetPot.

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