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

Parsed Boundary QoI. More...

#include <parsed_boundary_qoi.h>

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

Public Member Functions

 ParsedBoundaryQoI (const std::string &qoi_name)
 Constructor. More...
 
virtual ~ParsedBoundaryQoI ()
 
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 side_qoi (AssemblyContext &context, const unsigned int qoi_index)
 Compute the qoi value. More...
 
virtual void side_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 element_qoi (AssemblyContext &, const unsigned int)
 Compute the qoi value for element interiors. More...
 
virtual void element_qoi_derivative (AssemblyContext &, const unsigned int)
 Compute the qoi derivative with respect to the solution on element interiors. 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

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

Protected Attributes

libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
 
std::set< libMesh::boundary_id_type > _bc_ids
 List of boundary ids on 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

 ParsedBoundaryQoI ()
 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 Boundary QoI.

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

Definition at line 44 of file parsed_boundary_qoi.h.

Constructor & Destructor Documentation

GRINS::ParsedBoundaryQoI::ParsedBoundaryQoI ( 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_boundary_qoi.C.

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

Definition at line 61 of file parsed_boundary_qoi.C.

61 {}
GRINS::ParsedBoundaryQoI::ParsedBoundaryQoI ( const ParsedBoundaryQoI original)
protected

Manual copy constructor due to the UniquePtr.

Definition at line 45 of file parsed_boundary_qoi.C.

References _bc_ids, 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 
58  this->_bc_ids = original._bc_ids;
59  }
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids on which we want to compute this QoI.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
virtual void move_parameter(const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
When cloning an object, we need to update parameter pointers.
GRINS::ParsedBoundaryQoI::ParsedBoundaryQoI ( )
private

User never call default constructor.

Referenced by clone().

Member Function Documentation

bool GRINS::ParsedBoundaryQoI::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 96 of file parsed_boundary_qoi.h.

97  {
98  return false;
99  }
bool GRINS::ParsedBoundaryQoI::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 102 of file parsed_boundary_qoi.h.

103  {
104  return true;
105  }
QoIBase * GRINS::ParsedBoundaryQoI::clone ( ) const
virtual

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

Implements GRINS::QoIBase.

Definition at line 63 of file parsed_boundary_qoi.C.

References ParsedBoundaryQoI().

64  {
65  return new ParsedBoundaryQoI( *this );
66  }
ParsedBoundaryQoI()
User never call default constructor.
void GRINS::ParsedBoundaryQoI::init ( const GetPot &  input,
const MultiphysicsSystem system,
unsigned int  qoi_num 
)
virtual

Initialize local variables.

Reimplemented from GRINS::QoIBase.

Definition at line 68 of file parsed_boundary_qoi.C.

References _bc_ids, qoi_functional, and GRINS::ParameterUser::set_parameter().

71  {
72  // Read boundary ids on which we want to compute qoi
73  int num_bcs = input.vector_variable_size("QoI/ParsedBoundary/bc_ids");
74 
75  if( num_bcs <= 0 )
76  {
77  std::cerr << "Error: Must specify at least one boundary id to compute"
78  << " parsed boundary QoI." << std::endl
79  << "Found: " << num_bcs << std::endl;
80  libmesh_error();
81  }
82 
83  for( int i = 0; i < num_bcs; i++ )
84  {
85  _bc_ids.insert( input("QoI/ParsedBoundary/bc_ids", -1, i ) );
86  }
87 
90  (system, ""));
91  this->qoi_functional.reset(qf);
92 
93  this->set_parameter(*qf, input,
94  "QoI/ParsedBoundary/qoi_functional", "DIE!");
95  }
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.
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids on which we want to compute this QoI.
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
void GRINS::ParsedBoundaryQoI::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 97 of file parsed_boundary_qoi.C.

References qoi_functional.

98  {
99  libMesh::FEBase* side_fe;
100  context.get_side_fe<libMesh::Real>(0, side_fe);
101  side_fe->get_JxW();
102  side_fe->get_xyz();
103 
104  qoi_functional->init_context(context);
105  }
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
void GRINS::ParsedBoundaryQoI::side_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 107 of file parsed_boundary_qoi.C.

References _bc_ids.

109  {
110  bool on_correct_side = false;
111 
112  for (std::set<libMesh::boundary_id_type>::const_iterator id =
113  _bc_ids.begin(); id != _bc_ids.end(); id++ )
114  if( context.has_side_boundary_id( (*id) ) )
115  {
116  on_correct_side = true;
117  break;
118  }
119 
120  if (!on_correct_side)
121  return;
122 
123  libMesh::FEBase* side_fe;
124  context.get_side_fe<libMesh::Real>(0, side_fe);
125  const std::vector<libMesh::Real> &JxW = side_fe->get_JxW();
126 
127  const std::vector<libMesh::Point>& x_qp = side_fe->get_xyz();
128 
129  unsigned int n_qpoints = context.get_side_qrule().n_points();
130 
132  libMesh::Number& qoi = context.get_qois()[qoi_index];
133 
134  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
135  {
136  const libMesh::Number func_val =
137  (*qoi_functional)(context, x_qp[qp], context.get_time());
138 
139  qoi += func_val * JxW[qp];
140  }
141  }
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids on which we want to compute this QoI.
void GRINS::ParsedBoundaryQoI::side_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 143 of file parsed_boundary_qoi.C.

References _bc_ids.

145  {
146  bool on_correct_side = false;
147 
148  for (std::set<libMesh::boundary_id_type>::const_iterator id =
149  _bc_ids.begin(); id != _bc_ids.end(); id++ )
150  if( context.has_side_boundary_id( (*id) ) )
151  {
152  on_correct_side = true;
153  break;
154  }
155 
156  if (!on_correct_side)
157  return;
158 
159  libMesh::FEBase* side_fe;
160  context.get_side_fe<libMesh::Real>(0, side_fe);
161  const std::vector<libMesh::Real> &JxW = side_fe->get_JxW();
162 
163  const std::vector<libMesh::Point>& x_qp = side_fe->get_xyz();
164 
165  // Local DOF count and quadrature point count
166  const unsigned int n_u_dofs = context.get_dof_indices().size();
167 
168  unsigned int n_qpoints = context.get_side_qrule().n_points();
169 
170  // Local solution vector - non-const version for finite
171  // differenting purposes
172  libMesh::DenseVector<libMesh::Number>& elem_solution =
173  const_cast<libMesh::DenseVector<libMesh::Number>&>
174  (context.get_elem_solution());
175 
177  libMesh::DenseVector<libMesh::Number> &Qu =
178  context.get_qoi_derivatives()[qoi_index];
179 
180  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
181  {
182  // Central finite differencing to approximate derivatives.
183  // FIXME - we should hook the FParserAD stuff into
184  // ParsedFEMFunction
185 
186  for( unsigned int i = 0; i != n_u_dofs; ++i )
187  {
188  libMesh::Number &current_solution = elem_solution(i);
189  const libMesh::Number original_solution = current_solution;
190 
191  current_solution = original_solution + libMesh::TOLERANCE;
192 
193  const libMesh::Number plus_val =
194  (*qoi_functional)(context, x_qp[qp], context.get_time());
195 
196  current_solution = original_solution - libMesh::TOLERANCE;
197 
198  const libMesh::Number minus_val =
199  (*qoi_functional)(context, x_qp[qp], context.get_time());
200 
201  Qu(i) += (plus_val - minus_val) *
202  (0.5 / libMesh::TOLERANCE) * JxW[qp];
203 
204  // Don't forget to restore the correct solution...
205  current_solution = original_solution;
206  }
207  }
208  }
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids on which we want to compute this QoI.

Member Data Documentation

std::set<libMesh::boundary_id_type> GRINS::ParsedBoundaryQoI::_bc_ids
protected

List of boundary ids on which we want to compute this QoI.

Definition at line 84 of file parsed_boundary_qoi.h.

Referenced by init(), ParsedBoundaryQoI(), side_qoi(), and side_qoi_derivative().

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

Definition at line 80 of file parsed_boundary_qoi.h.

Referenced by init(), init_context(), and ParsedBoundaryQoI().


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