34 #include "libmesh/getpot.h"
35 #include "libmesh/fem_system.h"
36 #include "libmesh/quadrature.h"
59 (
_k, input,
"QoI/NusseltNumber/thermal_conductivity", -1.0 );
62 (
_scaling, input,
"QoI/NusseltNumber/scaling", 1.0 );
66 std::cerr <<
"Error: thermal conductivity for AverageNusseltNumber must be positive." << std::endl
67 <<
"Found k = " <<
_k << std::endl;
72 int num_bcs = input.vector_variable_size(
"QoI/NusseltNumber/bc_ids");
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;
82 for(
int i = 0; i < num_bcs; i++ )
84 _bc_ids.insert( input(
"QoI/NusseltNumber/bc_ids", -1, i ) );
88 std::string T_var_name = input(
"Physics/VariableNames/Temperature",
91 this->
_T_var = system.variable_number(T_var_name);
98 libMesh::FEBase* T_fe;
100 context.get_side_fe<libMesh::Real>(this->
_T_var, T_fe);
109 const unsigned int qoi_index )
111 bool on_correct_side =
false;
113 for (std::set<libMesh::boundary_id_type>::const_iterator
id =
115 if( context.has_side_boundary_id( (*
id) ) )
117 on_correct_side =
true;
121 if (!on_correct_side)
124 libMesh::FEBase* side_fe;
125 context.get_side_fe<libMesh::Real>(this->
_T_var, side_fe);
127 const std::vector<libMesh::Real> &JxW = side_fe->get_JxW();
129 const std::vector<libMesh::Point>& normals = side_fe->get_normals();
131 unsigned int n_qpoints = context.get_side_qrule().n_points();
133 libMesh::Number& qoi = context.get_qois()[qoi_index];
137 for (
unsigned int qp = 0; qp != n_qpoints; qp++)
140 libMesh::Gradient grad_T = 0.0;
141 context.side_gradient(this->_T_var, qp, grad_T);
144 qoi += (this->
_scaling)*(this->
_k)*(grad_T*normals[qp])*JxW[qp];
150 const unsigned int qoi_index )
153 for( std::set<libMesh::boundary_id_type>::const_iterator
id =
_bc_ids.begin();
156 if( context.has_side_boundary_id( (*
id) ) )
158 libMesh::FEBase* T_side_fe;
159 context.get_side_fe<libMesh::Real>(this->
_T_var, T_side_fe);
161 const std::vector<libMesh::Real> &JxW = T_side_fe->get_JxW();
163 const std::vector<libMesh::Point>& normals = T_side_fe->get_normals();
165 unsigned int n_qpoints = context.get_side_qrule().n_points();
167 const unsigned int n_T_dofs = context.get_dof_indices(_T_var).size();
169 const std::vector<std::vector<libMesh::Gradient> >& T_gradphi = T_side_fe->get_dphi();
171 libMesh::DenseSubVector<libMesh::Number>& dQ_dT =
172 context.get_qoi_derivatives(qoi_index, _T_var);
175 for (
unsigned int qp = 0; qp != n_qpoints; qp++)
178 libMesh::Gradient grad_T = 0.0;
179 context.side_gradient(this->_T_var, qp, grad_T);
184 for(
unsigned int i = 0; i != n_T_dofs; i++ )
186 dQ_dT(i) +=
_scaling*
_k*T_gradphi[i][qp]*normals[qp]*JxW[qp];
virtual void set_parameter(libMesh::Number ¶m_variable, const GetPot &input, const std::string ¶m_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.
virtual void init_context(AssemblyContext &context)
virtual ~AverageNusseltNumber()
libMesh::Real _scaling
Scaling constant.
const std::string T_var_name_default
temperature
virtual QoIBase * clone() const
Clone this QoI.
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.
libMesh::Real _k
Thermal conductivity.
virtual void init(const GetPot &input, const MultiphysicsSystem &system)
Method to allow QoI to cache any system information needed for QoI calculation, for example...
virtual void side_qoi(AssemblyContext &context, const unsigned int qoi_index)
Compute the qoi value on the domain boundary.
VariableIndex _T_var
Temperature variable index.
Interface with libMesh for solving Multiphysics problems.