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

Vorticity QoI. More...

#include <vorticity.h>

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

Public Member Functions

 Vorticity (const std::string &qoi_name)
 Constructor. More...
 
virtual ~Vorticity ()
 
virtual QoIBaseclone () const
 Required to provide clone (deep-copy) for adding QoI object to libMesh objects. 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 init (const GetPot &input, const MultiphysicsSystem &system)
 Initialize local variables. More...
 
virtual void init_context (AssemblyContext &context)
 
virtual void element_qoi (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi value. More...
 
virtual void element_qoi_derivative (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi derivative with respect to the solution. 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 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

VariableIndex _u_var
 u-velocity component variable index More...
 
VariableIndex _v_var
 v-velocity component variable index More...
 
std::set< libMesh::subdomain_id_type > _subdomain_ids
 List of sumdomain ids for which we want to compute this QoI. More...
 
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Private Member Functions

 Vorticity ()
 User never call default constructor. More...
 

Detailed Description

Vorticity QoI.

This class implement a vorticity QoI that can be used to both compute QoI values and drive QoI-based adaptive refinement. Currently, this QoI is only implemented in 2D and will error if it detects a three-dimensional problem.

Definition at line 42 of file vorticity.h.

Constructor & Destructor Documentation

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

Constructor.

Constructor takes GetPot object to read any input options associated with this QoI

Definition at line 41 of file vorticity.C.

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

Definition at line 47 of file vorticity.C.

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

User never call default constructor.

Referenced by clone().

Member Function Documentation

bool GRINS::Vorticity::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 98 of file vorticity.h.

99  {
100  return true;
101  }
bool GRINS::Vorticity::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 104 of file vorticity.h.

105  {
106  return false;
107  }
QoIBase * GRINS::Vorticity::clone ( ) const
virtual

Required to provide clone (deep-copy) for adding QoI object to libMesh objects.

Implements GRINS::QoIBase.

Definition at line 52 of file vorticity.C.

References Vorticity().

53  {
54  return new Vorticity( *this );
55  }
Vorticity()
User never call default constructor.
void GRINS::Vorticity::element_qoi ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtual

Compute the qoi value.

Currently, only implemented for 2D. Assumes that the vorticity will be computed over area of input subdomain id. Vorticity computed as $ \int_{\Omega} \nabla \times \mathbf{u} \; d\mathbf{x}$

Todo:
Need to generalize this to the multiple QoI case

Reimplemented from GRINS::QoIBase.

Definition at line 99 of file vorticity.C.

References _subdomain_ids, _u_var, and _v_var.

101  {
102 
103  if( _subdomain_ids.find( (&context.get_elem())->subdomain_id() ) != _subdomain_ids.end() )
104  {
105  libMesh::FEBase* element_fe;
106  context.get_element_fe<libMesh::Real>(this->_u_var, element_fe);
107  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
108 
109  unsigned int n_qpoints = context.get_element_qrule().n_points();
110 
112  libMesh::Number& qoi = context.get_qois()[qoi_index];
113 
114  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
115  {
116  libMesh::Gradient grad_u = 0.;
117  libMesh::Gradient grad_v = 0.;
118  context.interior_gradient( this->_u_var, qp, grad_u );
119  context.interior_gradient( this->_v_var, qp, grad_v );
120  qoi += (grad_v(0) - grad_u(1)) * JxW[qp];
121  }
122  }
123 
124  return;
125  }
std::set< libMesh::subdomain_id_type > _subdomain_ids
List of sumdomain ids for which we want to compute this QoI.
Definition: vorticity.h:89
VariableIndex _v_var
v-velocity component variable index
Definition: vorticity.h:86
VariableIndex _u_var
u-velocity component variable index
Definition: vorticity.h:83
void GRINS::Vorticity::element_qoi_derivative ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtual

Compute the qoi derivative with respect to the solution.

Currently, only implemented for 2D. Assumes that the vorticity will be computed over area of input subdomain id.

Todo:
Need to generalize this to the multiple QoI case

Reimplemented from GRINS::QoIBase.

Definition at line 127 of file vorticity.C.

References _subdomain_ids, _u_var, and _v_var.

129  {
130 
131  if( _subdomain_ids.find( (&context.get_elem())->subdomain_id() ) != _subdomain_ids.end() )
132  {
133  // Element
134  libMesh::FEBase* element_fe;
135  context.get_element_fe<libMesh::Real>(this->_u_var, element_fe);
136 
137  // Jacobian times integration weights
138  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
139 
140  // Grad of basis functions
141  const std::vector<std::vector<libMesh::RealGradient> >& du_phi =
142  context.get_element_fe(_u_var)->get_dphi();
143  const std::vector<std::vector<libMesh::RealGradient> >& dv_phi =
144  context.get_element_fe(_v_var)->get_dphi();
145 
146  // Local DOF count and quadrature point count
147  const unsigned int n_T_dofs = context.get_dof_indices(0).size();
148  unsigned int n_qpoints = context.get_element_qrule().n_points();
149 
150  // Warning: we assume here that vorticity is the only QoI!
151  // This should be consistent with the assertion in grins_mesh_adaptive_solver.C
153  libMesh::DenseSubVector<libMesh::Number> &Qu = context.get_qoi_derivatives(qoi_index, _u_var);
154  libMesh::DenseSubVector<libMesh::Number> &Qv = context.get_qoi_derivatives(qoi_index, _v_var);
155 
156  // Integration loop
157  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
158  {
159  for( unsigned int i = 0; i != n_T_dofs; i++ )
160  {
161  Qu(i) += - dv_phi[i][qp](1) * JxW[qp];
162  Qv(i) += du_phi[i][qp](0) * JxW[qp];
163  }
164  }
165  }
166 
167  return;
168  }
std::set< libMesh::subdomain_id_type > _subdomain_ids
List of sumdomain ids for which we want to compute this QoI.
Definition: vorticity.h:89
VariableIndex _v_var
v-velocity component variable index
Definition: vorticity.h:86
VariableIndex _u_var
u-velocity component variable index
Definition: vorticity.h:83
void GRINS::Vorticity::init ( const GetPot &  input,
const MultiphysicsSystem system 
)
virtual

Initialize local variables.

Any local variables that need information from libMesh get initialized here. For example, variable indices.

Reimplemented from GRINS::QoIBase.

Definition at line 57 of file vorticity.C.

References _subdomain_ids, _u_var, _v_var, GRINS::u_var_name_default, and GRINS::v_var_name_default.

58  {
59  // Extract subdomain on which to compute to qoi
60  int num_ids = input.vector_variable_size( "QoI/Vorticity/enabled_subdomains" );
61 
62  if( num_ids == 0 )
63  {
64  std::cerr << "Error: Must specify at least one subdomain id on which to compute vorticity." << std::endl;
65  libmesh_error();
66  }
67 
68  for( int i = 0; i < num_ids; i++ )
69  {
70  libMesh::subdomain_id_type s_id = input( "QoI/Vorticity/enabled_subdomains", -1, i );
71  _subdomain_ids.insert( s_id );
72  }
73 
74  // Grab velocity variable indices
75  std::string u_var_name = input("Physics/VariableNames/u_velocity", u_var_name_default);
76  std::string v_var_name = input("Physics/VariableNames/v_velocity", v_var_name_default);
77  this->_u_var = system.variable_number(u_var_name);
78  this->_v_var = system.variable_number(v_var_name);
79 
80  return;
81  }
std::set< libMesh::subdomain_id_type > _subdomain_ids
List of sumdomain ids for which we want to compute this QoI.
Definition: vorticity.h:89
const std::string v_var_name_default
y-velocity
const std::string u_var_name_default
Default physics variable names.
VariableIndex _v_var
v-velocity component variable index
Definition: vorticity.h:86
VariableIndex _u_var
u-velocity component variable index
Definition: vorticity.h:83
void GRINS::Vorticity::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 83 of file vorticity.C.

References _u_var, and _v_var.

84  {
85  libMesh::FEBase* u_fe = NULL;
86  libMesh::FEBase* v_fe = NULL;
87 
88  context.get_element_fe<libMesh::Real>(this->_u_var, u_fe);
89  context.get_element_fe<libMesh::Real>(this->_v_var, v_fe);
90 
91  u_fe->get_dphi();
92  u_fe->get_JxW();
93 
94  v_fe->get_dphi();
95 
96  return;
97  }
VariableIndex _v_var
v-velocity component variable index
Definition: vorticity.h:86
VariableIndex _u_var
u-velocity component variable index
Definition: vorticity.h:83
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(), GRINS::AverageNusseltNumber::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::QoIBase::side_qoi ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtualinherited

Compute the qoi value on the domain boundary.

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

Reimplemented in GRINS::AverageNusseltNumber.

Definition at line 75 of file qoi_base.C.

77  {
78  return;
79  }
void GRINS::QoIBase::side_qoi_derivative ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtualinherited

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 in GRINS::AverageNusseltNumber.

Definition at line 81 of file qoi_base.C.

83  {
84  return;
85  }
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::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
std::set<libMesh::subdomain_id_type> GRINS::Vorticity::_subdomain_ids
protected

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

Definition at line 89 of file vorticity.h.

Referenced by element_qoi(), element_qoi_derivative(), and init().

VariableIndex GRINS::Vorticity::_u_var
protected

u-velocity component variable index

Definition at line 83 of file vorticity.h.

Referenced by element_qoi(), element_qoi_derivative(), init(), and init_context().

VariableIndex GRINS::Vorticity::_v_var
protected

v-velocity component variable index

Definition at line 86 of file vorticity.h.

Referenced by element_qoi(), element_qoi_derivative(), init(), and init_context().


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