GRINS-0.6.0
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
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)
 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)
 
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...
 
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 register_parameter (const std::string &param_name, libMesh::ParameterMultiPointer< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 

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...
 
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Private Member Functions

 AverageNusseltNumber ()
 

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 40 of file average_nusselt_number.C.

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

Definition at line 46 of file average_nusselt_number.C.

47  {
48  return;
49  }
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 80 of file average_nusselt_number.h.

81  {
82  return false;
83  }
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 86 of file average_nusselt_number.h.

87  {
88  return true;
89  }
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 51 of file average_nusselt_number.C.

References AverageNusseltNumber().

52  {
53  return new AverageNusseltNumber( *this );
54  }
void GRINS::QoIBase::element_qoi ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtualinherited

Compute the qoi value for element interiors.

Override this method if your QoI is defined on element interiors

Reimplemented in GRINS::Vorticity, and GRINS::ParsedInteriorQoI.

Definition at line 63 of file qoi_base.C.

65  {
66  return;
67  }
void GRINS::QoIBase::element_qoi_derivative ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtualinherited

Compute the qoi derivative with respect to the solution on element interiors.

Override this method if your QoI is defined on element interiors

Reimplemented in GRINS::Vorticity, and GRINS::ParsedInteriorQoI.

Definition at line 69 of file qoi_base.C.

71  {
72  return;
73  }
void GRINS::AverageNusseltNumber::init ( const GetPot &  input,
const MultiphysicsSystem system 
)
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 56 of file average_nusselt_number.C.

References _bc_ids, _k, _scaling, _T_var, GRINS::ParameterUser::set_parameter(), and GRINS::T_var_name_default.

57  {
58  this->set_parameter
59  ( _k, input, "QoI/NusseltNumber/thermal_conductivity", -1.0 );
60 
61  this->set_parameter
62  ( _scaling, input, "QoI/NusseltNumber/scaling", 1.0 );
63 
64  if( this->_k < 0.0 )
65  {
66  std::cerr << "Error: thermal conductivity for AverageNusseltNumber must be positive." << std::endl
67  << "Found k = " << _k << std::endl;
68  libmesh_error();
69  }
70 
71  // Read boundary ids for which we want to compute
72  int num_bcs = input.vector_variable_size("QoI/NusseltNumber/bc_ids");
73 
74  if( num_bcs <= 0 )
75  {
76  std::cerr << "Error: Must specify at least one boundary id to compute"
77  << " average Nusselt number." << std::endl
78  << "Found: " << num_bcs << std::endl;
79  libmesh_error();
80  }
81 
82  for( int i = 0; i < num_bcs; i++ )
83  {
84  _bc_ids.insert( input("QoI/NusseltNumber/bc_ids", -1, i ) );
85  }
86 
87  // Grab temperature variable index
88  std::string T_var_name = input( "Physics/VariableNames/Temperature",
90 
91  this->_T_var = system.variable_number(T_var_name);
92 
93  return;
94  }
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 GRINS::AverageNusseltNumber::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 96 of file average_nusselt_number.C.

References _T_var.

97  {
98  libMesh::FEBase* T_fe;
99 
100  context.get_side_fe<libMesh::Real>(this->_T_var, T_fe);
101 
102  T_fe->get_dphi();
103  T_fe->get_JxW();
104 
105  return;
106  }
VariableIndex _T_var
Temperature variable index.
const std::string & GRINS::QoIBase::name ( ) const
inlineinherited

Returns the name of this QoI.

Definition at line 143 of file qoi_base.h.

References GRINS::QoIBase::_qoi_name.

Referenced by GRINS::SteadyVisualization::output_adjoint(), and GRINS::UnsteadyVisualization::output_adjoint().

144  {
145  return _qoi_name;
146  }
std::string _qoi_name
Definition: qoi_base.h:131
void GRINS::QoIBase::output_qoi ( std::ostream &  out) const
virtualinherited

Basic output for computed QoI's.

If fancier output is desired, override this method.

Definition at line 107 of file qoi_base.C.

References GRINS::QoIBase::_qoi_name, and GRINS::QoIBase::_qoi_value.

108  {
109  out << "==========================================================" << std::endl;
110 
111  out << _qoi_name+" = "
112  << std::setprecision(16)
113  << std::scientific
114  << _qoi_value << std::endl;
115 
116  out << "==========================================================" << std::endl;
117 
118  return;
119  }
std::string _qoi_name
Definition: qoi_base.h:131
libMesh::Number _qoi_value
Definition: qoi_base.h:133
void GRINS::QoIBase::parallel_op ( const libMesh::Parallel::Communicator &  communicator,
libMesh::Number &  sys_qoi,
libMesh::Number &  local_qoi 
)
virtualinherited

Call the parallel operation for this QoI and cache the value.

By default, this is just a sum. Override if QoI is more complex.

Definition at line 87 of file qoi_base.C.

References GRINS::QoIBase::_qoi_value.

90  {
91  communicator.sum(local_qoi);
92 
93  sys_qoi = local_qoi;
94 
95  _qoi_value = sys_qoi;
96 
97  return;
98  }
libMesh::Number _qoi_value
Definition: qoi_base.h:133
void GRINS::ParameterUser::register_parameter ( const std::string &  param_name,
libMesh::ParameterMultiPointer< libMesh::Number > &  param_pointer 
) const
virtualinherited

Each subclass will register its copy of an independent.

Reimplemented in GRINS::AxisymmetricHeatTransfer< Conductivity >, GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >, GRINS::IncompressibleNavierStokesBase< Viscosity >, GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >, GRINS::HeatConduction< Conductivity >, GRINS::HeatTransferBase< Conductivity >, and GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >.

Definition at line 50 of file parameter_user.C.

Referenced by GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::register_parameter(), GRINS::HeatTransferBase< Conductivity >::register_parameter(), GRINS::HeatConduction< Conductivity >::register_parameter(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::register_parameter(), GRINS::IncompressibleNavierStokesBase< Viscosity >::register_parameter(), GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >::register_parameter(), and GRINS::AxisymmetricHeatTransfer< Conductivity >::register_parameter().

53  {
54  std::map<std::string, libMesh::Number*>::const_iterator it =
55  _my_parameters.find(param_name);
56 
57  if (it != _my_parameters.end())
58  {
59  std::cout << _my_name << " uses parameter " << param_name
60  << std::endl;
61  param_pointer.push_back(it->second);
62  }
63  }
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::ParameterUser::set_parameter ( libMesh::Number &  param_variable,
const GetPot &  input,
const std::string &  param_name,
libMesh::Number  param_default 
)
virtualinherited

Each subclass can simultaneously read a parameter value from.

Definition at line 35 of file parameter_user.C.

References GRINS::ParameterUser::_my_name, and GRINS::ParameterUser::_my_parameters.

Referenced by GRINS::AveragedFanAdjointStabilization< Viscosity >::AveragedFanAdjointStabilization(), GRINS::AveragedTurbineAdjointStabilization< Viscosity >::AveragedTurbineAdjointStabilization(), GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::BoussinesqBuoyancyAdjointStabilization(), GRINS::BoussinesqBuoyancyBase::BoussinesqBuoyancyBase(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::BoussinesqBuoyancySPGSMStabilization(), GRINS::ConstantConductivity::ConstantConductivity(), GRINS::ConstantPrandtlConductivity::ConstantPrandtlConductivity(), GRINS::ConstantSourceFunction::ConstantSourceFunction(), GRINS::ConstantSourceTerm::ConstantSourceTerm(), GRINS::ConstantSpecificHeat::ConstantSpecificHeat(), GRINS::ConstantViscosity::ConstantViscosity(), GRINS::ElasticCable< StressStrainLaw >::ElasticCable(), GRINS::ElasticCableConstantGravity::ElasticCableConstantGravity(), GRINS::ElasticMembrane< StressStrainLaw >::ElasticMembrane(), GRINS::ElasticMembraneConstantPressure::ElasticMembraneConstantPressure(), GRINS::HeatConduction< Conductivity >::HeatConduction(), GRINS::HeatTransferBase< Conductivity >::HeatTransferBase(), GRINS::IncompressibleNavierStokesBase< Viscosity >::IncompressibleNavierStokesBase(), init(), GRINS::MooneyRivlin::MooneyRivlin(), GRINS::ReactingLowMachNavierStokesBase< Mixture, Evaluator >::ReactingLowMachNavierStokesBase(), GRINS::HookesLaw1D::read_input_options(), GRINS::HookesLaw::read_input_options(), GRINS::AxisymmetricBoussinesqBuoyancy::read_input_options(), and GRINS::VelocityDragAdjointStabilization< Viscosity >::VelocityDragAdjointStabilization().

39  {
40  param_variable = input(param_name, param_default);
41 
42  libmesh_assert_msg(!_my_parameters.count(param_name),
43  "ERROR: " << _my_name << " double-registered parameter " <<
44  param_name);
45 
46  _my_parameters[param_name] = &param_variable;
47  }
std::map< std::string, libMesh::Number * > _my_parameters
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 108 of file average_nusselt_number.C.

References _bc_ids, _k, _scaling, and _T_var.

110  {
111  bool on_correct_side = false;
112 
113  for (std::set<libMesh::boundary_id_type>::const_iterator id =
114  _bc_ids.begin(); id != _bc_ids.end(); id++ )
115  if( context.has_side_boundary_id( (*id) ) )
116  {
117  on_correct_side = true;
118  break;
119  }
120 
121  if (!on_correct_side)
122  return;
123 
124  libMesh::FEBase* side_fe;
125  context.get_side_fe<libMesh::Real>(this->_T_var, side_fe);
126 
127  const std::vector<libMesh::Real> &JxW = side_fe->get_JxW();
128 
129  const std::vector<libMesh::Point>& normals = side_fe->get_normals();
130 
131  unsigned int n_qpoints = context.get_side_qrule().n_points();
132 
133  libMesh::Number& qoi = context.get_qois()[qoi_index];
134 
135  // Loop over quadrature points
136 
137  for (unsigned int qp = 0; qp != n_qpoints; qp++)
138  {
139  // Get the solution value at the quadrature point
140  libMesh::Gradient grad_T = 0.0;
141  context.side_gradient(this->_T_var, qp, grad_T);
142 
143  // Update the elemental increment dR for each qp
144  qoi += (this->_scaling)*(this->_k)*(grad_T*normals[qp])*JxW[qp];
145 
146  } // quadrature loop
147  }
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 149 of file average_nusselt_number.C.

References _bc_ids, _k, _scaling, and _T_var.

151  {
152 
153  for( std::set<libMesh::boundary_id_type>::const_iterator id = _bc_ids.begin();
154  id != _bc_ids.end(); id++ )
155  {
156  if( context.has_side_boundary_id( (*id) ) )
157  {
158  libMesh::FEBase* T_side_fe;
159  context.get_side_fe<libMesh::Real>(this->_T_var, T_side_fe);
160 
161  const std::vector<libMesh::Real> &JxW = T_side_fe->get_JxW();
162 
163  const std::vector<libMesh::Point>& normals = T_side_fe->get_normals();
164 
165  unsigned int n_qpoints = context.get_side_qrule().n_points();
166 
167  const unsigned int n_T_dofs = context.get_dof_indices(_T_var).size();
168 
169  const std::vector<std::vector<libMesh::Gradient> >& T_gradphi = T_side_fe->get_dphi();
170 
171  libMesh::DenseSubVector<libMesh::Number>& dQ_dT =
172  context.get_qoi_derivatives(qoi_index, _T_var);
173 
174  // Loop over quadrature points
175  for (unsigned int qp = 0; qp != n_qpoints; qp++)
176  {
177  // Get the solution value at the quadrature point
178  libMesh::Gradient grad_T = 0.0;
179  context.side_gradient(this->_T_var, qp, grad_T);
180 
181  // Update the elemental increment dR for each qp
182  //qoi += (this->_scaling)*(this->_k)*(grad_T*normals[qp])*JxW[qp];
183 
184  for( unsigned int i = 0; i != n_T_dofs; i++ )
185  {
186  dQ_dT(i) += _scaling*_k*T_gradphi[i][qp]*normals[qp]*JxW[qp];
187  }
188 
189  } // quadrature loop
190 
191  } // end check on boundary id
192 
193  }
194 
195  return;
196  }
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::QoIBase::thread_join ( libMesh::Number &  qoi,
const libMesh::Number &  other_qoi 
)
virtualinherited

Call the operation to accumulate this QoI from multiple threads.

By default, this is just a sum. Override if QoI is more complex.

Definition at line 100 of file qoi_base.C.

101  {
102  qoi += other_qoi;
103 
104  return;
105  }
libMesh::Number GRINS::QoIBase::value ( ) const
inlineinherited

Returns the current QoI value.

Definition at line 137 of file qoi_base.h.

References GRINS::QoIBase::_qoi_value.

138  {
139  return _qoi_value;
140  }
libMesh::Number _qoi_value
Definition: qoi_base.h:133

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 68 of file average_nusselt_number.h.

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

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

Thermal conductivity.

Definition at line 62 of file average_nusselt_number.h.

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

std::string GRINS::QoIBase::_qoi_name
protectedinherited

Definition at line 131 of file qoi_base.h.

Referenced by GRINS::QoIBase::name(), and GRINS::QoIBase::output_qoi().

libMesh::Number GRINS::QoIBase::_qoi_value
protectedinherited
libMesh::Real GRINS::AverageNusseltNumber::_scaling
protected

Scaling constant.

Definition at line 71 of file average_nusselt_number.h.

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

VariableIndex GRINS::AverageNusseltNumber::_T_var
protected

Temperature variable index.

Definition at line 65 of file average_nusselt_number.h.

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


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

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