Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: An ExpList1D which is homogeneous in 2 directions and so
33 // uses much of the functionality from a ExpList2D and its daughters
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43  namespace MultiRegions
44  {
45  // Forward declaration for typedefs
46  ExpList1DHomogeneous2D::ExpList1DHomogeneous2D():
48  {
49  }
50 
51  // Constructor for ExpList1DHomogeneous2D to act as a Explist1D field
53  const LibUtilities::BasisKey &HomoBasis_y,
54  const LibUtilities::BasisKey &HomoBasis_z,
55  const NekDouble lhom_y,
56  const NekDouble lhom_z,
57  const bool useFFT,
58  const bool dealiasing,
59  const Array<OneD, ExpListSharedPtr> &points):
60  ExpListHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing)
61  {
62  int n,nel;
63 
64  ASSERTL1(m_ny*m_nz == points.num_elements(),
65  "Size of basis number of points and number of lines are "
66  "not the same");
67 
68  for(n = 0; n < points.num_elements(); ++n)
69  {
70  m_lines[n] = points[n];
71  }
72 
73  // Setup Default optimisation information.
74  nel = 1;
77 
78  SetCoeffPhys();
79  }
80 
81  /**
82  * @param In ExpList1DHomogeneous2D object to copy.
83  */
86  {
87  for(int n = 0; n < m_lines.num_elements(); ++n)
88  {
89  m_lines[n] = In.m_lines[n];
90  }
91 
92  SetCoeffPhys();
93  }
94 
95  /**
96  * Destructor
97  */
99  {
100  }
101 
103  {
104  int i,n,cnt;
105  int ncoeffs_per_line = m_lines[0]->GetNcoeffs();
106  int npoints_per_line = m_lines[0]->GetTotPoints();
107 
108  int nyzlines = m_lines.num_elements();
109 
110  // Set total coefficients and points
111  m_ncoeffs = ncoeffs_per_line*nyzlines;
112  m_npoints = npoints_per_line*nyzlines;
113 
116 
117  int nel = m_lines[0]->GetExpSize();
118  m_coeff_offset = Array<OneD,int>(nel*nyzlines);
119  m_phys_offset = Array<OneD,int>(nel*nyzlines);
120  m_offset_elmt_id = Array<OneD,int>(nel*nyzlines);
121  Array<OneD, NekDouble> tmparray;
122 
123  for(cnt = n = 0; n < nyzlines; ++n)
124  {
125  m_lines[n]->SetCoeffsArray(tmparray= m_coeffs + ncoeffs_per_line*n);
126  m_lines[n]->SetPhysArray(tmparray = m_phys + npoints_per_line*n);
127 
128  for(i = 0; i < nel; ++i)
129  {
130  m_coeff_offset[cnt] = m_lines[n]->GetCoeff_Offset(i) + n*ncoeffs_per_line;
131  m_phys_offset[cnt] = m_lines[n]->GetPhys_Offset(i) + n*npoints_per_line;
132  m_offset_elmt_id[cnt++] = m_lines[n]->GetOffset_Elmt_Id(i) + n*nel;
133  }
134  }
135  }
136 
141  {
142  int n,m,j;
143  Array<OneD, NekDouble> tmp_xc;
144  int nylines = m_homogeneousBasis_y->GetNumPoints();
145  int nzlines = m_homogeneousBasis_z->GetNumPoints();
146  int npoints = 1;
147 
148  // Fill x-y-z-direction
151 
152  Array<OneD, NekDouble> x(npoints);
153  Array<OneD, NekDouble> y(nylines);
154  Array<OneD, NekDouble> z(nzlines);
155 
156  Vmath::Smul(nylines,m_lhom_y/2.0,pts_y,1,y,1);
157  Vmath::Sadd(nylines,m_lhom_y/2.0,y,1,y,1);
158 
159  Vmath::Smul(nzlines,m_lhom_z/2.0,pts_z,1,z,1);
160  Vmath::Sadd(nzlines,m_lhom_z/2.0,z,1,z,1);
161 
162  m_lines[0]->GetCoords(x);
163 
164 
165  for(m = 0; m < nzlines; ++m)
166  {
167  for(j = 0; j < nylines; ++j)
168  {
169  for(n = 0; n < npoints; ++n)
170  {
171  Vmath::Fill(1,x[n],tmp_xc = xc0 + n +(j*npoints) + (m*npoints*nylines), 1);
172  Vmath::Fill(1,y[j],tmp_xc = xc1 + n +(j*npoints) + (m*npoints*nylines), 1);
173  Vmath::Fill(1,z[m],tmp_xc = xc2 + n +(j*npoints) + (m*npoints*nylines), 1);
174  }
175  }
176  }
177  }
178 
179  /**
180  * The operation calls the 2D plane coordinates through the
181  * function ExpList#GetCoords and then evaluated the third
182  * coordinate using the member \a m_lhom
183  *
184  * @param coord_0 After calculation, the \f$x_1\f$ coordinate
185  * will be stored in this array.
186  *
187  * @param coord_1 After calculation, the \f$x_2\f$ coordinate
188  * will be stored in this array. This
189  * coordinate might be evaluated using the
190  * predefined value \a m_lhom
191  *
192  * @param coord_2 After calculation, the \f$x_3\f$ coordinate
193  * will be stored in this array. This
194  * coordinate is evaluated using the
195  * predefined value \a m_lhom
196  */
200  {
201  int n,m,j;
202  Array<OneD, NekDouble> tmp_xc;
203  int npoints = 1;
204 
205  int nylines = m_homogeneousBasis_y->GetNumPoints();
206  int nzlines = m_homogeneousBasis_z->GetNumPoints();
207 
208  // Fill z-direction
211 
212  Array<OneD, NekDouble> x(npoints);
213  Array<OneD, NekDouble> y(nylines);
214  Array<OneD, NekDouble> z(nzlines);
215 
216  m_lines[0]->GetCoords(x);
217 
218  Vmath::Smul(nylines,m_lhom_y/2.0,pts_y,1,y,1);
219  Vmath::Sadd(nylines,m_lhom_y/2.0,y,1,y,1);
220 
221  Vmath::Smul(nzlines,m_lhom_z/2.0,pts_z,1,z,1);
222  Vmath::Sadd(nzlines,m_lhom_z/2.0,z,1,z,1);
223 
224  for(m = 0; m < nzlines; ++m)
225  {
226  for(j = 0; j < nylines; ++j)
227  {
228  for(n = 0; n < npoints; ++n)
229  {
230  Vmath::Fill(1,x[n],tmp_xc = xc0 + n +(j*npoints) + (m*npoints*nylines), 1);
231  Vmath::Fill(1,y[j],tmp_xc = xc1 + n +(j*npoints) + (m*npoints*nylines), 1);
232  Vmath::Fill(1,z[m],tmp_xc = xc2 + n +(j*npoints) + (m*npoints*nylines), 1);
233  }
234  }
235  }
236  }
237 
238 
239  /**
240  * Perform the 2D Forward transform of a set of points representing a plane of
241  * boundary conditions which are merely the collection of the boundary conditions
242  * coming from each 1D expansion.
243  * @param inarray The value of the BC on each point of the y-z homogeneous plane.
244  * @param outarray The value of the the coefficient of the 2D Fourier expansion
245  */
246  //void HomoFwdTrans2D(const Array<OneD, const NekDouble> &inarray, Array<OneD, NekDouble> &outarray)
247  //{
248 
249 
250  //}
251 
252  /**
253  * Write Tecplot Files Zone
254  * @param outfile Output file name.
255  * @param expansion Expansion that is considered
256  */
257  void ExpList1DHomogeneous2D::v_WriteTecplotZone(std::ostream &outfile, int expansion)
258  {
259  int i,j;
260 
261  int nquad0 = 1;
262  int nquad1 = m_homogeneousBasis_y->GetNumPoints();
263  int nquad2 = m_homogeneousBasis_z->GetNumPoints();
264 
265  Array<OneD,NekDouble> coords[3];
266 
267  coords[0] = Array<OneD,NekDouble>(3*nquad0*nquad1*nquad2);
268  coords[1] = coords[0] + nquad0*nquad1*nquad2;
269  coords[2] = coords[1] + nquad0*nquad1*nquad2;
270 
271  GetCoords(expansion,coords[0],coords[1],coords[2]);
272 
273  outfile << "Zone, I=" << nquad1 << ", J=" << nquad0*nquad2
274  << ", F=Block" << std::endl;
275 
276  for(j = 0; j < nquad1; ++j)
277  {
278  for(i = 0; i < nquad2*GetCoordim(0)+1; ++i)
279  {
280  outfile << coords[j][i] << " ";
281  }
282  outfile << std::endl;
283  }
284  }
285 
286 
287  void ExpList1DHomogeneous2D::v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
288  {
289  int i,j;
290 
291  int nquad0 = 1;
292  int nquad1 = m_homogeneousBasis_y->GetNumPoints();
293  int nquad2 = m_homogeneousBasis_z->GetNumPoints();
294 
295  int ntot = nquad0*nquad1*nquad2;
296  int ntotminus = (nquad0)*(nquad1-1)*(nquad2-1);
297 
298  Array<OneD,NekDouble> coords[3];
299  coords[0] = Array<OneD,NekDouble>(ntot);
300  coords[1] = Array<OneD,NekDouble>(ntot);
301  coords[2] = Array<OneD,NekDouble>(ntot);
302  GetCoords(expansion,coords[0],coords[1],coords[2]);
303 
304  outfile << " <Piece NumberOfPoints=\""
305  << ntot << "\" NumberOfCells=\""
306  << ntotminus << "\">" << endl;
307  outfile << " <Points>" << endl;
308  outfile << " <DataArray type=\"Float32\" "
309  << "NumberOfComponents=\"3\" format=\"ascii\">" << endl;
310  outfile << " ";
311  for (i = 0; i < ntot; ++i)
312  {
313  for (j = 0; j < 3; ++j)
314  {
315  outfile << coords[j][i] << " ";
316  }
317  outfile << endl;
318  }
319  outfile << endl;
320  outfile << " </DataArray>" << endl;
321  outfile << " </Points>" << endl;
322  outfile << " <Cells>" << endl;
323  outfile << " <DataArray type=\"Int32\" "
324  << "Name=\"connectivity\" format=\"ascii\">" << endl;
325  for (i = 0; i < nquad0; ++i)
326  {
327  for (j = 0; j < nquad1-1; ++j)
328  {
329  outfile << j*nquad0 + i << " "
330  << j*nquad0 + i + 1 << " "
331  << (j+1)*nquad0 + i + 1 << " "
332  << (j+1)*nquad0 + i << endl;
333  }
334  }
335  outfile << endl;
336  outfile << " </DataArray>" << endl;
337  outfile << " <DataArray type=\"Int32\" "
338  << "Name=\"offsets\" format=\"ascii\">" << endl;
339  for (i = 0; i < ntotminus; ++i)
340  {
341  outfile << i*4+4 << " ";
342  }
343  outfile << endl;
344  outfile << " </DataArray>" << endl;
345  outfile << " <DataArray type=\"UInt8\" "
346  << "Name=\"types\" format=\"ascii\">" << endl;
347  for (i = 0; i < ntotminus; ++i)
348  {
349  outfile << "9 ";
350  }
351  outfile << endl;
352  outfile << " </DataArray>" << endl;
353  outfile << " </Cells>" << endl;
354  outfile << " <PointData>" << endl;
355  }
356 
357 
358  } //end of namespace
359 } //end of namespace
360 
361 
362 /**
363 * $Log: v $
364 *
365 **/
366 
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1001
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:46
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:956
NekDouble m_lhom_z
Width of homogeneous direction z.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:939
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
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:988
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:199
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:991
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:917
Array< OneD, int > m_offset_elmt_id
Array containing the element id m_offset_elmt_id[n] that the n^th consecutive block of data in m_coef...
Definition: ExpList.h:999
NekDouble m_lhom_y
Width of homogeneous direction y.
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:301
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:1794
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
Describes the specification for a Basis.
Definition: Basis.h:50