libMesh
multi_predicates.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #ifndef LIBMESH_MULTI_PREDICATES_H
19 #define LIBMESH_MULTI_PREDICATES_H
20 
21 // Local includes
22 #include "libmesh/single_predicates.h"
23 
24 // C++ includes
25 #include <vector>
26 
27 namespace libMesh {
28 class Elem;
29 }
30 
31 namespace libMesh
32 {
33 
34 // Forward declarations
35 class BoundaryInfo;
36 
45 namespace Predicates
46 {
47 
48 // Empty place-holder base class for multi_predicates
49 struct multi_predicate {};
50 
51 
52 // This class represents a generic combination of more than one predicate.
53 // It is meant to be derived from to actually be used.
54 template <typename T>
56 {
57  // virtual destructor.
59  {
60  // Clean-up vector
61  for (std::size_t i=0; i<_predicates.size(); ++i)
62  delete _predicates[i];
63  }
64 
65  // operator= (perform deep copy of entries in _predicates vector
67  {
68  // First clear out the predicates vector
69  for (std::size_t i=0; i<_predicates.size(); ++i)
70  delete _predicates[i];
71 
72  // Now copy over the information from the rhs.
73  this->deep_copy(rhs);
74 
75  return *this;
76  }
77 
78  // operator() checks all the predicates in the vector.
79  virtual bool operator()(const T & it) const
80  {
81  for (std::size_t i=0; i<_predicates.size(); ++i)
82  {
83  const predicate<T> * pred = _predicates[i];
84 
85  libmesh_assert (pred);
86 
87  if (!(*pred)(it))
88  return false;
89  }
90 
91  return true;
92  }
93 
94 protected:
95  // Do not instantiate the base class.
97 
98  // Copy constructor.
100  {
101  this->deep_copy(rhs);
102  }
103 
104  // The deep_copy function is used by both the op= and
105  // copy constructors. This function uses the default (empty)
106  // copy constructor for the predicate class.
108  {
109  for (std::size_t i=0; i<rhs._predicates.size(); ++i)
110  _predicates.push_back(rhs._predicates[i]->clone());
111  }
112 
113  // Predicates to be evaluated.
114  std::vector<predicate<T> *> _predicates;
115 };
116 
117 
118 
122 template <typename T>
124 {
125  // Constructor, pushes back a single predicate
127  {
128  this->_predicates.push_back(new is_null<T>);
129  }
130 };
131 
132 
133 
137 template <typename T>
139 {
140  // Constructor, pushes back a single predicate
142  {
143  this->_predicates.push_back(new not_null<T>);
144  }
145 };
146 
147 
148 
152 template <typename T>
154 {
155  // Constructor, pushes back two single predicates
157  {
158  this->_predicates.push_back(new not_null<T>);
159  this->_predicates.push_back(new active<T>);
160  }
161 };
162 
163 
164 
168 template <typename T>
170 {
171  // Constructor, pushes back two single predicates
173  {
174  this->_predicates.push_back(new not_null<T>);
175  this->_predicates.push_back(new not_active<T>);
176  }
177 };
178 
179 
180 
181 
186 template <typename T>
188 {
189  // Constructor, pushes back two single predicates
191  {
192  this->_predicates.push_back(new not_null<T>);
193  this->_predicates.push_back(new ancestor<T>);
194  }
195 };
196 
197 
198 
199 
204 template <typename T>
206 {
207  // Constructor, pushes back two single predicates
209  {
210  this->_predicates.push_back(new not_null<T>);
211  this->_predicates.push_back(new not_ancestor<T>);
212  }
213 };
214 
215 
216 
217 
222 template <typename T>
224 {
225  // Constructor, pushes back two single predicates
227  {
228  this->_predicates.push_back(new not_null<T>);
229  this->_predicates.push_back(new subactive<T>);
230  }
231 };
232 
233 
234 
235 
240 template <typename T>
242 {
243  // Constructor, pushes back two single predicates
245  {
246  this->_predicates.push_back(new not_null<T>);
247  this->_predicates.push_back(new not_subactive<T>);
248  }
249 };
250 
251 
252 
257 template <typename T>
259 {
260  // Constructor, pushes back two single predicates
262  {
263  this->_predicates.push_back(new not_null<T>);
264  this->_predicates.push_back(new pid<T>(my_pid));
265  }
266 };
267 
268 
278 // template <typename T>
279 // struct SemiLocal : abstract_multi_predicate<T>
280 // {
281 // // Constructor, pushes back two single predicates
282 // SemiLocal(processor_id_type my_pid)
283 // {
284 // this->_predicates.push_back(new not_null<T>);
285 // this->_predicates.push_back(new not_subactive<T>);
286 // this->_predicates.push_back(new semilocal_pid<T>(my_pid));
287 // }
288 // };
289 
290 
295 template <typename T>
297 {
298  // Constructor, pushes back two single predicates
300  {
301  this->_predicates.push_back(new not_null<T>);
302  this->_predicates.push_back(new active<T>);
303  this->_predicates.push_back(new not_subactive<T>);
304  this->_predicates.push_back(new semilocal_pid<T>(my_pid));
305  }
306 };
307 
308 
314 template <typename T>
316 {
317  // Constructor, pushes back two single predicates
319  {
320  this->_predicates.push_back(new not_null<T>);
321  this->_predicates.push_back(new not_subactive<T>);
322  this->_predicates.push_back(new facelocal_pid<T>(my_pid));
323  }
324 };
325 
326 
327 
332 template <typename T>
334 {
335  // Constructor, pushes back two single predicates
337  {
338  this->_predicates.push_back(new not_null<T>);
339  this->_predicates.push_back(new not_pid<T>(my_pid));
340  }
341 };
342 
343 
348 template <typename T>
350 {
351  // Constructor, pushes back two single predicates
353  {
354  this->_predicates.push_back(new not_null<T>);
355  this->_predicates.push_back(new active<T>);
356  this->_predicates.push_back(new not_pid<T>(my_pid));
357  }
358 };
359 
360 
364 template <typename T>
366 {
368  {
369  this->_predicates.push_back(new not_null<T>);
370  this->_predicates.push_back(new elem_type<T>(type));
371  }
372 };
373 
374 
375 
379 template <typename T>
381 {
383  {
384  this->_predicates.push_back(new not_null<T>);
385  this->_predicates.push_back(new active<T>);
386  this->_predicates.push_back(new elem_type<T>(type));
387  }
388 };
389 
390 
391 
392 #ifdef LIBMESH_ENABLE_AMR
393 
397 template <typename T>
399 {
400  Flagged(unsigned char rflag)
401  {
402  this->_predicates.push_back(new not_null<T>);
403  this->_predicates.push_back(new flagged<T>(rflag));
404  }
405 };
406 
407 
408 
413 template <typename T>
415 {
416  FlaggedPID(unsigned char rflag, processor_id_type proc_id)
417  {
418  this->_predicates.push_back(new not_null<T>);
419  this->_predicates.push_back(new flagged<T>(rflag));
420  this->_predicates.push_back(new pid<T>(proc_id));
421  }
422 };
423 
424 #endif // LIBMESH_ENABLE_AMR
425 
426 
427 
428 
433 template <typename T>
435 {
437  {
438  this->_predicates.push_back(new not_null<T>);
439  this->_predicates.push_back(new active<T>);
440  this->_predicates.push_back(new pid<T>(proc_id));
441  }
442 };
443 
444 
445 
446 
447 
452 template <typename T>
454 {
456  {
457  this->_predicates.push_back(new not_null<T>);
458  this->_predicates.push_back(new active<T>);
459  this->_predicates.push_back(new pid<T>(my_pid));
460  }
461 };
462 
463 
464 
465 
466 
470 template <typename T>
472 {
474  {
475  this->_predicates.push_back(new not_null<T>);
476  this->_predicates.push_back(new pid<T>(proc_id));
477  }
478 };
479 
480 
481 
486 template <typename T>
488 {
489  BID(boundary_id_type bndry_id, const BoundaryInfo & bndry_info)
490  {
491  this->_predicates.push_back(new not_null<T>);
492  this->_predicates.push_back(new bid<T>(bndry_id, bndry_info));
493  }
494 };
495 
496 
497 
501 template <typename T>
503 {
504  BND(const BoundaryInfo & bndry_info)
505  {
506  this->_predicates.push_back(new not_null<T>);
507  this->_predicates.push_back(new bnd<T>(bndry_info));
508  }
509 };
510 
511 
512 
517 template <typename T>
519 {
521  {
522  this->_predicates.push_back(new not_null<T>);
523  this->_predicates.push_back(new not_pid<T>(proc_id));
524  }
525 };
526 
527 
528 
532 template <typename T>
534 {
535  Level(unsigned int l)
536  {
537  this->_predicates.push_back(new not_null<T>);
538  this->_predicates.push_back(new level<T>(l));
539  }
540 };
541 
542 
543 
548 template <typename T>
550 {
551  NotLevel(unsigned int l)
552  {
553  this->_predicates.push_back(new not_null<T>);
554  this->_predicates.push_back(new not_level<T>(l));
555  }
556 };
557 
558 
559 
564 template <typename T>
566 {
568  unsigned int l)
569  {
570  this->_predicates.push_back(new not_null<T>);
571  this->_predicates.push_back(new pid<T>(my_pid));
572  this->_predicates.push_back(new level<T>(l));
573  }
574 };
575 
576 
577 
582 template <typename T>
584 {
586  unsigned int l)
587  {
588  this->_predicates.push_back(new not_null<T>);
589  this->_predicates.push_back(new pid<T>(my_pid));
590  this->_predicates.push_back(new not_level<T>(l));
591  }
592 };
593 
594 
595 
600 template <typename T>
602 {
604  {
605  this->_predicates.push_back(new not_null<T>);
606  this->_predicates.push_back(new active<T>);
607  this->_predicates.push_back(new null_neighbor<T>);
608  }
609 };
610 
611 
612 
617 template <typename T>
619 {
621  {
622  this->_predicates.push_back(new boundary_side<T>);
623  }
624 };
625 
626 
627 
632 template <typename T>
634 {
636  subdomain_id_type subdomain_id)
637  {
638  this->_predicates.push_back(new not_null<T>);
639  this->_predicates.push_back(new active<T>);
640  this->_predicates.push_back(new pid<T>(my_pid));
641  this->_predicates.push_back(new subdomain<T>(subdomain_id));
642  }
643 };
644 
645 
646 
651 template <typename T>
653 {
655  {
656  this->_predicates.push_back(new not_null<T>);
657  this->_predicates.push_back(new active<T>);
658  this->_predicates.push_back(new subdomain<T>(subdomain_id));
659  }
660 };
661 
662 
663 
668 template <typename T>
670 {
671  ActiveSubdomainSet(std::set<subdomain_id_type> sset)
672  {
673  this->_predicates.push_back(new not_null<T>);
674  this->_predicates.push_back(new active<T>);
675  this->_predicates.push_back(new subdomain_set<T>(sset));
676  }
677 };
678 
679 
680 
685 template <typename T>
687 {
689  {
690  this->_predicates.push_back(new not_null<T>);
691  this->_predicates.push_back(new active<T>);
692  this->_predicates.push_back(new not_pid<T>(my_pid));
693  this->_predicates.push_back(new semilocal_pid<T>(my_pid));
694  }
695 };
696 
697 
698 
703 template <typename T>
705 {
707  const DofMap & dof_map,
708  unsigned int var_num = libMesh::invalid_uint)
709  {
710  this->_predicates.push_back(new not_null<T>);
711  this->_predicates.push_back(new active<T>);
712  this->_predicates.push_back(new pid<T>(my_pid));
713  this->_predicates.push_back(new evaluable<T>(dof_map, var_num));
714  }
715 };
716 
717 }
718 
719 
720 } // namespace libMesh
721 
722 #endif // LIBMESH_MULTI_PREDICATES_H
Ghost(processor_id_type my_pid)
FlaggedPID(unsigned char rflag, processor_id_type proc_id)
NotLocal(processor_id_type my_pid)
Used to iterate over non-NULL, elements of a given geometric type.
Used to iterate over non-NULL, active, local elements owned by a given processor. ...
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:184
Used to iterate over non-NULL, entries that have children (i.e.
BND(const BoundaryInfo &bndry_info)
Used to iterate over non-NULL, elements with a given refinement flag.
ActiveLocalSubdomain(processor_id_type my_pid, subdomain_id_type subdomain_id)
ActiveSubdomainSet(std::set< subdomain_id_type > sset)
Used to iterate over non-NULL elements of a specified (refinement) level.
ActiveSemiLocal(processor_id_type my_pid)
ElemType
Defines an enum for geometric element types.
uint8_t processor_id_type
Definition: id_types.h:99
Used to iterate over non-NULL, active elements on a given subdomain.
Used to iterate over non-NULL, active entries in a container.
Used to iterate over non-NULL local elements not of a specified (refinement) level.
The libMesh namespace provides an interface to certain functionality in the library.
Used to iterate over non-NULL entries in a container.
Used to iterate over NULL entries in a container.
libmesh_assert(j)
Evaluable(processor_id_type my_pid, const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
ActivePID(processor_id_type proc_id)
int8_t boundary_id_type
Definition: id_types.h:51
abstract_multi_predicate & operator=(const abstract_multi_predicate &rhs)
PID(processor_id_type proc_id)
Used to iterate over non-NULL, non-local entries in a container.
void deep_copy(const abstract_multi_predicate &rhs)
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:56
Used to iterate over non-NULL, elements with a given refinement flag belonging to a given processor...
Used to iterate over non-NULL, inactive entries in a container.
NotPID(processor_id_type proc_id)
std::vector< predicate< T > * > _predicates
PredBase * pred
The predicate object.
virtual bool operator()(const T &it) const
Used to iterate over non-NULL elements owned by a given processor.
Used to iterate over non-NULL, active elements owned by a given processor.
Used to iterate over non-NULL elements not of a specified (refinement) level.
LocalNotLevel(processor_id_type my_pid, unsigned int l)
ActiveLocal(processor_id_type my_pid)
Used to iterate over non-NULL, entries that have no children (i.e.
abstract_multi_predicate(const abstract_multi_predicate &rhs)
Flagged(unsigned char rflag)
Used to iterate over non-NULL elements on the boundary with a given ID.
Used to iterate over non-NULL, face-local entries (i.e.
Used to iterate over non-NULL elements not owned by a given processor.
Used to iterate over non-NULL, active, non-local entries in a container.
Local(processor_id_type my_pid)
Used to iterate over non-NULL, active elements whose subdomains are in a user-specified set...
FaceLocal(processor_id_type my_pid)
Used to iterate over non-NULL elements not owned by a given processor but semi-local to that processo...
Used to iterate over non-NULL, active elements which are on the boundary.
Used to iterate over non-NULL, local entries (i.e.
Used to iterate over non-NULL, subactive entries (i.e.
ActiveSubdomain(subdomain_id_type subdomain_id)
Used to iterate over non-NULL, semi-local entries (i.e.
Used to iterate over non-NULL elements on the boundary.
Used to iterate over non-NULL local elements with a specified (refinement) level. ...
ActiveNotLocal(processor_id_type my_pid)
BID(boundary_id_type bndry_id, const BoundaryInfo &bndry_info)
Used to iterate over non-NULL, active elements of a given geometric type.
LocalLevel(processor_id_type my_pid, unsigned int l)
Used to iterate over elements where solutions indexed by a given DofMap are evaluable for a given var...
Used to iterate over non-NULL, non-subactive entries (i.e.
Used to iterate over the sides of an element which are on the boundary of the Mesh.
Used to iterate over non-NULL, active elements with a given PID on a given subdomain.