Chombo + EB + MF  3.2
VectorTransformation.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 _VECTORTRANSFORMATION_H_
12 #define _VECTORTRANSFORMATION_H_
13 
14 #include "IntVect.H"
15 #include "RealVect.H"
16 #include "Tuple.H"
17 #include "FArrayBox.H"
18 
19 #include "NamespaceHeader.H"
20 
21 // ---------------------------------------------------------
22 /// Class to describe transformation of SpaceDim-vectors, typically from one block to another.
24 {
25 
27 
28 public:
29 
30  /// null constructor leaves object in undefined state
32  { }
33 
34  /// set one component of transformation matrix
35  void setComponent(int a_dirDst,
36  int a_dirSrc,
37  Real a_val)
38  { m_coeffs[matrixIndex(a_dirDst, a_dirSrc)] = a_val; }
39 
40  Real component(int a_dirDst,
41  int a_dirSrc) const
42  { return m_coeffs[matrixIndex(a_dirDst, a_dirSrc)]; }
43 
44  /// only for sending stuff to Fortran
45  const Real* dataPtr() const
46  { return m_coeffs; }
47 
48  /// apply this tranformation to vector
49  RealVect transform(const RealVect& a_vec) const;
50 
51  /// increment a vector-transformed cell-centered FAB
52  void addTransformFab(FArrayBox& a_dstFab,
53  const FArrayBox& a_srcFab,
54  const Box& a_bx,
55  Real a_weight = 1.) const;
56 
57  /// increment a vector-transformed cell-averaged FAB
58  void addTransformFabAvg(FArrayBox& a_dstFab,
59  const FArrayBox& a_srcFab,
60  const FArrayBox& a_gradFab,
61  const Vector<VectorTransformation>& a_vecTransformGrad,
62  const Box& a_bx,
63  Real a_weight = 1.) const;
64  ///
65  /**
66  Return the inverse transformation.
67  */
69 
70  ///
71  /**
72  Return the composite transformation:
73  that is, this transformation followed by a_next.
74  */
76 
78 
80  const VectorTransformation& p);
81 
83 
85  const VectorTransformation& p);
86 
88 
90 
92  const VectorTransformation& p);
93 
95 
97 
99  const VectorTransformation& p);
100 
101 
102  ///
103  /** The identity transformation, which leaves a vector the same.
104  */
106 
107  ///
108  /** Initializes VectorTransformation::Identity .
109  */
110  static int InitStatics();
111 
112 protected:
113 
114  const static int s_ncoeffs = SpaceDim*SpaceDim;
115 
116  // Tuple<RealVect, SpaceDim> m_matrix;
117  // Here RealVect m_matrix[idirDst] is for one destination.
118  // Length s_ncoeffs.
120 
121  // order in m_coeffs: [idirDst,idirSrc] ==
122  // [0,0], [0,1], [0,2], [1,0], [1,1], [1,2], [2,0], [2,1], [2,2];
123  // |-- m_matrix[0] --| |-- m_matrix[1] --| |--- m_matrix[2] --|
124  // hence index in m_coeffs is SpaceDim*idirDst + idirSrc.
125 
126  static inline int matrixIndex(int a_dirDst, int a_dirSrc)
127  {
128  return (SpaceDim*a_dirDst + a_dirSrc);
129  }
130 
131  Vector< Vector<Real> > vecvec(const Real* a_coeffs) const;
132 
133  Real determinant(const Real* a_matrix) const;
134 
135  Real determinant(const Vector< Vector<Real> >& a_matrix) const;
136 
137  Real matrixMinor(const Vector< Vector<Real> >& a_matrix,
138  int a_row,
139  int a_col) const;
140 };
141 
142 //
143 //// Static initialization. Gotta make sure there are no static object
144 //// definitions above here (except possibly stuff in headers). Otherwise,
145 //// the danger is that some static object's constructor calls
146 //// VectorTransformation::Identity, the very things the following
147 //// definition is supposed to initialize.
148 //// (I got this from IntVect.H)
150 
151 #include "NamespaceFooter.H"
152 
153 #endif // include guard
VectorTransformation & operator+=(const VectorTransformation &p)
Class to describe transformation of SpaceDim-vectors, typically from one block to another...
Definition: VectorAvgTransformation.H:20
Real component(int a_dirDst, int a_dirSrc) const
Definition: VectorTransformation.H:40
VectorTransformation & operator-=(const VectorTransformation &p)
one dimensional dynamic array
Definition: Vector.H:53
VectorTransformation()
null constructor leaves object in undefined state
Definition: VectorTransformation.H:31
VectorTransformation operator*(Real s) const
Real determinant(const Real *a_matrix) const
VectorTransformation & operator/=(Real s)
Class to describe transformation of SpaceDim-vectors, typically from one block to another...
Definition: VectorTransformation.H:23
VectorTransformation & operator*=(Real s)
const int SpaceDim
Definition: SPACE.H:38
Real matrixMinor(const Vector< Vector< Real > > &a_matrix, int a_row, int a_col) const
VectorTransformation inverse() const
double Real
Definition: REAL.H:33
static const int s_ncoeffs
Definition: VectorTransformation.H:114
static const VectorTransformation Identity
Definition: VectorTransformation.H:105
friend VectorTransformation operator+(const VectorTransformation &s, const VectorTransformation &p)
void addTransformFab(FArrayBox &a_dstFab, const FArrayBox &a_srcFab, const Box &a_bx, Real a_weight=1.) const
increment a vector-transformed cell-centered FAB
static int s_dummyForVectorTransformationH
Definition: VectorTransformation.H:149
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
const Real * dataPtr() const
only for sending stuff to Fortran
Definition: VectorTransformation.H:45
RealVect transform(const RealVect &a_vec) const
apply this tranformation to vector
static int InitStatics()
VectorTransformation operator/(Real s) const
friend VectorTransformation operator-(const VectorTransformation &s, const VectorTransformation &p)
void addTransformFabAvg(FArrayBox &a_dstFab, const FArrayBox &a_srcFab, const FArrayBox &a_gradFab, const Vector< VectorTransformation > &a_vecTransformGrad, const Box &a_bx, Real a_weight=1.) const
increment a vector-transformed cell-averaged FAB
Definition: FArrayBox.H:45
static int matrixIndex(int a_dirDst, int a_dirSrc)
Definition: VectorTransformation.H:126
VectorTransformation compose(const VectorTransformation &a_next) const
Vector< Vector< Real > > vecvec(const Real *a_coeffs) const
void setComponent(int a_dirDst, int a_dirSrc, Real a_val)
set one component of transformation matrix
Definition: VectorTransformation.H:35
Real m_coeffs[s_ncoeffs]
Definition: VectorTransformation.H:119