Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DisContField3DHomogeneous2D.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // File DisContField3DHomogeneous2D.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: Field definition for 3D domain with boundary
33 // conditions using LDG flux and a 2D homogeneous directions
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
40 
41 namespace Nektar
42 {
43  namespace MultiRegions
44  {
45 
48  m_bndCondExpansions(),
49  m_bndConditions()
50  {
51  }
52 
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  ExpList3DHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing),
61  m_bndCondExpansions(),
62  m_bndConditions()
63  {
64  }
65 
67  ExpList3DHomogeneous2D (In,false),
68  m_bndCondExpansions (In.m_bndCondExpansions),
69  m_bndConditions (In.m_bndConditions)
70  {
71  if(DeclareLinesSetCoeffPhys)
72  {
73  DisContField1DSharedPtr zero_line = boost::dynamic_pointer_cast<DisContField1D> (In.m_lines[0]);
74 
75  for(int n = 0; n < m_lines.num_elements(); ++n)
76  {
78  }
79 
80  SetCoeffPhys();
81  }
82  }
83 
85  const LibUtilities::BasisKey &HomoBasis_y,
86  const LibUtilities::BasisKey &HomoBasis_z,
87  const NekDouble lhom_y,
88  const NekDouble lhom_z,
89  const bool useFFT,
90  const bool dealiasing,
92  const std::string &variable):
93  ExpList3DHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing),
94  m_bndCondExpansions(),
95  m_bndConditions()
96  {
97  int i,n,nel;
98  DisContField1DSharedPtr line_zero;
99  SpatialDomains::BoundaryConditions bcs(pSession, graph1D);
100 
101  //
102  m_lines[0] = line_zero = MemoryManager<DisContField1D>::AllocateSharedPtr(pSession,graph1D,variable);
103 
105  nel = m_lines[0]->GetExpSize();
106 
107  for(i = 0; i < nel; ++i)
108  {
109  (*m_exp).push_back(m_lines[0]->GetExp(i));
110  }
111 
112  int nylines = m_homogeneousBasis_y->GetNumPoints();
113  int nzlines = m_homogeneousBasis_z->GetNumPoints();
114 
115  for(n = 1; n < nylines*nzlines; ++n)
116  {
117  m_lines[n] = MemoryManager<DisContField1D>::AllocateSharedPtr(pSession,graph1D,variable);
118  for(i = 0; i < nel; ++i)
119  {
120  (*m_exp).push_back((*m_exp)[i]);
121  }
122  }
123 
124  // Setup Default optimisation information.
125  nel = GetExpSize();
126 
129 
130  SetCoeffPhys();
131 
132  SetupBoundaryConditions(HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,bcs);
133  }
134 
136  {
137  }
138 
139 
141  const LibUtilities::BasisKey &HomoBasis_z,
142  const NekDouble lhom_y,
143  const NekDouble lhom_z,
145  {
146  int i,n;
147 
148  // Setup an ExpList1DHomogeneous2D expansion for boundary
149  // conditions and link to class declared in m_lines.
150 
151  int nlines = m_lines.num_elements();
152 
154 
155  int nbnd = bregions.size();
156 
157 
159 
160  Array<OneD, MultiRegions::ExpListSharedPtr> LinesBndCondExp(nlines);
161 
162  m_bndConditions = m_lines[0]->UpdateBndConditions();
163 
164  for(i = 0; i < nbnd; ++i)
165  {
166  for(n = 0; n < nlines; ++n)
167  {
168  LinesBndCondExp[n] = m_lines[n]->UpdateBndCondExpansion(i);
169  }
170 
171  m_bndCondExpansions[i] = MemoryManager<ExpList1DHomogeneous2D>::AllocateSharedPtr(m_session,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,m_useFFT,false,LinesBndCondExp);
172 
173  }
174 
176  }
177 
179  const NekDouble time,
180  const std::string varName)
181  {
182  int n, m;
185 
186  for (n = 0; n < m_nz; ++n)
187  {
188  for (m = 0; m < m_ny; ++m)
189  {
191  time, varName, 0.5*m_lhom_y*(1.0+y[m]),
192  0.5*m_lhom_z*(1.0+z[n]));
193  }
194  }
195 
196  // Fourier transform coefficient space boundary values
197  for (n = 0; n < m_bndCondExpansions.num_elements(); ++n)
198  {
199  if (time == 0.0 || m_bndConditions[n]->IsTimeDependent())
200  {
201  m_bndCondExpansions[n]->HomogeneousFwdTrans(
204  }
205  }
206  }
207 
209  const Array<OneD, const NekDouble> &inarray,
210  Array<OneD, NekDouble> &outarray,
211  const FlagList &flags,
212  const StdRegions::ConstFactorMap &factors,
213  const StdRegions::VarCoeffMap &varcoeff,
214  const Array<OneD, const NekDouble> &dirForcing,
215  const bool PhysSpaceForcing)
216  {
217  int n,m;
218  int cnt = 0;
219  int cnt1 = 0;
220  int nhom_modes_y = m_homogeneousBasis_y->GetNumModes();
221  int nhom_modes_z = m_homogeneousBasis_z->GetNumModes();
222  NekDouble beta_y;
223  NekDouble beta_z;
224  StdRegions::ConstFactorMap new_factors;
225 
227  Array<OneD, NekDouble> fce(inarray.num_elements());
229 
230  // Fourier transform forcing function
231  if(m_WaveSpace)
232  {
233  fce = inarray;
234  }
235  else
236  {
237  HomogeneousFwdTrans(inarray,fce);
238  }
239 
240  for(n = 0; n < nhom_modes_z; ++n)
241  {
242  for(m = 0; m < nhom_modes_y; ++m)
243  {
244  beta_z = 2*M_PI*(n/2)/m_lhom_z;
245  beta_y = 2*M_PI*(m/2)/m_lhom_y;
246  new_factors = factors;
247  new_factors[StdRegions::eFactorLambda] +=
248  beta_y*beta_y + beta_z*beta_z;
249 
250  wfce = (PhysSpaceForcing)? fce+cnt:fce+cnt1;
251  m_lines[n]->HelmSolve(wfce,
252  e_out = outarray + cnt1,
253  flags, new_factors,
254  varcoeff, dirForcing,
255  PhysSpaceForcing);
256 
257  cnt += m_lines[n]->GetTotPoints();
258  cnt1 += m_lines[n]->GetNcoeffs();
259  }
260  }
261  }
262 
264  const NekDouble time,
265  const std::string varName,
266  const NekDouble x2_in,
267  const NekDouble x3_in)
268  {
269  EvaluateBoundaryConditions(time, varName);
270  }
271 
273  {
274  return GetBndCondExpansions();
275  }
276 
278  {
279  return GetBndConditions();
280  }
281 
282  boost::shared_ptr<ExpList> &DisContField3DHomogeneous2D::v_UpdateBndCondExpansion(int i)
283  {
284  return UpdateBndCondExpansion(i);
285  }
286 
288  {
289  return UpdateBndConditions();
290  }
291 
293  {
294  if(m_BCtoElmMap.num_elements() == 0)
295  {
296  Array<OneD, int> ElmtID_tmp;
297  Array<OneD, int> EdgeID_tmp;
298 
299  m_lines[0]->GetBoundaryToElmtMap(ElmtID_tmp,EdgeID_tmp);
300  int nel_per_lines = m_lines[0]->GetExpSize();
301  int nlines = m_lines.num_elements();
302 
303  int MapSize = ElmtID_tmp.num_elements();
304 
305  m_BCtoElmMap = Array<OneD, int>(nlines*MapSize);
306  m_BCtoEdgMap = Array<OneD, int>(nlines*MapSize);
307  if (MapSize > 0)
308  {
309  int i ,j, n, cnt;
310  int cntLine = 0;
311  for (cnt=n=0; n < m_bndCondExpansions.num_elements(); ++n)
312  {
313  int lineExpSize = m_lines[0]
314  ->GetBndCondExpansions()[n]
315  ->GetExpSize();
316  for (i = 0; i < lineExpSize ; ++i, ++cntLine)
317  {
318  for(j = 0; j < nlines; j++)
319  {
320  m_BCtoElmMap[cnt+i+j*lineExpSize] =
321  ElmtID_tmp[cntLine]+j*nel_per_lines;
322  m_BCtoEdgMap[cnt+i+j*lineExpSize] =
323  EdgeID_tmp[cntLine];
324  }
325  }
326  cnt += m_bndCondExpansions[n]->GetExpSize();
327  }
328  }
329  }
330  ElmtID = m_BCtoElmMap;
331  EdgeID = m_BCtoEdgMap;
332  }
333 
335  boost::shared_ptr<ExpList> &result,
336  const bool DeclareCoeffPhysArrays)
337  {
338  int n, cnt, nq;
339  int offsetOld, offsetNew;
340 
341  std::vector<unsigned int> eIDs;
342  Array<OneD, int> ElmtID,EdgeID;
343  GetBoundaryToElmtMap(ElmtID,EdgeID);
344 
345  // Skip other boundary regions
346  for (cnt = n = 0; n < i; ++n)
347  {
348  cnt += m_bndCondExpansions[n]->GetExpSize();
349  }
350 
351  // Populate eIDs with information from BoundaryToElmtMap
352  for (n = 0; n < m_bndCondExpansions[i]->GetExpSize(); ++n)
353  {
354  eIDs.push_back(ElmtID[cnt+n]);
355  }
356 
357  // Create expansion list
358  result =
360  (*this, eIDs);
361 
362  // Copy phys and coeffs to new explist
363  if ( DeclareCoeffPhysArrays)
364  {
365  Array<OneD, NekDouble> tmp1, tmp2;
366  for (n = 0; n < result->GetExpSize(); ++n)
367  {
368  nq = GetExp(ElmtID[cnt+n])->GetTotPoints();
369  offsetOld = GetPhys_Offset(ElmtID[cnt+n]);
370  offsetNew = result->GetPhys_Offset(n);
371  Vmath::Vcopy(nq, tmp1 = GetPhys()+ offsetOld, 1,
372  tmp2 = result->UpdatePhys()+ offsetNew, 1);
373 
374  nq = GetExp(ElmtID[cnt+n])->GetNcoeffs();
375  offsetOld = GetCoeff_Offset(ElmtID[cnt+n]);
376  offsetNew = result->GetCoeff_Offset(n);
377  Vmath::Vcopy(nq, tmp1 = GetCoeffs()+ offsetOld, 1,
378  tmp2 = result->UpdateCoeffs()+ offsetNew, 1);
379  }
380  }
381 
382  // Set wavespace value
383  result->SetWaveSpace(GetWaveSpace());
384  }
385 
386  } // end of namespace
387 } //end of namespace
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
const Array< OneD, const NekDouble > & GetCoeffs() const
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
Definition: ExpList.h:1946
Array< OneD, SpatialDomains::BoundaryConditionShPtr > & UpdateBndConditions()
void HomogeneousFwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal, bool Shuff=true, bool UnShuff=true)
void EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="")
int GetCoeff_Offset(int n) const
Get the start offset position for a global list of m_coeffs correspoinding to element n...
Definition: ExpList.h:2084
const Array< OneD, const MultiRegions::ExpListSharedPtr > & GetBndCondExpansions()
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1060
virtual const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions()
int GetPhys_Offset(int n) const
Get the start offset position for a global list of m_phys correspoinding to element n...
Definition: ExpList.h:2092
Array< OneD, NekDouble > & UpdateCoeffs()
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
Definition: ExpList.h:2111
virtual Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions()
const boost::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2075
virtual boost::shared_ptr< ExpList > & v_UpdateBndCondExpansion(int i)
void SetupBoundaryConditions(const LibUtilities::BasisKey &HomoBasis_y, const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y, const NekDouble lhom_z, SpatialDomains::BoundaryConditions &bcs)
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:252
NekDouble m_lhom_z
Width of homogeneous direction z.
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
int GetExpSize(void)
This function returns the number of elements in the expansion.
Definition: ExpList.h:2054
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
virtual void v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const FlagList &flags, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing)
Array< OneD, ExpListSharedPtr > m_lines
Vector of ExpList, will be filled with ExpList1D.
Array< OneD, int > m_BCtoElmMap
Storage space for the boundary to element and boundary to trace map. This member variable is really a...
boost::shared_ptr< ExpList > & UpdateBndCondExpansion(int i)
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
virtual void v_EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="", const NekDouble x2_in=NekConstants::kNekUnsetDouble, const NekDouble x3_in=NekConstants::kNekUnsetDouble)
boost::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1036
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:227
void SetCoeffPhys(void)
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
NekDouble m_lhom_y
Width of homogeneous direction y.
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:217
This class is the abstraction of a global discontinuous two- dimensional spectral/hp element expansio...
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:969
double NekDouble
const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & GetBndConditions()
Defines a list of flags.
boost::shared_ptr< DisContField1D > DisContField1DSharedPtr
int m_ny
Number of modes = number of poitns in y direction.
virtual const Array< OneD, const boost::shared_ptr< ExpList > > & v_GetBndCondExpansions(void)
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.
const Array< OneD, const NekDouble > & GetPhys() const
This function returns (a reference to) the array (implemented as m_phys) containing the function ev...
Definition: ExpList.h:2045
virtual void v_GetBndElmtExpansion(int i, boost::shared_ptr< ExpList > &result, const bool DeclareCoeffPhysArrays)
void GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &EdgeID)
Set up a list of element ids and edge ids the link to the boundary conditions.
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition: Conditions.h:238
bool GetWaveSpace(void) const
This function returns the third direction expansion condition, which can be in wave space (coefficien...
Definition: ExpList.h:1592
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
Abstraction of a one-dimensional multi-elemental expansion which is merely a collection of local expa...
Describes the specification for a Basis.
Definition: Basis.h:50