34 #include "libmesh/getpot.h" 
   35 #include "libmesh/fem_system.h" 
   36 #include "libmesh/quadrature.h" 
   37 #include "libmesh/fe_base.h" 
   38 #include "libmesh/parsed_fem_function.h" 
   73     int num_bcs =  input.vector_variable_size(
"QoI/ParsedBoundary/bc_ids");
 
   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;
 
   83     for( 
int i = 0; i < num_bcs; i++ )
 
   85         _bc_ids.insert( input(
"QoI/ParsedBoundary/bc_ids", -1, i ) );
 
   94                         "QoI/ParsedBoundary/qoi_functional", 
"DIE!");
 
   99     libMesh::FEBase* side_fe;
 
  100     context.get_side_fe<libMesh::Real>(0, side_fe);
 
  108                                     const unsigned int qoi_index )
 
  110     bool on_correct_side = 
false;
 
  112     for (std::set<libMesh::boundary_id_type>::const_iterator 
id =
 
  114       if( context.has_side_boundary_id( (*
id) ) )
 
  116           on_correct_side = 
true;
 
  120     if (!on_correct_side)
 
  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();
 
  127     const std::vector<libMesh::Point>& x_qp = side_fe->get_xyz();
 
  129     unsigned int n_qpoints = context.get_side_qrule().n_points();
 
  132     libMesh::Number& qoi = context.get_qois()[qoi_index];
 
  134     for( 
unsigned int qp = 0; qp != n_qpoints; qp++ )
 
  136         const libMesh::Number func_val =
 
  137           (*qoi_functional)(context, x_qp[qp], context.get_time());
 
  139         qoi += func_val * JxW[qp];
 
  144                                                const unsigned int qoi_index )
 
  146     bool on_correct_side = 
false;
 
  148     for (std::set<libMesh::boundary_id_type>::const_iterator 
id =
 
  150       if( context.has_side_boundary_id( (*
id) ) )
 
  152           on_correct_side = 
true;
 
  156     if (!on_correct_side)
 
  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();
 
  163     const std::vector<libMesh::Point>& x_qp = side_fe->get_xyz();
 
  166     const unsigned int n_u_dofs = context.get_dof_indices().size();
 
  168     unsigned int n_qpoints = context.get_side_qrule().n_points();
 
  172     libMesh::DenseVector<libMesh::Number>& elem_solution =
 
  173       const_cast<libMesh::DenseVector<libMesh::Number>&
> 
  174         (context.get_elem_solution());
 
  177     libMesh::DenseVector<libMesh::Number> &Qu =
 
  178       context.get_qoi_derivatives()[qoi_index];
 
  180     for( 
unsigned int qp = 0; qp != n_qpoints; qp++ )
 
  186         for( 
unsigned int i = 0; i != n_u_dofs; ++i )
 
  188             libMesh::Number ¤t_solution = elem_solution(i);
 
  189             const libMesh::Number original_solution = current_solution;
 
  191             current_solution = original_solution + libMesh::TOLERANCE;
 
  193             const libMesh::Number plus_val =
 
  194               (*qoi_functional)(context, x_qp[qp], context.get_time());
 
  196             current_solution = original_solution - libMesh::TOLERANCE;
 
  198             const libMesh::Number minus_val =
 
  199               (*qoi_functional)(context, x_qp[qp], context.get_time());
 
  201             Qu(i) += (plus_val - minus_val) *
 
  202                      (0.5 / libMesh::TOLERANCE) * JxW[qp];
 
  205             current_solution = original_solution;
 
virtual void set_parameter(libMesh::Number ¶m_variable, const GetPot &input, const std::string ¶m_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from. 
 
virtual void init_context(AssemblyContext &context)
 
ParsedBoundaryQoI()
User never call default constructor. 
 
virtual QoIBase * clone() const 
Required to provide clone (deep-copy) for adding QoI object to libMesh objects. 
 
std::set< libMesh::boundary_id_type > _bc_ids
List of boundary ids on which we want to compute this QoI. 
 
virtual void init(const GetPot &input, const MultiphysicsSystem &system, unsigned int qoi_num)
Initialize local variables. 
 
virtual void side_qoi_derivative(AssemblyContext &context, const unsigned int qoi_index)
Compute the qoi derivative with respect to the solution. 
 
Interface with libMesh for solving Multiphysics problems. 
 
libMesh::UniquePtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
 
virtual void side_qoi(AssemblyContext &context, const unsigned int qoi_index)
Compute the qoi value. 
 
virtual ~ParsedBoundaryQoI()
 
virtual void move_parameter(const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
When cloning an object, we need to update parameter pointers.