Nektar++
ExpList3DHomogeneous2D.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ExpList3DHomogeneous2D.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 ExpList which is homogeneous in 2 directions and so
32// uses much of the functionality from a ExpList and its daughters
33//
34///////////////////////////////////////////////////////////////////////////////
35
38
39using namespace std;
40
42{
43// Forward declaration for typedefs
45{
46}
47
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,
53 [[maybe_unused]] const Collections::ImplementationType ImpType)
54 : ExpListHomogeneous2D(e3DH2D, pSession, HomoBasis_y, HomoBasis_z, lhom_y,
55 lhom_z, useFFT, dealiasing)
56{
57}
58
59// Constructor for ExpList3DHomogeneous2D to act as a Explist field
62 const LibUtilities::BasisKey &HomoBasis_y,
63 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
64 const NekDouble lhom_z, const bool useFFT, const bool dealiasing,
67 : ExpListHomogeneous2D(e3DH2D, pSession, HomoBasis_y, HomoBasis_z, lhom_y,
68 lhom_z, useFFT, dealiasing)
69{
70 int n, j, nel;
71 bool False = false;
72 ExpListSharedPtr line_zero;
73
74 //
76 m_session, graph1D, false, "DefaultVar", ImpType);
77
79 nel = m_lines[0]->GetExpSize();
80
81 for (j = 0; j < nel; ++j)
82 {
83 (*m_exp).push_back(m_lines[0]->GetExp(j));
84 }
85
86 int ny = m_homogeneousBasis_y->GetNumPoints();
87 int nz = m_homogeneousBasis_z->GetNumPoints();
88
89 for (n = 1; n < (ny * nz); ++n)
90 {
91 m_lines[n] =
93 for (j = 0; j < nel; ++j)
94 {
95 (*m_exp).push_back((*m_exp)[j]);
96 }
97 }
98
100}
101
102/**
103 * @param In ExpList3DHomogeneous2D object to copy.
104 */
106 const ExpList3DHomogeneous2D &In, const bool DeclareLinesSetCoeffPhys)
108{
109 if (DeclareLinesSetCoeffPhys)
110 {
111 bool False = false;
112 ExpListSharedPtr zero_line = In.m_lines[0];
113
114 for (int n = 0; n < m_lines.size(); ++n)
115 {
116 m_lines[n] =
118 }
119
120 SetCoeffPhys();
121 }
122}
123
124/**
125 *
126 */
128 const ExpList3DHomogeneous2D &In, const std::vector<unsigned int> &eIDs,
129 const bool DeclareLinesSetCoeffPhys,
131 : ExpListHomogeneous2D(In, eIDs)
132{
133 if (DeclareLinesSetCoeffPhys)
134 {
135 bool False = false;
136 std::vector<unsigned int> eIDsLine;
137 int nel = eIDs.size() / m_lines.size();
138
139 for (int i = 0; i < nel; ++i)
140 {
141 eIDsLine.push_back(eIDs[i]);
142 }
143
144 ExpListSharedPtr zero_line_old =
145 std::dynamic_pointer_cast<ExpList>(In.m_lines[0]);
146
148 *(zero_line_old), eIDsLine, ImpType);
149
150 for (int n = 0; n < m_lines.size(); ++n)
151 {
152 m_lines[n] =
154 }
155
156 SetCoeffPhys();
157 }
158}
159
160/**
161 * Destructor
162 */
164{
165}
166
168{
169 int i, n, cnt;
170 int ncoeffs_per_line = m_lines[0]->GetNcoeffs();
171 int npoints_per_line = m_lines[0]->GetTotPoints();
172
173 int nyzlines = m_lines.size();
174
175 // Set total coefficients and points
176 m_ncoeffs = ncoeffs_per_line * nyzlines;
177 m_npoints = npoints_per_line * nyzlines;
178
181
182 int nel = m_lines[0]->GetExpSize();
183 m_coeff_offset = Array<OneD, int>(nel * nyzlines);
184 m_phys_offset = Array<OneD, int>(nel * nyzlines);
185 Array<OneD, NekDouble> tmparray;
186
187 for (cnt = n = 0; n < nyzlines; ++n)
188 {
189 m_lines[n]->SetCoeffsArray(tmparray = m_coeffs + ncoeffs_per_line * n);
190 m_lines[n]->SetPhysArray(tmparray = m_phys + npoints_per_line * n);
191
192 for (i = 0; i < nel; ++i)
193 {
194 m_coeff_offset[cnt] =
195 m_lines[n]->GetCoeff_Offset(i) + n * ncoeffs_per_line;
196 m_phys_offset[cnt++] =
197 m_lines[n]->GetPhys_Offset(i) + n * npoints_per_line;
198 }
199 }
200}
201
206{
207 int n, m, j;
209 int nylines = m_homogeneousBasis_y->GetNumPoints();
210 int nzlines = m_homogeneousBasis_z->GetNumPoints();
211
212 int npoints = GetTotPoints(eid);
213
214 // Fill x-y-z-direction
217
218 Array<OneD, NekDouble> x(npoints);
219 Array<OneD, NekDouble> y(nylines);
220 Array<OneD, NekDouble> z(nzlines);
221
222 Vmath::Smul(nylines, m_lhom_y / 2.0, pts_y, 1, y, 1);
223 Vmath::Sadd(nylines, m_lhom_y / 2.0, y, 1, y, 1);
224
225 Vmath::Smul(nzlines, m_lhom_z / 2.0, pts_z, 1, z, 1);
226 Vmath::Sadd(nzlines, m_lhom_z / 2.0, z, 1, z, 1);
227
228 (*m_exp)[eid]->GetCoords(x);
229
230 for (m = 0; m < nzlines; ++m)
231 {
232 for (j = 0; j < nylines; ++j)
233 {
234 for (n = 0; n < npoints; ++n)
235 {
236 Vmath::Fill(1, x[n],
237 tmp_xc = xc0 + n + (j * npoints) +
238 (m * npoints * nylines),
239 1);
240 Vmath::Fill(1, y[j],
241 tmp_xc = xc1 + n + (j * npoints) +
242 (m * npoints * nylines),
243 1);
244 Vmath::Fill(1, z[m],
245 tmp_xc = xc2 + n + (j * npoints) +
246 (m * npoints * nylines),
247 1);
248 }
249 }
250 }
251}
252
253/**
254 * The operation calls the 2D plane coordinates through the
255 * function ExpList#GetCoords and then evaluated the third
256 * coordinate using the member \a m_lhom
257 *
258 * @param coord_0 After calculation, the \f$x_1\f$ coordinate
259 * will be stored in this array.
260 *
261 * @param coord_1 After calculation, the \f$x_2\f$ coordinate
262 * will be stored in this array.
263 *
264 * @param coord_2 After calculation, the \f$x_3\f$ coordinate
265 * will be stored in this array. This
266 * coordinate is evaluated using the
267 * predefined value \a m_lhom
268 */
272{
273 int n, m, j;
275 int npoints = m_lines[0]->GetTotPoints();
276
277 int nylines = m_homogeneousBasis_y->GetNumPoints();
278 int nzlines = m_homogeneousBasis_z->GetNumPoints();
279
280 // Fill z-direction
283
284 Array<OneD, NekDouble> x(npoints);
285 Array<OneD, NekDouble> y(nylines);
286 Array<OneD, NekDouble> z(nzlines);
287
288 m_lines[0]->GetCoords(x);
289
290 Vmath::Smul(nylines, m_lhom_y / 2.0, pts_y, 1, y, 1);
291 Vmath::Sadd(nylines, m_lhom_y / 2.0, y, 1, y, 1);
292
293 Vmath::Smul(nzlines, m_lhom_z / 2.0, pts_z, 1, z, 1);
294 Vmath::Sadd(nzlines, m_lhom_z / 2.0, z, 1, z, 1);
295
296 for (m = 0; m < nzlines; ++m)
297 {
298 for (j = 0; j < nylines; ++j)
299 {
300 for (n = 0; n < npoints; ++n)
301 {
302 Vmath::Fill(1, x[n],
303 tmp_xc = xc0 + n + (j * npoints) +
304 (m * npoints * nylines),
305 1);
306 Vmath::Fill(1, y[j],
307 tmp_xc = xc1 + n + (j * npoints) +
308 (m * npoints * nylines),
309 1);
310 Vmath::Fill(1, z[m],
311 tmp_xc = xc2 + n + (j * npoints) +
312 (m * npoints * nylines),
313 1);
314 }
315 }
316 }
317}
318
319/**
320 * Write Tecplot Files Zone
321 * @param outfile Output file name.
322 * @param expansion Expansion that is considered
323 */
325 int expansion)
326{
327 int i, j;
328
329 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
330 int nquad1 = m_homogeneousBasis_y->GetNumPoints();
331 int nquad2 = m_homogeneousBasis_z->GetNumPoints();
332
333 Array<OneD, NekDouble> coords[3];
334
335 coords[0] = Array<OneD, NekDouble>(3 * nquad0 * nquad1 * nquad2);
336 coords[1] = coords[0] + nquad0 * nquad1 * nquad2;
337 coords[2] = coords[1] + nquad0 * nquad1 * nquad2;
338
339 GetCoords(expansion, coords[0], coords[1], coords[2]);
340
341 outfile << "Zone, I=" << nquad0 << ", J=" << nquad1 << ",K=" << nquad2
342 << ", F=Block" << std::endl;
343
344 for (j = 0; j < 3; ++j)
345 {
346 for (i = 0; i < nquad0 * nquad1 * nquad2; ++i)
347 {
348 outfile << coords[j][i] << " ";
349 }
350 outfile << std::endl;
351 }
352}
353
355 int expansion, int)
356{
357 int i, j, k;
358 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
359 int nquad1 = m_homogeneousBasis_y->GetNumPoints();
360 int nquad2 = m_homogeneousBasis_z->GetNumPoints();
361 int ntot = nquad0 * nquad1 * nquad2;
362 int ntotminus = (nquad0 - 1) * (nquad1 - 1) * (nquad2 - 1);
363
364 Array<OneD, NekDouble> coords[3];
365 coords[0] = Array<OneD, NekDouble>(ntot);
366 coords[1] = Array<OneD, NekDouble>(ntot);
367 coords[2] = Array<OneD, NekDouble>(ntot);
368 GetCoords(expansion, coords[0], coords[1], coords[2]);
369
370 outfile << " <Piece NumberOfPoints=\"" << ntot << "\" NumberOfCells=\""
371 << ntotminus << "\">" << endl;
372 outfile << " <Points>" << endl;
373 outfile << " <DataArray type=\"Float64\" "
374 << R"(NumberOfComponents="3" format="ascii">)" << endl;
375 outfile << " ";
376 for (i = 0; i < ntot; ++i)
377 {
378 for (j = 0; j < 3; ++j)
379 {
380 outfile << coords[j][i] << " ";
381 }
382 outfile << endl;
383 }
384 outfile << endl;
385 outfile << " </DataArray>" << endl;
386 outfile << " </Points>" << endl;
387 outfile << " <Cells>" << endl;
388 outfile << " <DataArray type=\"Int32\" "
389 << R"(Name="connectivity" format="ascii">)" << endl;
390 for (i = 0; i < nquad0 - 1; ++i)
391 {
392 for (j = 0; j < nquad1 - 1; ++j)
393 {
394 for (k = 0; k < nquad2 - 1; ++k)
395 {
396 outfile << k * nquad0 * nquad1 + j * nquad0 + i << " "
397 << k * nquad0 * nquad1 + j * nquad0 + i + 1 << " "
398 << k * nquad0 * nquad1 + (j + 1) * nquad0 + i + 1 << " "
399 << k * nquad0 * nquad1 + (j + 1) * nquad0 + i << " "
400 << (k + 1) * nquad0 * nquad1 + j * nquad0 + i << " "
401 << (k + 1) * nquad0 * nquad1 + j * nquad0 + i + 1 << " "
402 << (k + 1) * nquad0 * nquad1 + (j + 1) * nquad0 + i + 1
403 << " "
404 << (k + 1) * nquad0 * nquad1 + (j + 1) * nquad0 + i
405 << " " << endl;
406 }
407 }
408 }
409 outfile << endl;
410 outfile << " </DataArray>" << endl;
411 outfile << " <DataArray type=\"Int32\" "
412 << R"(Name="offsets" format="ascii">)" << endl;
413 for (i = 0; i < ntotminus; ++i)
414 {
415 outfile << i * 8 + 8 << " ";
416 }
417 outfile << endl;
418 outfile << " </DataArray>" << endl;
419 outfile << " <DataArray type=\"UInt8\" "
420 << R"(Name="types" format="ascii">)" << endl;
421 for (i = 0; i < ntotminus; ++i)
422 {
423 outfile << "12 ";
424 }
425 outfile << endl;
426 outfile << " </DataArray>" << endl;
427 outfile << " </Cells>" << endl;
428 outfile << " <PointData>" << endl;
429}
430
432 const Array<OneD, const NekDouble> &inarray,
434{
435 int cnt = 0;
436 NekDouble errL2, err = 0.0;
439
440 int nylines = m_homogeneousBasis_y->GetNumPoints();
441 int nzlines = m_homogeneousBasis_z->GetNumPoints();
442
443 for (int m = 0; m < nzlines; ++m)
444 {
445 for (int n = 0; n < nylines; ++n)
446 {
447 errL2 = m_lines[n + (m * nylines)]->L2(inarray + cnt, soln + cnt);
448 cnt += m_lines[n + (m * nylines)]->GetTotPoints();
449 err += errL2 * errL2 * w_y[n] * m_lhom_y * 0.5 * w_z[m] * m_lhom_z *
450 0.5;
451 }
452 }
453
454 return sqrt(err);
455}
456} // namespace Nektar::MultiRegions
Describes the specification for a Basis.
Definition: Basis.h:45
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Abstraction of a one-dimensional multi-elemental expansion which is merely a collection of local expa...
void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip) override
NekDouble v_L2(const Array< OneD, const NekDouble > &inarray, const Array< OneD, const NekDouble > &soln=NullNekDouble1DArray) override
void v_WriteTecplotZone(std::ostream &outfile, int expansion) override
void SetCoeffPhys(void)
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
void v_GetCoords(Array< OneD, NekDouble > &coord_0, Array< OneD, NekDouble > &coord_1, Array< OneD, NekDouble > &coord_2) override
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
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.
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
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1118
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
NekDouble L2(const Array< OneD, const NekDouble > &inarray, const Array< OneD, const NekDouble > &soln=NullNekDouble1DArray)
This function calculates the error of the global This function calculates the error with respect to...
Definition: ExpList.h:514
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:1058
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
int GetTotPoints(void) const
Returns the total number of quadrature points m_npoints .
Definition: ExpList.h:1557
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
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
STL namespace.
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294