18 #include "libmesh/boundary_volume_solution_transfer.h" 19 #include "libmesh/elem.h" 20 #include "libmesh/numeric_vector.h" 21 #include "libmesh/dof_map.h" 37 libmesh_error_msg_if(from_dimension == to_dimension,
38 "Error: Transfer must be from volume mesh to its boundary or vice-versa!");
40 if (from_dimension > to_dimension)
61 const unsigned int from_sys_number = from_sys->
number();
62 const unsigned int from_var_number = from_var.
number();
64 const unsigned int to_sys_number = to_sys->
number();
65 const unsigned int to_var_number = to_var.
number();
69 const unsigned int to_n_comp = to_var.
n_components(to_mesh);
72 libmesh_assert_equal_to(from_n_comp, to_n_comp);
75 typedef std::map<numeric_index_type, numeric_index_type> DofMapping;
76 DofMapping dof_mapping;
79 for (
const auto & to_elem : to_mesh.active_local_element_ptr_range())
83 libmesh_error_msg_if(!from_elem,
"Error, transfer must be between a Mesh and its associated BoundaryMesh.");
86 for (
const Node & to_node : to_elem->node_ref_range())
91 const dof_id_type from_dof = from_node.dof_number(from_sys_number,
97 if (!dof_mapping.count(from_dof) &&
98 from_node.absolute_fuzzy_equals(to_node,
TOLERANCE))
101 const dof_id_type to_dof = to_node.dof_number(to_sys_number,
106 dof_mapping[from_dof] = to_dof;
114 std::vector<numeric_index_type> needed_indices;
115 needed_indices.reserve(dof_mapping.size());
118 it = dof_mapping.begin(),
119 end = dof_mapping.end();
121 for (; it!=end; ++it)
122 needed_indices.push_back(it->first);
127 std::vector<Number> needed_values;
128 from_sys->
solution->localize(needed_values, needed_indices);
134 it = dof_mapping.begin(),
135 end = dof_mapping.end();
137 for (
unsigned idx=0; it!=end; ++it, ++
idx)
138 to_sys->
solution->set(it->second, needed_values[
idx]);
157 const unsigned int to_sys_number = to_sys->
number();
158 const unsigned int to_var_number = to_var.
number();
159 const unsigned int from_var_number = from_var.
number();
163 std::vector<dof_id_type> from_dof_indices;
164 std::vector<Number>
value;
167 for (
const auto & from_elem : from_mesh.active_local_element_ptr_range())
171 libmesh_error_msg_if(!to_elem,
"Error, transfer must be between a Mesh and its associated BoundaryMesh.");
174 dof_map.
dof_indices(from_elem, from_dof_indices, from_var_number);
180 for (
auto node : from_elem->node_index_range())
183 const Node * from_node = from_elem->node_ptr(node);
189 if (to_node.absolute_fuzzy_equals(*from_node,
TOLERANCE))
void transfer_boundary_volume(const Variable &from_var, const Variable &to_var)
Transfer values from boundary mesh to volume mesh.
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
A Node is like a Point, but with more information.
const Elem * interior_parent() const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
static constexpr Real TOLERANCE
This is the base class from which all geometric element types are derived.
The libMesh namespace provides an interface to certain functionality in the library.
const MeshBase & get_mesh() const
This is the MeshBase class.
This class handles the numbering of degrees of freedom on a mesh.
unsigned int number() const
This class defines the notion of a variable in the system.
unsigned int n_components() const
Manages consistently variables, degrees of freedom, and coefficient vectors.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
SimpleRange< NodeRefIter > node_ref_range()
Returns a range with all nodes of an element, usable in range-based for loops.
unsigned int mesh_dimension() const
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
void transfer_volume_boundary(const Variable &from_var, const Variable &to_var)
Transfer values from volume mesh to boundary mesh.
unsigned int number() const
const DofMap & get_dof_map() const
virtual void transfer(const Variable &from_var, const Variable &to_var) override
Transfer values from a Variable in a System associated with a volume mesh to a Variable in a System a...