GRINS-0.6.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
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)
 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...
 
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...
 
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 register_parameter (const std::string &param_name, libMesh::ParameterMultiPointer< 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 AutoPtr. More...
 

Protected Attributes

libMesh::AutoPtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
 
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Private Member Functions

 ParsedInteriorQoI ()
 User never call default constructor. 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 43 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 52 of file parsed_interior_qoi.C.

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

Manual copy constructor due to the AutoPtr.

Definition at line 45 of file parsed_interior_qoi.C.

References qoi_functional.

46  : QoIBase(original.name())
47  {
48  if (original.qoi_functional.get())
49  this->qoi_functional = original.qoi_functional->clone();
50  }
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
libMesh::AutoPtr< 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 89 of file parsed_interior_qoi.h.

90  {
91  return true;
92  }
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 95 of file parsed_interior_qoi.h.

96  {
97  return false;
98  }
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 54 of file parsed_interior_qoi.C.

References ParsedInteriorQoI().

55  {
56  return new ParsedInteriorQoI( *this );
57  }
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 83 of file parsed_interior_qoi.C.

85  {
86  libMesh::FEBase* element_fe;
87  context.get_element_fe<libMesh::Real>(0, element_fe);
88  const std::vector<libMesh::Real> &JxW = element_fe->get_JxW();
89 
90  const std::vector<libMesh::Point>& x_qp = element_fe->get_xyz();
91 
92  unsigned int n_qpoints = context.get_element_qrule().n_points();
93 
95  libMesh::Number& qoi = context.get_qois()[qoi_index];
96 
97  for( unsigned int qp = 0; qp != n_qpoints; qp++ )
98  {
99  const libMesh::Number func_val =
100  (*qoi_functional)(context, x_qp[qp], context.get_time());
101 
102  qoi += func_val * JxW[qp];
103  }
104  }
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 106 of file parsed_interior_qoi.C.

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

Initialize local variables.

Reimplemented from GRINS::QoIBase.

Definition at line 59 of file parsed_interior_qoi.C.

References qoi_functional.

60  {
61  std::string qoi_functional_string =
62  input("QoI/ParsedInterior/qoi_functional", std::string("0"));
63 
64  if (qoi_functional_string == "0")
65  libmesh_error_msg("Error! Zero ParsedInteriorQoI specified!" <<
66  std::endl);
67 
68  this->qoi_functional.reset
69  (new libMesh::ParsedFEMFunction<libMesh::Number>
70  (system, qoi_functional_string));
71  }
libMesh::AutoPtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
void GRINS::ParsedInteriorQoI::init_context ( AssemblyContext context)
virtual

Reimplemented from GRINS::QoIBase.

Definition at line 73 of file parsed_interior_qoi.C.

References qoi_functional.

74  {
75  libMesh::FEBase* element_fe;
76  context.get_element_fe<libMesh::Real>(0, element_fe);
77  element_fe->get_JxW();
78  element_fe->get_xyz();
79 
80  qoi_functional->init_context(context);
81  }
libMesh::AutoPtr< libMesh::FEMFunctionBase< libMesh::Number > > qoi_functional
const std::string & GRINS::QoIBase::name ( ) const
inlineinherited

Returns the name of this QoI.

Definition at line 143 of file qoi_base.h.

References GRINS::QoIBase::_qoi_name.

Referenced by GRINS::SteadyVisualization::output_adjoint(), and GRINS::UnsteadyVisualization::output_adjoint().

144  {
145  return _qoi_name;
146  }
std::string _qoi_name
Definition: qoi_base.h:131
void GRINS::QoIBase::output_qoi ( std::ostream &  out) const
virtualinherited

Basic output for computed QoI's.

If fancier output is desired, override this method.

Definition at line 107 of file qoi_base.C.

References GRINS::QoIBase::_qoi_name, and GRINS::QoIBase::_qoi_value.

108  {
109  out << "==========================================================" << std::endl;
110 
111  out << _qoi_name+" = "
112  << std::setprecision(16)
113  << std::scientific
114  << _qoi_value << std::endl;
115 
116  out << "==========================================================" << std::endl;
117 
118  return;
119  }
std::string _qoi_name
Definition: qoi_base.h:131
libMesh::Number _qoi_value
Definition: qoi_base.h:133
void GRINS::QoIBase::parallel_op ( const libMesh::Parallel::Communicator &  communicator,
libMesh::Number &  sys_qoi,
libMesh::Number &  local_qoi 
)
virtualinherited

Call the parallel operation for this QoI and cache the value.

By default, this is just a sum. Override if QoI is more complex.

Definition at line 87 of file qoi_base.C.

References GRINS::QoIBase::_qoi_value.

90  {
91  communicator.sum(local_qoi);
92 
93  sys_qoi = local_qoi;
94 
95  _qoi_value = sys_qoi;
96 
97  return;
98  }
libMesh::Number _qoi_value
Definition: qoi_base.h:133
void GRINS::ParameterUser::register_parameter ( const std::string &  param_name,
libMesh::ParameterMultiPointer< libMesh::Number > &  param_pointer 
) const
virtualinherited

Each subclass will register its copy of an independent.

Reimplemented in GRINS::AxisymmetricHeatTransfer< Conductivity >, GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >, GRINS::IncompressibleNavierStokesBase< Viscosity >, GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >, GRINS::HeatConduction< Conductivity >, GRINS::HeatTransferBase< Conductivity >, and GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >.

Definition at line 50 of file parameter_user.C.

Referenced by GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::register_parameter(), GRINS::HeatTransferBase< Conductivity >::register_parameter(), GRINS::HeatConduction< Conductivity >::register_parameter(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::register_parameter(), GRINS::IncompressibleNavierStokesBase< Viscosity >::register_parameter(), GRINS::LowMachNavierStokesBase< Viscosity, SpecificHeat, ThermalConductivity >::register_parameter(), and GRINS::AxisymmetricHeatTransfer< Conductivity >::register_parameter().

53  {
54  std::map<std::string, libMesh::Number*>::const_iterator it =
55  _my_parameters.find(param_name);
56 
57  if (it != _my_parameters.end())
58  {
59  std::cout << _my_name << " uses parameter " << param_name
60  << std::endl;
61  param_pointer.push_back(it->second);
62  }
63  }
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::ParameterUser::set_parameter ( libMesh::Number &  param_variable,
const GetPot &  input,
const std::string &  param_name,
libMesh::Number  param_default 
)
virtualinherited

Each subclass can simultaneously read a parameter value from.

Definition at line 35 of file parameter_user.C.

References GRINS::ParameterUser::_my_name, and GRINS::ParameterUser::_my_parameters.

Referenced by GRINS::AveragedFanAdjointStabilization< Viscosity >::AveragedFanAdjointStabilization(), GRINS::AveragedTurbineAdjointStabilization< Viscosity >::AveragedTurbineAdjointStabilization(), GRINS::BoussinesqBuoyancyAdjointStabilization< Viscosity >::BoussinesqBuoyancyAdjointStabilization(), GRINS::BoussinesqBuoyancyBase::BoussinesqBuoyancyBase(), GRINS::BoussinesqBuoyancySPGSMStabilization< Viscosity >::BoussinesqBuoyancySPGSMStabilization(), GRINS::ConstantConductivity::ConstantConductivity(), GRINS::ConstantPrandtlConductivity::ConstantPrandtlConductivity(), GRINS::ConstantSourceFunction::ConstantSourceFunction(), GRINS::ConstantSourceTerm::ConstantSourceTerm(), GRINS::ConstantSpecificHeat::ConstantSpecificHeat(), GRINS::ConstantViscosity::ConstantViscosity(), GRINS::ElasticCable< StressStrainLaw >::ElasticCable(), GRINS::ElasticCableConstantGravity::ElasticCableConstantGravity(), GRINS::ElasticMembrane< StressStrainLaw >::ElasticMembrane(), GRINS::ElasticMembraneConstantPressure::ElasticMembraneConstantPressure(), GRINS::HeatConduction< Conductivity >::HeatConduction(), GRINS::HeatTransferBase< Conductivity >::HeatTransferBase(), GRINS::IncompressibleNavierStokesBase< Viscosity >::IncompressibleNavierStokesBase(), GRINS::AverageNusseltNumber::init(), GRINS::MooneyRivlin::MooneyRivlin(), GRINS::ReactingLowMachNavierStokesBase< Mixture, Evaluator >::ReactingLowMachNavierStokesBase(), GRINS::HookesLaw1D::read_input_options(), GRINS::HookesLaw::read_input_options(), GRINS::AxisymmetricBoussinesqBuoyancy::read_input_options(), and GRINS::VelocityDragAdjointStabilization< Viscosity >::VelocityDragAdjointStabilization().

39  {
40  param_variable = input(param_name, param_default);
41 
42  libmesh_assert_msg(!_my_parameters.count(param_name),
43  "ERROR: " << _my_name << " double-registered parameter " <<
44  param_name);
45 
46  _my_parameters[param_name] = &param_variable;
47  }
std::map< std::string, libMesh::Number * > _my_parameters
void GRINS::QoIBase::side_qoi ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtualinherited

Compute the qoi value on the domain boundary.

Override this method if your QoI is defined on the domain boundary

Reimplemented in GRINS::AverageNusseltNumber.

Definition at line 75 of file qoi_base.C.

77  {
78  return;
79  }
void GRINS::QoIBase::side_qoi_derivative ( AssemblyContext context,
const unsigned int  qoi_index 
)
virtualinherited

Compute the qoi derivative with respect to the solution on the domain boundary.

Override this method if your QoI is defined on the domain boundary

Reimplemented in GRINS::AverageNusseltNumber.

Definition at line 81 of file qoi_base.C.

83  {
84  return;
85  }
void GRINS::QoIBase::thread_join ( libMesh::Number &  qoi,
const libMesh::Number &  other_qoi 
)
virtualinherited

Call the operation to accumulate this QoI from multiple threads.

By default, this is just a sum. Override if QoI is more complex.

Definition at line 100 of file qoi_base.C.

101  {
102  qoi += other_qoi;
103 
104  return;
105  }
libMesh::Number GRINS::QoIBase::value ( ) const
inlineinherited

Returns the current QoI value.

Definition at line 137 of file qoi_base.h.

References GRINS::QoIBase::_qoi_value.

138  {
139  return _qoi_value;
140  }
libMesh::Number _qoi_value
Definition: qoi_base.h:133

Member Data Documentation

std::string GRINS::QoIBase::_qoi_name
protectedinherited

Definition at line 131 of file qoi_base.h.

Referenced by GRINS::QoIBase::name(), and GRINS::QoIBase::output_qoi().

libMesh::Number GRINS::QoIBase::_qoi_value
protectedinherited
libMesh::AutoPtr<libMesh::FEMFunctionBase<libMesh::Number> > GRINS::ParsedInteriorQoI::qoi_functional
protected

Definition at line 77 of file parsed_interior_qoi.h.

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


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

Generated on Mon Jun 22 2015 21:32:23 for GRINS-0.6.0 by  doxygen 1.8.9.1