GRINS-0.8.0
List of all members | Public Member Functions | Private Member Functions
GRINS::WeightedFluxQoI Class Reference

#include <weighted_flux_qoi.h>

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

Public Member Functions

 WeightedFluxQoI (const std::string &qoi_name)
 
virtual ~WeightedFluxQoI ()
 
virtual QoIBaseclone () const
 Clone this QoI. 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)
 Method to allow QoI to cache any system information needed for QoI calculation, for example, solution variable indices. More...
 
- Public Member Functions inherited from GRINS::QoIBase
 QoIBase (const std::string &qoi_name)
 
virtual ~QoIBase ()
 
virtual void init_context (AssemblyContext &)
 
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 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...
 

Private Member Functions

 WeightedFluxQoI ()
 

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...
 
- Protected Attributes inherited from GRINS::QoIBase
std::string _qoi_name
 
libMesh::Number _qoi_value
 

Detailed Description

Definition at line 44 of file weighted_flux_qoi.h.

Constructor & Destructor Documentation

GRINS::WeightedFluxQoI::WeightedFluxQoI ( const std::string &  qoi_name)

Definition at line 44 of file weighted_flux_qoi.C.

45  : QoIBase(qoi_name)
46  {
47  return;
48  }
QoIBase(const std::string &qoi_name)
Definition: qoi_base.C:39
GRINS::WeightedFluxQoI::~WeightedFluxQoI ( )
virtual

Definition at line 50 of file weighted_flux_qoi.C.

51  {
52  return;
53  }
GRINS::WeightedFluxQoI::WeightedFluxQoI ( )
private

Referenced by clone().

Member Function Documentation

bool GRINS::WeightedFluxQoI::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 69 of file weighted_flux_qoi.h.

70  {
71  // Although we are technically evaluating a lift-function-weighted
72  // residual on the interior, our evaluation gets done by the
73  // FEMSystem
74  return false;
75  }
bool GRINS::WeightedFluxQoI::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 78 of file weighted_flux_qoi.h.

79  {
80  // Although our QoI is a boundary integral, it doesn't get
81  // evaluated directly as such; FEMSystem uses a superconvergent
82  // flux calculation based on the adjoint BC we added.
83  return false;
84  }
QoIBase * GRINS::WeightedFluxQoI::clone ( ) const
virtual

Clone this QoI.

We return a raw pointer, but it is expected for the user to take ownership and delete the object when done.

Implements GRINS::QoIBase.

Definition at line 55 of file weighted_flux_qoi.C.

References WeightedFluxQoI().

56  {
57  return new WeightedFluxQoI( *this );
58  }
void GRINS::WeightedFluxQoI::init ( const GetPot &  ,
const MultiphysicsSystem ,
unsigned int   
)
virtual

Method to allow QoI to cache any system information needed for QoI calculation, for example, solution variable indices.

Reimplemented from GRINS::QoIBase.

Definition at line 61 of file weighted_flux_qoi.C.

64  {
65  // Read variables for which we want to compute fluxes
66  int num_vars = input.vector_variable_size("QoI/WeightedFlux/variables");
67 
68  if( num_vars <= 0 )
69  {
70  std::cerr << "Error: Must specify at least one variable to compute"
71  << " weighted fluxes." << std::endl
72  << "Found: " << num_vars << std::endl;
73  libmesh_error();
74  }
75 
76  // Read boundary ids on which we want to compute fluxes
77  int num_bcs =
78  input.vector_variable_size("QoI/WeightedFlux/bc_ids");
79 
80  if( num_bcs != num_vars )
81  {
82  std::cerr << "Error: Must specify exactly one boundary id"
83  << " for each specified weighted flux variable."
84  << std::endl
85  << "Found: " << num_bcs << std::endl;
86  libmesh_error();
87  }
88 
89  std::vector<libMesh::boundary_id_type> bc_ids;
90 
91  for( int i = 0; i < num_bcs; i++ )
92  bc_ids.push_back( input("QoI/WeightedFlux/bc_ids", -1, i ) );
93 
94  // Read weight functions with which to compute fluxes
95  int num_weights =
96  input.vector_variable_size("QoI/WeightedFlux/weights");
97 
98  if( num_weights != num_vars )
99  {
100  std::cerr << "Error: Must specify exactly one weight function"
101  << " for each specified weighted flux variable."
102  << std::endl
103  << "Found: " << num_weights << std::endl;
104  libmesh_error();
105  }
106 
107  for( int i = 0; i < num_weights; i++ )
108  {
109  const libMesh::boundary_id_type bc_id =
110  input("QoI/WeightedFlux/bc_ids", -1, i );
111 
112  libmesh_assert_not_equal_to (bc_id, -1);
113 
114  const std::string var_name =
115  ( input("QoI/WeightedFlux/variables", std::string(""), i ) );
116 
117  libmesh_assert_not_equal_to (var_name, std::string(""));
118 
119  const std::string func_string =
120  input("QoI/WeightedFlux/weights", std::string(""), i);
121 
122  libmesh_assert_not_equal_to (func_string, std::string(""));
123 
124  std::set<libMesh::boundary_id_type> bc_id_set;
125  bc_id_set.insert(bc_id);
126 
127  libMesh::ParsedFunction<libMesh::Number> raw_func (func_string);
128 
129  std::vector<unsigned int> var_indices;
130  var_indices.push_back( system.variable_number( var_name ) );
131 
134 
135  remapped_func->attach_subfunction(raw_func, var_indices);
136 
137  libMesh::DirichletBoundary adjoint_bc
138  (bc_id_set, var_indices, remapped_func);
139 
140  // FIXME: this is an ugly hack
141  MultiphysicsSystem & hacked_system =
142  const_cast<MultiphysicsSystem&>(system);
143  hacked_system.get_dof_map().add_adjoint_dirichlet_boundary
144  (adjoint_bc, qoi_num);
145  }
146 
147  MultiphysicsSystem & hacked_system =
148  const_cast<MultiphysicsSystem&>(system);
149  hacked_system.reinit_constraints();
150  }

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

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