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 : // Local includes 19 : #include "libmesh/single_predicates.h" 20 : #include "libmesh/enum_elem_type.h" 21 : #include "libmesh/boundary_info.h" 22 : #include "libmesh/dof_map.h" 23 : #include "libmesh/distributed_mesh.h" 24 : 25 : namespace libMesh 26 : { 27 : 28 : namespace Predicates 29 : { 30 : 31 : // The bid predicate returns true if has_boundary_id(node, id) returns true. 32 : template <typename T> 33 : bool 34 0 : bid<T>::operator()(const T & it) const 35 : { 36 0 : return _bndry_info.has_boundary_id(*it, _bid); 37 : } 38 : 39 : 40 : // The bnd predicate returns true if n_boundary_ids(node) > 0. 41 : template <typename T> 42 : bool 43 0 : bnd<T>::operator()(const T & it) const 44 : { 45 0 : return (_bndry_info.n_boundary_ids(*it) > 0); 46 : } 47 : 48 : template <typename T> 49 : bool 50 10129 : evaluable<T>::operator()(const T & it) const 51 : { 52 10129 : return _dof_map.is_evaluable(**it, _var_num); 53 : } 54 : 55 : template <typename T> 56 : bool 57 198 : multi_evaluable<T>::operator()(const T & it) const 58 : { 59 424 : for (const auto * const dof_map : _dof_maps) 60 : { 61 28 : libmesh_assert(dof_map); 62 316 : if (!dof_map->is_evaluable(**it)) 63 9 : return false; 64 : } 65 : 66 9 : return true; 67 : } 68 : 69 : 70 : // Instantiate with the useful values of T 71 : #define INSTANTIATE_NODAL_PREDICATES(IterType) \ 72 : template LIBMESH_EXPORT bool bid<IterType>::operator()(const IterType &) const; \ 73 : template LIBMESH_EXPORT bool bnd<IterType>::operator()(const IterType &) const; \ 74 : template LIBMESH_EXPORT bool evaluable<IterType>::operator()(const IterType &) const; \ 75 : template LIBMESH_EXPORT bool multi_evaluable<IterType>::operator()(const IterType &) const 76 : 77 : #define INSTANTIATE_ELEM_PREDICATES(IterType) \ 78 : template LIBMESH_EXPORT bool evaluable<IterType>::operator()(const IterType &) const; \ 79 : template LIBMESH_EXPORT bool multi_evaluable<IterType>::operator()(const IterType &) const 80 : 81 : // Handle commas in macro arguments 82 : #define LIBMESH_COMMA , 83 : 84 : // This should probably be replaced with 85 : // FooMesh::element_iterator_imp, etc 86 : INSTANTIATE_ELEM_PREDICATES(std::vector<Elem *>::iterator); 87 : INSTANTIATE_ELEM_PREDICATES(std::vector<Elem *>::const_iterator); 88 : INSTANTIATE_NODAL_PREDICATES(std::vector<Node *>::iterator); 89 : INSTANTIATE_NODAL_PREDICATES(std::vector<Node *>::const_iterator); 90 : INSTANTIATE_ELEM_PREDICATES(DistributedMesh::dofobject_container<Elem>::veclike_iterator); 91 : INSTANTIATE_ELEM_PREDICATES(DistributedMesh::dofobject_container<Elem>::const_veclike_iterator); 92 : INSTANTIATE_NODAL_PREDICATES(DistributedMesh::dofobject_container<Node>::veclike_iterator); 93 : INSTANTIATE_NODAL_PREDICATES(DistributedMesh::dofobject_container<Node>::const_veclike_iterator); 94 : 95 : 96 : } // namespace Predicates 97 : 98 : } // namespace libMesh