Nektar++
ContField3D.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File ContField3D.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 conditions
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42  namespace MultiRegions
43  {
44 
45  ContField3D::ContField3D():
47  m_locToGloMap(),
48  m_globalMat(),
49  m_globalLinSysManager(
50  std::bind(
51  &ContField3D::GenGlobalLinSys, this, std::placeholders::_1),
52  std::string("GlobalLinSys"))
53  {
54  }
55 
56 
57  /**
58  * Given a mesh \a graph2D, containing information about the domain and
59  * the spectral/hp element expansion, this constructor fills the list
60  * of local expansions #m_exp with the proper expansions, calculates
61  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
62  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
63  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
64  * mapping array (contained in #m_locToGloMap) for the transformation
65  * between local elemental level and global level, it calculates the
66  * total number global expansion coefficients \f$\hat{u}_n\f$ and
67  * allocates memory for the array #m_coeffs. The constructor also
68  * discretises the boundary conditions, specified by the argument \a
69  * bcs, by expressing them in terms of the coefficient of the expansion
70  * on the boundary.
71  *
72  * @param pSession Session information.
73  * @param graph3D A mesh, containing information about the domain
74  * and the spectral/hp element expansion.
75  * @param variable The variable associated with this field.
76  */
79  const std::string &variable,
80  const bool CheckIfSingularSystem,
81  const Collections::ImplementationType ImpType):
82  DisContField3D(pSession,graph3D,variable,false,ImpType),
83  m_globalMat(MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
85  std::bind(&ContField3D::GenGlobalLinSys, this, std::placeholders::_1),
86  std::string("GlobalLinSys"))
87  {
90  CheckIfSingularSystem, variable,
92 
93  if (m_session->DefinesCmdLineArgument("verbose"))
94  {
95  m_locToGloMap->PrintStats(std::cout, variable);
96  }
97  }
98 
99 
100  /**
101  * Given a mesh \a graph3D, containing information about the domain and
102  * the spectral/hp element expansion, this constructor fills the list
103  * of local expansions #m_exp with the proper expansions, calculates
104  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
105  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
106  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
107  * mapping array (contained in #m_locToGloMap) for the transformation
108  * between local elemental level and global level, it calculates the
109  * total number global expansion coefficients \f$\hat{u}_n\f$ and
110  * allocates memory for the array #m_coeffs. The constructor also
111  * discretises the boundary conditions, specified by the argument \a
112  * bcs, by expressing them in terms of the coefficient of the expansion
113  * on the boundary.
114  *
115  * @param In Existing ContField2D object used to provide the
116  * local to global mapping information and
117  * global solution type.
118  * @param graph3D A mesh, containing information about the domain
119  * and the spectral/hp element expansion.
120  * @param bcs The boundary conditions.
121  * @param bc_loc
122  */
124  const SpatialDomains::MeshGraphSharedPtr &graph3D,
125  const std::string &variable,
126  const bool CheckIfSingularSystem):
127  DisContField3D(In,graph3D,variable,false),
128  m_globalMat (MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
130  std::bind(&ContField3D::GenGlobalLinSys, this, std::placeholders::_1),
131  std::string("GlobalLinSys"))
132 
133  {
134  if(!SameTypeOfBoundaryConditions(In) || CheckIfSingularSystem)
135  {
139  CheckIfSingularSystem, variable,
141 
142  if (m_session->DefinesCmdLineArgument("verbose"))
143  {
144  m_locToGloMap->PrintStats(std::cout, variable);
145  }
146  }
147  else
148  {
150  }
151  }
152 
153 
155  DisContField3D(In),
159  {
160  }
161 
162 
164  {
165  }
166 
167 
168  /**
169  * Given the coefficients of an expansion, this function evaluates the
170  * spectral/hp expansion \f$u^{\delta}(\boldsymbol{x})\f$ at the
171  * quadrature points \f$\boldsymbol{x}_i\f$. This operation is
172  * evaluated locally by the function ExpList#BwdTrans.
173  *
174  * The coefficients of the expansion should be contained in the variable
175  * #inarray of the ExpList object \a In. The resulting physical values
176  * at the quadrature points \f$u^{\delta}(\boldsymbol{x}_i)\f$ are
177  * stored in the array #outarray.
178  *
179  * @param In An ExpList, containing the local coefficients
180  * \f$\hat{u}_n^e\f$ in its array #m_coeffs.
181  */
183  const Array<OneD, const NekDouble> &inarray,
184  Array<OneD, NekDouble> &outarray,
185  CoeffState coeffstate)
186  {
187  if(coeffstate == eGlobal)
188  {
189  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(
191 
192  if(doGlobalOp)
193  {
196  mat->Multiply(inarray,outarray);
197  }
198  else
199  {
201  GlobalToLocal(inarray,wsp);
202  BwdTrans_IterPerExp(wsp,outarray);
203  }
204  }
205  else
206  {
207  BwdTrans_IterPerExp(inarray,outarray);
208  }
209  }
210 
211 
212  /**
213  * The operation is evaluated locally (i.e. with respect to all local
214  * expansion modes) by the function ExpList#IProductWRTBase. The inner
215  * product with respect to the global expansion modes is than obtained
216  * by a global assembly operation.
217  *
218  * The values of the function \f$f(\boldsymbol{x})\f$ evaluated at the
219  * quadrature points \f$\boldsymbol{x}_i\f$ should be contained in the
220  * variable #m_phys of the ExpList object \a in. The result is stored
221  * in the array #m_coeffs.
222  *
223  * @param In An ExpList, containing the discrete evaluation
224  * of \f$f(\boldsymbol{x})\f$ at the quadrature
225  * points in its array #m_phys.
226  */
228  Array<OneD, NekDouble> &outarray,
229  CoeffState coeffstate)
230  {
231  if(coeffstate == eGlobal)
232  {
233  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(
235 
236  if(doGlobalOp)
237  {
239  m_locToGloMap);
241  mat->Multiply(inarray,outarray);
242  m_locToGloMap->UniversalAssemble(outarray);
243  }
244  else
245  {
247  IProductWRTBase_IterPerExp(inarray,wsp);
248  Assemble(wsp,outarray);
249  }
250  }
251  else
252  {
253  IProductWRTBase_IterPerExp(inarray,outarray);
254  }
255  }
256 
257 
259  Array<OneD, NekDouble> &outarray,
260  CoeffState coeffstate)
261  {
262  // Inner product of forcing
263  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
264  Array<OneD,NekDouble> wsp(contNcoeffs);
265  IProductWRTBase(inarray,wsp,eGlobal);
266 
267  // Solve the system
269 
270  if(coeffstate == eGlobal)
271  {
272  GlobalSolve(key,wsp,outarray);
273  }
274  else
275  {
276  Array<OneD,NekDouble> tmp(contNcoeffs,0.0);
277  GlobalSolve(key,wsp,tmp);
278  GlobalToLocal(tmp,outarray);
279  }
280  }
281 
282 
284  const Array<OneD, const NekDouble> &inarray,
285  Array<OneD, NekDouble> &outarray,
286  CoeffState coeffstate)
287 
288  {
289  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
291 
292  if(coeffstate == eGlobal)
293  {
294  if(inarray.data() == outarray.data())
295  {
296  Array<OneD, NekDouble> tmp(contNcoeffs,0.0);
297  Vmath::Vcopy(contNcoeffs,inarray,1,tmp,1);
298  GlobalSolve(key,tmp,outarray);
299  }
300  else
301  {
302  GlobalSolve(key,inarray,outarray);
303  }
304  }
305  else
306  {
307  Array<OneD, NekDouble> globaltmp(contNcoeffs,0.0);
308 
309  if(inarray.data() == outarray.data())
310  {
311  Array<OneD,NekDouble> tmp(inarray.num_elements());
312  Vmath::Vcopy(inarray.num_elements(),inarray,1,tmp,1);
313  Assemble(tmp,outarray);
314  }
315  else
316  {
317  Assemble(inarray,outarray);
318  }
319 
320  GlobalSolve(key,outarray,globaltmp);
321  GlobalToLocal(globaltmp,outarray);
322  }
323  }
324 
325 
327  Array<OneD, NekDouble> &inout,
328  Array<OneD, NekDouble> &outarray)
329  {
330  int bndcnt=0;
331  const Array<OneD,const int>& map = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
332  NekDouble sign;
333 
334  for(int i = 0; i < m_bndCondExpansions.num_elements(); ++i)
335  {
336  if(m_bndConditions[i]->GetBoundaryConditionType() == SpatialDomains::eDirichlet)
337  {
338  const Array<OneD,const NekDouble>& coeffs = m_bndCondExpansions[i]->GetCoeffs();
339  for(int j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
340  {
341  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
342  if(sign)
343  {
344  inout[map[bndcnt++]] = sign * coeffs[j];
345  }
346  else
347  {
348  bndcnt++;
349  }
350  }
351  }
352  else
353  {
354  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
355  }
356  }
357  GeneralMatrixOp(key,inout,outarray,eGlobal);
358  }
359 
360 
361 
362  // Note inout contains initial guess and final output.
364  const GlobalLinSysKey &key,
366  Array<OneD, NekDouble> &inout,
367  const Array<OneD, const NekDouble> &dirForcing)
368  {
369  int NumDirBcs = m_locToGloMap->GetNumGlobalDirBndCoeffs();
370  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
371 
372  // STEP 1: SET THE DIRICHLET DOFS TO THE RIGHT VALUE
373  // IN THE SOLUTION ARRAY
375 
376 
377  // STEP 2: CALCULATE THE HOMOGENEOUS COEFFICIENTS
378  if(contNcoeffs - NumDirBcs > 0)
379  {
381  LinSys->Solve(rhs,inout,m_locToGloMap,dirForcing);
382  }
383  }
384 
386  {
387  return m_globalLinSysManager[mkey];
388  }
389 
390 
392  {
394  "To use method must have a AssemblyMap "
395  "attached to key");
397  }
398 
399 
400  /**
401  * Returns the global matrix associated with the given GlobalMatrixKey.
402  * If the global matrix has not yet been constructed on this field,
403  * it is first constructed using GenGlobalMatrix().
404  * @param mkey Global matrix key.
405  * @returns Assocated global matrix.
406  */
408  {
410  "To use method must have a AssemblyMap "
411  "attached to key");
412 
413  GlobalMatrixSharedPtr glo_matrix;
414  auto matrixIter = m_globalMat->find(mkey);
415 
416  if(matrixIter == m_globalMat->end())
417  {
418  glo_matrix = GenGlobalMatrix(mkey,m_locToGloMap);
419  (*m_globalMat)[mkey] = glo_matrix;
420  }
421  else
422  {
423  glo_matrix = matrixIter->second;
424  }
425 
426  return glo_matrix;
427  }
428 
429 
431  {
432  int i,j;
433  int bndcnt = 0;
434  int nDir = m_locToGloMap->GetNumGlobalDirBndCoeffs();
435 
436  NekDouble sign;
437  const Array<OneD,const int> &bndMap =
438  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
439 
441  m_locToGloMap->GetNumGlobalBndCoeffs(), 0.0);
442 
443  // Fill in Dirichlet coefficients that are to be sent to other
444  // processors. This code block uses a tuple<int,int.NekDouble> which
445  // stores the local id of coefficent the global id of the data
446  // location and the inverse of the values of the data (arising from
447  // periodic boundary conditiosn)
448  map<int, vector<ExtraDirDof> > &extraDirDofs =
449  m_locToGloMap->GetExtraDirDofs();
450 
451  for (auto &it : extraDirDofs)
452  {
453  for (i = 0; i < it.second.size(); ++i)
454  {
455  tmp[std::get<1>(it.second.at(i))] =
456  m_bndCondExpansions[it.first]->GetCoeffs()[
457  std::get<0>(it.second.at(i))]*std::get<2>(it.second.at(i));
458  }
459  }
460 
461  m_locToGloMap->UniversalAssembleBnd(tmp);
462 
463  // Now fill in all other Dirichlet coefficients.
464  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
465  {
466  if(m_bndConditions[i]->GetBoundaryConditionType() ==
468  {
469  const Array<OneD,const NekDouble>& coeffs =
470  m_bndCondExpansions[i]->GetCoeffs();
471  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
472  {
473  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(
474  bndcnt);
475  if (sign)
476  {
477  tmp[bndMap[bndcnt++]] = sign * coeffs[j];
478  }
479  else
480  {
481  bndcnt++;
482  }
483  }
484  }
485  else if (m_bndConditions[i]->GetBoundaryConditionType() !=
487  {
488  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
489  }
490  }
491 
492  Vmath::Vcopy(nDir, tmp, 1, outarray, 1);
493  }
494 
496  {
497  NekDouble sign;
498  int bndcnt = 0;
499  const Array<OneD,const int> &bndMap =
500  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
501 
502  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
503  LocalToGlobal(m_coeffs,tmp,false);
504 
505  // Now fill in all other Dirichlet coefficients.
506  for(int i = 0; i < m_bndCondExpansions.num_elements(); ++i)
507  {
508  Array<OneD, NekDouble>& coeffs =
509  m_bndCondExpansions[i]->UpdateCoeffs();
510 
511  if(m_bndConditions[i]->GetBoundaryConditionType()
513  {
514  continue;
515  }
516 
517  for(int j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
518  {
519  sign = m_locToGloMap->
520  GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
521  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
522  }
523  }
524  }
525 
527  {
528  NekDouble sign;
529  int bndcnt = 0;
530  const Array<OneD,const int> &bndMap =
531  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
532 
533  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
534  LocalToGlobal(m_coeffs,tmp,false);
535 
536  ASSERTL1(nreg < m_bndCondExpansions.num_elements(),
537  "nreg is out or range since this many boundary "
538  "regions to not exist");
539 
540  // Now fill in all other Dirichlet coefficients.
541  Array<OneD, NekDouble>& coeffs =
542  m_bndCondExpansions[nreg]->UpdateCoeffs();
543 
544  for(int j = 0; j < nreg; ++j)
545  {
546  if(m_bndConditions[j]->GetBoundaryConditionType()
548  {
549  continue;
550  }
551  bndcnt += m_bndCondExpansions[j]->GetNcoeffs();
552  }
553 
554  for(int j = 0; j < (m_bndCondExpansions[nreg])->GetNcoeffs(); ++j)
555  {
556  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
557  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
558  }
559  }
560 
561 
562  void ContField3D::v_LocalToGlobal(bool useComm)
563  {
564  m_locToGloMap->LocalToGlobal(m_coeffs, m_coeffs,useComm);
565  }
566 
567 
569  const Array<OneD, const NekDouble> &inarray,
570  Array<OneD,NekDouble> &outarray,
571  bool useComm)
572  {
573  m_locToGloMap->LocalToGlobal(inarray, outarray, useComm);
574  }
575 
576 
578  {
579  m_locToGloMap->GlobalToLocal(m_coeffs, m_coeffs);
580  }
581 
582 
584  const Array<OneD, const NekDouble> &inarray,
585  Array<OneD,NekDouble> &outarray)
586  {
587  m_locToGloMap->GlobalToLocal(inarray, outarray);
588  }
589 
590 
592  const Array<OneD, const NekDouble> &inarray,
593  Array<OneD, NekDouble> &outarray,
594  const FlagList &flags,
595  const StdRegions::ConstFactorMap &factors,
596  const StdRegions::VarCoeffMap &varcoeff,
597  const MultiRegions::VarFactorsMap &varfactors,
598  const Array<OneD, const NekDouble> &dirForcing,
599  const bool PhysSpaceForcing)
600  {
601  // Inner product of forcing
602  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
603  Array<OneD,NekDouble> wsp(contNcoeffs);
604  if(PhysSpaceForcing)
605  {
606  IProductWRTBase(inarray,wsp,eGlobal);
607  }
608  else
609  {
610  Assemble(inarray,wsp);
611  }
612 
613  // Note -1.0 term necessary to invert forcing function to
614  // be consistent with matrix definition
615  Vmath::Neg(contNcoeffs, wsp, 1);
616 
617  // Forcing function with weak boundary conditions
618  int i,j;
619  int bndcnt = 0;
620  NekDouble sign;
621  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
622  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
623  {
624  if(m_bndConditions[i]->GetBoundaryConditionType() == SpatialDomains::eNeumann ||
625  m_bndConditions[i]->GetBoundaryConditionType() == SpatialDomains::eRobin)
626  {
627  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
628  {
629  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
630  gamma[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(bndcnt++)] +=
631  sign * (m_bndCondExpansions[i]->GetCoeffs())[j];
632  }
633  }
634  else if (m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::ePeriodic)
635  {
636  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
637  }
638  }
639  m_locToGloMap->UniversalAssemble(gamma);
640 
641  // Add weak boundary conditions to forcing
642  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
643 
644  // Solve the system
645  GlobalLinSysKey key(StdRegions::eHelmholtz, m_locToGloMap, factors,varcoeff,varfactors);
646 
647  if(flags.isSet(eUseGlobal))
648  {
649  GlobalSolve(key,wsp,outarray,dirForcing);
650  }
651  else
652  {
653  Array<OneD,NekDouble> tmp(contNcoeffs);
654  LocalToGlobal(outarray,tmp);
655  GlobalSolve(key,wsp,tmp,dirForcing);
656  GlobalToLocal(tmp,outarray);
657  }
658  }
659 
661  const GlobalMatrixKey &gkey,
662  const Array<OneD,const NekDouble> &inarray,
663  Array<OneD, NekDouble> &outarray,
664  CoeffState coeffstate)
665  {
666  if(coeffstate == eGlobal)
667  {
668  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(gkey.GetMatrixType());
669 
670  if(doGlobalOp)
671  {
673  mat->Multiply(inarray,outarray);
674  m_locToGloMap->UniversalAssemble(outarray);
675  }
676  else
677  {
679  Array<OneD,NekDouble> tmp2(tmp1+m_ncoeffs);
680  GlobalToLocal(inarray,tmp1);
681  GeneralMatrixOp_IterPerExp(gkey,tmp1,tmp2);
682  Assemble(tmp2,outarray);
683  }
684  }
685  else
686  {
687  GeneralMatrixOp_IterPerExp(gkey,inarray,outarray);
688  }
689  }
690 
691  /**
692  * First compute the inner product of forcing function with respect to
693  * base, and then solve the system with the linear advection operator.
694  * @param velocity Array of advection velocities in physical space
695  * @param inarray Forcing function.
696  * @param outarray Result.
697  * @param lambda reaction coefficient
698  * @param coeffstate State of Coefficients, Local or Global
699  * @param dirForcing Dirichlet Forcing.
700  */
701  // could combine this with HelmholtzCG.
703  const Array<OneD, Array<OneD, NekDouble> > &velocity,
704  const Array<OneD, const NekDouble> &inarray,
705  Array<OneD, NekDouble> &outarray,
706  const NekDouble lambda,
707  CoeffState coeffstate,
708  const Array<OneD, const NekDouble> &dirForcing)
709  {
710  // Inner product of forcing
711  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
712  Array<OneD, NekDouble> wsp(contNcoeffs);
713  IProductWRTBase(inarray, wsp, eGlobal);
714  // Note -1.0 term necessary to invert forcing function to
715  // be consistent with matrix definition
716  Vmath::Neg(contNcoeffs, wsp, 1);
717 
718  // Forcing function with weak boundary conditions
719  int i, j;
720  int bndcnt = 0;
721  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
722  for (i = 0; i < m_bndCondExpansions.num_elements(); ++i)
723  {
724  if (m_bndConditions[i]->GetBoundaryConditionType() !=
726  {
727  for (j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
728  {
729  gamma[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(
730  bndcnt++)] += (m_bndCondExpansions[i]->GetCoeffs())[j];
731  }
732  }
733  else
734  {
735  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
736  }
737  }
738  m_locToGloMap->UniversalAssemble(gamma);
739  // Add weak boundary conditions to forcing
740  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
741 
742  // Solve the system
744  factors[StdRegions::eFactorLambda] = lambda;
745  StdRegions::VarCoeffMap varcoeffs;
746  varcoeffs[StdRegions::eVarCoeffVelX] = velocity[0];
747  varcoeffs[StdRegions::eVarCoeffVelY] = velocity[1];
748  varcoeffs[StdRegions::eVarCoeffVelZ] = velocity[2];
751  factors,
752  varcoeffs);
753 
754  if (coeffstate == eGlobal)
755  {
756  GlobalSolve(key, wsp, outarray, dirForcing);
757  }
758  else
759  {
760  Array<OneD, NekDouble> tmp(contNcoeffs, 0.0);
761  GlobalSolve(key, wsp, tmp, dirForcing);
762  GlobalToLocal(tmp, outarray);
763  }
764  }
765 
766 
768  {
770  "To use method must have a AssemblyMap "
771  "attached to key");
772 
773  auto matrixIter = m_globalMat->find(gkey);
774 
775  if(matrixIter == m_globalMat->end())
776  {
777  return 0;
778  }
779  else
780  {
781  return matrixIter->second->GetNumNonZeroEntries();
782  }
783 
784  return 0;
785  }
786 
787 
788  /**
789  *
790  */
792  {
793  m_globalLinSysManager.ClearManager("GlobalLinSys");
794  }
795 
796  } //end of namespace
797 } //end of namespace
virtual void v_LinearAdvectionDiffusionReactionSolve(const Array< OneD, Array< OneD, NekDouble > > &velocity, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const NekDouble lambda, CoeffState coeffstate=eLocal, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
void LocalToGlobal(bool useComm=true)
Gathers the global coefficients from the local coefficients .
Definition: ExpList.h:2083
void GeneralMatrixOp_IterPerExp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: ExpList.cpp:1019
GlobalMatrixSharedPtr GetGlobalMatrix(const GlobalMatrixKey &mkey)
Returns the global matrix specified by mkey.
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
#define sign(a, b)
return the sign(b)*a
Definition: Polylib.cpp:16
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1106
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::map< GlobalMatrixKey, GlobalMatrixSharedPtr > GlobalMatrixMap
Mapping from global matrix keys to global matrices.
Definition: GlobalMatrix.h:90
int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey)
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Calculates the inner product of a function with respect to all global expansion modes ...
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
STL namespace.
PeriodicMap m_periodicFaces
A map which identifies pairs of periodic faces.
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:294
virtual void v_GlobalToLocal(void)
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:1052
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray)
Impose the Dirichlet Boundary Conditions on outarray.
Global coefficients.
void GeneralMatrixOp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
This function calculates the result of the multiplication of a matrix of type specified by mkey with ...
Definition: ExpList.h:2394
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
std::shared_ptr< GlobalMatrix > GenGlobalMatrix(const GlobalMatrixKey &mkey, const std::shared_ptr< AssemblyMapCG > &locToGloMap)
Generates a global matrix from the given key and map.
Definition: ExpList.cpp:1086
void BwdTrans_IterPerExp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function elementally evaluates the backward transformation of the global spectral/hp element exp...
Definition: ExpList.h:1786
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:264
int GetNcoeffs(void) const
Returns the total number of local degrees of freedom .
Definition: ExpList.h:1558
bool isSet(const FlagType &key) const
std::shared_ptr< GlobalMatrix > GlobalMatrixSharedPtr
Shared pointer to a GlobalMatrix object.
Definition: GlobalMatrix.h:88
bool LocToGloMapIsDefined() const
Returns true if a local to global map is defined.
void IProductWRTBase_IterPerExp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function calculates the inner product of a function with respect to all local expansion modes ...
Definition: ExpList.h:1725
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1030
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:1023
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
double NekDouble
bool SameTypeOfBoundaryConditions(const DisContField3D &In)
Defines a list of flags.
virtual void v_GeneralMatrixOp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
Calculates the result of the multiplication of a global matrix of type specified by mkey with a vecto...
Describe a linear system.
Describes a matrix with ordering defined by a local to global map.
AssemblyMapCGSharedPtr m_locToGloMap
Definition: ContField3D.h:103
GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey)
void GenerateDirBndCondForcing(const GlobalLinSysKey &key, Array< OneD, NekDouble > &inout, Array< OneD, NekDouble > &outarray)
virtual void v_MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
void GlobalSolve(const GlobalLinSysKey &key, const Array< OneD, const NekDouble > &rhs, Array< OneD, NekDouble > &inout, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
GlobalMatrixMapShPtr m_globalMat
(A shared pointer to) a list which collects all the global matrices being assembled, such that they should be constructed only once.
Definition: ContField3D.h:108
void IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Definition: ExpList.h:1714
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
std::shared_ptr< GlobalLinSys > GenGlobalLinSys(const GlobalLinSysKey &mkey, const std::shared_ptr< AssemblyMapCG > &locToGloMap)
This operation constructs the global linear system of type mkey.
Definition: ExpList.cpp:1362
LibUtilities::NekManager< GlobalLinSysKey, GlobalLinSys > m_globalLinSysManager
(A shared pointer to) a list which collects all the global linear system being assembled, such that they should be constructed only once.
Definition: ContField3D.h:113
virtual void v_LocalToGlobal(bool useComm)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Performs the backward transformation of the spectral/hp element expansion.
virtual void v_ClearGlobalLinSysManager(void)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
void GlobalToLocal(void)
Scatters from the global coefficients to the local coefficients .
Definition: ExpList.h:2096
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
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)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:302
PeriodicMap m_periodicEdges
A map which identifies groups of periodic edges.
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap