Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : #include "libmesh/static_condensation_dof_map.h" 19 : 20 : #include "libmesh/elem.h" 21 : #include "libmesh/mesh_base.h" 22 : 23 : namespace libMesh 24 : { 25 54 : StaticCondensationDofMap::StaticCondensationDofMap(MeshBase & mesh, 26 : System & system, 27 54 : const DofMap & dof_map) 28 90 : : ReducedDofMap(mesh, system, dof_map, "reduced") 29 : { 30 : libmesh_experimental(); 31 54 : } 32 : 33 54 : StaticCondensationDofMap::~StaticCondensationDofMap() = default; 34 : 35 2472198 : bool StaticCondensationDofMap::retain_field_dof(const Elem & elem, 36 : const unsigned int node_num, 37 : const unsigned int var_num, 38 : dof_id_type /*field_dof*/) const 39 : { 40 1648132 : if (_uncondensed_vars.count(var_num)) 41 : { 42 384 : libmesh_assert_msg( 43 : node_num == invalid_uint, 44 : "Users should not be providing continuous FEM variables to the uncondensed vars API"); 45 768 : return true; 46 : } 47 : 48 2471046 : return node_num != invalid_uint && !elem.is_internal(node_num); 49 : } 50 : 51 590451 : void StaticCondensationDofMap::retained_dof_added(const Elem & elem, const dof_id_type full_dof) 52 : { 53 590451 : auto & dof_data = _elem_to_dof_data[elem.id()]; 54 196817 : auto & map = dof_data.uncondensed_global_to_local_map; 55 590451 : const auto local_number = cast_int<dof_id_type>(map.size()); 56 196817 : map.emplace(full_dof, local_number); 57 590451 : dof_data.uncondensed_parent_dofs.push_back(this->parent_dof(full_dof)); 58 590451 : } 59 : 60 131865 : void StaticCondensationDofMap::unretained_dof_found(const Elem & elem, const dof_id_type full_dof) 61 : { 62 131865 : auto & dof_data = _elem_to_dof_data[elem.id()]; 63 43955 : auto & map = dof_data.condensed_global_to_local_map; 64 131865 : const auto local_number = cast_int<dof_id_type>(map.size()); 65 43955 : map.emplace(full_dof, local_number); 66 131865 : dof_data.condensed_parent_dofs.push_back(this->parent_dof(full_dof)); 67 131865 : } 68 : 69 360 : void StaticCondensationDofMap::reinit() 70 : { 71 360 : ReducedDofMap::reinit(); 72 : 73 : // StaticCondensation expects an entry for every active local element, including those without 74 : // any degrees of freedom 75 63564 : for (const auto * const elem : _mesh.active_local_element_ptr_range()) 76 47343 : _elem_to_dof_data[elem->id()]; 77 360 : } 78 : 79 366 : void StaticCondensationDofMap::clear() 80 : { 81 366 : ReducedDofMap::clear(); 82 122 : _elem_to_dof_data.clear(); 83 122 : _uncondensed_vars.clear(); 84 366 : } 85 : }