Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
36#include <boost/core/ignore_unused.hpp>
37
40
41using namespace std;
42
43namespace Nektar
44{
45namespace MultiRegions
46{
47// Forward declaration for typedefs
49{
50}
51
54 const LibUtilities::BasisKey &HomoBasis_y,
55 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
56 const NekDouble lhom_z, const bool useFFT, const bool dealiasing,
58 : ExpListHomogeneous2D(e3DH2D, pSession, HomoBasis_y, HomoBasis_z, lhom_y,
59 lhom_z, useFFT, dealiasing)
60{
61 boost::ignore_unused(ImpType);
62}
63
64// Constructor for ExpList3DHomogeneous2D to act as a Explist field
67 const LibUtilities::BasisKey &HomoBasis_y,
68 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
69 const NekDouble lhom_z, const bool useFFT, const bool dealiasing,
72 : ExpListHomogeneous2D(e3DH2D, pSession, HomoBasis_y, HomoBasis_z, lhom_y,
73 lhom_z, useFFT, dealiasing)
74{
75 int n, j, nel;
76 bool False = false;
77 ExpListSharedPtr line_zero;
78
79 //
81 m_session, graph1D, false, "DefaultVar", ImpType);
82
84 nel = m_lines[0]->GetExpSize();
85
86 for (j = 0; j < nel; ++j)
87 {
88 (*m_exp).push_back(m_lines[0]->GetExp(j));
89 }
90
91 int ny = m_homogeneousBasis_y->GetNumPoints();
92 int nz = m_homogeneousBasis_z->GetNumPoints();
93
94 for (n = 1; n < (ny * nz); ++n)
95 {
96 m_lines[n] =
98 for (j = 0; j < nel; ++j)
99 {
100 (*m_exp).push_back((*m_exp)[j]);
101 }
102 }
103
104 SetCoeffPhys();
105}
106
107/**
108 * @param In ExpList3DHomogeneous2D object to copy.
109 */
111 const ExpList3DHomogeneous2D &In, const bool DeclareLinesSetCoeffPhys)
113{
114 if (DeclareLinesSetCoeffPhys)
115 {
116 bool False = false;
117 ExpListSharedPtr zero_line = In.m_lines[0];
118
119 for (int n = 0; n < m_lines.size(); ++n)
120 {
121 m_lines[n] =
123 }
124
125 SetCoeffPhys();
126 }
127}
128
129/**
130 *
131 */
133 const ExpList3DHomogeneous2D &In, const std::vector<unsigned int> &eIDs,
134 const bool DeclareLinesSetCoeffPhys,
136 : ExpListHomogeneous2D(In, eIDs)
137{
138 if (DeclareLinesSetCoeffPhys)
139 {
140 bool False = false;
141 std::vector<unsigned int> eIDsLine;
142 int nel = eIDs.size() / m_lines.size();
143
144 for (int i = 0; i < nel; ++i)
145 {
146 eIDsLine.push_back(eIDs[i]);
147 }
148
149 ExpListSharedPtr zero_line_old =
150 std::dynamic_pointer_cast<ExpList>(In.m_lines[0]);
151
153 *(zero_line_old), eIDsLine, ImpType);
154
155 for (int n = 0; n < m_lines.size(); ++n)
156 {
157 m_lines[n] =
159 }
160
161 SetCoeffPhys();
162 }
163}
164
165/**
166 * Destructor
167 */
169{
170}
171
173{
174 int i, n, cnt;
175 int ncoeffs_per_line = m_lines[0]->GetNcoeffs();
176 int npoints_per_line = m_lines[0]->GetTotPoints();
177
178 int nyzlines = m_lines.size();
179
180 // Set total coefficients and points
181 m_ncoeffs = ncoeffs_per_line * nyzlines;
182 m_npoints = npoints_per_line * nyzlines;
183
186
187 int nel = m_lines[0]->GetExpSize();
188 m_coeff_offset = Array<OneD, int>(nel * nyzlines);
189 m_phys_offset = Array<OneD, int>(nel * nyzlines);
190 Array<OneD, NekDouble> tmparray;
191
192 for (cnt = n = 0; n < nyzlines; ++n)
193 {
194 m_lines[n]->SetCoeffsArray(tmparray = m_coeffs + ncoeffs_per_line * n);
195 m_lines[n]->SetPhysArray(tmparray = m_phys + npoints_per_line * n);
196
197 for (i = 0; i < nel; ++i)
198 {
199 m_coeff_offset[cnt] =
200 m_lines[n]->GetCoeff_Offset(i) + n * ncoeffs_per_line;
201 m_phys_offset[cnt++] =
202 m_lines[n]->GetPhys_Offset(i) + n * npoints_per_line;
203 }
204 }
205}
206
211{
212 int n, m, j;
214 int nylines = m_homogeneousBasis_y->GetNumPoints();
215 int nzlines = m_homogeneousBasis_z->GetNumPoints();
216
217 int npoints = GetTotPoints(eid);
218
219 // Fill x-y-z-direction
222
223 Array<OneD, NekDouble> x(npoints);
224 Array<OneD, NekDouble> y(nylines);
225 Array<OneD, NekDouble> z(nzlines);
226
227 Vmath::Smul(nylines, m_lhom_y / 2.0, pts_y, 1, y, 1);
228 Vmath::Sadd(nylines, m_lhom_y / 2.0, y, 1, y, 1);
229
230 Vmath::Smul(nzlines, m_lhom_z / 2.0, pts_z, 1, z, 1);
231 Vmath::Sadd(nzlines, m_lhom_z / 2.0, z, 1, z, 1);
232
233 (*m_exp)[eid]->GetCoords(x);
234
235 for (m = 0; m < nzlines; ++m)
236 {
237 for (j = 0; j < nylines; ++j)
238 {
239 for (n = 0; n < npoints; ++n)
240 {
241 Vmath::Fill(1, x[n],
242 tmp_xc = xc0 + n + (j * npoints) +
243 (m * npoints * nylines),
244 1);
245 Vmath::Fill(1, y[j],
246 tmp_xc = xc1 + n + (j * npoints) +
247 (m * npoints * nylines),
248 1);
249 Vmath::Fill(1, z[m],
250 tmp_xc = xc2 + n + (j * npoints) +
251 (m * npoints * nylines),
252 1);
253 }
254 }
255 }
256}
257
258/**
259 * The operation calls the 2D plane coordinates through the
260 * function ExpList#GetCoords and then evaluated the third
261 * coordinate using the member \a m_lhom
262 *
263 * @param coord_0 After calculation, the \f$x_1\f$ coordinate
264 * will be stored in this array.
265 *
266 * @param coord_1 After calculation, the \f$x_2\f$ coordinate
267 * will be stored in this array.
268 *
269 * @param coord_2 After calculation, the \f$x_3\f$ coordinate
270 * will be stored in this array. This
271 * coordinate is evaluated using the
272 * predefined value \a m_lhom
273 */
277{
278 int n, m, j;
280 int npoints = m_lines[0]->GetTotPoints();
281
282 int nylines = m_homogeneousBasis_y->GetNumPoints();
283 int nzlines = m_homogeneousBasis_z->GetNumPoints();
284
285 // Fill z-direction
288
289 Array<OneD, NekDouble> x(npoints);
290 Array<OneD, NekDouble> y(nylines);
291 Array<OneD, NekDouble> z(nzlines);
292
293 m_lines[0]->GetCoords(x);
294
295 Vmath::Smul(nylines, m_lhom_y / 2.0, pts_y, 1, y, 1);
296 Vmath::Sadd(nylines, m_lhom_y / 2.0, y, 1, y, 1);
297
298 Vmath::Smul(nzlines, m_lhom_z / 2.0, pts_z, 1, z, 1);
299 Vmath::Sadd(nzlines, m_lhom_z / 2.0, z, 1, z, 1);
300
301 for (m = 0; m < nzlines; ++m)
302 {
303 for (j = 0; j < nylines; ++j)
304 {
305 for (n = 0; n < npoints; ++n)
306 {
307 Vmath::Fill(1, x[n],
308 tmp_xc = xc0 + n + (j * npoints) +
309 (m * npoints * nylines),
310 1);
311 Vmath::Fill(1, y[j],
312 tmp_xc = xc1 + n + (j * npoints) +
313 (m * npoints * nylines),
314 1);
315 Vmath::Fill(1, z[m],
316 tmp_xc = xc2 + n + (j * npoints) +
317 (m * npoints * nylines),
318 1);
319 }
320 }
321 }
322}
323
324/**
325 * Write Tecplot Files Zone
326 * @param outfile Output file name.
327 * @param expansion Expansion that is considered
328 */
330 int expansion)
331{
332 int i, j;
333
334 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
335 int nquad1 = m_homogeneousBasis_y->GetNumPoints();
336 int nquad2 = m_homogeneousBasis_z->GetNumPoints();
337
338 Array<OneD, NekDouble> coords[3];
339
340 coords[0] = Array<OneD, NekDouble>(3 * nquad0 * nquad1 * nquad2);
341 coords[1] = coords[0] + nquad0 * nquad1 * nquad2;
342 coords[2] = coords[1] + nquad0 * nquad1 * nquad2;
343
344 GetCoords(expansion, coords[0], coords[1], coords[2]);
345
346 outfile << "Zone, I=" << nquad0 << ", J=" << nquad1 << ",K=" << nquad2
347 << ", F=Block" << std::endl;
348
349 for (j = 0; j < 3; ++j)
350 {
351 for (i = 0; i < nquad0 * nquad1 * nquad2; ++i)
352 {
353 outfile << coords[j][i] << " ";
354 }
355 outfile << std::endl;
356 }
357}
358
360 int expansion, int)
361{
362 int i, j, k;
363 int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
364 int nquad1 = m_homogeneousBasis_y->GetNumPoints();
365 int nquad2 = m_homogeneousBasis_z->GetNumPoints();
366 int ntot = nquad0 * nquad1 * nquad2;
367 int ntotminus = (nquad0 - 1) * (nquad1 - 1) * (nquad2 - 1);
368
369 Array<OneD, NekDouble> coords[3];
370 coords[0] = Array<OneD, NekDouble>(ntot);
371 coords[1] = Array<OneD, NekDouble>(ntot);
372 coords[2] = Array<OneD, NekDouble>(ntot);
373 GetCoords(expansion, coords[0], coords[1], coords[2]);
374
375 outfile << " <Piece NumberOfPoints=\"" << ntot << "\" NumberOfCells=\""
376 << ntotminus << "\">" << endl;
377 outfile << " <Points>" << endl;
378 outfile << " <DataArray type=\"Float64\" "
379 << "NumberOfComponents=\"3\" format=\"ascii\">" << endl;
380 outfile << " ";
381 for (i = 0; i < ntot; ++i)
382 {
383 for (j = 0; j < 3; ++j)
384 {
385 outfile << coords[j][i] << " ";
386 }
387 outfile << endl;
388 }
389 outfile << endl;
390 outfile << " </DataArray>" << endl;
391 outfile << " </Points>" << endl;
392 outfile << " <Cells>" << endl;
393 outfile << " <DataArray type=\"Int32\" "
394 << "Name=\"connectivity\" format=\"ascii\">" << endl;
395 for (i = 0; i < nquad0 - 1; ++i)
396 {
397 for (j = 0; j < nquad1 - 1; ++j)
398 {
399 for (k = 0; k < nquad2 - 1; ++k)
400 {
401 outfile << k * nquad0 * nquad1 + j * nquad0 + i << " "
402 << k * nquad0 * nquad1 + j * nquad0 + i + 1 << " "
403 << k * nquad0 * nquad1 + (j + 1) * nquad0 + i + 1 << " "
404 << k * nquad0 * nquad1 + (j + 1) * nquad0 + i << " "
405 << (k + 1) * nquad0 * nquad1 + j * nquad0 + i << " "
406 << (k + 1) * nquad0 * nquad1 + j * nquad0 + i + 1 << " "
407 << (k + 1) * nquad0 * nquad1 + (j + 1) * nquad0 + i + 1
408 << " "
409 << (k + 1) * nquad0 * nquad1 + (j + 1) * nquad0 + i
410 << " " << endl;
411 }
412 }
413 }
414 outfile << endl;
415 outfile << " </DataArray>" << endl;
416 outfile << " <DataArray type=\"Int32\" "
417 << "Name=\"offsets\" format=\"ascii\">" << endl;
418 for (i = 0; i < ntotminus; ++i)
419 {
420 outfile << i * 8 + 8 << " ";
421 }
422 outfile << endl;
423 outfile << " </DataArray>" << endl;
424 outfile << " <DataArray type=\"UInt8\" "
425 << "Name=\"types\" format=\"ascii\">" << endl;
426 for (i = 0; i < ntotminus; ++i)
427 {
428 outfile << "12 ";
429 }
430 outfile << endl;
431 outfile << " </DataArray>" << endl;
432 outfile << " </Cells>" << endl;
433 outfile << " <PointData>" << endl;
434}
435
437 const Array<OneD, const NekDouble> &inarray,
439{
440 int cnt = 0;
441 NekDouble errL2, err = 0.0;
444
445 int nylines = m_homogeneousBasis_y->GetNumPoints();
446 int nzlines = m_homogeneousBasis_z->GetNumPoints();
447
448 for (int m = 0; m < nzlines; ++m)
449 {
450 for (int n = 0; n < nylines; ++n)
451 {
452 errL2 = m_lines[n + (m * nylines)]->L2(inarray + cnt, soln + cnt);
453 cnt += m_lines[n + (m * nylines)]->GetTotPoints();
454 err += errL2 * errL2 * w_y[n] * m_lhom_y * 0.5 * w_z[m] * m_lhom_z *
455 0.5;
456 }
457 }
458
459 return sqrt(err);
460}
461} // namespace MultiRegions
462} // namespace Nektar
Describes the specification for a Basis.
Definition: Basis.h:47
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...
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip) override
virtual NekDouble v_L2(const Array< OneD, const NekDouble > &inarray, const Array< OneD, const NekDouble > &soln=NullNekDouble1DArray) override
virtual 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...
virtual 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:1092
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
Definition: ExpList.h:1136
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:1785
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1127
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1072
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2094
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:518
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:1067
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Definition: ExpList.h:1138
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Definition: ExpList.h:1108
int GetTotPoints(void) const
Returns the total number of quadrature points m_npoints .
Definition: ExpList.h:1572
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:176
std::vector< double > z(NPUPPER)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
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.cpp:245
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:43
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add scalar y = alpha + x.
Definition: Vmath.cpp:379
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294