Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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  {
216  int n,m;
217  int cnt = 0;
218  int cnt1 = 0;
219  int nhom_modes_y = m_homogeneousBasis_y->GetNumModes();
220  int nhom_modes_z = m_homogeneousBasis_z->GetNumModes();
221  NekDouble beta_y;
222  NekDouble beta_z;
223  StdRegions::ConstFactorMap new_factors;
224 
226  Array<OneD, NekDouble> fce(inarray.num_elements());
227 
228  // Fourier transform forcing function
229  if(m_WaveSpace)
230  {
231  fce = inarray;
232  }
233  else
234  {
235  HomogeneousFwdTrans(inarray,fce);
236  }
237 
238  for(n = 0; n < nhom_modes_z; ++n)
239  {
240  for(m = 0; m < nhom_modes_y; ++m)
241  {
242  beta_z = 2*M_PI*(n/2)/m_lhom_z;
243  beta_y = 2*M_PI*(m/2)/m_lhom_y;
244  new_factors = factors;
245  new_factors[StdRegions::eFactorLambda] += beta_y*beta_y + beta_z*beta_z;
246 
247  m_lines[n]->HelmSolve(fce + cnt,
248  e_out = outarray + cnt1,
249  flags, new_factors, varcoeff, dirForcing);
250 
251  cnt += m_lines[n]->GetTotPoints();
252  cnt1 += m_lines[n]->GetNcoeffs();
253  }
254  }
255  }
256 
258  const NekDouble time,
259  const std::string varName,
260  const NekDouble x2_in,
261  const NekDouble x3_in)
262  {
263  EvaluateBoundaryConditions(time, varName);
264  }
265 
267  {
268  return GetBndCondExpansions();
269  }
270 
272  {
273  return GetBndConditions();
274  }
275 
276  boost::shared_ptr<ExpList> &DisContField3DHomogeneous2D::v_UpdateBndCondExpansion(int i)
277  {
278  return UpdateBndCondExpansion(i);
279  }
280 
282  {
283  return UpdateBndConditions();
284  }
285 
287  {
288 
289  if(m_BCtoElmMap.num_elements() == 0)
290  {
291  Array<OneD, int> ElmtID_tmp;
292  Array<OneD, int> EdgeID_tmp;
293 
294  m_lines[0]->GetBoundaryToElmtMap(ElmtID_tmp,EdgeID_tmp);
295  int nel_per_lines = m_lines[0]->GetExpSize();
296  int nlines = m_lines.num_elements();
297 
298  int MapSize = ElmtID_tmp.num_elements();
299 
300  ElmtID = Array<OneD, int>(nlines*MapSize);
301  EdgeID = Array<OneD, int>(nlines*MapSize);
302  for(int i = 0; i < nlines; i++)
303  {
304  for(int j = 0; j < MapSize; j++)
305  {
306  ElmtID[j+i*MapSize] = ElmtID_tmp[j] + i*nel_per_lines;
307  EdgeID[j+i*MapSize] = EdgeID_tmp[j];
308  }
309  }
310  m_BCtoElmMap = Array<OneD, int>(nlines*MapSize);
311  m_BCtoEdgMap = Array<OneD, int>(nlines*MapSize);
312 
313  Vmath::Vcopy(nlines*MapSize,ElmtID,1,m_BCtoElmMap,1);
314  Vmath::Vcopy(nlines*MapSize,EdgeID,1,m_BCtoEdgMap,1);
315  }
316  else
317  {
318  int MapSize = m_BCtoElmMap.num_elements();
319 
320  ElmtID = Array<OneD, int>(MapSize);
321  EdgeID = Array<OneD, int>(MapSize);
322 
323  Vmath::Vcopy(MapSize,m_BCtoElmMap,1,ElmtID,1);
324  Vmath::Vcopy(MapSize,m_BCtoEdgMap,1,EdgeID,1);
325  }
326  }
327 
329  boost::shared_ptr<ExpList> &result)
330  {
331  int n, cnt, nq;
332  int offsetOld, offsetNew;
333  Array<OneD, NekDouble> tmp1, tmp2;
334  std::vector<unsigned int> eIDs;
335 
336  Array<OneD, int> ElmtID,EdgeID;
337  GetBoundaryToElmtMap(ElmtID,EdgeID);
338 
339  // Skip other boundary regions
340  for (cnt = n = 0; n < i; ++n)
341  {
342  cnt += m_bndCondExpansions[n]->GetExpSize();
343  }
344 
345  // Populate eIDs with information from BoundaryToElmtMap
346  for (n = 0; n < m_bndCondExpansions[i]->GetExpSize(); ++n)
347  {
348  eIDs.push_back(ElmtID[cnt+n]);
349  }
350 
351  // Create expansion list
352  result =
354 
355  // Copy phys and coeffs to new explist
356  for (n = 0; n < result->GetExpSize(); ++n)
357  {
358  nq = GetExp(ElmtID[cnt+n])->GetTotPoints();
359  offsetOld = GetPhys_Offset(ElmtID[cnt+n]);
360  offsetNew = result->GetPhys_Offset(n);
361  Vmath::Vcopy(nq, tmp1 = GetPhys()+ offsetOld, 1,
362  tmp2 = result->UpdatePhys()+ offsetNew, 1);
363 
364  nq = GetExp(ElmtID[cnt+n])->GetNcoeffs();
365  offsetOld = GetCoeff_Offset(ElmtID[cnt+n]);
366  offsetNew = result->GetCoeff_Offset(n);
367  Vmath::Vcopy(nq, tmp1 = GetCoeffs()+ offsetOld, 1,
368  tmp2 = result->UpdateCoeffs()+ offsetNew, 1);
369  }
370  }
371 
372  } // end of namespace
373 } //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:1837
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:1929
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:1001
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:1937
Array< OneD, NekDouble > & UpdateCoeffs()
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
Definition: ExpList.h:1956
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:1920
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:251
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)
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:1899
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_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:977
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:226
virtual void v_GetBndElmtExpansion(int i, boost::shared_ptr< ExpList > &result)
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:206
This class is the abstraction of a global discontinuous two- dimensional spectral/hp element expansio...
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:910
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:1890
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:227
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:1047
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