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

#include <qoi_factory.h>

Public Member Functions

 QoIFactory ()
 
virtual ~QoIFactory ()
 
virtual std::tr1::shared_ptr< CompositeQoIbuild (const GetPot &input)
 

Protected Member Functions

virtual void add_qoi (const GetPot &input, const std::string &qoi_name, std::tr1::shared_ptr< CompositeQoI > &qois)
 
virtual void check_qoi_physics_consistency (const GetPot &input, const std::string &qoi_name)
 
virtual void echo_qoi_list (std::tr1::shared_ptr< CompositeQoI > &qois)
 
void consistency_helper (const std::set< std::string > &requested_physics, const std::set< std::string > &required_physics, const std::string &qoi_name)
 
void consistency_error_msg (const std::string &qoi_name, const std::set< std::string > &required_physics)
 

Detailed Description

Definition at line 39 of file qoi_factory.h.

Constructor & Destructor Documentation

GRINS::QoIFactory::QoIFactory ( )

Definition at line 38 of file qoi_factory.C.

39  {
40  return;
41  }
GRINS::QoIFactory::~QoIFactory ( )
virtual

Definition at line 43 of file qoi_factory.C.

44  {
45  return;
46  }

Member Function Documentation

void GRINS::QoIFactory::add_qoi ( const GetPot &  input,
const std::string &  qoi_name,
std::tr1::shared_ptr< CompositeQoI > &  qois 
)
protectedvirtual

Definition at line 80 of file qoi_factory.C.

References GRINS::avg_nusselt, GRINS::parsed_interior, and GRINS::vorticity.

Referenced by build().

81  {
82  QoIBase* qoi = NULL;
83 
84  if( qoi_name == avg_nusselt )
85  {
86  qoi = new AverageNusseltNumber( avg_nusselt );
87  }
88 
89  else if( qoi_name == parsed_interior )
90  {
91  qoi = new ParsedInteriorQoI( parsed_interior );
92  }
93 
94  else if( qoi_name == vorticity )
95  {
96  qoi = new Vorticity( vorticity );
97  }
98 
99  else
100  {
101  libMesh::err << "Error: Invalid QoI name " << qoi_name << std::endl;
102  libmesh_error();
103  }
104 
105  libmesh_assert(qoi);
106 
107  qois->add_qoi( *qoi );
108 
109  return;
110  }
const std::string avg_nusselt
Definition: qoi_names.h:30
const std::string vorticity
Definition: qoi_names.h:31
const std::string parsed_interior
Definition: qoi_names.h:32
std::tr1::shared_ptr< CompositeQoI > GRINS::QoIFactory::build ( const GetPot &  input)
virtual

Definition at line 48 of file qoi_factory.C.

References add_qoi(), check_qoi_physics_consistency(), echo_qoi_list(), and GRINS::StringUtilities::split_string().

49  {
50  std::string qoi_list = input("QoI/enabled_qois", "none" );
51 
52  std::vector<std::string> qoi_names;
53 
54  if( qoi_list != std::string("none") )
55  {
56  StringUtilities::split_string( qoi_list, std::string(" "), qoi_names );
57  }
58 
59  std::tr1::shared_ptr<CompositeQoI> qois( new CompositeQoI );
60 
61  if( !qoi_names.empty() )
62  {
63  for( std::vector<std::string>::const_iterator name = qoi_names.begin();
64  name != qoi_names.end(); ++name )
65  {
66  this->add_qoi( input, *name, qois );
67 
68  this->check_qoi_physics_consistency( input, *name );
69  }
70 
71  if( input( "screen-options/echo_qoi", false ) )
72  {
73  this->echo_qoi_list( qois );
74  }
75  }
76 
77  return qois;
78  }
virtual void check_qoi_physics_consistency(const GetPot &input, const std::string &qoi_name)
Definition: qoi_factory.C:112
virtual void add_qoi(const GetPot &input, const std::string &qoi_name, std::tr1::shared_ptr< CompositeQoI > &qois)
Definition: qoi_factory.C:80
virtual void echo_qoi_list(std::tr1::shared_ptr< CompositeQoI > &qois)
Definition: qoi_factory.C:141
void split_string(const std::string &input, const std::string &delimiter, std::vector< std::string > &results)
Definition: string_utils.C:31
void GRINS::QoIFactory::check_qoi_physics_consistency ( const GetPot &  input,
const std::string &  qoi_name 
)
protectedvirtual

Definition at line 112 of file qoi_factory.C.

References GRINS::avg_nusselt, consistency_helper(), GRINS::heat_transfer, and GRINS::low_mach_navier_stokes.

Referenced by build().

114  {
115  int num_physics = input.vector_variable_size("Physics/enabled_physics");
116 
117  // This should be checked other places, but let's be double sure.
118  libmesh_assert(num_physics > 0);
119 
120  std::set<std::string> requested_physics;
121  std::set<std::string> required_physics;
122 
123  // Build Physics name set
124  for( int i = 0; i < num_physics; i++ )
125  {
126  requested_physics.insert( input("Physics/enabled_physics", "NULL", i ) );
127  }
128 
129  /* If it's Nusselt, we'd better have HeatTransfer or LowMachNavierStokes.
130  HeatTransfer implicitly requires fluids, so no need to check for those. `*/
131  if( qoi_name == avg_nusselt )
132  {
133  required_physics.insert(heat_transfer);
134  required_physics.insert(low_mach_navier_stokes);
135  this->consistency_helper( requested_physics, required_physics, qoi_name );
136  }
137 
138  return;
139  }
const std::string avg_nusselt
Definition: qoi_names.h:30
const PhysicsName low_mach_navier_stokes
const PhysicsName heat_transfer
void consistency_helper(const std::set< std::string > &requested_physics, const std::set< std::string > &required_physics, const std::string &qoi_name)
Definition: qoi_factory.C:157
void GRINS::QoIFactory::consistency_error_msg ( const std::string &  qoi_name,
const std::set< std::string > &  required_physics 
)
protected

Definition at line 176 of file qoi_factory.C.

Referenced by consistency_helper().

178  {
179  libMesh::err << "================================================================" << std::endl
180  << "QoI " << qoi_name << std::endl
181  << "requires one of the following physics which were not found:" <<std::endl;
182 
183  for( std::set<std::string>::const_iterator name = required_physics.begin();
184  name != required_physics.end();
185  name++ )
186  {
187  libMesh::err << *name << std::endl;
188  }
189 
190  libMesh::err << "================================================================" << std::endl;
191 
192  libmesh_error();
193  }
void GRINS::QoIFactory::consistency_helper ( const std::set< std::string > &  requested_physics,
const std::set< std::string > &  required_physics,
const std::string &  qoi_name 
)
protected

Definition at line 157 of file qoi_factory.C.

References consistency_error_msg().

Referenced by check_qoi_physics_consistency().

160  {
161  bool physics_found = false;
162  for( std::set<std::string>::const_iterator name = required_physics.begin();
163  name != required_physics.end();
164  name++ )
165  {
166  if( requested_physics.find( (*name) ) != requested_physics.end() )
167  physics_found = true;
168  }
169 
170  if( !physics_found )
171  this->consistency_error_msg( qoi_name, required_physics );
172 
173  return;
174  }
void consistency_error_msg(const std::string &qoi_name, const std::set< std::string > &required_physics)
Definition: qoi_factory.C:176
void GRINS::QoIFactory::echo_qoi_list ( std::tr1::shared_ptr< CompositeQoI > &  qois)
protectedvirtual
Todo:
Generalize to multiple QoI case when CompositeQoI is implemented in libMesh

Definition at line 141 of file qoi_factory.C.

Referenced by build().

142  {
144  std::cout << "==========================================================" << std::endl
145  << "List of Enabled QoIs:" << std::endl;
146 
147  for( unsigned int q = 0; q < qois->n_qois(); q++ )
148  {
149  std::cout << qois->get_qoi(q).name() << std::endl;
150  }
151 
152  std::cout << "==========================================================" << std::endl;
153 
154  return;
155  }

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

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