/usr/include/libmesh/single_predicates.h is in libmesh-dev 0.7.1-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | // $Id: single_predicates.h 3874 2010-07-02 21:57:26Z roystgnr $
// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef __single_predicates_h__
#define __single_predicates_h__
#include <vector>
#include "enum_elem_type.h"
#include "id_types.h"
namespace libMesh
{
/**
* This file declares several predicates in the Predicates namespace. They
* are called "single predicates" since the purpose of each one is to act
* as a single functor which returns true or false depending on the result
* of the operator() function. The single predicates are used together
* as building blocks to create the "multi predicates" which can be found
* in the multi_predicates.h header file.
*
* @author John W. Peterson, 2004
*/
namespace Predicates
{
// Forward declaration
template <typename T> class abstract_multi_predicate;
// abstract single predicate. Derived classes must implement the clone()
// function. Be careful using it since it allocates memory! The clone()
// function is necessary since the predicate class has pure virtual
// functions.
template <typename T>
struct predicate
{
virtual ~predicate() {}
virtual bool operator()(const T& it) const = 0;
protected:
friend class abstract_multi_predicate<T>;
virtual predicate* clone() const = 0;
};
// The is_null predicate returns true if the underlying pointer is NULL.
template <typename T>
struct is_null : predicate<T>
{
virtual ~is_null() {}
virtual bool operator()(const T& it) const { return *it == NULL; }
protected:
virtual predicate<T>* clone() const { return new is_null<T>(*this); }
};
// The not_null predicate simply returns true if the pointer is not NULL.
template <typename T>
struct not_null : is_null<T>
{
virtual bool operator()(const T& it) const { return !is_null<T>::operator()(it); }
protected:
virtual predicate<T>* clone() const { return new not_null<T>(*this); }
};
// The active predicate returns true if the pointer is active.
template <typename T>
struct active : predicate<T>
{
virtual ~active() {}
virtual bool operator()(const T& it) const { return (*it)->active(); }
protected:
virtual predicate<T>* clone() const { return new active<T>(*this); }
};
// The not active predicate returns true when the pointer is inactive
template <typename T>
struct not_active : active<T>
{
virtual bool operator()(const T& it) const { return !active<T>::operator()(it); }
protected:
virtual predicate<T>* clone() const { return new not_active<T>(*this); }
};
// The ancestor predicate returns true if the pointer is ancestor.
template <typename T>
struct ancestor : predicate<T>
{
virtual ~ancestor() {}
virtual bool operator()(const T& it) const { return (*it)->ancestor(); }
protected:
virtual predicate<T>* clone() const { return new ancestor<T>(*this); }
};
// The not_ancestor predicate returns true when the pointer is not ancestor
template <typename T>
struct not_ancestor : ancestor<T>
{
virtual bool operator()(const T& it) const { return !ancestor<T>::operator()(it); }
protected:
virtual predicate<T>* clone() const { return new not_ancestor<T>(*this); }
};
// The subactive predicate returns true if the pointer is subactive.
template <typename T>
struct subactive : predicate<T>
{
virtual ~subactive() {}
virtual bool operator()(const T& it) const { return (*it)->subactive(); }
protected:
virtual predicate<T>* clone() const { return new subactive<T>(*this); }
};
// The not_subactive predicate returns true when the pointer is not subactive
template <typename T>
struct not_subactive : subactive<T>
{
virtual bool operator()(const T& it) const { return !subactive<T>::operator()(it); }
protected:
virtual predicate<T>* clone() const { return new not_subactive<T>(*this); }
};
// The pid predicate returns true if the pointers
// processor id matches a given processor id.
template <typename T>
struct pid : predicate<T>
{
// Constructor
pid(const unsigned int p) : _pid(p) {}
virtual ~pid() {}
// op()
virtual bool operator()(const T& it) const { return (*it)->processor_id() == _pid; }
protected:
virtual predicate<T>* clone() const { return new pid<T>(*this); }
const unsigned int _pid;
};
// The not_pid predicate returns ture if the pointers
// processor id does _not_ match p.
template <typename T>
struct not_pid : pid<T>
{
not_pid(const unsigned int p) : pid<T>(p) {}
virtual bool operator()(const T& it) const { return !pid<T>::operator()(it); }
protected:
virtual predicate<T>* clone() const { return new not_pid<T>(*this); }
};
// The elem_type predicate returns true if the pointers
// type matches the given type. Of course, this one can only
// be instantiated for objects which return Elem*s when dereferened.
template <typename T>
struct elem_type : predicate<T>
{
// Constructor
elem_type (const ElemType t) : _elem_type(t) {}
virtual ~elem_type() {}
virtual bool operator()(const T& it) const { return (*it)->type() == _elem_type; }
protected:
virtual predicate<T>* clone() const { return new elem_type<T>(*this); }
const ElemType _elem_type;
};
// The level predicate returns true if the pointers level
// matches the given level.
template <typename T>
struct level : predicate<T>
{
// Constructor
level (const unsigned int l) : _level(l) {}
virtual ~level() {}
virtual bool operator()(const T& it) const { return (*it)->level() == _level; }
protected:
virtual predicate<T>* clone() const { return new level<T>(*this); }
const unsigned int _level;
};
// The not_level predicate returns true if the pointers level
// _does not_ match the given level.
template <typename T>
struct not_level : level<T>
{
// Constructor
not_level(const unsigned int l) : level<T>(l) {}
virtual bool operator()(const T& it) const { return !level<T>::operator()(it); }
protected:
virtual predicate<T>* clone() const { return new not_level<T>(*this); }
};
// The null_neighbor predicate returns true if the pointer has any
// NULL neigbors.
template <typename T>
struct null_neighbor : predicate<T>
{
virtual ~null_neighbor() {}
virtual bool operator()(const T& it) const
{
return (*it)->on_boundary();
}
protected:
virtual predicate<T>* clone() const { return new null_neighbor<T>(*this); }
};
// This predicate simply forwards the work of determining whether
// a particular side is on the boundary to the iterator itself, which
// has more information.
template <typename T>
struct boundary_side : predicate<T>
{
virtual ~boundary_side() {}
virtual bool operator()(const T& it) const
{
return it.side_on_boundary();
}
protected:
virtual predicate<T>* clone() const { return new boundary_side<T>(*this); }
};
// The subdomain predicate returns true if the pointers
// subdimain id matches a given subdomain id.
template <typename T>
struct subdomain : predicate<T>
{
// Constructor
subdomain(const unsigned int sid) : _subdomain(sid) {}
virtual ~subdomain() {}
// op()
virtual bool operator()(const T& it) const { return (*it)->subdomain_id() == _subdomain; }
protected:
virtual predicate<T>* clone() const { return new subdomain<T>(*this); }
const subdomain_id_type _subdomain;
};
}
} // namespace libMesh
#endif
|