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
63/**
64 *
65 */
68 const TiXmlElement *pMapping)
69{
70 m_constantJacobian = true;
71 // When there is no Mapping object defined, use the identity
72 // transformation as a default
73 if (m_session->DefinesElement("Nektar/Mapping"))
74 {
75 Mapping::v_InitObject(pFields, pMapping);
76 }
77 else
78 {
79 int phystot = pFields[0]->GetTotPoints();
80
81 m_timeDependent = false;
82
85 for (int i = 0; i < 3; i++)
86 {
87 m_coords[i] = Array<OneD, NekDouble>(phystot);
88 m_coordsVel[i] = Array<OneD, NekDouble>(phystot, 0.0);
89 }
90
91 m_fields[0]->GetCoords(m_coords[0], m_coords[1], m_coords[2]);
92
93 // Initialise workspace variables
95 for (int i = 0; i < m_nConvectiveFields; i++)
96 {
97 m_tmp[i] = Array<OneD, NekDouble>(phystot, 0.0);
98 }
99 }
100}
101
103 const Array<OneD, Array<OneD, NekDouble>> &inarray,
105{
106 int physTot = m_fields[0]->GetTotPoints();
107
108 for (int i = 0; i < m_nConvectiveFields; ++i)
109 {
110 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
111 }
112}
113
115 const Array<OneD, Array<OneD, NekDouble>> &inarray,
117{
118 int physTot = m_fields[0]->GetTotPoints();
119
120 for (int i = 0; i < m_nConvectiveFields; ++i)
121 {
122 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
123 }
124}
125
127 const Array<OneD, Array<OneD, NekDouble>> &inarray,
129{
130 int physTot = m_fields[0]->GetTotPoints();
131
132 for (int i = 0; i < m_nConvectiveFields; ++i)
133 {
134 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
135 }
136}
137
139 const Array<OneD, Array<OneD, NekDouble>> &inarray,
141{
142 int physTot = m_fields[0]->GetTotPoints();
143
144 for (int i = 0; i < m_nConvectiveFields; ++i)
145 {
146 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
147 }
148}
149
151{
152 int physTot = m_fields[0]->GetTotPoints();
153 Vmath::Fill(physTot, 1.0, outarray, 1);
154}
155
157 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &inarray,
158 Array<OneD, NekDouble> &outarray)
159{
160 int physTot = m_fields[0]->GetTotPoints();
161
162 Vmath::Zero(physTot, outarray, 1);
163}
164
167{
168 int physTot = m_fields[0]->GetTotPoints();
169 int nvel = m_nConvectiveFields;
170
171 for (int i = 0; i < nvel * nvel; i++)
172 {
173 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
174 }
175 // Fill diagonal with 1.0
176 for (int i = 0; i < nvel; i++)
177 {
178 Vmath::Sadd(physTot, 1.0, outarray[i + nvel * i], 1,
179 outarray[i + nvel * i], 1);
180 }
181}
182
185{
186 int physTot = m_fields[0]->GetTotPoints();
187 int nvel = m_nConvectiveFields;
188
189 for (int i = 0; i < nvel * nvel; i++)
190 {
191 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
192 }
193 // Fill diagonal with 1.0
194 for (int i = 0; i < nvel; i++)
195 {
196 Vmath::Sadd(physTot, 1.0, outarray[i + nvel * i], 1,
197 outarray[i + nvel * i], 1);
198 }
199}
200
202 const Array<OneD, Array<OneD, NekDouble>> &inarray,
204{
205 int physTot = m_fields[0]->GetTotPoints();
206 int nvel = m_nConvectiveFields;
207
208 for (int i = 0; i < nvel; i++)
209 {
210 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
211 }
212 // Copy
213 for (int i = 0; i < nvel; i++)
214 {
215 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
216 }
217}
218
220 const Array<OneD, Array<OneD, NekDouble>> &inarray,
222{
223 int physTot = m_fields[0]->GetTotPoints();
224 int nvel = m_nConvectiveFields;
225
226 for (int i = 0; i < nvel; i++)
227 {
228 outarray[i] = Array<OneD, NekDouble>(physTot, 0.0);
229 }
230 // Copy
231 for (int i = 0; i < nvel; i++)
232 {
233 Vmath::Vcopy(physTot, inarray[i], 1, outarray[i], 1);
234 }
235}
236
238 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &inarray,
240{
241 int physTot = m_fields[0]->GetTotPoints();
242 int nvel = m_nConvectiveFields;
243
244 for (int i = 0; i < nvel; i++)
245 {
246 for (int j = 0; j < nvel; j++)
247 {
248 outarray[i * nvel + j] = Array<OneD, NekDouble>(physTot, 0.0);
249 }
250 }
251}
252
254 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &inarray,
256{
257 int physTot = m_fields[0]->GetTotPoints();
258 int nvel = m_nConvectiveFields;
259
260 for (int i = 0; i < nvel; i++)
261 {
262 for (int j = 0; j < nvel; j++)
263 {
264 outarray[i * nvel + j] = Array<OneD, NekDouble>(physTot, 0.0);
265 }
266 }
267}
268
270{
271}
272
273} // namespace Nektar::GlobalMapping
Base class for mapping to be applied to the coordinate system.
Definition: Mapping.h:67
int m_nConvectiveFields
Number of velocity components.
Definition: Mapping.h:412
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Mapping.h:400
Array< OneD, Array< OneD, NekDouble > > m_coords
Array with the Cartesian coordinates.
Definition: Mapping.h:406
Array< OneD, Array< OneD, NekDouble > > m_coordsVel
Array with the velocity of the coordinates.
Definition: Mapping.h:408
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Definition: Mapping.h:404
virtual GLOBAL_MAPPING_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pMapping)
Definition: Mapping.cpp:97
Array< OneD, Array< OneD, NekDouble > > m_tmp
Definition: Mapping.h:435
bool m_constantJacobian
Flag defining if the Jacobian is constant.
Definition: Mapping.h:421
bool m_timeDependent
Flag defining if the Mapping is time-dependent.
Definition: Mapping.h:423
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:49
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