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 
158  m_bndCondExpansions = Array<OneD,MultiRegions::ExpListSharedPtr>(nbnd);
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;
183  const Array<OneD, const NekDouble> y = m_homogeneousBasis_y->GetZ();
184  const Array<OneD, const NekDouble> z = m_homogeneousBasis_z->GetZ();
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]->GetUserDefined() ==
201  {
202  m_bndCondExpansions[n]->HomogeneousFwdTrans(
205  }
206  }
207  }
208 
210  const Array<OneD, const NekDouble> &inarray,
211  Array<OneD, NekDouble> &outarray,
212  const FlagList &flags,
213  const StdRegions::ConstFactorMap &factors,
214  const StdRegions::VarCoeffMap &varcoeff,
215  const Array<OneD, const NekDouble> &dirForcing)
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 
226  Array<OneD, NekDouble> e_out;
227  Array<OneD, NekDouble> fce(inarray.num_elements());
228 
229  // Fourier transform forcing function
230  if(m_WaveSpace)
231  {
232  fce = inarray;
233  }
234  else
235  {
236  HomogeneousFwdTrans(inarray,fce);
237  }
238 
239  for(n = 0; n < nhom_modes_z; ++n)
240  {
241  for(m = 0; m < nhom_modes_y; ++m)
242  {
243  beta_z = 2*M_PI*(n/2)/m_lhom_z;
244  beta_y = 2*M_PI*(m/2)/m_lhom_y;
245  new_factors = factors;
246  new_factors[StdRegions::eFactorLambda] += beta_y*beta_y + beta_z*beta_z;
247 
248  m_lines[n]->HelmSolve(fce + cnt,
249  e_out = outarray + cnt1,
250  flags, new_factors, varcoeff, dirForcing);
251 
252  cnt += m_lines[n]->GetTotPoints();
253  cnt1 += m_lines[n]->GetNcoeffs();
254  }
255  }
256  }
257 
259  const NekDouble time,
260  const std::string varName,
261  const NekDouble x2_in,
262  const NekDouble x3_in)
263  {
264  EvaluateBoundaryConditions(time, varName);
265  }
266 
267  const Array<OneD,const boost::shared_ptr<ExpList> > &DisContField3DHomogeneous2D::v_GetBndCondExpansions(void)
268  {
269  return GetBndCondExpansions();
270  }
271 
272  const Array<OneD,const SpatialDomains::BoundaryConditionShPtr> &DisContField3DHomogeneous2D::v_GetBndConditions()
273  {
274  return GetBndConditions();
275  }
276 
277  boost::shared_ptr<ExpList> &DisContField3DHomogeneous2D::v_UpdateBndCondExpansion(int i)
278  {
279  return UpdateBndCondExpansion(i);
280  }
281 
282  Array<OneD, SpatialDomains::BoundaryConditionShPtr> &DisContField3DHomogeneous2D::v_UpdateBndConditions()
283  {
284  return UpdateBndConditions();
285  }
286 
287  void DisContField3DHomogeneous2D::GetBoundaryToElmtMap(Array<OneD, int> &ElmtID, Array<OneD,int> &EdgeID)
288  {
289 
290  if(m_BCtoElmMap.num_elements() == 0)
291  {
292  Array<OneD, int> ElmtID_tmp;
293  Array<OneD, int> EdgeID_tmp;
294 
295  m_lines[0]->GetBoundaryToElmtMap(ElmtID_tmp,EdgeID_tmp);
296  int nel_per_lines = m_lines[0]->GetExpSize();
297  int nlines = m_lines.num_elements();
298 
299  int MapSize = ElmtID_tmp.num_elements();
300 
301  ElmtID = Array<OneD, int>(nlines*MapSize);
302  EdgeID = Array<OneD, int>(nlines*MapSize);
303  for(int i = 0; i < nlines; i++)
304  {
305  for(int j = 0; j < MapSize; j++)
306  {
307  ElmtID[j+i*MapSize] = ElmtID_tmp[j] + i*nel_per_lines;
308  EdgeID[j+i*MapSize] = EdgeID_tmp[j];
309  }
310  }
311  m_BCtoElmMap = Array<OneD, int>(nlines*MapSize);
312  m_BCtoEdgMap = Array<OneD, int>(nlines*MapSize);
313 
314  Vmath::Vcopy(nlines*MapSize,ElmtID,1,m_BCtoElmMap,1);
315  Vmath::Vcopy(nlines*MapSize,EdgeID,1,m_BCtoEdgMap,1);
316  }
317  else
318  {
319  int MapSize = m_BCtoElmMap.num_elements();
320 
321  ElmtID = Array<OneD, int>(MapSize);
322  EdgeID = Array<OneD, int>(MapSize);
323 
324  Vmath::Vcopy(MapSize,m_BCtoElmMap,1,ElmtID,1);
325  Vmath::Vcopy(MapSize,m_BCtoEdgMap,1,EdgeID,1);
326  }
327  }
328 
329 
330  } // end of namespace
331 } //end of namespace