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
37
39{
40
43 "Translation", MappingTranslation::create,
44 "Translation mapping (X_i = x_i + constant)");
45
46/**
47 * @class MappingTranslation
48 * This class implements a trivial mapping defined by
49 * \f[ \bar{x} = x + c_1 \f]
50 * \f[ \bar{y} = y + c_2 \f]
51 * \f[ \bar{z} = z + c_3 \f]
52 * where \f$c_i\f$ are constants, \f$(\bar{x},\bar{y},\bar{z})\f$ are the
53 * Cartesian (physical) coordinates and \f$(x,y,z)\f$ are the transformed
54 * (computational) coordinates.
55 */
59 : Mapping(pSession, pFields)
60{
61}
62
65 const TiXmlElement *pMapping)
66{
67 m_constantJacobian = true;
68 // When there is no Mapping object defined, use the identity
69 // transformation as a default
70 if (m_session->DefinesElement("Nektar/Mapping"))
71 {
72 Mapping::v_InitObject(pFields, pMapping);
73 }
74 else
75 {
76 int phystot = pFields[0]->GetTotPoints();
77
78 m_timeDependent = false;
79
82 for (int i = 0; i < 3; i++)
83 {
84 m_coords[i] = Array<OneD, NekDouble>(phystot);
85 m_coordsVel[i] = Array<OneD, NekDouble>(phystot, 0.0);
86 }
87
88 m_fields[0]->GetCoords(m_coords[0], m_coords[1], m_coords[2]);
89
90 // Initialise workspace variables
92 for (int i = 0; i < m_nConvectiveFields; i++)
93 {
94 m_tmp[i] = Array<OneD, NekDouble>(phystot, 0.0);
95 }
96 }
97}
98
100 const Array<OneD, Array<OneD, NekDouble>> &inarray,
102{
103 int physTot = m_fields[0]->GetTotPoints();
104
105 for (int i = 0; i < m_nConvectiveFields; ++i)
106 {
107 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
108 }
109}
110
112 const Array<OneD, Array<OneD, NekDouble>> &inarray,
114{
115 int physTot = m_fields[0]->GetTotPoints();
116
117 for (int i = 0; i < m_nConvectiveFields; ++i)
118 {
119 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
120 }
121}
122
124 const Array<OneD, Array<OneD, NekDouble>> &inarray,
126{
127 int physTot = m_fields[0]->GetTotPoints();
128
129 for (int i = 0; i < m_nConvectiveFields; ++i)
130 {
131 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
132 }
133}
134
136 const Array<OneD, Array<OneD, NekDouble>> &inarray,
138{
139 int physTot = m_fields[0]->GetTotPoints();
140
141 for (int i = 0; i < m_nConvectiveFields; ++i)
142 {
143 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
144 }
145}
146
148{
149 int physTot = m_fields[0]->GetTotPoints();
150 Vmath::Fill(physTot, 1.0, outarray, 1);
151}
152
154 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &inarray,
155 Array<OneD, NekDouble> &outarray)
156{
157 int physTot = m_fields[0]->GetTotPoints();
158
159 Vmath::Zero(physTot, outarray, 1);
160}
161
164{
165 int physTot = m_fields[0]->GetTotPoints();
166 int nvel = m_nConvectiveFields;
167
168 for (int i = 0; i < nvel * nvel; i++)
169 {
170 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
171 }
172 // Fill diagonal with 1.0
173 for (int i = 0; i < nvel; i++)
174 {
175 Vmath::Sadd(physTot, 1.0, outarray[i + nvel * i], 1,
176 outarray[i + nvel * i], 1);
177 }
178}
179
182{
183 int physTot = m_fields[0]->GetTotPoints();
184 int nvel = m_nConvectiveFields;
185
186 for (int i = 0; i < nvel * nvel; i++)
187 {
188 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
189 }
190 // Fill diagonal with 1.0
191 for (int i = 0; i < nvel; i++)
192 {
193 Vmath::Sadd(physTot, 1.0, outarray[i + nvel * i], 1,
194 outarray[i + nvel * i], 1);
195 }
196}
197
199 const Array<OneD, Array<OneD, NekDouble>> &inarray,
201{
202 int physTot = m_fields[0]->GetTotPoints();
203 int nvel = m_nConvectiveFields;
204
205 for (int i = 0; i < nvel; i++)
206 {
207 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
208 }
209 // Copy
210 for (int i = 0; i < nvel; i++)
211 {
212 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
213 }
214}
215
217 const Array<OneD, Array<OneD, NekDouble>> &inarray,
219{
220 int physTot = m_fields[0]->GetTotPoints();
221 int nvel = m_nConvectiveFields;
222
223 for (int i = 0; i < nvel; i++)
224 {
225 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
226 }
227 // Copy
228 for (int i = 0; i < nvel; i++)
229 {
230 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
231 }
232}
233
235 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &inarray,
237{
238 int physTot = m_fields[0]->GetTotPoints();
239 int nvel = m_nConvectiveFields;
240
241 for (int i = 0; i < nvel; i++)
242 {
243 for (int j = 0; j < nvel; j++)
244 {
245 outarray[i * nvel + j] = Array<OneD, NekDouble>(physTot, 0.0);
246 }
247 }
248}
249
251 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &inarray,
253{
254 int physTot = m_fields[0]->GetTotPoints();
255 int nvel = m_nConvectiveFields;
256
257 for (int i = 0; i < nvel; i++)
258 {
259 for (int j = 0; j < nvel; j++)
260 {
261 outarray[i * nvel + j] = Array<OneD, NekDouble>(physTot, 0.0);
262 }
263 }
264}
265
267{
268}
269
270} // namespace Nektar::GlobalMapping
Base class for mapping to be applied to the coordinate system.
Definition: Mapping.h:73
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:418
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Mapping.h:406
Array< OneD, Array< OneD, NekDouble > > m_coords
Array with the Cartesian coordinates.
Definition: Mapping.h:412
Array< OneD, Array< OneD, NekDouble > > m_coordsVel
Array with the velocity of the coordinates.
Definition: Mapping.h:414
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:410
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Definition: Mapping.cpp:95
Array< OneD, Array< OneD, NekDouble > > m_tmp
Definition: Mapping.h:441
bool m_constantJacobian
Flag defining if the Jacobian is constant.
Definition: Mapping.h:427
bool m_timeDependent
Flag defining if the Mapping is time-dependent.
Definition: Mapping.h:429
GLOBAL_MAPPING_EXPORT void v_CovarFromCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_UpdateGeomInfo() override
GLOBAL_MAPPING_EXPORT void v_ContravarToCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_GetInvMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_ApplyChristoffelContravar(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping) override
GLOBAL_MAPPING_EXPORT void v_ApplyChristoffelCovar(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_GetMetricTensor(Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_LowerIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_ContravarFromCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_CovarToCartesian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_RaiseIndex(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray) override
GLOBAL_MAPPING_EXPORT void v_GetJacobian(Array< OneD, NekDouble > &outarray) override
MappingTranslation(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
GLOBAL_MAPPING_EXPORT void v_DotGradJacobian(const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray) override
static std::string className
Name of the class.
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.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
MappingFactory & GetMappingFactory()
Declaration of the mapping factory singleton.
Definition: Mapping.cpp:47
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.hpp:54
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.hpp:194
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825