Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 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 : 19 : 20 : #ifndef LIBMESH_OVERLAP_COUPLING_H 21 : #define LIBMESH_OVERLAP_COUPLING_H 22 : 23 : // Local Includes 24 : #include "libmesh/ghosting_functor.h" 25 : 26 : #include "libmesh/fe_map.h" 27 : #include "libmesh/quadrature.h" 28 : 29 : // C++ Includes 30 : #include <memory> 31 : 32 : namespace libMesh 33 : { 34 : 35 : // Forward declarations 36 : class PeriodicBoundaries; 37 : 38 : 39 : /** 40 : * This class implements ghosting of elements that overlap or touch at 41 : * at least one sampled point, even if no topological connection 42 : * between the elements exists. This may be useful for immersed 43 : * methods, or for integration along both sides of mesh "slits" with 44 : * no neighbor information. 45 : * 46 : * \author Roy H. Stogner 47 : * \date 2025 48 : */ 49 : class OverlapCoupling : public GhostingFunctor 50 : { 51 : public: 52 : 53 : /** 54 : * Constructor. Defaults to using a Simpson's Rule quadrature to 55 : * choose sampling points. Users may wish to attach custom 56 : * quadrature rules matching those used for their system 57 : * integration. 58 : */ 59 : OverlapCoupling(); 60 : 61 : /** 62 : * Copy constructor. 63 : */ 64 : OverlapCoupling(const OverlapCoupling & other); 65 : 66 : /** 67 : * A clone() is needed because GhostingFunctor can not be shared between 68 : * different meshes. The operations in GhostingFunctor are mesh dependent. 69 : */ 70 0 : virtual std::unique_ptr<GhostingFunctor> clone () const override 71 0 : { return std::make_unique<OverlapCoupling>(*this); } 72 : 73 : // Change coupling matrix after construction 74 : void set_dof_coupling(const CouplingMatrix * dof_coupling) 75 : { _dof_coupling = dof_coupling; } 76 : 77 : // Change quadrature rule after construction. This function takes 78 : // ownership of the rule object and uses it for elements of the 79 : // appropriate dimension. 80 : void set_quadrature_rule(std::unique_ptr<QBase> new_q_rule); 81 : 82 : /** 83 : * We need an updated point locator to see what other elements might 84 : * share each quadrature point. 85 : */ 86 : virtual void mesh_reinit () override; 87 : 88 603 : virtual void redistribute () override 89 603 : { this->mesh_reinit(); } 90 : 91 765 : virtual void delete_remote_elements() override 92 765 : { this->mesh_reinit(); } 93 : 94 : /** 95 : * For the specified range of active elements, find the elements 96 : * which will be coupled to them in the sparsity pattern. 97 : * 98 : * This will include whatever the point locator finds at each 99 : * quadrature point in the range. 100 : */ 101 : virtual void operator() (const MeshBase::const_element_iterator & range_begin, 102 : const MeshBase::const_element_iterator & range_end, 103 : processor_id_type p, 104 : map_type & coupled_elements) override; 105 : 106 : private: 107 : 108 : const CouplingMatrix * _dof_coupling; 109 : 110 : // Quadrature rules for different element dimensions 111 : std::array<std::unique_ptr<QBase>, 3> _q_rules; 112 : 113 : // FE Map from quadrature space to physical space 114 : FEMap _fe_map; 115 : }; 116 : 117 : } // namespace libMesh 118 : 119 : #endif // LIBMESH_OVERLAP_COUPLING_H