Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Trivial mapping for translation transformation
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 #include <MultiRegions/ExpList.h>
38 
39 namespace Nektar
40 {
41 namespace GlobalMapping
42 {
43 
46  MappingTranslation::create, "Translation mapping (X_i = x_i + constant)");
47 
48 /**
49  * @class MappingTranslation
50  * This class implements a trivial mapping defined by
51  * \f[ \bar{x} = x + c_1 \f]
52  * \f[ \bar{y} = y + c_2 \f]
53  * \f[ \bar{z} = z + c_3 \f]
54  * where \f$c_i\f$ are constants, \f$(\bar{x},\bar{y},\bar{z})\f$ are the
55  * Cartesian (physical) coordinates and \f$(x,y,z)\f$ are the transformed
56  * (computational) coordinates.
57  */
61  : Mapping(pSession, pFields)
62 {
63 }
64 
65 
66 /**
67  *
68  */
71  const TiXmlElement *pMapping)
72 {
73  m_constantJacobian = true;
74  // When there is no Mapping object defined, use the identity
75  // transformation as a default
76  if (m_session->DefinesElement("Nektar/Mapping"))
77  {
78  Mapping::v_InitObject(pFields, pMapping);
79  }
80  else
81  {
82  int phystot = pFields[0]->GetTotPoints();
83 
84  m_timeDependent = false;
85 
88  for (int i = 0; i < 3; i++)
89  {
90  m_coords[i] = Array<OneD, NekDouble> (phystot);
91  m_coordsVel[i] = Array<OneD, NekDouble> (phystot, 0.0);
92  }
93 
94  m_fields[0]->GetCoords(m_coords[0], m_coords[1], m_coords[2]);
95 
96  // Initialise workspace variables
98  for (int i=0; i< m_nConvectiveFields; i++)
99  {
100  m_tmp[i] = Array<OneD, NekDouble>(phystot,0.0);
101  }
102  }
103 
104 }
105 
107  const Array<OneD, Array<OneD, NekDouble> > &inarray,
108  Array<OneD, Array<OneD, NekDouble> > &outarray)
109 {
110  int physTot = m_fields[0]->GetTotPoints();
111 
112  for (int i = 0; i < m_nConvectiveFields; ++i)
113  {
114  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
115  }
116 }
117 
119  const Array<OneD, Array<OneD, NekDouble> > &inarray,
120  Array<OneD, Array<OneD, NekDouble> > &outarray)
121 {
122  int physTot = m_fields[0]->GetTotPoints();
123 
124  for (int i = 0; i < m_nConvectiveFields; ++i)
125  {
126  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
127  }
128 }
129 
131  const Array<OneD, Array<OneD, NekDouble> > &inarray,
132  Array<OneD, Array<OneD, NekDouble> > &outarray)
133 {
134  int physTot = m_fields[0]->GetTotPoints();
135 
136  for (int i = 0; i < m_nConvectiveFields; ++i)
137  {
138  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
139  }
140 }
141 
143  const Array<OneD, Array<OneD, NekDouble> > &inarray,
144  Array<OneD, Array<OneD, NekDouble> > &outarray)
145 {
146  int physTot = m_fields[0]->GetTotPoints();
147 
148  for (int i = 0; i < m_nConvectiveFields; ++i)
149  {
150  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
151  }
152 }
153 
155  Array<OneD, NekDouble> &outarray)
156 {
157  int physTot = m_fields[0]->GetTotPoints();
158  Vmath::Fill(physTot, 1.0, outarray, 1);
159 }
160 
162  const Array<OneD, Array<OneD, NekDouble> > &inarray,
163  Array<OneD, NekDouble> &outarray)
164 {
165  int physTot = m_fields[0]->GetTotPoints();
166 
167  Vmath::Zero(physTot, outarray, 1);
168 }
169 
171  Array<OneD, Array<OneD, NekDouble> > &outarray)
172 {
173  int physTot = m_fields[0]->GetTotPoints();
174  int nvel = m_nConvectiveFields;
175 
176  for (int i=0; i<nvel*nvel; i++)
177  {
178  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
179  }
180  // Fill diagonal with 1.0
181  for (int i=0; i<nvel; i++)
182  {
183  Vmath::Sadd(physTot, 1.0, outarray[i+nvel*i], 1,
184  outarray[i+nvel*i], 1);
185  }
186 }
187 
189  Array<OneD, Array<OneD, NekDouble> > &outarray)
190 {
191  int physTot = m_fields[0]->GetTotPoints();
192  int nvel = m_nConvectiveFields;
193 
194  for (int i=0; i<nvel*nvel; i++)
195  {
196  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
197  }
198  // Fill diagonal with 1.0
199  for (int i=0; i<nvel; i++)
200  {
201  Vmath::Sadd(physTot, 1.0, outarray[i+nvel*i], 1,
202  outarray[i+nvel*i], 1);
203  }
204 }
205 
207  const Array<OneD, Array<OneD, NekDouble> > &inarray,
208  Array<OneD, Array<OneD, NekDouble> > &outarray)
209 {
210  int physTot = m_fields[0]->GetTotPoints();
211  int nvel = m_nConvectiveFields;
212 
213  for (int i=0; i<nvel; i++)
214  {
215  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
216  }
217  // Copy
218  for (int i=0; i<nvel; i++)
219  {
220  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
221  }
222 }
223 
225  const Array<OneD, Array<OneD, NekDouble> > &inarray,
226  Array<OneD, Array<OneD, NekDouble> > &outarray)
227 {
228  int physTot = m_fields[0]->GetTotPoints();
229  int nvel = m_nConvectiveFields;
230 
231  for (int i=0; i<nvel; i++)
232  {
233  outarray[i] = Array<OneD, NekDouble> (physTot, 0.0);
234  }
235  // Copy
236  for (int i=0; i<nvel; i++)
237  {
238  Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
239  }
240 }
241 
243  const Array<OneD, Array<OneD, NekDouble> > &inarray,
244  Array<OneD, Array<OneD, NekDouble> > &outarray)
245 {
246  int physTot = m_fields[0]->GetTotPoints();
247  int nvel = m_nConvectiveFields;
248 
249  for (int i = 0; i< nvel; i++)
250  {
251  for (int j = 0; j< nvel; j++)
252  {
253  outarray[i*nvel+j] = Array<OneD, NekDouble>(physTot,0.0);
254  }
255  }
256 }
257 
259  const Array<OneD, Array<OneD, NekDouble> > &inarray,
260  Array<OneD, Array<OneD, NekDouble> > &outarray)
261 {
262  int physTot = m_fields[0]->GetTotPoints();
263  int nvel = m_nConvectiveFields;
264 
265  for (int i = 0; i< nvel; i++)
266  {
267  for (int j = 0; j< nvel; j++)
268  {
269  outarray[i*nvel+j] = Array<OneD, NekDouble>(physTot,0.0);
270  }
271  }
272 }
273 
275 {
276 
277 }
278 
279 }
280 }
Array< OneD, Array< OneD, NekDouble > > m_coords
Array with the Cartesian coordinates.
Definition: Mapping.h:411
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:49
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:46
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)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:417
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:409
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Mapping.h:405
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:429
virtual GLOBAL_MAPPING_EXPORT void v_UpdateGeomInfo()
Array< OneD, Array< OneD, NekDouble > > m_coordsVel
Array with the velocity of the coordinates.
Definition: Mapping.h:413
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:427
virtual GLOBAL_MAPPING_EXPORT void v_GetJacobian(Array< OneD, NekDouble > &outarray)
Array< OneD, Array< OneD, NekDouble > > m_tmp
Definition: Mapping.h:441
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:301
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:69
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)
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:359
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
virtual GLOBAL_MAPPING_EXPORT void v_GetMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray)
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
static std::string className
Name of the class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215