Chombo + EB  3.2
TransformIF.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _TRANSFORMIF_H_
12 #define _TRANSFORMIF_H_
13 
14 #include "MayDay.H"
15 #include "RealVect.H"
16 #include "Vector.H"
17 
18 #include "BaseIF.H"
19 
20 #include "NamespaceHeader.H"
21 
22 ///
23 /**
24  This implicit function is a tranformed version of the implicit function
25  passed in the constructor. Various transformations (in 2D and 3D) are
26  allowed including translating, scaling, and rotations.
27  */
28 class TransformIF: public BaseIF
29 {
30 public:
31  ///
32  /**
33  Constructor specifying the implicit function
34  */
35  TransformIF(const BaseIF& a_impFunc);
36 
37  /// Copy constructor
38  TransformIF(const TransformIF& a_inputIF);
39 
40  /// Destructor
41  virtual ~TransformIF();
42 
43  ///
44  /**
45  Translate by a_trans
46  */
47  void translate(const RealVect& a_trans);
48 
49  ///
50  /**
51  Scale (uniformly) by a_scale
52  */
53  void scale(const Real& a_scale);
54 
55  ///
56  /**
57  Scale in each direction (idir) by a_scale[idir]
58  */
59  void scale(const RealVect& a_scale);
60 
61  ///
62  /**
63  In 2D - rotate by a_angle about a_point, a_axis is ignored.
64  In 3D - rotate by a_angle about the line in space specified by
65  a_point and and a_axis.
66  */
67  void rotate(const Real& a_angle,
68  const RealVect& a_point = RealVect::Zero,
69  const RealVect& a_axis = BASISREALV(0));
70 
71  ///
72  /**
73  About a_point, Rotate vector a_axis1 to align with vector a_axis2
74  */
75  void rotate(const RealVect& a_axis1,
76  const RealVect& a_axis2,
77  const RealVect& a_point = RealVect::Zero);
78 
79  ///
80  /**
81  Return the value of the function at a_point.
82  */
83  virtual Real value(const RealVect& a_point) const;
84 
85  Real value(const IndexTM<Real,GLOBALDIM>& a_point) const;
86 
87  virtual BaseIF* newImplicitFunction() const;
88 
89  virtual bool fastIntersection(const RealVect& a_lo,
90  const RealVect& a_hi) const ;
91 
92  virtual GeometryService::InOut InsideOutside(const RealVect& a_lo,
93  const RealVect& a_hi) const ;
94 
95  ///
96  /**
97  Pass this call onto the IFs contained in this IF class.
98  */
99  virtual void boxLayoutChanged(const DisjointBoxLayout & a_newBoxLayout,
100  const RealVect & a_dx)
101  {
102  m_impFunc->boxLayoutChanged(a_newBoxLayout,a_dx);
103  }
104 
105 protected:
106  ///
107  /**
108  Constructor for the factory
109  */
110  TransformIF(const BaseIF& a_impFunc,
111  const Real a_transform[SpaceDim+1][SpaceDim+1],
112  const Real a_invTransform[SpaceDim+1][SpaceDim+1]);
113 
114  // transformation (in homogeneous coordinates)
116 
117  // inverse transformation (in homogeneous coordinates)
119 
120  BaseIF* m_impFunc; // implicit function to transform
121 
122  void vectorMultiply(RealVect& m_outPoint,
123  const Real m_intrans[SpaceDim+1][SpaceDim+1],
124  const RealVect& m_inPoint) const;
125 
126  void vectorMultiply(IndexTM<Real,GLOBALDIM>& m_outPoint,
127  const Real m_intrans[SpaceDim+1][SpaceDim+1],
128  const IndexTM<Real,GLOBALDIM>& m_inPoint) const;
129 
130  void matrixIdentity(Real m_trans[SpaceDim+1][SpaceDim+1]) const;
131 
132  void matrixMultiply(Real m_outTrans[SpaceDim+1][SpaceDim+1],
133  const Real m_intrans1[SpaceDim+1][SpaceDim+1],
134  const Real m_intrans2[SpaceDim+1][SpaceDim+1]) const;
135 
136  void matrixTranslate(Real m_trans[SpaceDim+1][SpaceDim+1],
137  const RealVect& m_translate) const;
138 
139  void matrixScale(Real m_trans[SpaceDim+1][SpaceDim+1],
140  const RealVect& m_scale) const;
141 
142 private:
144  {
145  MayDay::Abort("TransformIF uses strong construction");
146  }
147 
148  void operator=(const TransformIF& a_inputIF)
149  {
150  MayDay::Abort("TransformIF doesn't allow assignment");
151  }
152 };
153 
154 #include "NamespaceFooter.H"
155 #endif
void rotate(const Real &a_angle, const RealVect &a_point=RealVect::Zero, const RealVect &a_axis=BASISREALV(0))
void matrixMultiply(Real m_outTrans[SpaceDim+1][SpaceDim+1], const Real m_intrans1[SpaceDim+1][SpaceDim+1], const Real m_intrans2[SpaceDim+1][SpaceDim+1]) const
virtual BaseIF * newImplicitFunction() const
void matrixIdentity(Real m_trans[SpaceDim+1][SpaceDim+1]) const
virtual bool fastIntersection(const RealVect &a_lo, const RealVect &a_hi) const
void vectorMultiply(RealVect &m_outPoint, const Real m_intrans[SpaceDim+1][SpaceDim+1], const RealVect &m_inPoint) const
virtual void boxLayoutChanged(const DisjointBoxLayout &a_newBoxLayout, const RealVect &a_dx)
Definition: BaseIF.H:259
BaseIF * m_impFunc
Definition: TransformIF.H:120
Real m_transform[SpaceDim+1][SpaceDim+1]
Definition: TransformIF.H:115
const int SpaceDim
Definition: SPACE.H:38
InOut
Definition: GeometryService.H:41
void translate(const RealVect &a_trans)
virtual ~TransformIF()
Destructor.
Definition: BaseIF.H:32
static const RealVect Zero
Definition: RealVect.H:421
double Real
Definition: REAL.H:33
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
void matrixTranslate(Real m_trans[SpaceDim+1][SpaceDim+1], const RealVect &m_translate) const
virtual void boxLayoutChanged(const DisjointBoxLayout &a_newBoxLayout, const RealVect &a_dx)
Definition: TransformIF.H:99
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
RealVect BASISREALV(int idir)
Definition: TransformIF.H:28
void scale(const Real &a_scale)
virtual GeometryService::InOut InsideOutside(const RealVect &a_lo, const RealVect &a_hi) const
TransformIF()
Definition: TransformIF.H:143
void matrixScale(Real m_trans[SpaceDim+1][SpaceDim+1], const RealVect &m_scale) const
Real m_invTransform[SpaceDim+1][SpaceDim+1]
Definition: TransformIF.H:118
void operator=(const TransformIF &a_inputIF)
Definition: TransformIF.H:148
virtual Real value(const RealVect &a_point) const
static void Abort(const char *const a_msg=m_nullString)
Print out message to cerr and exit via abort() (if serial) or MPI_Abort() (if parallel).