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 
55  const LibUtilities::BasisKey &HomoBasis_y,
56  const LibUtilities::BasisKey &HomoBasis_z,
57  const NekDouble lhom_y,
58  const NekDouble lhom_z,
59  const bool useFFT,
60  const bool dealiasing,
61  const Collections::ImplementationType ImpType):
62  ExpList3DHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing,ImpType),
63  m_bndCondExpansions(),
64  m_bndConditions()
65  {
66  }
67 
69  ExpList3DHomogeneous2D (In,false),
70  m_bndCondExpansions (In.m_bndCondExpansions),
71  m_bndConditions (In.m_bndConditions)
72  {
73  if(DeclareLinesSetCoeffPhys)
74  {
75  DisContField1DSharedPtr zero_line = boost::dynamic_pointer_cast<DisContField1D> (In.m_lines[0]);
76 
77  for(int n = 0; n < m_lines.num_elements(); ++n)
78  {
80  }
81 
82  SetCoeffPhys();
83  }
84  }
85 
88  const LibUtilities::BasisKey &HomoBasis_y,
89  const LibUtilities::BasisKey &HomoBasis_z,
90  const NekDouble lhom_y,
91  const NekDouble lhom_z,
92  const bool useFFT,
93  const bool dealiasing,
95  const std::string &variable,
96  const Collections::ImplementationType ImpType):
97  ExpList3DHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing,ImpType),
98  m_bndCondExpansions(),
99  m_bndConditions()
100  {
101  int i,n,nel;
102  DisContField1DSharedPtr line_zero;
103  SpatialDomains::BoundaryConditions bcs(pSession, graph1D);
104 
105  //
106  m_lines[0] = line_zero = MemoryManager<DisContField1D>::AllocateSharedPtr(pSession,graph1D,variable,ImpType);
107 
109  nel = m_lines[0]->GetExpSize();
110 
111  for(i = 0; i < nel; ++i)
112  {
113  (*m_exp).push_back(m_lines[0]->GetExp(i));
114  }
115 
116  int nylines = m_homogeneousBasis_y->GetNumPoints();
117  int nzlines = m_homogeneousBasis_z->GetNumPoints();
118 
119  for(n = 1; n < nylines*nzlines; ++n)
120  {
121  m_lines[n] = MemoryManager<DisContField1D>::AllocateSharedPtr(pSession,graph1D,variable,ImpType);
122  for(i = 0; i < nel; ++i)
123  {
124  (*m_exp).push_back((*m_exp)[i]);
125  }
126  }
127 
128  // Setup Default optimisation information.
129  nel = GetExpSize();
130 
133 
134  SetCoeffPhys();
135 
136  SetupBoundaryConditions(HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,bcs);
137  }
138 
140  {
141  }
142 
143 
145  const LibUtilities::BasisKey &HomoBasis_z,
146  const NekDouble lhom_y,
147  const NekDouble lhom_z,
149  {
150  int i,n;
151 
152  // Setup an ExpList1DHomogeneous2D expansion for boundary
153  // conditions and link to class declared in m_lines.
154 
155  int nlines = m_lines.num_elements();
156 
158 
159  int nbnd = bregions.size();
160 
161 
163 
164  Array<OneD, MultiRegions::ExpListSharedPtr> LinesBndCondExp(nlines);
165 
166  m_bndConditions = m_lines[0]->UpdateBndConditions();
167 
168  for(i = 0; i < nbnd; ++i)
169  {
170  for(n = 0; n < nlines; ++n)
171  {
172  LinesBndCondExp[n] = m_lines[n]->UpdateBndCondExpansion(i);
173  }
174 
175  m_bndCondExpansions[i] = MemoryManager<ExpList1DHomogeneous2D>::AllocateSharedPtr(m_session,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,m_useFFT,false,LinesBndCondExp);
176 
177  }
178 
180  }
181 
183  const NekDouble time,
184  const std::string varName)
185  {
186  int n, m;
189 
190  for (n = 0; n < m_nz; ++n)
191  {
192  for (m = 0; m < m_ny; ++m)
193  {
195  time, varName, 0.5*m_lhom_y*(1.0+y[m]),
196  0.5*m_lhom_z*(1.0+z[n]));
197  }
198  }
199 
200  // Fourier transform coefficient space boundary values
201  for (n = 0; n < m_bndCondExpansions.num_elements(); ++n)
202  {
203  if (time == 0.0 || m_bndConditions[n]->IsTimeDependent())
204  {
205  m_bndCondExpansions[n]->HomogeneousFwdTrans(
208  }
209  }
210  }
211 
213  const Array<OneD, const NekDouble> &inarray,
214  Array<OneD, NekDouble> &outarray,
215  const FlagList &flags,
216  const StdRegions::ConstFactorMap &factors,
217  const StdRegions::VarCoeffMap &varcoeff,
218  const Array<OneD, const NekDouble> &dirForcing,
219  const bool PhysSpaceForcing)
220  {
221  int n,m;
222  int cnt = 0;
223  int cnt1 = 0;
224  int nhom_modes_y = m_homogeneousBasis_y->GetNumModes();
225  int nhom_modes_z = m_homogeneousBasis_z->GetNumModes();
226  NekDouble beta_y;
227  NekDouble beta_z;
228  StdRegions::ConstFactorMap new_factors;
229 
231  Array<OneD, NekDouble> fce(inarray.num_elements());
233 
234  // Fourier transform forcing function
235  if(m_WaveSpace)
236  {
237  fce = inarray;
238  }
239  else
240  {
241  HomogeneousFwdTrans(inarray,fce);
242  }
243 
244  for(n = 0; n < nhom_modes_z; ++n)
245  {
246  for(m = 0; m < nhom_modes_y; ++m)
247  {
248  beta_z = 2*M_PI*(n/2)/m_lhom_z;
249  beta_y = 2*M_PI*(m/2)/m_lhom_y;
250  new_factors = factors;
251  new_factors[StdRegions::eFactorLambda] +=
252  beta_y*beta_y + beta_z*beta_z;
253 
254  wfce = (PhysSpaceForcing)? fce+cnt:fce+cnt1;
255  m_lines[n]->HelmSolve(wfce,
256  e_out = outarray + cnt1,
257  flags, new_factors,
258  varcoeff, dirForcing,
259  PhysSpaceForcing);
260 
261  cnt += m_lines[n]->GetTotPoints();
262  cnt1 += m_lines[n]->GetNcoeffs();
263  }
264  }
265  }
266 
268  const NekDouble time,
269  const std::string varName,
270  const NekDouble x2_in,
271  const NekDouble x3_in)
272  {
273  EvaluateBoundaryConditions(time, varName);
274  }
275 
277  {
278  return GetBndCondExpansions();
279  }
280 
282  {
283  return GetBndConditions();
284  }
285 
286  boost::shared_ptr<ExpList> &DisContField3DHomogeneous2D::v_UpdateBndCondExpansion(int i)
287  {
288  return UpdateBndCondExpansion(i);
289  }
290 
292  {
293  return UpdateBndConditions();
294  }
295 
297  {
298  if(m_BCtoElmMap.num_elements() == 0)
299  {
300  Array<OneD, int> ElmtID_tmp;
301  Array<OneD, int> EdgeID_tmp;
302 
303  m_lines[0]->GetBoundaryToElmtMap(ElmtID_tmp,EdgeID_tmp);
304  int nel_per_lines = m_lines[0]->GetExpSize();
305  int nlines = m_lines.num_elements();
306 
307  int MapSize = ElmtID_tmp.num_elements();
308 
309  m_BCtoElmMap = Array<OneD, int>(nlines*MapSize);
310  m_BCtoEdgMap = Array<OneD, int>(nlines*MapSize);
311  if (MapSize > 0)
312  {
313  int i ,j, n, cnt;
314  int cntLine = 0;
315  for (cnt=n=0; n < m_bndCondExpansions.num_elements(); ++n)
316  {
317  int lineExpSize = m_lines[0]
318  ->GetBndCondExpansions()[n]
319  ->GetExpSize();
320  for (i = 0; i < lineExpSize ; ++i, ++cntLine)
321  {
322  for(j = 0; j < nlines; j++)
323  {
324  m_BCtoElmMap[cnt+i+j*lineExpSize] =
325  ElmtID_tmp[cntLine]+j*nel_per_lines;
326  m_BCtoEdgMap[cnt+i+j*lineExpSize] =
327  EdgeID_tmp[cntLine];
328  }
329  }
330  cnt += m_bndCondExpansions[n]->GetExpSize();
331  }
332  }
333  }
334  ElmtID = m_BCtoElmMap;
335  EdgeID = m_BCtoEdgMap;
336  }
337 
339  boost::shared_ptr<ExpList> &result,
340  const bool DeclareCoeffPhysArrays)
341  {
342  int n, cnt, nq;
343  int offsetOld, offsetNew;
344 
345  std::vector<unsigned int> eIDs;
346  Array<OneD, int> ElmtID,EdgeID;
347  GetBoundaryToElmtMap(ElmtID,EdgeID);
348 
349  // Skip other boundary regions
350  for (cnt = n = 0; n < i; ++n)
351  {
352  cnt += m_bndCondExpansions[n]->GetExpSize();
353  }
354 
355  // Populate eIDs with information from BoundaryToElmtMap
356  for (n = 0; n < m_bndCondExpansions[i]->GetExpSize(); ++n)
357  {
358  eIDs.push_back(ElmtID[cnt+n]);
359  }
360 
361  // Create expansion list
362  result =
364  (*this, eIDs);
365 
366  // Copy phys and coeffs to new explist
367  if ( DeclareCoeffPhysArrays)
368  {
369  Array<OneD, NekDouble> tmp1, tmp2;
370  for (n = 0; n < result->GetExpSize(); ++n)
371  {
372  nq = GetExp(ElmtID[cnt+n])->GetTotPoints();
373  offsetOld = GetPhys_Offset(ElmtID[cnt+n]);
374  offsetNew = result->GetPhys_Offset(n);
375  Vmath::Vcopy(nq, tmp1 = GetPhys()+ offsetOld, 1,
376  tmp2 = result->UpdatePhys()+ offsetNew, 1);
377 
378  nq = GetExp(ElmtID[cnt+n])->GetNcoeffs();
379  offsetOld = GetCoeff_Offset(ElmtID[cnt+n]);
380  offsetNew = result->GetCoeff_Offset(n);
381  Vmath::Vcopy(nq, tmp1 = GetCoeffs()+ offsetOld, 1,
382  tmp2 = result->UpdateCoeffs()+ offsetNew, 1);
383  }
384  }
385 
386  // Set wavespace value
387  result->SetWaveSpace(GetWaveSpace());
388  }
389 
390  } // end of namespace
391 } //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:1938
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:2076
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:1052
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:2084
Array< OneD, NekDouble > & UpdateCoeffs()
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
Definition: ExpList.h:2095
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:2067
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:2046
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:2037
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:1584
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