34 #include "libmesh/composite_function.h"
35 #include "libmesh/dirichlet_boundaries.h"
36 #include "libmesh/dof_map.h"
37 #include "libmesh/getpot.h"
38 #include "libmesh/fem_system.h"
39 #include "libmesh/parsed_function.h"
40 #include "libmesh/quadrature.h"
63 unsigned int qoi_num )
66 int num_vars = input.vector_variable_size(
"QoI/WeightedFlux/variables");
70 std::cerr <<
"Error: Must specify at least one variable to compute"
71 <<
" weighted fluxes." << std::endl
72 <<
"Found: " << num_vars << std::endl;
78 input.vector_variable_size(
"QoI/WeightedFlux/bc_ids");
80 if( num_bcs != num_vars )
82 std::cerr <<
"Error: Must specify exactly one boundary id"
83 <<
" for each specified weighted flux variable."
85 <<
"Found: " << num_bcs << std::endl;
89 std::vector<libMesh::boundary_id_type> bc_ids;
91 for(
int i = 0; i < num_bcs; i++ )
92 bc_ids.push_back( input(
"QoI/WeightedFlux/bc_ids", -1, i ) );
96 input.vector_variable_size(
"QoI/WeightedFlux/weights");
98 if( num_weights != num_vars )
100 std::cerr <<
"Error: Must specify exactly one weight function"
101 <<
" for each specified weighted flux variable."
103 <<
"Found: " << num_weights << std::endl;
107 for(
int i = 0; i < num_weights; i++ )
109 const libMesh::boundary_id_type bc_id =
110 input(
"QoI/WeightedFlux/bc_ids", -1, i );
112 libmesh_assert_not_equal_to (bc_id, -1);
114 const std::string var_name =
115 ( input(
"QoI/WeightedFlux/variables", std::string(
""), i ) );
117 libmesh_assert_not_equal_to (var_name, std::string(
""));
119 const std::string func_string =
120 input(
"QoI/WeightedFlux/weights", std::string(
""), i);
122 libmesh_assert_not_equal_to (func_string, std::string(
""));
124 std::set<libMesh::boundary_id_type> bc_id_set;
125 bc_id_set.insert(bc_id);
129 std::vector<unsigned int> var_indices;
130 var_indices.push_back( system.variable_number( var_name ) );
135 remapped_func->attach_subfunction(raw_func, var_indices);
137 libMesh::DirichletBoundary adjoint_bc
138 (bc_id_set, var_indices, remapped_func);
143 hacked_system.get_dof_map().add_adjoint_dirichlet_boundary
144 (adjoint_bc, qoi_num);
149 hacked_system.reinit_constraints();
virtual ~WeightedFluxQoI()
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...
Interface with libMesh for solving Multiphysics problems.
virtual QoIBase * clone() const
Clone this QoI.