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

Parsed Interior QoI. More...

#include <parsed_interior_qoi.h>

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

Public Member Functions

 ParsedInteriorQoI (const std::string &qoi_name)
 Constructor. More...
 
virtual ~ParsedInteriorQoI ()
 
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 Member Functions

 ParsedInteriorQoI (const ParsedInteriorQoI &original)
 Manual copy constructor due to the UniquePtr. More...
 

Protected Attributes

libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
 
- Protected Attributes inherited from GRINS::QoIBase
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Private Member Functions

 ParsedInteriorQoI ()
 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

Parsed Interior QoI.

This class implements a QoI that is an arbitrary integral of a parsed function on the interior of the domain.

Definition at line 44 of file parsed_interior_qoi.h.

Constructor & Destructor Documentation

GRINS::ParsedInteriorQoI::ParsedInteriorQoI ( 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 parsed_interior_qoi.C.

43  : QoIBase(qoi_name) {}
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
GRINS::ParsedInteriorQoI::~ParsedInteriorQoI ( )
virtual

Definition at line 59 of file parsed_interior_qoi.C.

59 {}
GRINS::ParsedInteriorQoI::ParsedInteriorQoI ( const ParsedInteriorQoI original)
protected

Manual copy constructor due to the UniquePtr.

Definition at line 45 of file parsed_interior_qoi.C.

References GRINS::ParameterUser::move_parameter(), and qoi_functional.

46  : QoIBase(original)
47  {
48  if (original.qoi_functional.get())
49  {
50  this->qoi_functional = original.qoi_functional->clone();
51  this->move_parameter
53  (original.qoi_functional.get()),
55  (this->qoi_functional.get()));
56  }
57  }
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
virtual void move_parameter(const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
When cloning an object, we need to update parameter pointers.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
GRINS::ParsedInteriorQoI::ParsedInteriorQoI ( )
private

User never call default constructor.

Referenced by clone().

Member Function Documentation

bool GRINS::ParsedInteriorQoI::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 92 of file parsed_interior_qoi.h.

93  {
94  return true;
95  }
bool GRINS::ParsedInteriorQoI::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 98 of file parsed_interior_qoi.h.

99  {
100  return false;
101  }
QoIBase * GRINS::ParsedInteriorQoI::clone ( ) const
virtual

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

Implements GRINS::QoIBase.

Definition at line 61 of file parsed_interior_qoi.C.

References ParsedInteriorQoI().

62  {
63  return new ParsedInteriorQoI( *this );
64  }
ParsedInteriorQoI()
User never call default constructor.
void GRINS::ParsedInteriorQoI::element_qoi ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtual

Compute the qoi value.

Todo:
Need to generalize this to the multiple QoI case

Reimplemented from GRINS::QoIBase.

Definition at line 90 of file parsed_interior_qoi.C.

92  {
93  libMesh::FEBase* element_fe;
94  context.get_element_fe<libMesh::Real>(0, element_fe);
95  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
96 
97  const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
98 
99  unsigned int n_qpoints = context.get_element_qrule().n_points();
100 
102  libMesh::Number& qoi = context.get_qois()[qoi_index];
103 
104  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
105  {
106  const libMesh::Number func_val =
107  (*qoi_functional)(context, x_qp[qp], context.get_time());
108 
109  qoi += func_val * JxW[qp];
110  }
111  }
void GRINS::ParsedInteriorQoI::element_qoi_derivative ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtual

Compute the qoi derivative with respect to the solution.

Todo:
Need to generalize this to the multiple QoI case

Reimplemented from GRINS::QoIBase.

Definition at line 113 of file parsed_interior_qoi.C.

115  {
116  libMesh::FEBase* element_fe;
117  context.get_element_fe<libMesh::Real>(0, element_fe);
118  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
119 
120  const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
121 
122  // Local DOF count and quadrature point count
123  const unsigned int n_u_dofs = context.get_dof_indices().size();
124 
125  unsigned int n_qpoints = context.get_element_qrule().n_points();
126 
127  // Local solution vector - non-const version for finite
128  // differenting purposes
129  libMesh::DenseVector<libMesh::Number>& elem_solution =
130  const_cast<libMesh::DenseVector<libMesh::Number>&>
131  (context.get_elem_solution());
132 
134  libMesh::DenseVector<libMesh::Number> &Qu =
135  context.get_qoi_derivatives()[qoi_index];
136 
137  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
138  {
139  // Central finite differencing to approximate derivatives.
140  // FIXME - we should hook the FParserAD stuff into
141  // ParsedFEMFunction
142 
143  for( unsigned int i = 0; i != n_u_dofs; ++i )
144  {
145  libMesh::Number &current_solution = elem_solution(i);
146  const libMesh::Number original_solution = current_solution;
147 
148  current_solution = original_solution + libMesh::TOLERANCE;
149 
150  const libMesh::Number plus_val =
151  (*qoi_functional)(context, x_qp[qp], context.get_time());
152 
153  current_solution = original_solution - libMesh::TOLERANCE;
154 
155  const libMesh::Number minus_val =
156  (*qoi_functional)(context, x_qp[qp], context.get_time());
157 
158  Qu(i) += (plus_val - minus_val) *
159  (0.5 / libMesh::TOLERANCE) * JxW[qp];
160 
161  // Don't forget to restore the correct solution...
162  current_solution = original_solution;
163  }
164  }
165  }
void GRINS::ParsedInteriorQoI::init ( const GetPot &  input,
const MultiphysicsSystem system,
unsigned int  qoi_num 
)
virtual

Initialize local variables.

Reimplemented from GRINS::QoIBase.

Definition at line 67 of file parsed_interior_qoi.C.

70  {
73  (system, ""));
74  this->qoi_functional.reset(qf);
75 
76  this->set_parameter(*qf, input,
77  "QoI/ParsedInterior/qoi_functional", "DIE!");
78  }
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.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
void GRINS::ParsedInteriorQoI::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 80 of file parsed_interior_qoi.C.

References qoi_functional.

81  {
82  libMesh::FEBase* element_fe;
83  context.get_element_fe<libMesh::Real>(0, element_fe);
84  element_fe->get_JxW();
85  element_fe->get_xyz();
86 
87  qoi_functional->init_context(context);
88  }
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional

Member Data Documentation

libMesh::UniquePtr<libMesh::FEMFunctionBase<libMesh::Number> > GRINS::ParsedInteriorQoI::qoi_functional
protected

Definition at line 80 of file parsed_interior_qoi.h.

Referenced by init_context(), and ParsedInteriorQoI().


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

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