OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BCond.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef BCOND_H
12 #define BCOND_H
13 
14 // include files
15 #include "AppTypes/dcomplex.h"
16 #include "Utility/RefCounted.h"
17 #include "Utility/vmap.h"
18 
19 #include <iostream>
20 
21 // forward declarations
22 template <unsigned D> class NDIndex;
23 template <class T, unsigned D> class Vektor;
24 template <class T, unsigned D> class Tenzor;
25 template <class T, unsigned D> class SymTenzor;
26 template <class T, unsigned D> class AntiSymTenzor;
27 template<unsigned D, class T> class UniformCartesian;
28 template<class T, unsigned D> class LField;
29 template<class T, unsigned D> class BareField;
30 template<class T, unsigned D, class M, class C> class Field;
31 template <class T, unsigned D, class M, class C> class BCondBase;
32 template <class T, unsigned D, class M, class C>
33 std::ostream& operator<<(std::ostream&, const BCondBase<T,D,M,C>&);
34 template <class T, unsigned D, class M, class C> class BConds;
35 template <class T, unsigned D, class M, class C>
36 std::ostream& operator<<(std::ostream&, const BConds<T,D,M,C>&);
37 
39 
40 //
41 // Traits used by the single-component version of the applicative templates.
42 // General case: this covers intrinsic types like double, bool automatically:
43 //
44 
45 template<class T>
47 {
48  typedef T type;
49 };
50 
51 //
52 // Specializations for multicomponent IPPL types;
53 //
54 template<class T,unsigned D>
56 {
57  typedef T type;
58 };
59 
60 template<class T,unsigned D>
62 {
63  typedef T type;
64 };
65 
66 template<class T,unsigned D>
68 {
69  typedef T type;
70 };
71 
72 template<class T,unsigned D>
74 {
75  typedef T type;
76 };
77 
78 // Helper classes for getting info about number of indices into
79 // BCond-class ctor functions.
80 // Define tag types (like iterator tags in stl):
81 
83 {
84 #ifdef IPPL_PURIFY
85 public:
86  scalar_tag() {}
87  scalar_tag(const scalar_tag &) {}
88  scalar_tag& operator=(const scalar_tag &) { return *this; }
89 #endif
90 };
91 
93 {
94 #ifdef IPPL_PURIFY
95 public:
96  vektor_tag() {}
97  vektor_tag(const vektor_tag &) {}
98  vektor_tag& operator=(const vektor_tag &) { return *this; }
99 #endif
100 };
101 
103 {
104 #ifdef IPPL_PURIFY
105 public:
106  tenzor_tag() {}
107  tenzor_tag(const tenzor_tag &) {}
108  tenzor_tag& operator=(const tenzor_tag &) { return *this; }
109 #endif
110 };
111 
113 {
114 #ifdef IPPL_PURIFY
115 public:
116  symtenzor_tag() {}
117  symtenzor_tag(const symtenzor_tag &) {}
118  symtenzor_tag& operator=(const symtenzor_tag &) { return *this; }
119 #endif
120 };
121 
123 {
124 #ifdef IPPL_PURIFY
125 public:
126  antisymtenzor_tag() {}
128  antisymtenzor_tag& operator=(const antisymtenzor_tag &) { return *this; }
129 #endif
130 };
131 
132 // Implement tag types for intrinsic types:
133 inline scalar_tag get_tag(dcomplex) { return scalar_tag(); }
134 inline scalar_tag get_tag(double) { return scalar_tag(); }
135 inline scalar_tag get_tag(float) { return scalar_tag(); }
136 inline scalar_tag get_tag(int) { return scalar_tag(); }
137 inline scalar_tag get_tag(bool) { return scalar_tag(); }
138 inline scalar_tag get_tag(short) { return scalar_tag(); }
139 
140 // Tag for Vektor types:
141 template<class T, unsigned D>
142 inline vektor_tag
144 
145 // Tag for Tenzor types:
146 template<class T, unsigned D>
147 inline tenzor_tag
149 
150 // Tag for AntiSymTenzor types
151 template<class T, unsigned D>
152 inline antisymtenzor_tag
154 
155 // Tag for SymTenzor types
156 template<class T, unsigned D>
157 inline symtenzor_tag
159 
160 // Functions which return an enum value indicating scalar, vector, tensor,
161 // or anti/symtensor type; used in constructors for PeriodicFace, etc., to
162 // determine how to turn two 1D component indices into a single index value
163 // for pointer offsetting into the Tenzor/Anti/SymTenzor object:
167 {return IPPL_SCALAR;}
169 {return IPPL_VECTOR;}
171 {return IPPL_TENSOR;}
173 {return IPPL_ANTISYMTENSOR;}
175 {return IPPL_SYMTENSOR;}
176 
178 
179 template<class T, unsigned D, class M, class C>
180 class BCondBase : public RefCounted
181 {
182 public:
183 
184  // Special value designating application to all components of elements:
185  static int allComponents;
186 
187  // Constructor takes:
188  // face: the face to apply the boundary condition on.
189  // i,j : what component of T to apply the boundary condition to.
190  // The components default to setting all components.
191  BCondBase(unsigned int face,
192  int i = allComponents,
193  int j = allComponents);
194  virtual ~BCondBase() { }
195 
196  virtual void apply( Field<T,D,M,C>& ) = 0;
197  virtual BCondBase<T,D,M,C>* clone() const = 0;
198 
199  // The convert_type() implementation is commented out, since it doesn't
200  // work in general. If nobody really needs it, it will eventually be
201  // eliminated; if somebody needs it, somebody needs to do a new
202  // implementation. --TJW
203  // virtual BCondBase<int,D,M,C>* convert_type(int) const = 0;
204  virtual void write(std::ostream&) const;
205 
206  // Return component of Field element on which BC applies
207  int getComponent() const { return m_component; }
208 
209  // Return face on which BC applies
210  unsigned int getFace() const { return m_face; }
211 
212  // Returns whether or not this BC changes physical cells.
213  bool changesPhysicalCells() const { return m_changePhysical; }
214 
215 protected:
216 
217  // Following are hooks for BC-by-Field-element-component support:
218  // Component of Field elements (Vektor, e.g.) on which the BC applies:
220 
221  // What face to apply the boundary condition to.
222  unsigned int m_face;
223 
224  // True if this boundary condition changes physical cells.
226 };
227 
229 
230 template<
231  class T,
232  unsigned D,
234  class C=typename M::DefaultCentering>
235 class BConds
236  : public vmap<int, RefCountedP< BCondBase<T,D,M,C> > >
237 {
238 public:
243  // See comments in BCondBase class definition regarding convert_type() --TJW
244  // BConds<int,D,M,C>* convert_type(int) const ;
245  void apply( Field<T,D,M,C>& a );
246  bool changesPhysicalCells() const;
247  virtual void write(std::ostream&) const;
248 };
249 
251 
252 // TJW: so far, componentwise specification of BCondNoAction not possible
253 
254 template<class T,
255  unsigned D,
257  class C=typename M::DefaultCentering>
258 class BCondNoAction : public BCondBase<T,D,M,C>
259 {
260 public:
261  BCondNoAction(int face) : BCondBase<T,D,M,C>(face) {}
262 
263  virtual void apply( Field<T,D,M,C>& ) {}
265  {
266  return new BCondNoAction<T,D,M,C>( *this );
267  }
268 
269  // Print out information about the BC to a stream.
270  virtual void write(std::ostream& out) const;
271 };
272 
274 
275 template<class T,
276  unsigned D,
278  class C=typename M::DefaultCentering>
279 class PeriodicFace : public BCondBase<T,D,M,C>
280 {
281 public:
282  // Constructor takes zero, one, or two int's specifying components of
283  // multicomponent types like Vektor/Tenzor/Anti/SymTenzor this BC applies to.
284  // Zero int's specified means apply to all components; one means apply to
285  // component (i), and two means apply to component (i,j),
287 
288  PeriodicFace(unsigned f,
291 
292  // Apply the boundary condition to a particular Field.
293  virtual void apply( Field<T,D,M,C>& );
294 
295  // Make a copy of the concrete type.
296  virtual BCondBase<T,D,M,C>* clone() const
297  {
298  return new PeriodicFace<T,D,M,C>( *this );
299  }
300 
301  // Print out information about the BC to a stream.
302  virtual void write(std::ostream& out) const;
303 };
304 
305 
306 
308 //BENI adds Periodic Boundary Conditions for Interpolations///////////
310 template<class T,
311  unsigned D,
313  class C=typename M::DefaultCentering>
314 class InterpolationFace : public BCondBase<T,D,M,C>
315 {
316 public:
317  // Constructor takes zero, one, or two int's specifying components of
318  // multicomponent types like Vektor/Tenzor/Anti/SymTenzor this BC applies to.
319  // Zero int's specified means apply to all components; one means apply to
320  // component (i), and two means apply to component (i,j),
322 
323  InterpolationFace(unsigned f,
326 
327  // Apply the boundary condition to a particular Field.
328  virtual void apply( Field<T,D,M,C>& );
329 
330  // Make a copy of the concrete type.
331  virtual BCondBase<T,D,M,C>* clone() const
332  {
333  return new InterpolationFace<T,D,M,C>( *this );
334  }
335 
336  // Print out information about the BC to a stream.
337  virtual void write(std::ostream& out) const;
338 };
339 
341 
342 template<class T, unsigned D,
344  class C=typename M::DefaultCentering>
345 class ParallelPeriodicFace : public PeriodicFace<T,D,M,C>
346 {
347 public:
348 
349  // Constructor takes zero, one, or two int's specifying components
350  // of multicomponent types like Vektor/Tenzor/AntiTenzor/SymTenzor
351  // this BC applies to. Zero int's means apply to all components;
352  // one means apply to component (i), and two means apply to
353  // component (i,j),
354 
356 
357  ParallelPeriodicFace(unsigned f,
358  int i = Base_t::allComponents,
359  int j = Base_t::allComponents)
360  : PeriodicFace<T,D,M,C>(f,i,j)
361  { }
362 
363  // Apply the boundary condition to a particular Field.
364 
365  virtual void apply( Field<T,D,M,C>& );
366 
367  // Make a copy of the concrete type.
368 
369  virtual Base_t * clone() const
370  {
371  return new ParallelPeriodicFace<T,D,M,C>( *this );
372  }
373 
374  // Print out information about the BC to a stream.
375 
376  virtual void write(std::ostream& out) const;
377 };
378 
380 
381 
383 // BENI adds parallel Interpolation Face
385 
386 template<class T, unsigned D,
388  class C=typename M::DefaultCentering>
390 {
391 public:
392 
393  // Constructor takes zero, one, or two int's specifying components
394  // of multicomponent types like Vektor/Tenzor/AntiTenzor/SymTenzor
395  // this BC applies to. Zero int's means apply to all components;
396  // one means apply to component (i), and two means apply to
397  // component (i,j),
398 
400 
402  int i = Base_t::allComponents,
403  int j = Base_t::allComponents)
404  : InterpolationFace<T,D,M,C>(f,i,j)
405  { }
406 
407  // Apply the boundary condition to a particular Field.
408 
409  virtual void apply( Field<T,D,M,C>& );
410 
411  // Make a copy of the concrete type.
412 
413  virtual Base_t * clone() const
414  {
415  return new ParallelInterpolationFace<T,D,M,C>( *this );
416  }
417 
418  // Print out information about the BC to a stream.
419 
420  virtual void write(std::ostream& out) const;
421 };
422 
424 
425 
426 template<class T,
427  unsigned D,
429  class C=typename M::DefaultCentering>
430 class ExtrapolateFace : public BCondBase<T,D,M,C>
431 {
432 public:
433  // Constructor takes zero, one, or two int's specifying components of
434  // multicomponent types like Vektor/Tenzor/Anti/SymTenzor this BC applies to.
435  // Zero int's specified means apply to all components; one means apply to
436  // component (i), and two means apply to component (i,j),
438  ExtrapolateFace(unsigned f, T o, T s,
441 
442  // Apply the boundary condition to a given Field.
443  virtual void apply( Field<T,D,M,C>& );
444 
445  // Make a copy of the concrete type.
446  virtual BCondBase<T,D,M,C>* clone() const
447  {
448  return new ExtrapolateFace<T,D,M,C>( *this );
449  }
450 
451  // Print out some information about the BC to a given stream.
452  virtual void write(std::ostream&) const;
453 
454  const T& getOffset() const { return Offset; }
455  const T& getSlope() const { return Slope; }
456 
457 protected:
459 };
460 
461 
463 
464 // TJW added 12/16/1997 as per Tecolote team's request: this one sets last
465 // physical element layer to zero for vert-centered elements/components. For
466 // cell-centered, doesn't need to do this because the zero point of an odd
467 // function is halfway between the last physical element and the first guard
468 // element.
469 
470 template<class T,
471  unsigned D,
473  class C=typename M::DefaultCentering>
474 class ExtrapolateAndZeroFace : public BCondBase<T,D,M,C>
475 {
476 public:
477  // Constructor takes zero, one, or two int's specifying components of
478  // multicomponent types like Vektor/Tenzor/Anti/SymTenzor this BC applies to.
479  // Zero int's specified means apply to all components; one means apply to
480  // component (i), and two means apply to component (i,j),
482  ExtrapolateAndZeroFace(unsigned f, T o, T s,
485 
486  // Apply the boundary condition to a given Field.
487  virtual void apply( Field<T,D,M,C>& );
488 
489  // Make a copy of the concrete type.
490  virtual BCondBase<T,D,M,C>* clone() const
491  {
492  return new ExtrapolateAndZeroFace<T,D,M,C>( *this );
493  }
494 
495  // Print out some information about the BC to a given stream.
496  virtual void write(std::ostream&) const;
497 
498  const T& getOffset() const { return Offset; }
499  const T& getSlope() const { return Slope; }
500 
501 protected:
503 };
504 
505 
507 
508 template<class T,
509  unsigned D,
511  class C=typename M::DefaultCentering>
512 class PosReflectFace : public ExtrapolateFace<T,D,M,C>
513 {
514 public:
516  PosReflectFace(unsigned f,
519  : ExtrapolateFace<T,D,M,C>(f,0,1,i,j) {}
520 
521  // Print out information about the BC to a stream.
522  virtual void write(std::ostream& out) const;
523 };
524 
526 
527 template<class T,
528  unsigned D,
530  class C=typename M::DefaultCentering>
531 class NegReflectFace : public ExtrapolateFace<T,D,M,C>
532 {
533 public:
535  NegReflectFace(unsigned f,
538  : ExtrapolateFace<T,D,M,C>(f,0,-1,i,j) {}
539 
540  // Print out information about the BC to a stream.
541  virtual void write(std::ostream& out) const;
542 };
543 
545 
546 // TJW added 12/16/1997 as per Tecolote team's request: this one sets last
547 // physical element layer to zero for vert-centered elements/components. For
548 // cell-centered, doesn't need to do this because the zero point of an odd
549 // function is halfway between the last physical element and the first guard
550 // element.
551 
552 template<class T,
553  unsigned D,
555  class C=typename M::DefaultCentering>
557 {
558 public:
563  : ExtrapolateAndZeroFace<T,D,M,C>(f,0,-1,i,j) {}
564 
565  // Print out information about the BC to a stream.
566  virtual void write(std::ostream& out) const;
567 };
568 
570 
571 template<class T,
572  unsigned D,
574  class C=typename M::DefaultCentering>
575 class ConstantFace : public ExtrapolateFace<T,D,M,C>
576 {
577 public:
579  ConstantFace(unsigned f, T c,
582  : ExtrapolateFace<T,D,M,C>(f,c,0,i,j) {}
583 
584  // Print out information about the BC to a stream.
585  virtual void write(std::ostream& out) const;
586 };
587 
589 
590 template<class T,
591  unsigned D,
593  class C=typename M::DefaultCentering>
594 class ZeroFace : public ExtrapolateFace<T,D,M,C>
595 {
596 public:
598  ZeroFace(unsigned f,
601  : ExtrapolateFace<T,D,M,C>(f,0,0,i,j) {}
602 
603  // Print out information about the BC to a stream.
604  virtual void write(std::ostream& out) const;
605 };
606 
608 
609 // TJW added 1/25/1998 as per Blanca's (Don Marshal's, for the Lagrangian
610 // code) request: this one sets last physical element layer to zero for
611 // vert-centered elements/components. For cell-centered, doesn't need to do
612 // this because the zero point of an odd function is halfway between the last
613 // physical element and the first guard element.
614 
615 template<class T,
616  unsigned D,
618  class C=typename M::DefaultCentering>
620 {
621 public:
626  : ExtrapolateAndZeroFace<T,D,M,C>(f,0,0,i,j) {}
627 
628  // Print out information about the BC to a stream.
629  virtual void write(std::ostream& out) const;
630 };
631 
633 
634 //-----------------------------------------------------------------------------
635 // Had to depart from the paradigm of the other boundary condition types to
636 // implement FunctionFace. Couldn't use the same single FunctionFace class for
637 // both whole-Field-element and componentwise functions, because the return
638 // of the user-provided function has to be different for the two cases.
639 // Instead, left FunctionFace as whole-element-only (no component specification
640 // allowed) and introduced new ComponentFunctionFace for componentwise,
641 // disallowing via runtime error the allComponents specification allowed in all
642 // the other BC types. --Tim Williams 3/31/1997
643 //-----------------------------------------------------------------------------
644 
645 template<class T,
646  unsigned D,
648  class C=typename M::DefaultCentering>
649 class FunctionFace : public BCondBase<T,D,M,C>
650 {
651 public:
652  // Constructor does *not* allow extra one or two arguments specifying
653  // components of multicomponent types, as PeriodicFace and all other BC types
654  // here do; user must use ComponentFunctionFace for these cases. This
655  // constructor only takes the takes arguments for the user-supplied function
656  // and for the active face on the mesh to which this BC applies. The function
657  // must have return type T (can't return single components; must use the
658  // other class ComponentFunctionFace to do this):
659  FunctionFace(T (*func)(const T&), unsigned face);
660 
661  void apply( Field<T,D,M,C>& );
662 
664  {
665  return new FunctionFace<T,D,M,C>( *this );
666  }
667  // See comments in BCondBase class definition regarding convert_type() --TJW
668  // BCondBase<int,D,M,C>* convert_type(int) const
669  // {
670  // assert(false);
671  // return 0;
672  // }
673 
674  // Print out information about the BC to a stream.
675  virtual void write(std::ostream& out) const;
676 
677  // tjw 3/12/1999: see below
678  T (*Func)(const T&);
679 
680 private:
681  // tjw 3/12/1999; had to make this public for test/simple/bc2.cpp to work:
682  // T (*Func)(T&);
683 };
684 
686 
687 template<class T,
688  unsigned D,
690  class C=typename M::DefaultCentering>
691 class ComponentFunctionFace : public BCondBase<T,D,M,C>
692 {
693 public:
694  // In addition to arguments for FunctionFace, this constructor takes
695  // one, or two unsigned's specifying components of multicomponent types like
696  // Vektor/Tenzor/Anti/SymTenzor this BC applies to.
697  // One unsigned means apply to component (i), and two means apply to
698  // component (i,j). Note: unlike all other non-FunctionFace BC types here,
699  // you *can't* specify nothing or BCondBase<T,D,M,C>::allComponents to
700  // indicate all components; you *must* use FunctionFace class for doing
701  // all components.
702  // ComponentFunctionFace() will give a runtime error if you try to construct
703  // it for all components (which it defaults to, meaning the default is a
704  // runtime error, which should probably be changed some time if somebody can
705  // figure out how). This is not as bad as you might think, though; most
706  // likely the user would be specifying T as the return type of his supplied
707  // function when he is trying to do the all-component case, in which he'd
708  // get a compile error on the type of the constructor argument Func.
711  (*func)( typename ApplyToComponentType<T>::type),
712  unsigned face,
715 
716  void apply( Field<T,D,M,C>& );
717 
719  {
720  return new ComponentFunctionFace<T,D,M,C>( *this );
721  }
722  // See comments in BCondBase class definition regarding convert_type() --TJW
723  // BCondBase<int,D,M,C>* convert_type(int) const
724  // {
725  // assert(false);
726  // return 0;
727  // }
728 
729  // Print out information about the BC to a stream.
730  virtual void write(std::ostream& out) const;
731 
732  // tjw 3/12/1999: see below
735 
736 private:
737  // tjw 3/12/1999; had to make this public for test/simple/bc2.cpp to work:
738  // typename ApplyToComponentType<T>::type
739  // (*Func)( typename ApplyToComponentType<T>::type );
740 };
741 
743 
744 /*
745  Special for Conejo: The Eureka boundary condition.
746 
747  This is an augmented zero boundary condition which sets
748  more locations to zero for some cases.
749 
750  Instead of setting just the guard layers to zero, it sets the guard
751  layers plus one to zero in all cases except one:
752  Face centered data (which as all but one dimension cell centered),
753  on the directions in which it is cell centered.
754 
755 */
756 
757 template<class T,
758  unsigned D,
760  class C=typename M::DefaultCentering>
761 class EurekaFace : public BCondBase<T,D,M,C>
762 {
763 public:
764  // Constructor takes:
765  // face: the face to apply the boundary condition on.
766  // i,j : what component of T to apply the boundary condition to.
767  // The components default to setting all components.
768  // All it has to do is tell the base class to set itself up.
770  EurekaFace(unsigned int face,
773  : BCondBase<T,D,M,C>(face,i,j) { BCondBase<T,D,M,C>::m_changePhysical = true; }
774 
775  // Apply the boundary condition to a given Field.
776  virtual void apply( Field<T,D,M,C>& ) ;
777 
778  // Make a copy of one of these.
780  {
781  return new EurekaFace<T,D,M,C>(*this);
782  }
783 
784  // Print out information about the BC to a stream.
785  virtual void write(std::ostream& out) const;
786 
787 };
788 
790 
791 // ----------------------------------------------------------------------------
792 // TJW added 1/26/1998 as per Blanca's (Jerry Brock's, for the tracer particle
793 // code) request: this one takes the values of the last two physical elements,
794 // and linearly extrapolates from the line through them out to all the guard
795 // elements. This is independent of centering. The intended use is for filling
796 // global guard layers of a Field of Vektors holding the mesh node position
797 // values, for which this does the right thing at hi and lo faces (exactly
798 // right for uniform cartesian meshes, and a reasonable thing to do for
799 // nonuniform cartesian meshes).
800 //
801 // Had to depart from the paradigm of the other boundary condition types to
802 // implement LinearExtrapolateFace. Couldn't use the same single
803 // LinearExtrapolateFace class for both whole-Field-element and componentwise
804 // functions, because I couldn't figure out how to implement it using PETE and
805 // applicative templates. Instead, created LinearExtrapolateFace as
806 // whole-element-only (no component specification allowed) and separate
807 // ComponentLinearExtrapolateFace for componentwise, disallowing via runtime
808 // error the allComponents specification allowed in all the other BC
809 // types. --Tim Williams 1/26/1999
810 // ----------------------------------------------------------------------------
811 
812 template<class T,
813  unsigned D,
815  class C=typename M::DefaultCentering>
816 class LinearExtrapolateFace : public BCondBase<T,D,M,C>
817 {
818 public:
819  // Constructor takes zero, one, or two int's specifying components of
820  // multicomponent types like Vektor/Tenzor/Anti/SymTenzor this BC applies to.
821  // Zero int's specified means apply to all components; one means apply to
822  // component (i), and two means apply to component (i,j),
824  LinearExtrapolateFace(unsigned f) :
825  BCondBase<T,D,M,C>(f) {}
826 
827  // Apply the boundary condition to a given Field.
828  virtual void apply( Field<T,D,M,C> &A);
829 
830  // Make a copy of the concrete type.
831  virtual BCondBase<T,D,M,C>* clone() const
832  {
833  return new LinearExtrapolateFace<T,D,M,C>( *this );
834  }
835 
836  // Print out some information about the BC to a given stream.
837  virtual void write(std::ostream&) const;
838 
839 };
840 
841 
842 template<class T,
843  unsigned D,
845  class C=typename M::DefaultCentering>
847 {
848 public:
849  // Constructor takes zero, one, or two int's specifying components of
850  // multicomponent types like Vektor/Tenzor/Anti/SymTenzor this BC applies to.
851  // Zero int's specified means apply to all components; one means apply to
852  // component (i), and two means apply to component (i,j),
857  BCondBase<T,D,M,C>(f,i,j) {
858  // Disallow specification of all components (default, unfortunately):
859  if ( (j == BCondBase<T,D,M,C>::allComponents) &&
861  ERRORMSG("ComponentLinearExtrapolateFace(): allComponents specified; "
862  << "not allowed; use LinearExtrapolateFace "
863  << "class instead." << endl);
864  }
865 
866  // Apply the boundary condition to a given Field.
867  virtual void apply( Field<T,D,M,C> &A);
868 
869  // Make a copy of the concrete type.
870  virtual BCondBase<T,D,M,C>* clone() const
871  {
872  return new ComponentLinearExtrapolateFace<T,D,M,C>( *this );
873  }
874 
875  // Print out some information about the BC to a given stream.
876  virtual void write(std::ostream&) const;
877 
878 };
879 
880 
882 
883 template<class T,
884  unsigned D,
886  class C=typename M::DefaultCentering>
887 class PatchBC : public BCondBase<T,D,M,C>
888 {
889 public:
890 
891  //
892  // Initialize with a functor and the face to apply that functor to.
893  //
894  PatchBC(unsigned face);
895 
896  //
897  // Virtual function to apply this BC to a Field.
898  //
899  void apply( Field<T,D,M,C>& );
900 
901  //
902  // Virtual function for the user to supply to apply this BC to
903  // a given vnode.
904  //
905  virtual void applyPatch(typename Field<T,D,M,C>::iterator,
906  const NDIndex<D>&) = 0;
907 
908  //
909  // Print out information about the BC to a stream.
910  //
911  virtual void write(std::ostream& out) const
912  {
913  out << "PatchBC(" << this->getFace() << ")";
914  }
915 
916 private:
917 
918 };
919 
921 
922 //
923 // Define global streaming functions that just call the
924 // write function for each of the above base classes.
925 //
926 
927 template<class T, unsigned D, class M, class C >
928 inline std::ostream&
929 operator<<(std::ostream& o, const BCondBase<T,D,M,C>& bc)
930 {
931  bc.write(o);
932  return o;
933 }
934 
935 
936 template<class T, unsigned D, class M, class C >
937 inline std::ostream&
938 operator<<(std::ostream& o, const BConds<T,D,M,C>& bc)
939 {
940  bc.write(o);
941  return o;
942 }
943 
945 
946 #include "Field/BCond.hpp"
947 
948 #endif // BCOND_H
949 
950 /***************************************************************************
951  * $RCSfile: BCond.h,v $ $Author: adelmann $
952  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
953  * IPPL_VERSION_ID: $Id: BCond.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
954  ***************************************************************************/
virtual Base_t * clone() const
Definition: BCond.h:413
scalar_tag get_tag(dcomplex)
Definition: BCond.h:133
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:769
virtual void apply(Field< T, D, M, C > &A)
Definition: BCond.hpp:5843
virtual void write(std::ostream &out) const
virtual void write(std::ostream &out) const
Definition: BCond.hpp:205
virtual void apply(Field< T, D, M, C > &)=0
virtual BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:331
unsigned int m_face
Definition: BCond.h:222
PatchBC(unsigned face)
Definition: BCond.hpp:6192
NegReflectFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:535
Definition: TSVMeta.h:24
Definition: rbendmap.h:8
void apply(Field< T, D, M, C > &a)
Definition: BCond.hpp:273
ParallelInterpolationFace(unsigned f, int i=Base_t::allComponents, int j=Base_t::allComponents)
Definition: BCond.h:401
virtual BCondBase< T, D, M, C > * clone() const =0
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:597
virtual void write(std::ostream &out) const
Definition: BCond.h:911
virtual void write(std::ostream &) const
Definition: BCond.hpp:222
LinearExtrapolateFace(unsigned f)
Definition: BCond.h:824
BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:779
virtual ~BCondBase()
Definition: BCond.h:194
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:481
#define ERRORMSG(msg)
Definition: IpplInfo.h:399
virtual void write(std::ostream &out) const
Definition: BCond.hpp:172
virtual BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:831
EurekaFace(unsigned int face, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:770
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:515
ExtrapolateFace(unsigned f, T o, T s, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.hpp:315
BCondBase< T, D, M, C > Base_t
Definition: BCond.h:355
BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:264
Definition: FFT.h:31
std::complex< double > dcomplex
Definition: dcomplex.h:30
TensorOrder_e
Definition: BCond.h:164
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:5409
int getComponent() const
Definition: BCond.h:207
virtual void applyPatch(typename Field< T, D, M, C >::iterator, const NDIndex< D > &)=0
NegReflectAndZeroFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:560
InterpolationFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.hpp:307
Definition: BCond.h:34
virtual BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:296
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:534
ComponentLinearExtrapolateFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:854
virtual void write(std::ostream &) const
Definition: BCond.hpp:122
virtual void write(std::ostream &) const
Definition: BCond.hpp:241
virtual void write(std::ostream &) const
Definition: BCond.hpp:212
ZeroFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:598
ParallelPeriodicFace(unsigned f, int i=Base_t::allComponents, int j=Base_t::allComponents)
Definition: BCond.h:357
virtual void write(std::ostream &out) const
Definition: BCond.hpp:160
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:2821
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:559
BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:663
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:578
virtual void write(std::ostream &out) const
Definition: BCond.hpp:184
virtual void apply(Field< T, D, M, C > &A)
Definition: BCond.hpp:6025
virtual void write(std::ostream &out) const
Definition: BCond.hpp:193
BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:718
Definition: BCond.h:887
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:52
vmap< int, RefCountedP< BCondBase< T, D, M, C > > >::iterator iterator
Definition: BCond.h:240
virtual void write(std::ostream &out) const
Definition: BCond.hpp:199
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:853
const T & getOffset() const
Definition: BCond.h:498
virtual void write(std::ostream &) const
Definition: BCond.hpp:251
const T & getOffset() const
Definition: BCond.h:454
bool changesPhysicalCells() const
Definition: BCond.hpp:283
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:3637
virtual void write(std::ostream &out) const
Definition: BCond.hpp:135
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.h:263
void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:5018
virtual void write(std::ostream &out) const
Definition: BCond.hpp:154
virtual void write(std::ostream &out) const
Definition: BCond.hpp:142
virtual BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:446
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:823
Definition: FFT.h:30
static int allComponents
Definition: BCond.h:185
bool changesPhysicalCells() const
Definition: BCond.h:213
ConstantFace(unsigned f, T c, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:579
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:709
int m_component
Definition: BCond.h:219
virtual void write(std::ostream &out) const
Definition: BCond.hpp:148
void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:6207
ZeroGuardsAndZeroFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:623
ComponentFunctionFace(typename ApplyToComponentType< T >::type(*func)(typename ApplyToComponentType< T >::type), unsigned face, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.hpp:342
const T & getSlope() const
Definition: BCond.h:455
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:286
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:321
virtual BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:870
ExtrapolateAndZeroFace(unsigned f, T o, T s, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.hpp:324
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:499
PosReflectFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.h:516
ApplyToComponentType< T >::type(* Func)(typename ApplyToComponentType< T >::type)
Definition: BCond.h:734
virtual void write(std::ostream &) const
Definition: BCond.hpp:232
FunctionFace(T(*func)(const T &), unsigned face)
Definition: BCond.hpp:333
virtual void write(std::ostream &out) const
Definition: BCond.hpp:128
BCondNoAction(int face)
Definition: BCond.h:261
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:622
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:508
BCondBase(unsigned int face, int i=allComponents, int j=allComponents)
Definition: BCond.hpp:71
vmap< int, RefCountedP< BCondBase< T, D, M, C > > >::const_iterator const_iterator
Definition: BCond.h:242
void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:4566
virtual Base_t * clone() const
Definition: BCond.h:369
virtual void write(std::ostream &out) const
Definition: BCond.hpp:166
virtual BCondBase< T, D, M, C > * clone() const
Definition: BCond.h:490
TensorOrder_e getTensorOrder(const scalar_tag &)
Definition: BCond.h:166
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:1343
bool m_changePhysical
Definition: BCond.h:225
const T & getSlope() const
Definition: BCond.h:499
T(* Func)(const T &)
Definition: BCond.h:678
BCondBase< T, D, M, C > Base_t
Definition: BCond.h:399
BCondBase< T, D, M, C > BCondBaseTDMC
Definition: BCond.h:437
PeriodicFace(unsigned f, int i=BCondBaseTDMC::allComponents, int j=BCondBaseTDMC::allComponents)
Definition: BCond.hpp:297
virtual void write(std::ostream &out) const
Definition: BCond.hpp:178
virtual void apply(Field< T, D, M, C > &)
Definition: BCond.hpp:2060
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
rep_type::const_iterator const_iterator
Definition: vmap.h:117
unsigned int getFace() const
Definition: BCond.h:210
Definition: vmap.h:65