GRINS-0.7.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 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...
 
- 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

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

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

Definition at line 48 of file vorticity.C.

49  {
50  return;
51  }
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 100 of file vorticity.h.

101  {
102  return true;
103  }
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 106 of file vorticity.h.

107  {
108  return false;
109  }
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 53 of file vorticity.C.

References Vorticity().

54  {
55  return new Vorticity( *this );
56  }
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 103 of file vorticity.C.

References _subdomain_ids, _u_var, and _v_var.

105  {
106 
107  if( _subdomain_ids.find( (&context.get_elem())->subdomain_id() ) != _subdomain_ids.end() )
108  {
109  libMesh::FEBase* element_fe;
110  context.get_element_fe<libMesh::Real>(this->_u_var, element_fe);
111  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
112 
113  unsigned int n_qpoints = context.get_element_qrule().n_points();
114 
116  libMesh::Number& qoi = context.get_qois()[qoi_index];
117 
118  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
119  {
120  libMesh::Gradient grad_u = 0.;
121  libMesh::Gradient grad_v = 0.;
122  context.interior_gradient( this->_u_var, qp, grad_u );
123  context.interior_gradient( this->_v_var, qp, grad_v );
124  qoi += (grad_v(0) - grad_u(1)) * JxW[qp];
125  }
126  }
127 
128  return;
129  }
std::set< libMesh::subdomain_id_type > _subdomain_ids
List of sumdomain ids for which we want to compute this QoI.
Definition: vorticity.h:91
VariableIndex _v_var
v-velocity component variable index
Definition: vorticity.h:88
VariableIndex _u_var
u-velocity component variable index
Definition: vorticity.h:85
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 131 of file vorticity.C.

References _subdomain_ids, _u_var, and _v_var.

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

References GRINS::u_var_name_default, and GRINS::v_var_name_default.

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

Reimplemented from GRINS::QoIBase.

Definition at line 87 of file vorticity.C.

References _u_var, and _v_var.

88  {
89  libMesh::FEBase* u_fe = NULL;
90  libMesh::FEBase* v_fe = NULL;
91 
92  context.get_element_fe<libMesh::Real>(this->_u_var, u_fe);
93  context.get_element_fe<libMesh::Real>(this->_v_var, v_fe);
94 
95  u_fe->get_dphi();
96  u_fe->get_JxW();
97 
98  v_fe->get_dphi();
99 
100  return;
101  }
VariableIndex _v_var
v-velocity component variable index
Definition: vorticity.h:88
VariableIndex _u_var
u-velocity component variable index
Definition: vorticity.h:85

Member Data Documentation

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 91 of file vorticity.h.

Referenced by element_qoi(), and element_qoi_derivative().

VariableIndex GRINS::Vorticity::_u_var
protected

u-velocity component variable index

Definition at line 85 of file vorticity.h.

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

VariableIndex GRINS::Vorticity::_v_var
protected

v-velocity component variable index

Definition at line 88 of file vorticity.h.

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


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

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