Nektar++
ContField3DHomogeneous2D.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // File ContField3DHomogeneous2D.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: Field definition for 3D domain with boundary
32 // conditions and a 2 homogeneous directions
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
38 
39 namespace Nektar
40 {
41  namespace MultiRegions
42  {
43 
46  {
47  }
48 
50  const ContField3DHomogeneous2D &In):
52  {
53 
54  ContField1DSharedPtr zero_line = std::dynamic_pointer_cast<ContField1D> (In.m_lines[0]);
55 
56  for(int n = 0; n < m_lines.num_elements(); ++n)
57  {
59  }
60 
61  SetCoeffPhys();
62  }
63 
65  {
66  }
67 
70  const LibUtilities::BasisKey &HomoBasis_y,
71  const LibUtilities::BasisKey &HomoBasis_z,
72  const NekDouble lhom_y,
73  const NekDouble lhom_z,
74  const bool useFFT,
75  const bool dealiasing,
77  const std::string &variable,
78  const Collections::ImplementationType ImpType):
79  DisContField3DHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing,ImpType)
80  {
81  int i,n,nel;
82  ContField1DSharedPtr line_zero;
83  SpatialDomains::BoundaryConditions bcs(pSession, graph1D);
84 
85  m_lines[0] = line_zero = MemoryManager<ContField1D>::AllocateSharedPtr(pSession,graph1D,variable,ImpType);
86 
88  nel = m_lines[0]->GetExpSize();
89 
90  for(i = 0; i < nel; ++i)
91  {
92  (*m_exp).push_back(m_lines[0]->GetExp(i));
93  }
94 
95  int nylines = m_homogeneousBasis_y->GetNumPoints();
96  int nzlines = m_homogeneousBasis_z->GetNumPoints();
97 
98  for(n = 1; n < nylines*nzlines; ++n)
99  {
100  m_lines[n] = MemoryManager<ContField1D>::AllocateSharedPtr(pSession,graph1D,variable,ImpType);
101 
102  for(i = 0; i < nel; ++i)
103  {
104  (*m_exp).push_back((*m_exp)[i]);
105  }
106  }
107 
108  // Setup Default optimisation information.
109  nel = GetExpSize();
110 
113 
114  SetCoeffPhys();
115 
116  SetupBoundaryConditions(HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,bcs);
117  }
118 
119 
121  {
123  int ncoeffs = m_lines[0]->GetNcoeffs();
124 
125  for(int n = 0; n < m_lines.num_elements(); ++n)
126  {
127  m_lines[n]->ImposeDirichletConditions(tmp = outarray +
128  n*ncoeffs);
129  }
130  }
131 
132 
133  /**
134  *
135  */
137  {
138  for(int n = 0; n < m_lines.num_elements(); ++n)
139  {
140  m_lines[n]->LocalToGlobal(useComm);
141  }
142  }
143 
144 
145  /**
146  *
147  */
149  {
150  for(int n = 0; n < m_lines.num_elements(); ++n)
151  {
152  m_lines[n]->GlobalToLocal();
153  }
154  }
155 
156 
158  const Array<OneD, const NekDouble> &inarray,
159  Array<OneD, NekDouble> &outarray,
160  const FlagList &flags,
161  const StdRegions::ConstFactorMap &factors,
162  const StdRegions::VarCoeffMap &varcoeff,
163  const MultiRegions::VarFactorsMap &varfactors,
164  const Array<OneD, const NekDouble> &dirForcing,
165  const bool PhysSpaceForcing)
166  {
167  int n,m;
168  int cnt = 0;
169  int cnt1 = 0;
170  int nhom_modes_y = m_homogeneousBasis_y->GetNumModes();
171  int nhom_modes_z = m_homogeneousBasis_z->GetNumModes();
172  NekDouble beta_y;
173  NekDouble beta_z;
174  NekDouble beta;
175  StdRegions::ConstFactorMap new_factors;
176 
178  Array<OneD, NekDouble> fce(inarray.num_elements());
180 
181  if(m_WaveSpace)
182  {
183  fce = inarray;
184  }
185  else
186  {
187  // Fourier transform forcing function
188  HomogeneousFwdTrans(inarray,fce,(flags.isSet(eUseGlobal))?eGlobal:eLocal);
189  }
190 
191  int l =0;
192  for(n = 0; n < nhom_modes_z; ++n)
193  {
194  for(m = 0; m < nhom_modes_y; ++m, l++)
195  {
196  beta_z = 2*M_PI*(n/2)/m_lhom_z;
197  beta_y = 2*M_PI*(m/2)/m_lhom_y;
198  beta = beta_y*beta_y + beta_z*beta_z;
199  new_factors = factors;
200  new_factors[StdRegions::eFactorLambda] += beta;
201 
202  wfce = (PhysSpaceForcing)? fce+cnt:fce+cnt1;
203  m_lines[l]->HelmSolve(wfce,
204  e_out = outarray + cnt1,
205  flags, new_factors, varcoeff, varfactors,
206  dirForcing,
207  PhysSpaceForcing);
208 
209  cnt += m_lines[l]->GetTotPoints();
210  cnt1 += m_lines[l]->GetNcoeffs();
211  }
212  }
213  }
214 
215  /**
216  * Reset the GlobalLinSys Manager
217  */
219  {
220  for(int n = 0; n < m_lines.num_elements(); ++n)
221  {
222  m_lines[n]->ClearGlobalLinSysManager();
223  }
224  }
225 
226  } // end of namespace
227 } //end of namespace
void HomogeneousFwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal, bool Shuff=true, bool UnShuff=true)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
std::shared_ptr< ContField1D > ContField1DSharedPtr
Definition: ContField1D.h:238
Local coefficients.
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1090
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1106
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:294
NekDouble m_lhom_z
Width of homogeneous direction z.
int GetExpSize(void)
This function returns the number of elements in the expansion.
Definition: ExpList.h:2170
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2191
Global coefficients.
Array< OneD, ExpListSharedPtr > m_lines
Vector of ExpList, will be filled with ExpList1D.
virtual void v_GlobalToLocal(void)
Template method virtual forwarded for GlobalToLocal()
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
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 MultiRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing)
Solves the three-dimensional Helmholtz equation, subject to the boundary conditions specified...
Abstraction of a global continuous one-dimensional spectral/hp element expansion which approximates t...
Definition: ContField1D.h:55
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:264
bool isSet(const FlagType &key) const
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.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
Defines a list of flags.
LibUtilities::BasisSharedPtr m_homogeneousBasis_y
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray)
virtual void v_LocalToGlobal(bool useComm)
Template method virtual forwarded for LocalToGlobal()
Describes the specification for a Basis.
Definition: Basis.h:49
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap