Nektar++
ExpList2DHomogeneous2D.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ExpList2DHomogeneous2D.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: An ExpList1D which is homogeneous in 2 directions and so
32// uses much of the functionality from a ExpList2D and its daughters
33//
34///////////////////////////////////////////////////////////////////////////////
35
37
38using namespace std;
39
41{
42// Forward declaration for typedefs
44{
45}
46
47// Constructor for ExpList2DHomogeneous2D to act as a Explist1D field
50 const LibUtilities::BasisKey &HomoBasis_y,
51 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
52 const NekDouble lhom_z, const bool useFFT, const bool dealiasing,
54 : ExpListHomogeneous2D(eNoType, pSession, HomoBasis_y, HomoBasis_z, lhom_y,
55 lhom_z, useFFT, dealiasing)
56{
57 int n;
58
59 ASSERTL1(m_ny * m_nz == points.size(),
60 "Size of basis number of points and number of lines are "
61 "not the same");
62
63 for (n = 0; n < points.size(); ++n)
64 {
65 m_lines[n] = points[n];
66 (*m_exp).push_back(points[n]->GetExp(0));
67 }
68
70}
71
72/**
73 * @param In ExpList2DHomogeneous2D object to copy.
74 */
77{
78 for (int n = 0; n < m_lines.size(); ++n)
79 {
80 m_lines[n] = In.m_lines[n];
81 }
82
84}
85
86/**
87 * Destructor
88 */
90{
91}
92
94{
95 int i, n, cnt;
96 int ncoeffs_per_line = m_lines[0]->GetNcoeffs();
97 int npoints_per_line = m_lines[0]->GetTotPoints();
98
99 int nyzlines = m_lines.size();
100
101 // Set total coefficients and points
102 m_ncoeffs = ncoeffs_per_line * nyzlines;
103 m_npoints = npoints_per_line * nyzlines;
104
107
108 int nel = m_lines[0]->GetExpSize();
109 m_coeff_offset = Array<OneD, int>(nel * nyzlines);
110 m_phys_offset = Array<OneD, int>(nel * nyzlines);
111 Array<OneD, NekDouble> tmparray;
112
113 for (cnt = n = 0; n < nyzlines; ++n)
114 {
115 m_lines[n]->SetCoeffsArray(tmparray = m_coeffs + ncoeffs_per_line * n);
116 m_lines[n]->SetPhysArray(tmparray = m_phys + npoints_per_line * n);
117
118 for (i = 0; i < nel; ++i)
119 {
120 m_coeff_offset[cnt] =
121 m_lines[n]->GetCoeff_Offset(i) + n * ncoeffs_per_line;
122 m_phys_offset[cnt++] =
123 m_lines[n]->GetPhys_Offset(i) + n * npoints_per_line;
124 }
125 }
126}
127
128void ExpList2DHomogeneous2D::v_GetCoords([[maybe_unused]] const int eid,
132{
133 int n, m, j;
135 int nylines = m_homogeneousBasis_y->GetNumPoints();
136 int nzlines = m_homogeneousBasis_z->GetNumPoints();
137 int npoints = 1;
138
139 // Fill x-y-z-direction
142
143 Array<OneD, NekDouble> x(npoints);
144 Array<OneD, NekDouble> y(nylines);
145 Array<OneD, NekDouble> z(nzlines);
146
147 Vmath::Smul(nylines, m_lhom_y / 2.0, pts_y, 1, y, 1);
148 Vmath::Sadd(nylines, m_lhom_y / 2.0, y, 1, y, 1);
149
150 Vmath::Smul(nzlines, m_lhom_z / 2.0, pts_z, 1, z, 1);
151 Vmath::Sadd(nzlines, m_lhom_z / 2.0, z, 1, z, 1);
152
153 m_lines[0]->GetCoords(x);
154
155 for (m = 0; m < nzlines; ++m)
156 {
157 for (j = 0; j < nylines; ++j)
158 {
159 for (n = 0; n < npoints; ++n)
160 {
161 Vmath::Fill(1, x[n],
162 tmp_xc = xc0 + n + (j * npoints) +
163 (m * npoints * nylines),
164 1);
165 Vmath::Fill(1, y[j],
166 tmp_xc = xc1 + n + (j * npoints) +
167 (m * npoints * nylines),
168 1);
169 Vmath::Fill(1, z[m],
170 tmp_xc = xc2 + n + (j * npoints) +
171 (m * npoints * nylines),
172 1);
173 }
174 }
175 }
176}
177
179 const Array<OneD, const NekDouble> &inarray,
180 Array<OneD, NekDouble> &outarray)
181{
182 // just have a point expansion so copy inarray to outarray
183 Vmath::Vcopy(m_npoints, inarray, 1, outarray, 1);
184
185 if (!m_WaveSpace)
186 {
187 HomogeneousFwdTrans(m_npoints, outarray, outarray);
188 }
189}
190
192 const Array<OneD, const NekDouble> &inarray,
193 Array<OneD, NekDouble> &outarray)
194{
195 v_FwdTrans(inarray, outarray);
196}
197
199 const Array<OneD, const NekDouble> &inarray,
200 Array<OneD, NekDouble> &outarray)
201{
202 v_FwdTrans(inarray, outarray);
203}
204
205/**
206 * The operation calls the 2D plane coordinates through the
207 * function ExpList#GetCoords and then evaluated the third
208 * coordinate using the member \a m_lhom
209 *
210 * @param coord_0 After calculation, the \f$x_1\f$ coordinate
211 * will be stored in this array.
212 *
213 * @param coord_1 After calculation, the \f$x_2\f$ coordinate
214 * will be stored in this array. This
215 * coordinate might be evaluated using the
216 * predefined value \a m_lhom
217 *
218 * @param coord_2 After calculation, the \f$x_3\f$ coordinate
219 * will be stored in this array. This
220 * coordinate is evaluated using the
221 * predefined value \a m_lhom
222 */
226{
227 int n, m, j;
229 int npoints = 1;
230
231 int nylines = m_homogeneousBasis_y->GetNumPoints();
232 int nzlines = m_homogeneousBasis_z->GetNumPoints();
233
234 // Fill z-direction
237
238 Array<OneD, NekDouble> x(npoints);
239 Array<OneD, NekDouble> y(nylines);
240 Array<OneD, NekDouble> z(nzlines);
241
242 m_lines[0]->GetCoords(x);
243
244 Vmath::Smul(nylines, m_lhom_y / 2.0, pts_y, 1, y, 1);
245 Vmath::Sadd(nylines, m_lhom_y / 2.0, y, 1, y, 1);
246
247 Vmath::Smul(nzlines, m_lhom_z / 2.0, pts_z, 1, z, 1);
248 Vmath::Sadd(nzlines, m_lhom_z / 2.0, z, 1, z, 1);
249
250 for (m = 0; m < nzlines; ++m)
251 {
252 for (j = 0; j < nylines; ++j)
253 {
254 for (n = 0; n < npoints; ++n)
255 {
256 Vmath::Fill(1, x[n],
257 tmp_xc = xc0 + n + (j * npoints) +
258 (m * npoints * nylines),
259 1);
260 Vmath::Fill(1, y[j],
261 tmp_xc = xc1 + n + (j * npoints) +
262 (m * npoints * nylines),
263 1);
264 Vmath::Fill(1, z[m],
265 tmp_xc = xc2 + n + (j * npoints) +
266 (m * npoints * nylines),
267 1);
268 }
269 }
270 }
271}
272
273/**
274 * Write Tecplot Files Zone
275 * @param outfile Output file name.
276 * @param expansion Expansion that is considered
277 */
279 int expansion)
280{
281 int i, j;
282
283 int nquad0 = 1;
284 int nquad1 = m_homogeneousBasis_y->GetNumPoints();
285 int nquad2 = m_homogeneousBasis_z->GetNumPoints();
286
287 Array<OneD, NekDouble> coords[3];
288
289 coords[0] = Array<OneD, NekDouble>(3 * nquad0 * nquad1 * nquad2);
290 coords[1] = coords[0] + nquad0 * nquad1 * nquad2;
291 coords[2] = coords[1] + nquad0 * nquad1 * nquad2;
292
293 GetCoords(expansion, coords[0], coords[1], coords[2]);
294
295 outfile << "Zone, I=" << nquad1 << ", J=" << nquad0 * nquad2 << ", F=Block"
296 << std::endl;
297
298 for (j = 0; j < nquad1; ++j)
299 {
300 for (i = 0; i < nquad2 * GetCoordim(0) + 1; ++i)
301 {
302 outfile << coords[j][i] << " ";
303 }
304 outfile << std::endl;
305 }
306}
307
309 int expansion,
310 [[maybe_unused]] int istrip)
311{
312 int i, j;
313
314 int nquad0 = 1;
315 int nquad1 = m_homogeneousBasis_y->GetNumPoints();
316 int nquad2 = m_homogeneousBasis_z->GetNumPoints();
317
318 int ntot = nquad0 * nquad1 * nquad2;
319 int ntotminus = (nquad0) * (nquad1 - 1) * (nquad2 - 1);
320
321 Array<OneD, NekDouble> coords[3];
322 coords[0] = Array<OneD, NekDouble>(ntot);
323 coords[1] = Array<OneD, NekDouble>(ntot);
324 coords[2] = Array<OneD, NekDouble>(ntot);
325 GetCoords(expansion, coords[0], coords[1], coords[2]);
326
327 outfile << " <Piece NumberOfPoints=\"" << ntot << "\" NumberOfCells=\""
328 << ntotminus << "\">" << endl;
329 outfile << " <Points>" << endl;
330 outfile << " <DataArray type=\"Float32\" "
331 << R"(NumberOfComponents="3" format="ascii">)" << endl;
332 outfile << " ";
333 for (i = 0; i < ntot; ++i)
334 {
335 for (j = 0; j < 3; ++j)
336 {
337 outfile << coords[j][i] << " ";
338 }
339 outfile << endl;
340 }
341 outfile << endl;
342 outfile << " </DataArray>" << endl;
343 outfile << " </Points>" << endl;
344 outfile << " <Cells>" << endl;
345 outfile << " <DataArray type=\"Int32\" "
346 << R"(Name="connectivity" format="ascii">)" << endl;
347 for (i = 0; i < nquad0; ++i)
348 {
349 for (j = 0; j < nquad1 - 1; ++j)
350 {
351 outfile << j * nquad0 + i << " " << j * nquad0 + i + 1 << " "
352 << (j + 1) * nquad0 + i + 1 << " " << (j + 1) * nquad0 + i
353 << endl;
354 }
355 }
356 outfile << endl;
357 outfile << " </DataArray>" << endl;
358 outfile << " <DataArray type=\"Int32\" "
359 << R"(Name="offsets" format="ascii">)" << endl;
360 for (i = 0; i < ntotminus; ++i)
361 {
362 outfile << i * 4 + 4 << " ";
363 }
364 outfile << endl;
365 outfile << " </DataArray>" << endl;
366 outfile << " <DataArray type=\"UInt8\" "
367 << R"(Name="types" format="ascii">)" << endl;
368 for (i = 0; i < ntotminus; ++i)
369 {
370 outfile << "9 ";
371 }
372 outfile << endl;
373 outfile << " </DataArray>" << endl;
374 outfile << " </Cells>" << endl;
375 outfile << " <PointData>" << endl;
376}
377
378} // namespace Nektar::MultiRegions
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
Describes the specification for a Basis.
Definition: Basis.h:45
Abstraction of a one-dimensional multi-elemental expansion which is merely a collection of local expa...
void SetCoeffPhys(void)
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
void v_FwdTransBndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_WriteTecplotZone(std::ostream &outfile, int expansion) override
void v_FwdTransLocalElmt(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_GetCoords(Array< OneD, NekDouble > &coord_0, Array< OneD, NekDouble > &coord_1, Array< OneD, NekDouble > &coord_2) override
void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip) override
void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
int m_nz
Number of modes = number of poitns in z direction.
LibUtilities::BasisSharedPtr m_homogeneousBasis_y
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
NekDouble m_lhom_z
Width of homogeneous direction z.
int m_ny
Number of modes = number of poitns in y direction.
Array< OneD, ExpListSharedPtr > m_lines
Vector of ExpList, will be filled with ExpList1D.
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
NekDouble m_lhom_y
Width of homogeneous direction y.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:1083
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
Definition: ExpList.h:1123
void GetCoords(Array< OneD, NekDouble > &coord_0, Array< OneD, NekDouble > &coord_1=NullNekDouble1DArray, Array< OneD, NekDouble > &coord_2=NullNekDouble1DArray)
This function calculates the coordinates of all the elemental quadrature points .
Definition: ExpList.h:1770
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1063
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2070
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Definition: ExpList.h:1125
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Definition: ExpList.h:1099
void HomogeneousFwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true)
Definition: ExpList.h:1840
int GetCoordim(int eid)
This function returns the dimension of the coordinates of the element eid.
Definition: ExpList.h:1903
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< double > z(NPUPPER)
double NekDouble
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.hpp:100
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
STL namespace.