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_ELEM_SIDE_BUILDER_H 21 : #define LIBMESH_ELEM_SIDE_BUILDER_H 22 : 23 : #include "libmesh/elem.h" 24 : 25 : namespace libMesh 26 : { 27 : 28 : /** 29 : * Helper for building element sides that minimizes the construction 30 : * of new elements. 31 : * 32 : * The building of element side pointers has the option to pass an 33 : * existing constructed element to avoid extraneous allocation. 34 : * If the element that is passed is of the correct type, the 35 : * build is done in place, that is, the nodes and subdomain are 36 : * done in place. 37 : * 38 : * This tool contains a cache with an entry per element type. 39 : * When a side is requested, the cached element of the desired 40 : * type is utilized. On first request of a side of a specific 41 : * type, the desired element is constructed. On all subsequent 42 : * calls for a side of the same type, the cached element is 43 : * used and the necessary members (nodes and subdomain) 44 : * are changed in place. 45 : * 46 : * NOTE: This tool is meant for on-the-fly use. Because 47 : * the cache is changed on each call, the references obtained 48 : * from previous calls should be considered invalid. 49 : */ 50 6346 : class ElemSideBuilder 51 : { 52 : public: 53 : /** 54 : * \returns an element side for side \p s of element \p elem. 55 : */ 56 : ///@{ 57 : Elem & operator()(Elem & elem, const unsigned int s); 58 : const Elem & operator()(const Elem & elem, const unsigned int s); 59 : ///@} 60 : 61 : private: 62 : /// Element cache for building sides; indexed by ElemType 63 : std::vector<std::unique_ptr<Elem>> _cached_elems; 64 : }; 65 : 66 : } // namespace libMesh 67 : 68 : #endif // LIBMESH_ELEM_SIDE_BUILDER_H