Nektar++
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// 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 using LDG flux and a 2D homogeneous directions
33//
34///////////////////////////////////////////////////////////////////////////////
35
39
41{
42
44 : ExpList3DHomogeneous2D(), m_bndCondExpansions(), m_bndCondBndWeight(),
45 m_bndConditions()
46{
47}
48
51 const LibUtilities::BasisKey &HomoBasis_y,
52 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
53 const NekDouble lhom_z, const bool useFFT, const bool dealiasing,
55 : ExpList3DHomogeneous2D(pSession, HomoBasis_y, HomoBasis_z, lhom_y, lhom_z,
56 useFFT, dealiasing, ImpType),
57 m_bndCondExpansions(), m_bndCondBndWeight(), m_bndConditions()
58{
59}
60
62 const DisContField3DHomogeneous2D &In, const bool DeclareLinesSetCoeffPhys)
63 : ExpList3DHomogeneous2D(In, false),
64 m_bndCondExpansions(In.m_bndCondExpansions),
65 m_bndCondBndWeight(In.m_bndCondBndWeight),
66 m_bndConditions(In.m_bndConditions)
67{
68 if (DeclareLinesSetCoeffPhys)
69 {
70 DisContFieldSharedPtr zero_line =
71 std::dynamic_pointer_cast<DisContField>(In.m_lines[0]);
72
73 for (int n = 0; n < m_lines.size(); ++n)
74 {
75 m_lines[n] =
77 }
78
80 }
81}
82
85 const LibUtilities::BasisKey &HomoBasis_y,
86 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
87 const NekDouble lhom_z, const bool useFFT, const bool dealiasing,
89 const std::string &variable, const Collections::ImplementationType ImpType)
90 : ExpList3DHomogeneous2D(pSession, HomoBasis_y, HomoBasis_z, lhom_y, lhom_z,
91 useFFT, dealiasing, ImpType),
92 m_bndCondExpansions(), m_bndCondBndWeight(), m_bndConditions()
93{
94 int i, n, nel;
95 DisContFieldSharedPtr line_zero;
96 SpatialDomains::BoundaryConditions bcs(pSession, graph1D);
97
98 //
100 pSession, graph1D, variable, ImpType);
101
103 nel = m_lines[0]->GetExpSize();
104
105 for (i = 0; i < nel; ++i)
106 {
107 (*m_exp).push_back(m_lines[0]->GetExp(i));
108 }
109
110 int nylines = m_homogeneousBasis_y->GetNumPoints();
111 int nzlines = m_homogeneousBasis_z->GetNumPoints();
112
113 for (n = 1; n < nylines * nzlines; ++n)
114 {
116 pSession, graph1D, variable, ImpType);
117 for (i = 0; i < nel; ++i)
118 {
119 (*m_exp).push_back((*m_exp)[i]);
120 }
121 }
122
123 // Setup Default optimisation information.
124 nel = GetExpSize();
125
126 SetCoeffPhys();
127
128 SetupBoundaryConditions(HomoBasis_y, HomoBasis_z, lhom_y, lhom_z, bcs,
129 variable);
130}
131
133{
134}
135
137 const LibUtilities::BasisKey &HomoBasis_y,
138 const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y,
140 const std::string variable)
141{
142 // Setup an ExpList2DHomogeneous2D expansion for boundary
143 // conditions and link to class declared in m_lines.
144
145 size_t nlines = m_lines.size();
146
148 bcs.GetBoundaryRegions();
149
150 size_t nbnd = bregions.size();
151
154
155 Array<OneD, MultiRegions::ExpListSharedPtr> LinesBndCondExp(nlines);
156
157 m_bndConditions = m_lines[0]->UpdateBndConditions();
158
159 for (int i = 0; i < nbnd; ++i)
160 {
161 for (int n = 0; n < nlines; ++n)
162 {
163 LinesBndCondExp[n] = m_lines[n]->UpdateBndCondExpansion(i);
164 }
165
168 m_session, HomoBasis_y, HomoBasis_z, lhom_y, lhom_z, m_useFFT,
169 false, LinesBndCondExp);
170 }
171
172 v_EvaluateBoundaryConditions(0.0, variable);
173}
174
176 const Array<OneD, const NekDouble> &inarray,
178 const StdRegions::VarCoeffMap &varcoeff,
179 const MultiRegions::VarFactorsMap &varfactors,
180 const Array<OneD, const NekDouble> &dirForcing, const bool PhysSpaceForcing)
181{
182 int n, m;
183 int cnt = 0;
184 int cnt1 = 0;
185 int nhom_modes_y = m_homogeneousBasis_y->GetNumModes();
186 int nhom_modes_z = m_homogeneousBasis_z->GetNumModes();
187 NekDouble beta_y;
188 NekDouble beta_z;
189 StdRegions::ConstFactorMap new_factors;
190
191 int npts_fce = PhysSpaceForcing ? m_npoints : m_ncoeffs;
193 Array<OneD, NekDouble> fce(npts_fce);
195
196 // Fourier transform forcing function
197 if (m_WaveSpace)
198 {
199 fce = inarray;
200 }
201 else
202 {
203 HomogeneousFwdTrans(npts_fce, inarray, fce);
204 }
205
206 for (n = 0; n < nhom_modes_z; ++n)
207 {
208 for (m = 0; m < nhom_modes_y; ++m)
209 {
210 beta_z = 2 * M_PI * (n / 2) / m_lhom_z;
211 beta_y = 2 * M_PI * (m / 2) / m_lhom_y;
212 new_factors = factors;
213 new_factors[StdRegions::eFactorLambda] +=
214 beta_y * beta_y + beta_z * beta_z;
215
216 wfce = (PhysSpaceForcing) ? fce + cnt : fce + cnt1;
217 m_lines[n]->HelmSolve(wfce, e_out = outarray + cnt1, new_factors,
218 varcoeff, varfactors, dirForcing,
219 PhysSpaceForcing);
220
221 cnt += m_lines[n]->GetTotPoints();
222 cnt1 += m_lines[n]->GetNcoeffs();
223 }
224 }
225 return NullGlobalLinSysKey;
226}
227
229 int i, std::shared_ptr<ExpList> &result, const bool DeclareCoeffPhysArrays)
230{
231 int cnt, n;
232
233 std::vector<unsigned int> eIDs;
234 Array<OneD, int> ElmtID, EdgeID;
235 GetBoundaryToElmtMap(ElmtID, EdgeID);
236
237 // Skip other boundary regions
238 for (cnt = n = 0; n < i; ++n)
239 {
240 cnt += m_bndCondExpansions[n]->GetExpSize();
241 }
242
243 // Populate eIDs with information from BoundaryToElmtMap
244 for (n = 0; n < m_bndCondExpansions[i]->GetExpSize(); ++n)
245 {
246 eIDs.push_back(ElmtID[cnt + n]);
247 }
248
249 // Create expansion list
250 result =
252
253 // Copy phys and coeffs to new explist
254 if (DeclareCoeffPhysArrays)
255 {
256 int nq, offsetOld, offsetNew;
257 Array<OneD, NekDouble> tmp1, tmp2;
258 for (n = 0; n < result->GetExpSize(); ++n)
259 {
260 nq = GetExp(ElmtID[cnt + n])->GetTotPoints();
261 offsetOld = GetPhys_Offset(ElmtID[cnt + n]);
262 offsetNew = result->GetPhys_Offset(n);
263 Vmath::Vcopy(nq, tmp1 = GetPhys() + offsetOld, 1,
264 tmp2 = result->UpdatePhys() + offsetNew, 1);
265
266 nq = GetExp(ElmtID[cnt + n])->GetNcoeffs();
267 offsetOld = GetCoeff_Offset(ElmtID[cnt + n]);
268 offsetNew = result->GetCoeff_Offset(n);
269 Vmath::Vcopy(nq, tmp1 = GetCoeffs() + offsetOld, 1,
270 tmp2 = result->UpdateCoeffs() + offsetNew, 1);
271 }
272 }
273
274 // Set wavespace value
275 result->SetWaveSpace(GetWaveSpace());
276}
277
279 Array<OneD, int> &ElmtID, Array<OneD, int> &EdgeID)
280{
281 if (m_BCtoElmMap.size() == 0)
282 {
283 Array<OneD, int> ElmtID_tmp;
284 Array<OneD, int> EdgeID_tmp;
285
286 m_lines[0]->GetBoundaryToElmtMap(ElmtID_tmp, EdgeID_tmp);
287 int nel_per_lines = m_lines[0]->GetExpSize();
288 int nlines = m_lines.size();
289
290 int MapSize = ElmtID_tmp.size();
291
292 m_BCtoElmMap = Array<OneD, int>(nlines * MapSize);
293 m_BCtoEdgMap = Array<OneD, int>(nlines * MapSize);
294 if (MapSize > 0)
295 {
296 int i, j, n, cnt;
297 int cntLine = 0;
298 for (cnt = n = 0; n < m_bndCondExpansions.size(); ++n)
299 {
300 int lineExpSize =
301 m_lines[0]->GetBndCondExpansions()[n]->GetExpSize();
302 for (i = 0; i < lineExpSize; ++i, ++cntLine)
303 {
304 for (j = 0; j < nlines; j++)
305 {
306 m_BCtoElmMap[cnt + i + j * lineExpSize] =
307 ElmtID_tmp[cntLine] + j * nel_per_lines;
308 m_BCtoEdgMap[cnt + i + j * lineExpSize] =
309 EdgeID_tmp[cntLine];
310 }
311 }
312 cnt += m_bndCondExpansions[n]->GetExpSize();
313 }
314 }
315 }
316 ElmtID = m_BCtoElmMap;
317 EdgeID = m_BCtoEdgMap;
318}
319
320/// @todo Fix Robin BCs for homogeneous case
321std::map<int, RobinBCInfoSharedPtr> DisContField3DHomogeneous2D::
323{
324 return std::map<int, RobinBCInfoSharedPtr>();
325}
326
328 const NekDouble time, const std::string varName,
329 [[maybe_unused]] const NekDouble x2_in,
330 [[maybe_unused]] const NekDouble x3_in)
331{
332 int n, m;
335
336 for (n = 0; n < m_nz; ++n)
337 {
338 for (m = 0; m < m_ny; ++m)
339 {
341 time, varName, 0.5 * m_lhom_y * (1.0 + y[m]),
342 0.5 * m_lhom_z * (1.0 + z[n]));
343 }
344 }
345
346 // Fourier transform coefficient space boundary values
347 for (n = 0; n < m_bndCondExpansions.size(); ++n)
348 {
349 if (time == 0.0 || m_bndConditions[n]->IsTimeDependent())
350 {
351 m_bndCondBndWeight[n] = 1.0;
352 m_bndCondExpansions[n]->HomogeneousFwdTrans(
356 }
357 }
358}
359
362{
363 return m_bndCondExpansions;
364}
365
368{
369 return m_bndConditions;
370}
371
373 int i)
374{
375 return m_bndCondExpansions[i];
376}
377
380{
381 return m_bndConditions;
382}
383
385 const NekDouble value)
386{
387 m_bndCondBndWeight[index] = value;
388}
389} // namespace Nektar::MultiRegions
Describes the specification for a Basis.
Definition: Basis.h:45
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void v_GetBndElmtExpansion(int i, std::shared_ptr< ExpList > &result, const bool DeclareCoeffPhysArrays) override
void SetupBoundaryConditions(const LibUtilities::BasisKey &HomoBasis_y, const LibUtilities::BasisKey &HomoBasis_z, const NekDouble lhom_y, const NekDouble lhom_z, SpatialDomains::BoundaryConditions &bcs, const std::string variable)
void v_GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &EdgeID) override
const Array< OneD, const std::shared_ptr< ExpList > > & v_GetBndCondExpansions(void) override
Array< OneD, int > m_BCtoElmMap
Storage space for the boundary to element and boundary to trace map. This member variable is really a...
void v_SetBndCondBwdWeight(const int index, const NekDouble value) override
Array< OneD, SpatialDomains::BoundaryConditionShPtr > & v_UpdateBndConditions() override
void v_EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="", const NekDouble x2_in=NekConstants::kNekUnsetDouble, const NekDouble x3_in=NekConstants::kNekUnsetDouble) override
std::map< int, RobinBCInfoSharedPtr > v_GetRobinBCInfo() override
GlobalLinSysKey v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const MultiRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
std::shared_ptr< ExpList > & v_UpdateBndCondExpansion(int i) override
const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & v_GetBndConditions() override
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
Abstraction of a one-dimensional multi-elemental expansion which is merely a collection of local expa...
void SetCoeffPhys(void)
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.
LibUtilities::BasisSharedPtr m_homogeneousBasis_y
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
NekDouble m_lhom_z
Width of homogeneous direction z.
int m_ny
Number of modes = number of poitns in y direction.
Array< OneD, ExpListSharedPtr > m_lines
Vector of ExpList, will be filled with ExpList1D.
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
NekDouble m_lhom_y
Width of homogeneous direction y.
Array< OneD, NekDouble > & UpdateCoeffs()
This function returns (a reference to) the array (implemented as m_coeffs) containing all local expa...
Definition: ExpList.h:2095
int GetNcoeffs(void) const
Returns the total number of local degrees of freedom .
Definition: ExpList.h:1512
void GetBoundaryToElmtMap(Array< OneD, int > &ElmtID, Array< OneD, int > &EdgeID)
Definition: ExpList.h:2261
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:1944
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:2030
int GetCoeff_Offset(int n) const
Get the start offset position for a local contiguous list of coeffs correspoinding to element n.
Definition: ExpList.h:2078
int GetExpSize(void)
This function returns the number of elements in the expansion.
Definition: ExpList.h:2038
std::shared_ptr< LocalRegions::ExpansionVector > m_exp
The list of local expansions.
Definition: ExpList.h:1118
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1063
void EvaluateBoundaryConditions(const NekDouble time=0.0, const std::string varName="", const NekDouble=NekConstants::kNekUnsetDouble, const NekDouble=NekConstants::kNekUnsetDouble)
Definition: ExpList.h:2250
const std::shared_ptr< LocalRegions::ExpansionVector > GetExp() const
This function returns the vector of elements in the expansion.
Definition: ExpList.h:2070
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:1058
bool GetWaveSpace(void) const
This function returns the third direction expansion condition, which can be in wave space (coefficien...
Definition: ExpList.h:1604
int GetPhys_Offset(int n) const
Get the start offset position for a local contiguous list of quadrature points in a full array corres...
Definition: ExpList.h:2085
void HomogeneousFwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true)
Definition: ExpList.h:1840
const BoundaryRegionCollection & GetBoundaryRegions(void) const
Definition: Conditions.h:234
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< DisContField > DisContFieldSharedPtr
Definition: DisContField.h:346
static GlobalLinSysKey NullGlobalLinSysKey(StdRegions::eNoMatrixType)
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
Definition: Conditions.h:210
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:430
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:375
std::vector< double > z(NPUPPER)
StdRegions::ConstFactorMap factors
double NekDouble
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825