GRINS-0.8.0
physics_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_PHYSICS_FACTORY_BASE_H
26 #define GRINS_PHYSICS_FACTORY_BASE_H
27 
28 // GRINS
30 #include "grins/physics.h"
31 
32 namespace GRINS
33 {
34  // According to the standard, we need a declaration of the
35  // specialization which precedes any automatic instantiation.
37  template<> const GetPot* FactoryWithGetPot<Physics>::_input;
38 
40 
46  {
47  public:
48  PhysicsFactoryBase( const std::string& physics_name )
49  : FactoryWithGetPotPhysicsName<Physics>(physics_name)
50  {}
51 
53 
54  protected:
55 
56  virtual libMesh::UniquePtr<Physics> build_physics( const GetPot& input,
57  const std::string& physics_name ) =0;
58 
59  private:
60 
61  virtual libMesh::UniquePtr<Physics> create();
62 
63  };
64 
65  inline
66  libMesh::UniquePtr<Physics> PhysicsFactoryBase::create()
67  {
68  // Make sure user set the physics name
69  if( _physics_name == std::string("DIE!") )
70  libmesh_error_msg("ERROR: must call set_physics_name() before building Physics!");
71 
72  if( !_input )
73  libmesh_error_msg("ERROR: must call set_getpot() before building Physics!");
74 
75  libMesh::UniquePtr<Physics> new_physics = this->build_physics( *_input, _physics_name );
76 
77  // Reset the _physics_name for error checking
78  _physics_name = std::string("DIE!");
79 
80  libmesh_assert(new_physics);
81 
82  return new_physics;
83  }
84 
85 } // end namespace GRINS
86 
87 #endif // GRINS_PHYSICS_FACTORY_BASE_H
Abstract factory that provides availability of GetPot and a physics_name.
Physics abstract base class. Defines API for physics to be added to MultiphysicsSystem.
Definition: physics.h:106
GRINS namespace.
Builds Physics objects, used by PhysicsBuilder.
PhysicsFactoryBase(const std::string &physics_name)
static const GetPot * _input
We store only a raw pointer here because we can't make a copy.
virtual libMesh::UniquePtr< Physics > create()
Subclasses implement the actual construction of the Base object in create().
virtual libMesh::UniquePtr< Physics > build_physics(const GetPot &input, const std::string &physics_name)=0
Abstract factory that provides availability of GetPot.

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