Nektar++
MappingTranslation.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: MappingTranslation.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Trivial mapping for translation transformation
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
38 #include <MultiRegions/ExpList.h>
39 
40 namespace Nektar
41 {
42 namespace GlobalMapping
43 {
44 
47  MappingTranslation::create, "Translation mapping (X_i = x_i + constant)");
48 
49 /**
50  * @class MappingTranslation
51  * This class implements a trivial mapping defined by
52  * \f[ \bar{x} = x + c_1 \f]
53  * \f[ \bar{y} = y + c_2 \f]
54  * \f[ \bar{z} = z + c_3 \f]
55  * where \f$c_i\f$ are constants, \f$(\bar{x},\bar{y},\bar{z})\f$ are the
56  * Cartesian (physical) coordinates and \f$(x,y,z)\f$ are the transformed
57  * (computational) coordinates.
58  */
62  : Mapping(pSession, pFields)
63 {
64 }
65 
66 
67 /**
68  *
69  */
72  const TiXmlElement *pMapping)
73 {
74  m_constantJacobian = true;
75  // When there is no Mapping object defined, use the identity
76  // transformation as a default
77  if (m_session->DefinesElement("Nektar/Mapping"))
78  {
79  Mapping::v_InitObject(pFields, pMapping);
80  }
81  else
82  {
83  int phystot = pFields[0]->GetTotPoints();
84 
85  m_timeDependent = false;
86 
89  for (int i = 0; i < 3; i++)
90  {
91  m_coords[i] = Array<OneD, NekDouble> (phystot);
92  m_coordsVel[i] = Array<OneD, NekDouble> (phystot, 0.0);
93  }
94 
95  m_fields[0]->GetCoords(m_coords[0], m_coords[1], m_coords[2]);
96 
97  // Initialise workspace variables
99  for (int i=0; i< m_nConvectiveFields; i++)
100  {
101  m_tmp[i] = Array<OneD, NekDouble>(phystot,0.0);
102  }
103  }
104 
105 }
106 
108  const Array<OneD, Array<OneD, NekDouble> > &inarray,
109  Array<OneD, Array<OneD, NekDouble> > &outarray)
110 {
111  int physTot = m_fields[0]->GetTotPoints();
112 
113  for (int i = 0; i < m_nConvectiveFields; ++i)
114  {
115  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
116  }
117 }
118 
120  const Array<OneD, Array<OneD, NekDouble> > &inarray,
121  Array<OneD, Array<OneD, NekDouble> > &outarray)
122 {
123  int physTot = m_fields[0]->GetTotPoints();
124 
125  for (int i = 0; i < m_nConvectiveFields; ++i)
126  {
127  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
128  }
129 }
130 
132  const Array<OneD, Array<OneD, NekDouble> > &inarray,
133  Array<OneD, Array<OneD, NekDouble> > &outarray)
134 {
135  int physTot = m_fields[0]->GetTotPoints();
136 
137  for (int i = 0; i < m_nConvectiveFields; ++i)
138  {
139  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
140  }
141 }
142 
144  const Array<OneD, Array<OneD, NekDouble> > &inarray,
145  Array<OneD, Array<OneD, NekDouble> > &outarray)
146 {
147  int physTot = m_fields[0]->GetTotPoints();
148 
149  for (int i = 0; i < m_nConvectiveFields; ++i)
150  {
151  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
152  }
153 }
154 
156  Array<OneD, NekDouble> &outarray)
157 {
158  int physTot = m_fields[0]->GetTotPoints();
159  Vmath::Fill(physTot, 1.0, outarray, 1);
160 }
161 
163  const Array<OneD, Array<OneD, NekDouble> > &inarray,
164  Array<OneD, NekDouble> &outarray)
165 {
166  boost::ignore_unused(inarray);
167 
168  int physTot = m_fields[0]->GetTotPoints();
169 
170  Vmath::Zero(physTot, outarray, 1);
171 }
172 
174  Array<OneD, Array<OneD, NekDouble> > &outarray)
175 {
176  int physTot = m_fields[0]->GetTotPoints();
177  int nvel = m_nConvectiveFields;
178 
179  for (int i=0; i<nvel*nvel; i++)
180  {
181  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
182  }
183  // Fill diagonal with 1.0
184  for (int i=0; i<nvel; i++)
185  {
186  Vmath::Sadd(physTot, 1.0, outarray[i+nvel*i], 1,
187  outarray[i+nvel*i], 1);
188  }
189 }
190 
192  Array<OneD, Array<OneD, NekDouble> > &outarray)
193 {
194  int physTot = m_fields[0]->GetTotPoints();
195  int nvel = m_nConvectiveFields;
196 
197  for (int i=0; i<nvel*nvel; i++)
198  {
199  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
200  }
201  // Fill diagonal with 1.0
202  for (int i=0; i<nvel; i++)
203  {
204  Vmath::Sadd(physTot, 1.0, outarray[i+nvel*i], 1,
205  outarray[i+nvel*i], 1);
206  }
207 }
208 
210  const Array<OneD, Array<OneD, NekDouble> > &inarray,
211  Array<OneD, Array<OneD, NekDouble> > &outarray)
212 {
213  int physTot = m_fields[0]->GetTotPoints();
214  int nvel = m_nConvectiveFields;
215 
216  for (int i=0; i<nvel; i++)
217  {
218  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
219  }
220  // Copy
221  for (int i=0; i<nvel; i++)
222  {
223  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
224  }
225 }
226 
228  const Array<OneD, Array<OneD, NekDouble> > &inarray,
229  Array<OneD, Array<OneD, NekDouble> > &outarray)
230 {
231  int physTot = m_fields[0]->GetTotPoints();
232  int nvel = m_nConvectiveFields;
233 
234  for (int i=0; i<nvel; i++)
235  {
236  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
237  }
238  // Copy
239  for (int i=0; i<nvel; i++)
240  {
241  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
242  }
243 }
244 
246  const Array<OneD, Array<OneD, NekDouble> > &inarray,
247  Array<OneD, Array<OneD, NekDouble> > &outarray)
248 {
249  boost::ignore_unused(inarray);
250 
251  int physTot = m_fields[0]->GetTotPoints();
252  int nvel = m_nConvectiveFields;
253 
254  for (int i = 0; i< nvel; i++)
255  {
256  for (int j = 0; j< nvel; j++)
257  {
258  outarray[i*nvel+j] = Array<OneD, NekDouble>(physTot,0.0);
259  }
260  }
261 }
262 
264  const Array<OneD, Array<OneD, NekDouble> > &inarray,
265  Array<OneD, Array<OneD, NekDouble> > &outarray)
266 {
267  boost::ignore_unused(inarray);
268 
269  int physTot = m_fields[0]->GetTotPoints();
270  int nvel = m_nConvectiveFields;
271 
272  for (int i = 0; i< nvel; i++)
273  {
274  for (int j = 0; j< nvel; j++)
275  {
276  outarray[i*nvel+j] = Array<OneD, NekDouble>(physTot,0.0);
277  }
278  }
279 }
280 
282 {
283 
284 }
285 
286 }
287 }
Array< OneD, Array< OneD, NekDouble > > m_coords
Array with the Cartesian coordinates.
Definition: Mapping.h:410
virtual GLOBAL_MAPPING_EXPORT void v_RaiseIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
MappingFactory & GetMappingFactory()
Declaration of the mapping factory singleton.
Definition: Mapping.cpp:52
virtual GLOBAL_MAPPING_EXPORT void v_ApplyChristoffelContravar(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
virtual GLOBAL_MAPPING_EXPORT void v_DotGradJacobian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
virtual GLOBAL_MAPPING_EXPORT void v_CovarFromCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
MappingTranslation(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:416
virtual GLOBAL_MAPPING_EXPORT void v_CovarToCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:408
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Mapping.h:404
virtual GLOBAL_MAPPING_EXPORT void v_GetInvMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray)
static GLOBAL_MAPPING_EXPORT MappingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Creates an instance of this class.
bool m_timeDependent
Flag defining if the Mapping is time-dependent.
Definition: Mapping.h:428
virtual GLOBAL_MAPPING_EXPORT void v_UpdateGeomInfo()
Array< OneD, Array< OneD, NekDouble > > m_coordsVel
Array with the velocity of the coordinates.
Definition: Mapping.h:412
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Definition: Mapping.cpp:100
bool m_constantJacobian
Flag defining if the Jacobian is constant.
Definition: Mapping.h:426
virtual GLOBAL_MAPPING_EXPORT void v_GetJacobian(Array< OneD, NekDouble > &outarray)
Array< OneD, Array< OneD, NekDouble > > m_tmp
Definition: Mapping.h:440
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
Definition: Vmath.cpp:318
virtual GLOBAL_MAPPING_EXPORT void v_ContravarToCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
Base class for mapping to be applied to the coordinate system.
Definition: Mapping.h:68
virtual GLOBAL_MAPPING_EXPORT void v_ApplyChristoffelCovar(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
virtual GLOBAL_MAPPING_EXPORT void v_LowerIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
virtual GLOBAL_MAPPING_EXPORT void v_ContravarFromCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
virtual GLOBAL_MAPPING_EXPORT void v_GetMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
static std::string className
Name of the class.