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

#include <qoi_factory.h>

Public Member Functions

 QoIFactory ()
 
virtual ~QoIFactory ()
 
virtual SharedPtr< CompositeQoIbuild (const GetPot &input)
 

Protected Member Functions

virtual void add_qoi (const GetPot &input, const std::string &qoi_name, SharedPtr< CompositeQoI > &qois)
 
virtual void check_qoi_physics_consistency (const GetPot &input, const std::string &qoi_name)
 
virtual void echo_qoi_list (SharedPtr< 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 40 of file qoi_factory.C.

41  {
42  return;
43  }
GRINS::QoIFactory::~QoIFactory ( )
virtual

Definition at line 45 of file qoi_factory.C.

46  {
47  return;
48  }

Member Function Documentation

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

Definition at line 82 of file qoi_factory.C.

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

Referenced by build().

83  {
84  QoIBase* qoi = NULL;
85 
86  if( qoi_name == avg_nusselt )
87  {
88  qoi = new AverageNusseltNumber( avg_nusselt );
89  }
90 
91  else if( qoi_name == parsed_boundary )
92  {
93  qoi = new ParsedBoundaryQoI( parsed_boundary );
94  }
95 
96  else if( qoi_name == parsed_interior )
97  {
98  qoi = new ParsedInteriorQoI( parsed_interior );
99  }
100 
101  else if( qoi_name == vorticity )
102  {
103  qoi = new Vorticity( vorticity );
104  }
105 
106  else if( qoi_name == weighted_flux )
107  {
108  qoi = new WeightedFluxQoI( weighted_flux );
109  }
110 
111  else
112  {
113  libMesh::err << "Error: Invalid QoI name " << qoi_name << std::endl;
114  libmesh_error();
115  }
116 
117  libmesh_assert(qoi);
118 
119  qois->add_qoi( *qoi );
120 
121  return;
122  }
const std::string avg_nusselt
Definition: qoi_names.h:30
const std::string vorticity
Definition: qoi_names.h:31
const std::string weighted_flux
Definition: qoi_names.h:34
const std::string parsed_boundary
Definition: qoi_names.h:32
const std::string parsed_interior
Definition: qoi_names.h:33
SharedPtr< CompositeQoI > GRINS::QoIFactory::build ( const GetPot &  input)
virtual

Definition at line 50 of file qoi_factory.C.

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

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

Definition at line 124 of file qoi_factory.C.

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

Referenced by build().

126  {
127  int num_physics = input.vector_variable_size("Physics/enabled_physics");
128 
129  // This should be checked other places, but let's be double sure.
130  libmesh_assert(num_physics > 0);
131 
132  std::set<std::string> requested_physics;
133  std::set<std::string> required_physics;
134 
135  // Build Physics name set
136  for( int i = 0; i < num_physics; i++ )
137  {
138  requested_physics.insert( input("Physics/enabled_physics", "NULL", i ) );
139  }
140 
141  /* If it's Nusselt, we'd better have HeatTransfer or LowMachNavierStokes.
142  HeatTransfer implicitly requires fluids, so no need to check for those. `*/
143  if( qoi_name == avg_nusselt )
144  {
145  required_physics.insert(PhysicsNaming::heat_transfer());
146  required_physics.insert(PhysicsNaming::low_mach_navier_stokes());
147  this->consistency_helper( requested_physics, required_physics, qoi_name );
148  }
149 
150  return;
151  }
static PhysicsName heat_transfer()
static PhysicsName low_mach_navier_stokes()
const std::string avg_nusselt
Definition: qoi_names.h:30
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:169
void GRINS::QoIFactory::consistency_error_msg ( const std::string &  qoi_name,
const std::set< std::string > &  required_physics 
)
protected

Definition at line 188 of file qoi_factory.C.

Referenced by consistency_helper().

190  {
191  libMesh::err << "================================================================" << std::endl
192  << "QoI " << qoi_name << std::endl
193  << "requires one of the following physics which were not found:" <<std::endl;
194 
195  for( std::set<std::string>::const_iterator name = required_physics.begin();
196  name != required_physics.end();
197  name++ )
198  {
199  libMesh::err << *name << std::endl;
200  }
201 
202  libMesh::err << "================================================================" << std::endl;
203 
204  libmesh_error();
205  }
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 169 of file qoi_factory.C.

References consistency_error_msg().

Referenced by check_qoi_physics_consistency().

172  {
173  bool physics_found = false;
174  for( std::set<std::string>::const_iterator name = required_physics.begin();
175  name != required_physics.end();
176  name++ )
177  {
178  if( requested_physics.find( (*name) ) != requested_physics.end() )
179  physics_found = true;
180  }
181 
182  if( !physics_found )
183  this->consistency_error_msg( qoi_name, required_physics );
184 
185  return;
186  }
void consistency_error_msg(const std::string &qoi_name, const std::set< std::string > &required_physics)
Definition: qoi_factory.C:188
void GRINS::QoIFactory::echo_qoi_list ( SharedPtr< CompositeQoI > &  qois)
protectedvirtual
Todo:
Generalize to multiple QoI case when CompositeQoI is implemented in libMesh

Definition at line 153 of file qoi_factory.C.

Referenced by build().

154  {
156  std::cout << "==========================================================" << std::endl
157  << "List of Enabled QoIs:" << std::endl;
158 
159  for( unsigned int q = 0; q < qois->n_qois(); q++ )
160  {
161  std::cout << qois->get_qoi(q).name() << std::endl;
162  }
163 
164  std::cout << "==========================================================" << std::endl;
165 
166  return;
167  }

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

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