Nektar++
ExpList1DHomogeneous2D.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File ExpList1DHomogeneous2D.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 
36 #include <boost/core/ignore_unused.hpp>
37 
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
44  namespace MultiRegions
45  {
46  // Forward declaration for typedefs
47  ExpList1DHomogeneous2D::ExpList1DHomogeneous2D():
49  {
50  }
51 
52  // Constructor for ExpList1DHomogeneous2D to act as a Explist1D field
54  const LibUtilities::BasisKey &HomoBasis_y,
55  const LibUtilities::BasisKey &HomoBasis_z,
56  const NekDouble lhom_y,
57  const NekDouble lhom_z,
58  const bool useFFT,
59  const bool dealiasing,
60  const Array<OneD, ExpListSharedPtr> &points):
61  ExpListHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing)
62  {
63  int n,nel;
64 
65  ASSERTL1(m_ny*m_nz == points.num_elements(),
66  "Size of basis number of points and number of lines are "
67  "not the same");
68 
69  for(n = 0; n < points.num_elements(); ++n)
70  {
71  m_lines[n] = points[n];
72  (*m_exp).push_back(points[n]->GetExp(0));
73  }
74 
75  // Setup Default optimisation information.
76  nel = 1;
79 
80  SetCoeffPhys();
81  }
82 
83  /**
84  * @param In ExpList1DHomogeneous2D object to copy.
85  */
88  {
89  for(int n = 0; n < m_lines.num_elements(); ++n)
90  {
91  m_lines[n] = In.m_lines[n];
92  }
93 
94  SetCoeffPhys();
95  }
96 
97  /**
98  * Destructor
99  */
101  {
102  }
103 
105  {
106  int i,n,cnt;
107  int ncoeffs_per_line = m_lines[0]->GetNcoeffs();
108  int npoints_per_line = m_lines[0]->GetTotPoints();
109 
110  int nyzlines = m_lines.num_elements();
111 
112  // Set total coefficients and points
113  m_ncoeffs = ncoeffs_per_line*nyzlines;
114  m_npoints = npoints_per_line*nyzlines;
115 
118 
119  int nel = m_lines[0]->GetExpSize();
120  m_coeff_offset = Array<OneD,int>(nel*nyzlines);
121  m_phys_offset = Array<OneD,int>(nel*nyzlines);
122  Array<OneD, NekDouble> tmparray;
123 
124  for(cnt = n = 0; n < nyzlines; ++n)
125  {
126  m_lines[n]->SetCoeffsArray(tmparray= m_coeffs + ncoeffs_per_line*n);
127  m_lines[n]->SetPhysArray(tmparray = m_phys + npoints_per_line*n);
128 
129  for(i = 0; i < nel; ++i)
130  {
131  m_coeff_offset[cnt] = m_lines[n]->GetCoeff_Offset(i) + n*ncoeffs_per_line;
132  m_phys_offset[cnt++] = m_lines[n]->GetPhys_Offset(i) + n*npoints_per_line;
133  }
134  }
135  }
136 
141  {
142  boost::ignore_unused(eid);
143 
144  int n,m,j;
145  Array<OneD, NekDouble> tmp_xc;
146  int nylines = m_homogeneousBasis_y->GetNumPoints();
147  int nzlines = m_homogeneousBasis_z->GetNumPoints();
148  int npoints = 1;
149 
150  // Fill x-y-z-direction
153 
154  Array<OneD, NekDouble> x(npoints);
155  Array<OneD, NekDouble> y(nylines);
156  Array<OneD, NekDouble> z(nzlines);
157 
158  Vmath::Smul(nylines,m_lhom_y/2.0,pts_y,1,y,1);
159  Vmath::Sadd(nylines,m_lhom_y/2.0,y,1,y,1);
160 
161  Vmath::Smul(nzlines,m_lhom_z/2.0,pts_z,1,z,1);
162  Vmath::Sadd(nzlines,m_lhom_z/2.0,z,1,z,1);
163 
164  m_lines[0]->GetCoords(x);
165 
166 
167  for(m = 0; m < nzlines; ++m)
168  {
169  for(j = 0; j < nylines; ++j)
170  {
171  for(n = 0; n < npoints; ++n)
172  {
173  Vmath::Fill(1,x[n],tmp_xc = xc0 + n +(j*npoints) + (m*npoints*nylines), 1);
174  Vmath::Fill(1,y[j],tmp_xc = xc1 + n +(j*npoints) + (m*npoints*nylines), 1);
175  Vmath::Fill(1,z[m],tmp_xc = xc2 + n +(j*npoints) + (m*npoints*nylines), 1);
176  }
177  }
178  }
179  }
180 
181  /**
182  * The operation calls the 2D plane coordinates through the
183  * function ExpList#GetCoords and then evaluated the third
184  * coordinate using the member \a m_lhom
185  *
186  * @param coord_0 After calculation, the \f$x_1\f$ coordinate
187  * will be stored in this array.
188  *
189  * @param coord_1 After calculation, the \f$x_2\f$ coordinate
190  * will be stored in this array. This
191  * coordinate might be evaluated using the
192  * predefined value \a m_lhom
193  *
194  * @param coord_2 After calculation, the \f$x_3\f$ coordinate
195  * will be stored in this array. This
196  * coordinate is evaluated using the
197  * predefined value \a m_lhom
198  */
202  {
203  int n,m,j;
204  Array<OneD, NekDouble> tmp_xc;
205  int npoints = 1;
206 
207  int nylines = m_homogeneousBasis_y->GetNumPoints();
208  int nzlines = m_homogeneousBasis_z->GetNumPoints();
209 
210  // Fill z-direction
213 
214  Array<OneD, NekDouble> x(npoints);
215  Array<OneD, NekDouble> y(nylines);
216  Array<OneD, NekDouble> z(nzlines);
217 
218  m_lines[0]->GetCoords(x);
219 
220  Vmath::Smul(nylines,m_lhom_y/2.0,pts_y,1,y,1);
221  Vmath::Sadd(nylines,m_lhom_y/2.0,y,1,y,1);
222 
223  Vmath::Smul(nzlines,m_lhom_z/2.0,pts_z,1,z,1);
224  Vmath::Sadd(nzlines,m_lhom_z/2.0,z,1,z,1);
225 
226  for(m = 0; m < nzlines; ++m)
227  {
228  for(j = 0; j < nylines; ++j)
229  {
230  for(n = 0; n < npoints; ++n)
231  {
232  Vmath::Fill(1,x[n],tmp_xc = xc0 + n +(j*npoints) + (m*npoints*nylines), 1);
233  Vmath::Fill(1,y[j],tmp_xc = xc1 + n +(j*npoints) + (m*npoints*nylines), 1);
234  Vmath::Fill(1,z[m],tmp_xc = xc2 + n +(j*npoints) + (m*npoints*nylines), 1);
235  }
236  }
237  }
238  }
239 
240 
241  /**
242  * Perform the 2D Forward transform of a set of points representing a plane of
243  * boundary conditions which are merely the collection of the boundary conditions
244  * coming from each 1D expansion.
245  * @param inarray The value of the BC on each point of the y-z homogeneous plane.
246  * @param outarray The value of the the coefficient of the 2D Fourier expansion
247  */
248  //void HomoFwdTrans2D(const Array<OneD, const NekDouble> &inarray, Array<OneD, NekDouble> &outarray)
249  //{
250 
251 
252  //}
253 
254  /**
255  * Write Tecplot Files Zone
256  * @param outfile Output file name.
257  * @param expansion Expansion that is considered
258  */
259  void ExpList1DHomogeneous2D::v_WriteTecplotZone(std::ostream &outfile, int expansion)
260  {
261  int i,j;
262 
263  int nquad0 = 1;
264  int nquad1 = m_homogeneousBasis_y->GetNumPoints();
265  int nquad2 = m_homogeneousBasis_z->GetNumPoints();
266 
267  Array<OneD,NekDouble> coords[3];
268 
269  coords[0] = Array<OneD,NekDouble>(3*nquad0*nquad1*nquad2);
270  coords[1] = coords[0] + nquad0*nquad1*nquad2;
271  coords[2] = coords[1] + nquad0*nquad1*nquad2;
272 
273  GetCoords(expansion,coords[0],coords[1],coords[2]);
274 
275  outfile << "Zone, I=" << nquad1 << ", J=" << nquad0*nquad2
276  << ", F=Block" << std::endl;
277 
278  for(j = 0; j < nquad1; ++j)
279  {
280  for(i = 0; i < nquad2*GetCoordim(0)+1; ++i)
281  {
282  outfile << coords[j][i] << " ";
283  }
284  outfile << std::endl;
285  }
286  }
287 
288 
289  void ExpList1DHomogeneous2D::v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
290  {
291  boost::ignore_unused(istrip);
292 
293  int i,j;
294 
295  int nquad0 = 1;
296  int nquad1 = m_homogeneousBasis_y->GetNumPoints();
297  int nquad2 = m_homogeneousBasis_z->GetNumPoints();
298 
299  int ntot = nquad0*nquad1*nquad2;
300  int ntotminus = (nquad0)*(nquad1-1)*(nquad2-1);
301 
302  Array<OneD,NekDouble> coords[3];
303  coords[0] = Array<OneD,NekDouble>(ntot);
304  coords[1] = Array<OneD,NekDouble>(ntot);
305  coords[2] = Array<OneD,NekDouble>(ntot);
306  GetCoords(expansion,coords[0],coords[1],coords[2]);
307 
308  outfile << " <Piece NumberOfPoints=\""
309  << ntot << "\" NumberOfCells=\""
310  << ntotminus << "\">" << endl;
311  outfile << " <Points>" << endl;
312  outfile << " <DataArray type=\"Float32\" "
313  << "NumberOfComponents=\"3\" format=\"ascii\">" << endl;
314  outfile << " ";
315  for (i = 0; i < ntot; ++i)
316  {
317  for (j = 0; j < 3; ++j)
318  {
319  outfile << coords[j][i] << " ";
320  }
321  outfile << endl;
322  }
323  outfile << endl;
324  outfile << " </DataArray>" << endl;
325  outfile << " </Points>" << endl;
326  outfile << " <Cells>" << endl;
327  outfile << " <DataArray type=\"Int32\" "
328  << "Name=\"connectivity\" format=\"ascii\">" << endl;
329  for (i = 0; i < nquad0; ++i)
330  {
331  for (j = 0; j < nquad1-1; ++j)
332  {
333  outfile << j*nquad0 + i << " "
334  << j*nquad0 + i + 1 << " "
335  << (j+1)*nquad0 + i + 1 << " "
336  << (j+1)*nquad0 + i << endl;
337  }
338  }
339  outfile << endl;
340  outfile << " </DataArray>" << endl;
341  outfile << " <DataArray type=\"Int32\" "
342  << "Name=\"offsets\" format=\"ascii\">" << endl;
343  for (i = 0; i < ntotminus; ++i)
344  {
345  outfile << i*4+4 << " ";
346  }
347  outfile << endl;
348  outfile << " </DataArray>" << endl;
349  outfile << " <DataArray type=\"UInt8\" "
350  << "Name=\"types\" format=\"ascii\">" << endl;
351  for (i = 0; i < ntotminus; ++i)
352  {
353  outfile << "9 ";
354  }
355  outfile << endl;
356  outfile << " </DataArray>" << endl;
357  outfile << " </Cells>" << endl;
358  outfile << " <PointData>" << endl;
359  }
360 
361 
362  } //end of namespace
363 } //end of namespace
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1106
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void SetCoeffPhys(void)
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
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 . ...
STL namespace.
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
Definition: ExpList.h:1069
NekDouble m_lhom_z
Width of homogeneous direction z.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:1052
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2191
Array< OneD, ExpListSharedPtr > m_lines
Vector of ExpList, will be filled with ExpList1D.
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
Definition: ExpList.h:1101
Abstraction of a one-dimensional multi-elemental expansion which is merely a collection of local expa...
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:216
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Definition: ExpList.h:1104
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1030
NekDouble m_lhom_y
Width of homogeneous direction y.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
virtual void v_GetCoords(Array< OneD, NekDouble > &coord_0, Array< OneD, NekDouble > &coord_1, Array< OneD, NekDouble > &coord_2)
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.cpp:318
int m_ny
Number of modes = number of poitns in y direction.
LibUtilities::BasisSharedPtr m_homogeneousBasis_y
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
int m_nz
Number of modes = number of poitns in z direction.
virtual void v_WriteTecplotZone(std::ostream &outfile, int expansion)
int GetCoordim(int eid)
This function returns the dimension of the coordinates of the element eid.
Definition: ExpList.h:2013
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
Describes the specification for a Basis.
Definition: Basis.h:49
std::shared_ptr< SessionReader > SessionReaderSharedPtr