GRINS-0.8.0
List of all members | Public Member Functions | Static Public Member Functions | Static Private Member Functions
GRINS::PhysicsBuilder Class Reference

Manages runtime construction of Physics objects. More...

#include <physics_builder.h>

Public Member Functions

 PhysicsBuilder ()
 
 ~PhysicsBuilder ()
 

Static Public Member Functions

static PhysicsList build_physics_map (const GetPot &input)
 Returns container of constructed Physics objects. More...
 

Static Private Member Functions

static void parse_requested_physics (const GetPot &input, std::set< std::string > &requested_physics)
 Parses the requested Physics from input and populates the set passed to this function. More...
 

Detailed Description

Manages runtime construction of Physics objects.

This will parse the input file for the requested Physics and manage their construction. Actual construction of the Physics object is delegated to PhysicsFactoryBase subclasses. The PhysicsBuilder merely manages tasks around them as needed. To add a new Physics, the user should instantiate an appropriate PhysicsFactoryBase subclass.

Definition at line 49 of file physics_builder.h.

Constructor & Destructor Documentation

GRINS::PhysicsBuilder::PhysicsBuilder ( )
inline

Definition at line 53 of file physics_builder.h.

53 {};
GRINS::PhysicsBuilder::~PhysicsBuilder ( )
inline

Definition at line 55 of file physics_builder.h.

55 {};

Member Function Documentation

PhysicsList GRINS::PhysicsBuilder::build_physics_map ( const GetPot &  input)
static

Returns container of constructed Physics objects.

Definition at line 38 of file physics_builder.C.

References GRINS::FactoryAbstract< Physics >::build(), GRINS::PhysicsNaming::clear_suffix(), GRINS::PhysicsNaming::extract_physics(), GRINS::PhysicsNaming::extract_suffix(), parse_requested_physics(), GRINS::FactoryWithGetPot< Physics >::set_getpot(), GRINS::FactoryWithGetPotPhysicsName< Physics >::set_physics_name(), and GRINS::PhysicsNaming::set_suffix().

Referenced by GRINS::Simulation::init_multiphysics_system().

39  {
40  // First parse what Physics the user requested
41  std::set<std::string> requested_physics;
42  PhysicsBuilder::parse_requested_physics(input,requested_physics);
43 
44  // Give the PhysicsFactories access to the GetPot object
46 
47  PhysicsList physics_map;
48 
49  // Now populate the PhysicsList with with of the corresponding Physics objects
50  for( std::set<std::string>::const_iterator physics_name_it = requested_physics.begin();
51  physics_name_it != requested_physics.end();
52  physics_name_it++ )
53  {
54  // Convenience
55  std::string physics_name = *physics_name_it;
56 
57  // Set the physics_name in the PhysicsFactory as it will be used internally
58  // to feed to the Physics constructors
60 
61  // Set the suffix in PhysicsNaming so it propagates to the Physics classes
62  std::string physics_suffix = PhysicsNaming::extract_suffix(physics_name);
63  PhysicsNaming::set_suffix(physics_suffix);
64 
65  // Strip any suffix out when querying the PhysicsFactories
66  std::string physics_name_prefix = PhysicsNaming::extract_physics(physics_name);
67 
68  // Now build the actual Physics object
69  libMesh::UniquePtr<Physics> physics_ptr = PhysicsFactoryBase::build(physics_name_prefix);
70 
71  // Clear out the suffix now that we're done
73 
74  // Now give it to the PhysicsList
75  physics_map[physics_name] = SharedPtr<Physics>( physics_ptr.release() );
76  }
77 
78  // Echo Physics to display, if requested
79  if( input( "screen-options/echo_physics", true ) )
80  {
81  libMesh::out << "==========================================================" << std::endl
82  << "List of Enabled Physics:" << std::endl;
83 
84  for( PhysicsListIter it = physics_map.begin();
85  it != physics_map.end();
86  it++ )
87  {
88  libMesh::out << it->first << std::endl;
89  }
90  libMesh::out << "==========================================================" << std::endl;
91  }
92 
93  return physics_map;
94  }
static void set_getpot(const GetPot &input)
static libMesh::UniquePtr< Physics > build(const std::string &name)
Use this method to build objects of type Base.
static void parse_requested_physics(const GetPot &input, std::set< std::string > &requested_physics)
Parses the requested Physics from input and populates the set passed to this function.
static std::string extract_physics(const std::string &full_name)
Extract the physics name from the full_name.
static void set_physics_name(const std::string &physics_name)
Setter for physics name.
std::map< std::string, SharedPtr< GRINS::Physics > > PhysicsList
Container for GRINS::Physics object pointers.
Definition: var_typedefs.h:59
static std::string extract_suffix(const std::string &full_name)
Extract the suffix from the full_name.
std::map< std::string, SharedPtr< GRINS::Physics > >::const_iterator PhysicsListIter
Iterator for PhysicsList.
Definition: var_typedefs.h:62
static void clear_suffix()
static void set_suffix(const std::string &suff)
void GRINS::PhysicsBuilder::parse_requested_physics ( const GetPot &  input,
std::set< std::string > &  requested_physics 
)
staticprivate

Parses the requested Physics from input and populates the set passed to this function.

Definition at line 96 of file physics_builder.C.

Referenced by build_physics_map().

97  {
98  int num_physics = input.vector_variable_size("Physics/enabled_physics");
99 
100  if( num_physics < 1 )
101  libmesh_error_msg("Error: Must enable at least one physics model!");
102 
103  for( int i = 0; i < num_physics; i++ )
104  requested_physics.insert( input("Physics/enabled_physics", "NULL", i ) );
105  }

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

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