GRINS-0.8.0
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
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, unsigned int qoi_num)
 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...
 
- Public Member Functions inherited from GRINS::QoIBase
 QoIBase (const std::string &qoi_name)
 
virtual ~QoIBase ()
 
virtual void reinit (MultiphysicsSystem &)
 Reinitialize QoI. More...
 
virtual void side_qoi (AssemblyContext &, const unsigned int)
 Compute the qoi value on the domain boundary. More...
 
virtual void side_qoi_derivative (AssemblyContext &, const unsigned int)
 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...
 
- 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 Attributes

const VelocityVariable_flow_vars
 
std::set< libMesh::subdomain_id_type > _subdomain_ids
 List of sumdomain ids for which we want to compute this QoI. More...
 
- Protected Attributes inherited from GRINS::QoIBase
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Private Member Functions

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

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

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 44 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 45 of file vorticity.C.

46  : QoIBase(qoi_name)
47  {
48  return;
49  }
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
GRINS::Vorticity::~Vorticity ( )
virtual

Definition at line 51 of file vorticity.C.

52  {
53  return;
54  }
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 56 of file vorticity.C.

References Vorticity().

57  {
58  return new Vorticity( *this );
59  }
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 100 of file vorticity.C.

References _flow_vars, _subdomain_ids, GRINS::MultcomponentVectorVariable::u(), and GRINS::MultcomponentVectorVariable::v().

102  {
103 
104  if( _subdomain_ids.find( (&context.get_elem())->subdomain_id() ) != _subdomain_ids.end() )
105  {
106  libMesh::FEBase* element_fe;
107  context.get_element_fe<libMesh::Real>(_flow_vars->u(), element_fe);
108  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
109 
110  unsigned int n_qpoints = context.get_element_qrule().n_points();
111 
113  libMesh::Number& qoi = context.get_qois()[qoi_index];
114 
115  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
116  {
117  libMesh::Gradient grad_u = 0.;
118  libMesh::Gradient grad_v = 0.;
119  context.interior_gradient( _flow_vars->u(), qp, grad_u );
120  context.interior_gradient( _flow_vars->v(), qp, grad_v );
121  qoi += (grad_v(0) - grad_u(1)) * JxW[qp];
122  }
123  }
124 
125  return;
126  }
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 VelocityVariable * _flow_vars
Definition: vorticity.h:86
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 128 of file vorticity.C.

References _flow_vars, _subdomain_ids, GRINS::MultcomponentVectorVariable::u(), and GRINS::MultcomponentVectorVariable::v().

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

References GRINS::VariablesParsing::QOI, and GRINS::VariablesParsing::velocity_variable_name().

65  {
66  // Extract subdomain on which to compute to qoi
67  int num_ids = input.vector_variable_size( "QoI/Vorticity/enabled_subdomains" );
68 
69  if( num_ids == 0 )
70  {
71  std::cerr << "Error: Must specify at least one subdomain id on which to compute vorticity." << std::endl;
72  libmesh_error();
73  }
74 
75  for( int i = 0; i < num_ids; i++ )
76  {
77  libMesh::subdomain_id_type s_id = input( "QoI/Vorticity/enabled_subdomains", -1, i );
78  _subdomain_ids.insert( s_id );
79  }
80 
81  _flow_vars = &(GRINSPrivate::VariableWarehouse::get_variable_subclass<VelocityVariable>(VariablesParsing::velocity_variable_name(input,"Vorticity",VariablesParsing::QOI)));
82  }
static std::string velocity_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
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 VelocityVariable * _flow_vars
Definition: vorticity.h:86
void GRINS::Vorticity::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 84 of file vorticity.C.

References _flow_vars, GRINS::MultcomponentVectorVariable::u(), and GRINS::MultcomponentVectorVariable::v().

85  {
86  libMesh::FEBase* u_fe = NULL;
87  libMesh::FEBase* v_fe = NULL;
88 
89  context.get_element_fe<libMesh::Real>(_flow_vars->u(), u_fe);
90  context.get_element_fe<libMesh::Real>(_flow_vars->v(), v_fe);
91 
92  u_fe->get_dphi();
93  u_fe->get_JxW();
94 
95  v_fe->get_dphi();
96 
97  return;
98  }
const VelocityVariable * _flow_vars
Definition: vorticity.h:86

Member Data Documentation

const VelocityVariable* GRINS::Vorticity::_flow_vars
protected

Definition at line 86 of file vorticity.h.

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

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(), and element_qoi_derivative().


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

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1