GRINS-0.7.0
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
GRINS::AverageNusseltNumber Class Reference

#include <average_nusselt_number.h>

Inheritance diagram for GRINS::AverageNusseltNumber:
Inheritance graph
[legend]
Collaboration diagram for GRINS::AverageNusseltNumber:
Collaboration graph
[legend]

Public Member Functions

 AverageNusseltNumber (const std::string &qoi_name)
 
virtual ~AverageNusseltNumber ()
 
virtual QoIBaseclone () const
 Clone this QoI. More...
 
virtual bool assemble_on_interior () const
 Does the QoI need an element interior assembly loop? More...
 
virtual bool assemble_on_sides () const
 Does the QoI need a domain boundary assembly loop? More...
 
virtual void side_qoi (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi value on the domain boundary. More...
 
virtual void side_qoi_derivative (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi derivative with respect to the solution on the domain boundary. More...
 
virtual void init (const GetPot &input, const MultiphysicsSystem &system, unsigned int qoi_num)
 Method to allow QoI to cache any system information needed for QoI calculation, for example, solution variable indices. More...
 
virtual void init_context (AssemblyContext &context)
 
- Public Member Functions inherited from GRINS::QoIBase
 QoIBase (const std::string &qoi_name)
 
virtual ~QoIBase ()
 
virtual void element_qoi (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi value for element interiors. More...
 
virtual void element_qoi_derivative (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi derivative with respect to the solution on element interiors. More...
 
virtual void parallel_op (const libMesh::Parallel::Communicator &communicator, libMesh::Number &sys_qoi, libMesh::Number &local_qoi)
 Call the parallel operation for this QoI and cache the value. More...
 
virtual void thread_join (libMesh::Number &qoi, const libMesh::Number &other_qoi)
 Call the operation to accumulate this QoI from multiple threads. More...
 
virtual void output_qoi (std::ostream &out) const
 Basic output for computed QoI's. More...
 
libMesh::Number value () const
 Returns the current QoI value. More...
 
const std::string & name () const
 Returns the name of this QoI. More...
 
- Public Member Functions inherited from GRINS::ParameterUser
 ParameterUser (const std::string &user_name)
 
virtual ~ParameterUser ()
 
virtual void set_parameter (libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
 Each subclass can simultaneously read a parameter value from. More...
 
virtual void set_parameter (libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void set_parameter (libMesh::ParsedFEMFunction< libMesh::Number > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void move_parameter (const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &old_func, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFEMFunction< libMesh::Number > &old_func, libMesh::ParsedFEMFunction< libMesh::Number > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 

Protected Member Functions

void parse_thermal_conductivity (const GetPot &input)
 

Protected Attributes

libMesh::Real _k
 Thermal conductivity. More...
 
VariableIndex _T_var
 Temperature variable index. More...
 
std::set< libMesh::boundary_id_type > _bc_ids
 List of boundary ids for which we want to compute this QoI. More...
 
libMesh::Real _scaling
 Scaling constant. More...
 
- Protected Attributes inherited from GRINS::QoIBase
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Private Member Functions

 AverageNusseltNumber ()
 

Additional Inherited Members

- Static Public Attributes inherited from GRINS::ParameterUser
static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 

Detailed Description

Definition at line 35 of file average_nusselt_number.h.

Constructor & Destructor Documentation

GRINS::AverageNusseltNumber::AverageNusseltNumber ( const std::string &  qoi_name)

Definition at line 41 of file average_nusselt_number.C.

42  : QoIBase(qoi_name)
43  {
44  return;
45  }
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
GRINS::AverageNusseltNumber::~AverageNusseltNumber ( )
virtual

Definition at line 47 of file average_nusselt_number.C.

48  {
49  return;
50  }
GRINS::AverageNusseltNumber::AverageNusseltNumber ( )
private

Referenced by clone().

Member Function Documentation

bool GRINS::AverageNusseltNumber::assemble_on_interior ( ) const
inlinevirtual

Does the QoI need an element interior assembly loop?

This is pure virtual to force to user to specify.

Implements GRINS::QoIBase.

Definition at line 84 of file average_nusselt_number.h.

85  {
86  return false;
87  }
bool GRINS::AverageNusseltNumber::assemble_on_sides ( ) const
inlinevirtual

Does the QoI need a domain boundary assembly loop?

This is pure virtual to force to user to specify.

Implements GRINS::QoIBase.

Definition at line 90 of file average_nusselt_number.h.

91  {
92  return true;
93  }
QoIBase * GRINS::AverageNusseltNumber::clone ( ) const
virtual

Clone this QoI.

We return a raw pointer, but it is expected for the user to take ownership and delete the object when done.

Implements GRINS::QoIBase.

Definition at line 52 of file average_nusselt_number.C.

References _k, _scaling, AverageNusseltNumber(), and GRINS::ParameterUser::move_parameter().

53  {
54  AverageNusseltNumber *returnval = new AverageNusseltNumber( *this );
55  returnval->move_parameter(_k, returnval->_k);
56  returnval->move_parameter(_scaling, returnval->_scaling);
57  return returnval;
58  }
libMesh::Real _scaling
Scaling constant.
libMesh::Real _k
Thermal conductivity.
void GRINS::AverageNusseltNumber::init ( const GetPot &  input,
const MultiphysicsSystem system,
unsigned int  qoi_num 
)
virtual

Method to allow QoI to cache any system information needed for QoI calculation, for example, solution variable indices.

Reimplemented from GRINS::QoIBase.

Definition at line 61 of file average_nusselt_number.C.

References GRINS::T_var_name_default.

64  {
65  this->parse_thermal_conductivity(input);
66 
67  this->set_parameter
68  ( _scaling, input, "QoI/NusseltNumber/scaling", 1.0 );
69 
70  if( this->_k < 0.0 )
71  {
72  std::cerr << "Error: thermal conductivity for AverageNusseltNumber must be positive." << std::endl
73  << "Found k = " << _k << std::endl;
74  libmesh_error();
75  }
76 
77  // Read boundary ids for which we want to compute
78  int num_bcs = input.vector_variable_size("QoI/NusseltNumber/bc_ids");
79 
80  if( num_bcs <= 0 )
81  {
82  std::cerr << "Error: Must specify at least one boundary id to compute"
83  << " average Nusselt number." << std::endl
84  << "Found: " << num_bcs << std::endl;
85  libmesh_error();
86  }
87 
88  for( int i = 0; i < num_bcs; i++ )
89  {
90  _bc_ids.insert( input("QoI/NusseltNumber/bc_ids", -1, i ) );
91  }
92 
93  // Grab temperature variable index
94  std::string T_var_name = input( "Physics/VariableNames/Temperature",
96 
97  this->_T_var = system.variable_number(T_var_name);
98 
99  return;
100  }
virtual void set_parameter(libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from.
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids for which we want to compute this QoI.
libMesh::Real _scaling
Scaling constant.
const std::string T_var_name_default
temperature
libMesh::Real _k
Thermal conductivity.
VariableIndex _T_var
Temperature variable index.
void parse_thermal_conductivity(const GetPot &input)
void GRINS::AverageNusseltNumber::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 102 of file average_nusselt_number.C.

References _T_var.

103  {
104  libMesh::FEBase* T_fe;
105 
106  context.get_side_fe<libMesh::Real>(this->_T_var, T_fe);
107 
108  T_fe->get_dphi();
109  T_fe->get_JxW();
110 
111  return;
112  }
VariableIndex _T_var
Temperature variable index.
void GRINS::AverageNusseltNumber::parse_thermal_conductivity ( const GetPot &  input)
protected

Definition at line 204 of file average_nusselt_number.C.

References _k, GRINS::MaterialsParsing::dep_input_warning(), GRINS::MaterialsParsing::duplicate_input_test(), and GRINS::ParameterUser::set_parameter().

205  {
206  std::string material = input("QoI/NusseltNumber/material", "NoMaterial!");
207 
209  "Materials/"+material+"/ThermalConductivity/value",
210  "QoI/NusseltNumber/thermal_conductivity");
211 
212  // Parse the old version
213  if( input.have_variable("QoI/NusseltNumber/thermal_conductivity") )
214  {
215  MaterialsParsing::dep_input_warning( "QoI/NusseltNumber/thermal_conductivity",
216  "ThermalConductivity/value" );
217 
218  this->set_parameter
219  ( _k, input, "QoI/NusseltNumber/thermal_conductivity", -1.0 );
220  }
221  // Parse new version
222  else if( input.have_variable("Materials/"+material+"/ThermalConductivity/value") )
223  {
224  // This is currently only valid for constant thermal conductivity models
225  if( input("Materials/"+material+"/ThermalConductivity/model", "DIE!")
226  != std::string("constant") )
227  {
228  libmesh_error_msg("ERROR: Only constant ThermalConductivity model supported in NusseltNumber!");
229  }
230 
231  this->set_parameter
232  ( _k, input, "Materials/"+material+"/ThermalConductivity/value", -1.0 );
233  }
234  else
235  libmesh_error_msg("ERROR: Could not find valid thermal conducitivity value!");
236 
237  // thermal conducivity should be positive
238  if( _k <= 0.0 )
239  libmesh_error_msg("ERROR: Detected non-positive thermal conductivity!");
240  }
virtual void set_parameter(libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from.
libMesh::Real _k
Thermal conductivity.
static void dep_input_warning(const std::string &old_option, const std::string &property)
Helper function for parsing/maintaing backward compatibility.
static void duplicate_input_test(const GetPot &input, const std::string &option1, const std::string &option2)
Helper function for parsing/maintaing backward compatibility.
void GRINS::AverageNusseltNumber::side_qoi ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtual

Compute the qoi value on the domain boundary.

Override this method if your QoI is defined on the domain boundary

Reimplemented from GRINS::QoIBase.

Definition at line 114 of file average_nusselt_number.C.

References _bc_ids, _k, _scaling, and _T_var.

116  {
117  bool on_correct_side = false;
118 
119  for (std::set<libMesh::boundary_id_type>::const_iterator id =
120  _bc_ids.begin(); id != _bc_ids.end(); id++ )
121  if( context.has_side_boundary_id( (*id) ) )
122  {
123  on_correct_side = true;
124  break;
125  }
126 
127  if (!on_correct_side)
128  return;
129 
130  libMesh::FEBase* side_fe;
131  context.get_side_fe<libMesh::Real>(this->_T_var, side_fe);
132 
133  const std::vector<libMesh::Real> &JxW = side_fe->get_JxW();
134 
135  const std::vector<libMesh::Point>& normals = side_fe->get_normals();
136 
137  unsigned int n_qpoints = context.get_side_qrule().n_points();
138 
139  libMesh::Number& qoi = context.get_qois()[qoi_index];
140 
141  // Loop over quadrature points
142 
143  for (unsigned int qp = 0; qp != n_qpoints; qp++)
144  {
145  // Get the solution value at the quadrature point
146  libMesh::Gradient grad_T = 0.0;
147  context.side_gradient(this->_T_var, qp, grad_T);
148 
149  // Update the elemental increment dR for each qp
150  qoi += (this->_scaling)*(this->_k)*(grad_T*normals[qp])*JxW[qp];
151 
152  } // quadrature loop
153  }
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids for which we want to compute this QoI.
libMesh::Real _scaling
Scaling constant.
libMesh::Real _k
Thermal conductivity.
VariableIndex _T_var
Temperature variable index.
void GRINS::AverageNusseltNumber::side_qoi_derivative ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtual

Compute the qoi derivative with respect to the solution on the domain boundary.

Override this method if your QoI is defined on the domain boundary

Reimplemented from GRINS::QoIBase.

Definition at line 155 of file average_nusselt_number.C.

References _bc_ids, _k, _scaling, and _T_var.

157  {
158 
159  for( std::set<libMesh::boundary_id_type>::const_iterator id = _bc_ids.begin();
160  id != _bc_ids.end(); id++ )
161  {
162  if( context.has_side_boundary_id( (*id) ) )
163  {
164  libMesh::FEBase* T_side_fe;
165  context.get_side_fe<libMesh::Real>(this->_T_var, T_side_fe);
166 
167  const std::vector<libMesh::Real> &JxW = T_side_fe->get_JxW();
168 
169  const std::vector<libMesh::Point>& normals = T_side_fe->get_normals();
170 
171  unsigned int n_qpoints = context.get_side_qrule().n_points();
172 
173  const unsigned int n_T_dofs = context.get_dof_indices(_T_var).size();
174 
175  const std::vector<std::vector<libMesh::Gradient> >& T_gradphi = T_side_fe->get_dphi();
176 
177  libMesh::DenseSubVector<libMesh::Number>& dQ_dT =
178  context.get_qoi_derivatives(qoi_index, _T_var);
179 
180  // Loop over quadrature points
181  for (unsigned int qp = 0; qp != n_qpoints; qp++)
182  {
183  // Get the solution value at the quadrature point
184  libMesh::Gradient grad_T = 0.0;
185  context.side_gradient(this->_T_var, qp, grad_T);
186 
187  // Update the elemental increment dR for each qp
188  //qoi += (this->_scaling)*(this->_k)*(grad_T*normals[qp])*JxW[qp];
189 
190  for( unsigned int i = 0; i != n_T_dofs; i++ )
191  {
192  dQ_dT(i) += _scaling*_k*T_gradphi[i][qp]*normals[qp]*JxW[qp];
193  }
194 
195  } // quadrature loop
196 
197  } // end check on boundary id
198 
199  }
200 
201  return;
202  }
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids for which we want to compute this QoI.
libMesh::Real _scaling
Scaling constant.
libMesh::Real _k
Thermal conductivity.
VariableIndex _T_var
Temperature variable index.

Member Data Documentation

std::set<libMesh::boundary_id_type> GRINS::AverageNusseltNumber::_bc_ids
protected

List of boundary ids for which we want to compute this QoI.

Definition at line 72 of file average_nusselt_number.h.

Referenced by side_qoi(), and side_qoi_derivative().

libMesh::Real GRINS::AverageNusseltNumber::_k
protected

Thermal conductivity.

Definition at line 66 of file average_nusselt_number.h.

Referenced by clone(), parse_thermal_conductivity(), side_qoi(), and side_qoi_derivative().

libMesh::Real GRINS::AverageNusseltNumber::_scaling
protected

Scaling constant.

Definition at line 75 of file average_nusselt_number.h.

Referenced by clone(), side_qoi(), and side_qoi_derivative().

VariableIndex GRINS::AverageNusseltNumber::_T_var
protected

Temperature variable index.

Definition at line 69 of file average_nusselt_number.h.

Referenced by init_context(), side_qoi(), and side_qoi_derivative().


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

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