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 : 19 : 20 : #ifndef LIBMESH_DEFAULT_COUPLING_H 21 : #define LIBMESH_DEFAULT_COUPLING_H 22 : 23 : // Local Includes 24 : #include "libmesh/ghosting_functor.h" 25 : 26 : // C++ includes 27 : #include <memory> 28 : 29 : namespace libMesh 30 : { 31 : 32 : // Forward declarations 33 : class PeriodicBoundaries; 34 : 35 : 36 : /** 37 : * This class implements the default algebraic coupling in libMesh: 38 : * elements couple to themselves, but may also couple to neighbors 39 : * both locally and across periodic boundary conditions. 40 : * 41 : * \author Roy H. Stogner 42 : * \date 2016 43 : */ 44 0 : class DefaultCoupling : public GhostingFunctor 45 : { 46 : public: 47 : 48 : /** 49 : * Constructor. 50 : */ 51 728304 : DefaultCoupling() : 52 705396 : _dof_coupling(nullptr), 53 : #ifdef LIBMESH_ENABLE_PERIODIC 54 705396 : _periodic_bcs(nullptr), 55 : #endif 56 728304 : _n_levels(0) 57 1736 : {} 58 : 59 : /** 60 : * Constructor. 61 : */ 62 31296 : DefaultCoupling(const DefaultCoupling & other) : 63 : GhostingFunctor(other), 64 31296 : _dof_coupling(other._dof_coupling), 65 : #ifdef LIBMESH_ENABLE_PERIODIC 66 31296 : _periodic_bcs(other._periodic_bcs), 67 : #endif 68 31296 : _n_levels(other._n_levels) 69 30356 : {} 70 : 71 : /** 72 : * A clone() is needed because GhostingFunctor can not be shared between 73 : * different meshes. The operations in GhostingFunctor are mesh dependent. 74 : */ 75 31296 : virtual std::unique_ptr<GhostingFunctor> clone () const override 76 31296 : { return std::make_unique<DefaultCoupling>(*this); } 77 : 78 : // Change coupling matrix after construction 79 : void set_dof_coupling(const CouplingMatrix * dof_coupling); 80 : 81 : // Return number of levels of neighbors we will couple. 82 11616 : unsigned int n_levels() 83 394797 : { return _n_levels; } 84 : 85 : // Change number of levels of neighbors to couple. 86 4364 : void set_n_levels(unsigned int n_levels) 87 1490795 : { _n_levels = n_levels; } 88 : 89 : #ifdef LIBMESH_ENABLE_PERIODIC 90 : // Set PeriodicBoundaries to couple 91 747742 : void set_periodic_boundaries(const PeriodicBoundaries * periodic_bcs) override 92 747742 : { _periodic_bcs = periodic_bcs; } 93 : 94 30266 : const PeriodicBoundaries * get_periodic_boundaries() override 95 30266 : { return _periodic_bcs; } 96 : #endif 97 : 98 : /** 99 : * If we have periodic boundaries, then we'll need the mesh to have 100 : * an updated point locator whenever we're about to query them. 101 : */ 102 : virtual void mesh_reinit () override; 103 : 104 132422 : virtual void redistribute () override 105 132422 : { this->mesh_reinit(); } 106 : 107 129815 : virtual void delete_remote_elements() override 108 129815 : { this->mesh_reinit(); } 109 : 110 : /** 111 : * For the specified range of active elements, find the elements 112 : * which will be coupled to them in the sparsity pattern. 113 : * 114 : * This will be only the elements themselves by default, but will 115 : * include side neighbors if an all-discontinuous-variable system is 116 : * detected and/or if the user specified --implicit_neighbor_dofs on 117 : * the command line or used set_implicit_neighbor_dofs() in their 118 : * code. 119 : */ 120 : virtual void operator() (const MeshBase::const_element_iterator & range_begin, 121 : const MeshBase::const_element_iterator & range_end, 122 : processor_id_type p, 123 : map_type & coupled_elements) override; 124 : 125 : private: 126 : 127 : const CouplingMatrix * _dof_coupling; 128 : #ifdef LIBMESH_ENABLE_PERIODIC 129 : const PeriodicBoundaries * _periodic_bcs; 130 : #endif 131 : unsigned int _n_levels; 132 : }; 133 : 134 : } // namespace libMesh 135 : 136 : #endif // LIBMESH_DEFAULT_COUPLING_H