Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // 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 and a 2 homogeneous directions
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
39 
40 namespace Nektar
41 {
42  namespace MultiRegions
43  {
44 
47  {
48  }
49 
51  const ContField3DHomogeneous2D &In):
53  {
54 
55  ContField1DSharedPtr zero_line = boost::dynamic_pointer_cast<ContField1D> (In.m_lines[0]);
56 
57  for(int n = 0; n < m_lines.num_elements(); ++n)
58  {
60  }
61 
62  SetCoeffPhys();
63  }
64 
66  {
67  }
68 
71  const LibUtilities::BasisKey &HomoBasis_y,
72  const LibUtilities::BasisKey &HomoBasis_z,
73  const NekDouble lhom_y,
74  const NekDouble lhom_z,
75  const bool useFFT,
76  const bool dealiasing,
78  const std::string &variable,
79  const Collections::ImplementationType ImpType):
80  DisContField3DHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing,ImpType)
81  {
82  int i,n,nel;
83  ContField1DSharedPtr line_zero;
84  SpatialDomains::BoundaryConditions bcs(pSession, graph1D);
85 
86  m_lines[0] = line_zero = MemoryManager<ContField1D>::AllocateSharedPtr(pSession,graph1D,variable,ImpType);
87 
89  nel = m_lines[0]->GetExpSize();
90 
91  for(i = 0; i < nel; ++i)
92  {
93  (*m_exp).push_back(m_lines[0]->GetExp(i));
94  }
95 
96  int nylines = m_homogeneousBasis_y->GetNumPoints();
97  int nzlines = m_homogeneousBasis_z->GetNumPoints();
98 
99  for(n = 1; n < nylines*nzlines; ++n)
100  {
101  m_lines[n] = MemoryManager<ContField1D>::AllocateSharedPtr(pSession,graph1D,variable,ImpType);
102 
103  for(i = 0; i < nel; ++i)
104  {
105  (*m_exp).push_back((*m_exp)[i]);
106  }
107  }
108 
109  // Setup Default optimisation information.
110  nel = GetExpSize();
111 
114 
115  SetCoeffPhys();
116 
117  SetupBoundaryConditions(HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,bcs);
118  }
119 
120 
122  {
124  int ncoeffs = m_lines[0]->GetNcoeffs();
125 
126  for(int n = 0; n < m_lines.num_elements(); ++n)
127  {
128  m_lines[n]->ImposeDirichletConditions(tmp = outarray +
129  n*ncoeffs);
130  }
131  }
132 
133 
134  /**
135  *
136  */
138  {
139  for(int n = 0; n < m_lines.num_elements(); ++n)
140  {
141  m_lines[n]->LocalToGlobal(useComm);
142  }
143  };
144 
145 
146  /**
147  *
148  */
150  {
151  for(int n = 0; n < m_lines.num_elements(); ++n)
152  {
153  m_lines[n]->GlobalToLocal();
154  }
155  };
156 
157 
159  const Array<OneD, const NekDouble> &inarray,
160  Array<OneD, NekDouble> &outarray,
161  const FlagList &flags,
162  const StdRegions::ConstFactorMap &factors,
163  const StdRegions::VarCoeffMap &varcoeff,
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, dirForcing,
206  PhysSpaceForcing);
207 
208  cnt += m_lines[l]->GetTotPoints();
209  cnt1 += m_lines[l]->GetNcoeffs();
210  }
211  }
212  }
213 
214  /**
215  * Reset the GlobalLinSys Manager
216  */
218  {
219  for(int n = 0; n < m_lines.num_elements(); ++n)
220  {
221  m_lines[n]->ClearGlobalLinSysManager();
222  }
223  }
224 
225  } // end of namespace
226 } //end of namespace
void HomogeneousFwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal, bool Shuff=true, bool UnShuff=true)
boost::shared_ptr< ContField1D > ContField1DSharedPtr
Definition: ContField1D.h:238
Local coefficients.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1052
const boost::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2067
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.
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
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()
bool isSet(const FlagType &key) const
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
boost::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1036
Abstraction of a global continuous one-dimensional spectral/hp element expansion which approximates t...
Definition: ContField1D.h:56
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.
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_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)
Solves the three-dimensional Helmholtz equation, subject to the boundary conditions specified...
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray)
virtual void v_LocalToGlobal(bool useComm)
Template method virtual forwarded for LocalToGlobal()
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
Describes the specification for a Basis.
Definition: Basis.h:50