Nektar++
ContField2D.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File ContField2D.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 2D domain with boundary conditions
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42  namespace MultiRegions
43  {
44  /**
45  * @class ContField2D
46  * The class #ContField2D is
47  * able to incorporate the boundary conditions imposed to the problem
48  * to be solved. Therefore, the class is equipped with three additional
49  * data members:
50  * - #m_bndCondExpansions
51  * - #m_bndTypes
52  * - #m_bndCondEquations
53  *
54  * The first data structure, #m_bndCondExpansions, contains the
55  * one-dimensional spectral/hp expansion on the boundary, #m_bndTypes
56  * stores information about the type of boundary condition on the
57  * different parts of the boundary while #m_bndCondEquations holds the
58  * equation of the imposed boundary conditions.
59  *
60  * Furthermore, in case of Dirichlet boundary conditions, this class is
61  * capable of lifting a known solution satisfying these boundary
62  * conditions. If we denote the unknown solution by
63  * \f$u^{\mathcal{H}}(\boldsymbol{x})\f$ and the known Dirichlet
64  * boundary conditions by \f$u^{\mathcal{D}}(\boldsymbol{x})\f$, the
65  * expansion then can be decomposed as
66  * \f[ u^{\delta}(\boldsymbol{x}_i)=u^{\mathcal{D}}(\boldsymbol{x}_i)+
67  * u^{\mathcal{H}}(\boldsymbol{x}_i)=\sum_{n=0}^{N^{\mathcal{D}}-1}
68  * \hat{u}_n^{\mathcal{D}}\Phi_n(\boldsymbol{x}_i)+
69  * \sum_{n={N^{\mathcal{D}}}}^{N_{\mathrm{dof}}-1}
70  * \hat{u}_n^{\mathcal{H}} \Phi_n(\boldsymbol{x}_i).\f]
71  * This lifting is accomplished by ordering the known global degrees of
72  * freedom, prescribed by the Dirichlet boundary conditions, first in
73  * the global array
74  * \f$\boldsymbol{\hat{u}}\f$, that is,
75  * \f[\boldsymbol{\hat{u}}=\left[ \begin{array}{c}
76  * \boldsymbol{\hat{u}}^{\mathcal{D}}\\
77  * \boldsymbol{\hat{u}}^{\mathcal{H}}
78  * \end{array} \right].\f]
79  * Such kind of expansions are also referred to as continuous fields.
80  * This class should be used when solving 2D problems using a standard
81  * Galerkin approach.
82  */
83 
84  /**
85  *
86  */
87  ContField2D::ContField2D():
89  m_locToGloMap(),
90  m_globalMat(),
91  m_globalLinSysManager(
92  std::bind(&ContField2D::GenGlobalLinSys, this, std::placeholders::_1),
93  std::string("GlobalLinSys"))
94  {
95  }
96 
97 
98  /**
99  * Given a mesh \a graph2D, containing information about the domain and
100  * the spectral/hp element expansion, this constructor fills the list
101  * of local expansions #m_exp with the proper expansions, calculates
102  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
103  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
104  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
105  * mapping array (contained in #m_locToGloMap) for the transformation
106  * between local elemental level and global level, it calculates the
107  * total number global expansion coefficients \f$\hat{u}_n\f$ and
108  * allocates memory for the array #m_contCoeffs. The constructor also
109  * discretises the boundary conditions, specified by the argument \a
110  * bcs, by expressing them in terms of the coefficient of the expansion
111  * on the boundary.
112  *
113  * @param graph2D A mesh, containing information about the domain
114  * and the spectral/hp element expansion.
115  * @param bcs The boundary conditions.
116  * @param variable An optional parameter to indicate for which
117  * variable the field should be constructed.
118  */
120  const LibUtilities::SessionReaderSharedPtr &pSession,
121  const SpatialDomains::MeshGraphSharedPtr &graph2D,
122  const std::string &variable,
123  const bool DeclareCoeffPhysArrays,
124  const bool CheckIfSingularSystem,
125  const Collections::ImplementationType ImpType):
126  DisContField2D(pSession,graph2D,variable,false,DeclareCoeffPhysArrays,ImpType),
127  m_globalMat(MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
129  std::bind(&ContField2D::GenGlobalLinSys, this, std::placeholders::_1),
130  std::string("GlobalLinSys"))
131  {
136  CheckIfSingularSystem,
137  variable,
140 
141  if (m_session->DefinesCmdLineArgument("verbose"))
142  {
143  m_locToGloMap->PrintStats(std::cout, variable);
144  }
145  }
146 
147 
148  /**
149  * Given a mesh \a graph2D, containing information about the domain and
150  * the spectral/hp element expansion, this constructor fills the list
151  * of local expansions #m_exp with the proper expansions, calculates
152  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
153  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
154  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
155  * mapping array (contained in #m_locToGloMap) for the transformation
156  * between local elemental level and global level, it calculates the
157  * total number global expansion coefficients \f$\hat{u}_n\f$ and
158  * allocates memory for the array #m_coeffs. The constructor also
159  * discretises the boundary conditions, specified by the argument \a
160  * bcs, by expressing them in terms of the coefficient of the expansion
161  * on the boundary.
162  *
163  * @param In Existing ContField2D object used to provide the
164  * local to global mapping information and
165  * global solution type.
166  * @param graph2D A mesh, containing information about the domain
167  * and the spectral/hp element expansion.
168  * @param bcs The boundary conditions.
169  * @param bc_loc
170  */
172  const SpatialDomains::MeshGraphSharedPtr &graph2D,
173  const std::string &variable,
174  bool DeclareCoeffPhysArrays,
175  const bool CheckIfSingularSystem):
176  DisContField2D(In,graph2D,variable,false,DeclareCoeffPhysArrays),
177  m_globalMat (MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
179  std::bind(&ContField2D::GenGlobalLinSys, this, std::placeholders::_1),
180  std::string("GlobalLinSys"))
181  {
182  if(!SameTypeOfBoundaryConditions(In) || CheckIfSingularSystem)
183  {
188  CheckIfSingularSystem,
189  variable,
192 
193  if (m_session->DefinesCmdLineArgument("verbose"))
194  {
195  m_locToGloMap->PrintStats(std::cout, variable);
196  }
197  }
198  else
199  {
201  }
202  }
203 
204 
205  /**
206  * Initialises the object as a copy of an existing ContField2D object.
207  * @param In Existing ContField2D object.
208  * @param DeclareCoeffPhysArrays bool to declare if \a m_phys
209  * and \a m_coeffs should be declared. Default is true
210  */
211  ContField2D::ContField2D(const ContField2D &In, bool DeclareCoeffPhysArrays):
212  DisContField2D(In,DeclareCoeffPhysArrays),
216  {
217  }
218 
219 
220  /**
221  *
222  */
224  {
225  }
226 
227 
228  /**
229  * Given a function \f$f(\boldsymbol{x})\f$ defined at the quadrature
230  * points, this function determines the unknown global coefficients
231  * \f$\boldsymbol{\hat{u}}^{\mathcal{H}}\f$ employing a discrete
232  * Galerkin projection from physical space to coefficient
233  * space. The operation is evaluated by the function #GlobalSolve using
234  * the global mass matrix.
235  *
236  * The values of the function \f$f(\boldsymbol{x})\f$ evaluated at the
237  * quadrature points \f$\boldsymbol{x}_i\f$ should be contained in the
238  * variable #m_phys of the ExpList object \a Sin. The resulting global
239  * coefficients \f$\hat{u}_g\f$ are stored in the array #m_coeffs.
240  *
241  * @param Sin An ExpList, containing the discrete evaluation
242  * of \f$f(\boldsymbol{x})\f$ at the quadrature
243  * points in its array #m_phys.
244  */
246  Array<OneD, NekDouble> &outarray,
247  CoeffState coeffstate)
248 
249  {
250  // Inner product of forcing
251  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
252  Array<OneD,NekDouble> wsp(contNcoeffs);
253  IProductWRTBase(inarray,wsp,eGlobal);
254 
255  // Solve the system
257 
258  if(coeffstate == eGlobal)
259  {
260  GlobalSolve(key,wsp,outarray);
261  }
262  else
263  {
264  Array<OneD,NekDouble> tmp(contNcoeffs,0.0);
265  GlobalSolve(key,wsp,tmp);
266  GlobalToLocal(tmp,outarray);
267  }
268  }
269 
270  /**
271  *
272  */
274  {
275  int gloNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
276  Array<OneD,NekDouble> tmp1(gloNcoeffs);
277  Array<OneD,NekDouble> tmp2(gloNcoeffs);
278 
279  IProductWRTBase(field,tmp1,eGlobal);
280  MultiplyByInvMassMatrix(tmp1,tmp2,eGlobal);
281  BwdTrans(tmp2,field,eGlobal);
282  }
283 
284 
285  /**
286  * Computes the matrix vector product
287  * @f$ \mathbf{y} = \mathbf{M}^{-1}\mathbf{x} @f$. If \a coeffstate == eGlobal
288  * is set then the elemental system is used directly. If not set, the
289  * global system is assembled, the system is solved, and mapped back to
290  * the local elemental system.
291  *
292  * @param inarray Input vector @f$\mathbf{x}@f$.
293  * @param outarray Output vector @f$\mathbf{y}@f$.
294  * @param coeffState Flag for using global system.
295  */
297  const Array<OneD, const NekDouble> &inarray,
298  Array<OneD, NekDouble> &outarray,
299  CoeffState coeffstate)
300 
301  {
303  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
304 
305  if(coeffstate == eGlobal)
306  {
307  if(inarray.data() == outarray.data())
308  {
309  Array<OneD, NekDouble> tmp(contNcoeffs,0.0);
310  Vmath::Vcopy(contNcoeffs,inarray,1,tmp,1);
311  GlobalSolve(key,tmp,outarray);
312  }
313  else
314  {
315  GlobalSolve(key,inarray,outarray);
316  }
317  }
318  else
319  {
320  Array<OneD, NekDouble> globaltmp(contNcoeffs,0.0);
321 
322  if(inarray.data() == outarray.data())
323  {
324  Array<OneD,NekDouble> tmp(inarray.num_elements());
325  Vmath::Vcopy(inarray.num_elements(),inarray,1,tmp,1);
326  Assemble(tmp,outarray);
327  }
328  else
329  {
330  Assemble(inarray,outarray);
331  }
332 
333  GlobalSolve(key,outarray,globaltmp);
334  GlobalToLocal(globaltmp,outarray);
335  }
336  }
337 
338 
339  /**
340  * Consider the two dimensional Laplace equation,
341  * \f[\nabla\cdot\left(\boldsymbol{\sigma}\nabla
342  * u(\boldsymbol{x})\right) = f(\boldsymbol{x}),\f] supplemented with
343  * appropriate boundary conditions (which are contained in the data
344  * member #m_bndCondExpansions). In the equation above
345  * \f$\boldsymbol{\sigma}\f$ is the (symmetric positive definite)
346  * diffusion tensor:
347  * \f[ \sigma = \left[ \begin{array}{cc}
348  * \sigma_{00}(\boldsymbol{x},t) & \sigma_{01}(\boldsymbol{x},t) \\
349  * \sigma_{01}(\boldsymbol{x},t) & \sigma_{11}(\boldsymbol{x},t)
350  * \end{array} \right]. \f]
351  * Applying a \f$C^0\f$ continuous Galerkin discretisation, this
352  * equation leads to the following linear system:
353  * \f[\boldsymbol{L}
354  * \boldsymbol{\hat{u}}_g=\boldsymbol{\hat{f}}\f]
355  * where \f$\boldsymbol{L}\f$ is the Laplacian matrix. This function
356  * solves the system above for the global coefficients
357  * \f$\boldsymbol{\hat{u}}\f$ by a call to the function #GlobalSolve.
358  *
359  * The values of the function \f$f(\boldsymbol{x})\f$ evaluated at the
360  * quadrature points \f$\boldsymbol{x}_i\f$ should be contained in the
361  * variable #m_phys of the ExpList object \a Sin. The resulting global
362  * coefficients \f$\boldsymbol{\hat{u}}_g\f$ are stored in the array
363  * #m_coeffs.
364  *
365  * @param Sin An ExpList, containing the discrete evaluation
366  * of the forcing function \f$f(\boldsymbol{x})\f$
367  * at the quadrature points in its array #m_phys.
368  * @param variablecoeffs The (optional) parameter containing the
369  * coefficients evaluated at the quadrature
370  * points. It is an Array of (three) arrays which
371  * stores the laplacian coefficients in the
372  * following way
373  * \f[\mathrm{variablecoeffs} = \left[ \begin{array}{c}
374  * \left[\sigma_{00}(\boldsymbol{x_i},t)\right]_i \\
375  * \left[\sigma_{01}(\boldsymbol{x_i},t)\right]_i \\
376  * \left[\sigma_{11}(\boldsymbol{x_i},t)\right]_i
377  * \end{array}\right]
378  * \f]
379  * If this argument is not passed to the function, the following
380  * equation will be solved:
381  * \f[\nabla^2u(\boldsymbol{x}) = f(\boldsymbol{x}),\f]
382  *
383  * @param time The time-level at which the coefficients are
384  * evaluated
385  */
387  const Array<OneD, const NekDouble> &inarray,
388  Array<OneD, NekDouble> &outarray,
389  const Array<OneD, const NekDouble> &dirForcing,
390  const Array<OneD, Array<OneD,NekDouble> >& variablecoeffs,
391  NekDouble time,
392  CoeffState coeffstate)
393  {
394  // Inner product of forcing
395  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
396  Array<OneD,NekDouble> wsp(contNcoeffs);
397  IProductWRTBase(inarray,wsp,eGlobal);
398  // Note -1.0 term necessary to invert forcing function to
399  // be consistent with matrix definition
400  Vmath::Neg(m_ncoeffs, wsp, 1);
401 
402  // Forcing function with weak boundary conditions
403  int i,j;
404  int bndcnt=0;
405  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
406  {
407  if(m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::eDirichlet)
408  {
409  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
410  {
411  wsp[m_locToGloMap
412  ->GetBndCondCoeffsToGlobalCoeffsMap(bndcnt++)]
413  += (m_bndCondExpansions[i]->GetCoeffs())[j];
414  }
415  }
416  else
417  {
418  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
419  }
420  }
421 
422  StdRegions::VarCoeffMap varcoeffs;
423  varcoeffs[StdRegions::eVarCoeffD00] = variablecoeffs[0];
424  varcoeffs[StdRegions::eVarCoeffD11] = variablecoeffs[3];
425  varcoeffs[StdRegions::eVarCoeffD22] = variablecoeffs[5];
427  factors[StdRegions::eFactorTime] = time;
428 
429  // Solve the system
431  varcoeffs);
432 
433  if(coeffstate == eGlobal)
434  {
435  GlobalSolve(key,wsp,outarray,dirForcing);
436  }
437  else
438  {
439  Array<OneD,NekDouble> tmp(contNcoeffs,0.0);
440  GlobalSolve(key,wsp,tmp,dirForcing);
441  GlobalToLocal(tmp,outarray);
442  }
443  }
444 
445 
446  /**
447  * Constructs the GlobalLinearSysKey for the linear advection operator
448  * with the supplied parameters, and computes the eigenvectors and
449  * eigenvalues of the associated matrix.
450  * @param ax Advection parameter, x.
451  * @param ay Advection parameter, y.
452  * @param Real Computed eigenvalues, real component.
453  * @param Imag Computed eigenvalues, imag component.
454  * @param Evecs Computed eigenvectors.
455  */
457  const NekDouble ay,
460  Array<OneD, NekDouble> &Evecs)
461  {
462  // Solve the system
466  vel[0] = vel_x;
467  vel[1] = vel_y;
468 
469  StdRegions::VarCoeffMap varcoeffs;
473  factors[StdRegions::eFactorTime] = 0.0;
475  factors,varcoeffs);
476 
478  Gmat->EigenSolve(Real,Imag,Evecs);
479  }
480 
481 
482 
483 
484  /**
485  * Given a linear system specified by the key \a key,
486  * \f[\boldsymbol{M}\boldsymbol{\hat{u}}_g=\boldsymbol{\hat{f}},\f]
487  * this function solves this linear system taking into account the
488  * boundary conditions specified in the data member
489  * #m_bndCondExpansions. Therefore, it adds an array
490  * \f$\boldsymbol{\hat{g}}\f$ which represents the non-zero surface
491  * integral resulting from the weak boundary conditions (e.g. Neumann
492  * boundary conditions) to the right hand side, that is,
493  * \f[\boldsymbol{M}\boldsymbol{\hat{u}}_g=\boldsymbol{\hat{f}}+
494  * \boldsymbol{\hat{g}}.\f]
495  * Furthermore, it lifts the known degrees of freedom which are
496  * prescribed by the Dirichlet boundary conditions. As these known
497  * coefficients \f$\boldsymbol{\hat{u}}^{\mathcal{D}}\f$ are numbered
498  * first in the global coefficient array \f$\boldsymbol{\hat{u}}_g\f$,
499  * the linear system can be decomposed as,
500  * \f[\left[\begin{array}{cc}
501  * \boldsymbol{M}^{\mathcal{DD}}&\boldsymbol{M}^{\mathcal{DH}}\\
502  * \boldsymbol{M}^{\mathcal{HD}}&\boldsymbol{M}^{\mathcal{HH}}
503  * \end{array}\right]
504  * \left[\begin{array}{c}
505  * \boldsymbol{\hat{u}}^{\mathcal{D}}\\
506  * \boldsymbol{\hat{u}}^{\mathcal{H}}
507  * \end{array}\right]=
508  * \left[\begin{array}{c}
509  * \boldsymbol{\hat{f}}^{\mathcal{D}}\\
510  * \boldsymbol{\hat{f}}^{\mathcal{H}}
511  * \end{array}\right]+
512  * \left[\begin{array}{c}
513  * \boldsymbol{\hat{g}}^{\mathcal{D}}\\
514  * \boldsymbol{\hat{g}}^{\mathcal{H}}
515  * \end{array}\right]
516  * \f]
517  * which will then be solved for the unknown coefficients
518  * \f$\boldsymbol{\hat{u}}^{\mathcal{H}}\f$ as,
519  * \f[
520  * \boldsymbol{M}^{\mathcal{HH}}\boldsymbol{\hat{u}}^{\mathcal{H}}=
521  * \boldsymbol{\hat{f}}^{\mathcal{H}}+
522  * \boldsymbol{\hat{g}}^{\mathcal{H}}-
523  * \boldsymbol{M}^{\mathcal{HD}}\boldsymbol{\hat{u}}^{\mathcal{D}}\f]
524  *
525  * @param mkey This key uniquely defines the linear system to
526  * be solved.
527  * @param Sin An ExpList, containing the discrete evaluation
528  * of the forcing function \f$f(\boldsymbol{x})\f$
529  * at the quadrature points in its array #m_phys.
530  * @param ScaleForcing An optional parameter with which the forcing
531  * vector \f$\boldsymbol{\hat{f}}\f$ should be
532  * multiplied.
533  * @note inout contains initial guess and final output.
534  */
536  const GlobalLinSysKey &key,
538  Array<OneD, NekDouble>& inout,
539  const Array<OneD, const NekDouble>& dirForcing)
540  {
541  int NumDirBcs = m_locToGloMap->GetNumGlobalDirBndCoeffs();
542  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
543 
544  // STEP 1: SET THE DIRICHLET DOFS TO THE RIGHT VALUE
545  // IN THE SOLUTION ARRAY
547 
548  // STEP 2: CALCULATE THE HOMOGENEOUS COEFFICIENTS
549  if(contNcoeffs - NumDirBcs > 0)
550  {
552  LinSys->Solve(rhs,inout,m_locToGloMap,dirForcing);
553  }
554  }
555 
556 
557  /**
558  * Returns the global matrix associated with the given GlobalMatrixKey.
559  * If the global matrix has not yet been constructed on this field,
560  * it is first constructed using GenGlobalMatrix().
561  * @param mkey Global matrix key.
562  * @returns Assocated global matrix.
563  */
565  const GlobalMatrixKey &mkey)
566  {
568  "To use method must have a AssemblyMap "
569  "attached to key");
570 
571  GlobalMatrixSharedPtr glo_matrix;
572  auto matrixIter = m_globalMat->find(mkey);
573 
574  if(matrixIter == m_globalMat->end())
575  {
576  glo_matrix = GenGlobalMatrix(mkey,m_locToGloMap);
577  (*m_globalMat)[mkey] = glo_matrix;
578  }
579  else
580  {
581  glo_matrix = matrixIter->second;
582  }
583 
584  return glo_matrix;
585  }
586 
587 
588  /**
589  * The function searches the map #m_globalLinSys to see if the
590  * global matrix has been created before. If not, it calls the function
591  * #GenGlobalLinSys to generate the requested global system.
592  *
593  * @param mkey This key uniquely defines the requested
594  * linear system.
595  */
597  const GlobalLinSysKey &mkey)
598  {
599  return m_globalLinSysManager[mkey];
600  }
601 
603  const GlobalLinSysKey &mkey)
604  {
606  "To use method must have a AssemblyMap "
607  "attached to key");
609  }
610 
611 
612  /**
613  *
614  */
616  const Array<OneD, const NekDouble> &inarray,
617  Array<OneD, NekDouble> &outarray,
618  CoeffState coeffstate)
619  {
620  BwdTrans(inarray,outarray,coeffstate);
621  }
622 
623 
624  /**
625  *
626  */
628  const Array<OneD, const NekDouble> &inarray,
629  Array<OneD, NekDouble> &outarray,
630  CoeffState coeffstate)
631  {
632  FwdTrans(inarray,outarray,coeffstate);
633  }
634 
636  {
637  int i,j;
638  int bndcnt=0;
639  int nDir = m_locToGloMap->GetNumGlobalDirBndCoeffs();
640 
641  // STEP 1: SET THE DIRICHLET DOFS TO THE RIGHT VALUE IN THE SOLUTION
642  // ARRAY
643  NekDouble sign;
644  const Array<OneD,const int> &bndMap =
645  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
646 
648  m_locToGloMap->GetNumGlobalBndCoeffs(), 0.0);
649 
650  // Fill in Dirichlet coefficients that are to be sent to
651  // other processors. This code block uses a
652  // tuple<int,int.NekDouble> which stores the local id of
653  // coefficent the global id of the data location and the
654  // inverse of the values of the data (arising from
655  // periodic boundary conditiosn)
656  map<int, vector<ExtraDirDof> > &extraDirDofs =
657  m_locToGloMap->GetExtraDirDofs();
658 
659  for (auto &it : extraDirDofs)
660  {
661  for (i = 0; i < it.second.size(); ++i)
662  {
663  tmp[std::get<1>(it.second.at(i))] =
664  m_bndCondExpansions[it.first]->GetCoeffs()[
665  std::get<0>(it.second.at(i))]*std::get<2>(it.second.at(i));
666  }
667  }
668  m_locToGloMap->UniversalAssembleBnd(tmp);
669 
670  // Now fill in all other Dirichlet coefficients.
671  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
672  {
673  if(m_bndConditions[i]->GetBoundaryConditionType() ==
675  {
676  const Array<OneD,const NekDouble>& coeffs =
677  m_bndCondExpansions[i]->GetCoeffs();
678  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
679  {
680  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(
681  bndcnt);
682  tmp[bndMap[bndcnt++]] = sign * coeffs[j];
683  }
684  }
685  else if(m_bndConditions[i]->GetBoundaryConditionType() !=
687  {
688  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
689  }
690  }
691 
692  Vmath::Vcopy(nDir, tmp, 1, outarray, 1);
693  }
694 
696  {
697  NekDouble sign;
698  int bndcnt = 0;
699  const Array<OneD,const int> &bndMap =
700  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
701 
702  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
703  LocalToGlobal(m_coeffs,tmp);
704 
705  // Now fill in all other Dirichlet coefficients.
706  for(int i = 0; i < m_bndCondExpansions.num_elements(); ++i)
707  {
708  if (m_bndConditions[i]->GetBoundaryConditionType() ==
710  {
711  continue;
712  }
713 
714  Array<OneD, NekDouble>& coeffs = m_bndCondExpansions[i]->UpdateCoeffs();
715 
716  for(int j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
717  {
718  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
719  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
720  }
721  }
722  }
723 
724 
726  {
727  NekDouble sign;
728  int bndcnt = 0;
729  const Array<OneD,const int> &bndMap =
730  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
731 
732  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
733  LocalToGlobal(m_coeffs,tmp,false);
734 
735  ASSERTL1(nreg < m_bndCondExpansions.num_elements(),
736  "nreg is out or range since this many boundary "
737  "regions to not exist");
738 
739  // Now fill in all other Dirichlet coefficients.
740  Array<OneD, NekDouble>& coeffs = m_bndCondExpansions[nreg]->UpdateCoeffs();
741 
742  for(int j = 0; j < nreg; ++j)
743  {
744  if (m_bndConditions[j]->GetBoundaryConditionType() ==
746  {
747  continue;
748  }
749 
750  bndcnt += m_bndCondExpansions[j]->GetNcoeffs();
751  }
752 
753  for(int j = 0; j < (m_bndCondExpansions[nreg])->GetNcoeffs(); ++j)
754  {
755  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
756  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
757  }
758  }
759 
760 
761  /**
762  * This operation is evaluated as:
763  * \f{tabbing}
764  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
765  * > > Do \= $i=$ $0,N_m^e-1$ \\
766  * > > > $\boldsymbol{\hat{u}}^{e}[i] = \mbox{sign}[e][i] \cdot
767  * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]$ \\
768  * > > continue \\
769  * > continue
770  * \f}
771  * where \a map\f$[e][i]\f$ is the mapping array and \a
772  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
773  * correct modal connectivity between the different elements (both
774  * these arrays are contained in the data member #m_locToGloMap). This
775  * operation is equivalent to the scatter operation
776  * \f$\boldsymbol{\hat{u}}_l=\mathcal{A}\boldsymbol{\hat{u}}_g\f$,
777  * where \f$\mathcal{A}\f$ is the
778  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
779  *
780  * @note The array #m_coeffs should be filled with the global
781  * coefficients \f$\boldsymbol{\hat{u}}_g\f$ and that the resulting
782  * local coefficients \f$\boldsymbol{\hat{u}}_l\f$ will be stored in
783  * #m_coeffs.
784  */
786  const Array<OneD, const NekDouble> &inarray,
787  Array<OneD,NekDouble> &outarray)
788  {
789  m_locToGloMap->GlobalToLocal(inarray, outarray);
790  }
791 
792 
794  {
795  m_locToGloMap->GlobalToLocal(m_coeffs,m_coeffs);
796  }
797 
798 
799  /**
800  * This operation is evaluated as:
801  * \f{tabbing}
802  * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
803  * > > Do \= $i=$ $0,N_m^e-1$ \\
804  * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
805  * \mbox{sign}[e][i] \cdot \boldsymbol{\hat{u}}^{e}[i]$\\
806  * > > continue\\
807  * > continue
808  * \f}
809  * where \a map\f$[e][i]\f$ is the mapping array and \a
810  * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
811  * correct modal connectivity between the different elements (both
812  * these arrays are contained in the data member #m_locToGloMap). This
813  * operation is equivalent to the gather operation
814  * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{-1}\boldsymbol{\hat{u}}_l\f$,
815  * where \f$\mathcal{A}\f$ is the
816  * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
817  *
818  * @note The array #m_coeffs should be filled with the local
819  * coefficients \f$\boldsymbol{\hat{u}}_l\f$ and that
820  * the resulting global coefficients
821  * \f$\boldsymbol{\hat{u}}_g\f$ will be stored in
822  * #m_coeffs. Also if useComm is set to false then no
823  * communication call will be made to check if all
824  * values are consistent over processors
825  */
826 
828  const Array<OneD, const NekDouble> &inarray,
829  Array<OneD,NekDouble> &outarray,
830  bool useComm)
831  {
832  m_locToGloMap->LocalToGlobal(inarray, outarray, useComm);
833  }
834 
835 
836  void ContField2D::v_LocalToGlobal(bool useComm)
837 
838  {
839  m_locToGloMap->LocalToGlobal(m_coeffs,m_coeffs, useComm);
840  }
841 
842  /**
843  *
844  */
846  const Array<OneD, const NekDouble> &inarray,
847  Array<OneD, NekDouble> &outarray,
848  CoeffState coeffstate)
849  {
850  MultiplyByInvMassMatrix(inarray,outarray,coeffstate);
851  }
852 
853 
854  /**
855  * Consider the two dimensional Helmholtz equation,
856  * \f[\nabla^2u(\boldsymbol{x})-\lambda u(\boldsymbol{x})
857  * = f(\boldsymbol{x}),\f] supplemented with appropriate boundary
858  * conditions (which are contained in the data member
859  * #m_bndCondExpansions). Applying a \f$C^0\f$ continuous Galerkin
860  * discretisation, this equation leads to the following linear system:
861  * \f[\left(\boldsymbol{L}+\lambda\boldsymbol{M}\right)
862  * \boldsymbol{\hat{u}}_g=\boldsymbol{\hat{f}}\f] where
863  * \f$\boldsymbol{L}\f$ and \f$\boldsymbol{M}\f$ are the Laplacian and
864  * mass matrix respectively. This function solves the system above for
865  * the global coefficients \f$\boldsymbol{\hat{u}}\f$ by a call to the
866  * function #GlobalSolve. It is assumed #m_coeff contains an
867  * initial estimate for the solution.
868  *
869  * The values of the function \f$f(\boldsymbol{x})\f$
870  * evaluated at the quadrature points \f$\boldsymbol{x}_i\f$
871  * should be contained in the variable #m_phys of the ExpList
872  * object \a inarray. The resulting global coefficients
873  * \f$\boldsymbol{\hat{u}}_g\f$ are stored in the array
874  * #m_contCoeffs or #m_coeffs depending on whether
875  * \a coeffstate is eGlobal or eLocal
876  *
877  * @param inarray An ExpList, containing the discrete evaluation
878  * of the forcing function \f$f(\boldsymbol{x})\f$
879  * at the quadrature points in its array #m_phys.
880  * @param factors The parameter \f$\lambda\f$ of the Helmholtz
881  * equation is specified through the factors map
882  */
884  const Array<OneD, const NekDouble> &inarray,
885  Array<OneD, NekDouble> &outarray,
886  const FlagList &flags,
887  const StdRegions::ConstFactorMap &factors,
888  const StdRegions::VarCoeffMap &varcoeff,
889  const MultiRegions::VarFactorsMap &varfactors,
890  const Array<OneD, const NekDouble> &dirForcing,
891  const bool PhysSpaceForcing)
892 
893  {
894  //----------------------------------
895  // Setup RHS Inner product
896  //----------------------------------
897  // Inner product of forcing
898  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
899  Array<OneD,NekDouble> wsp(contNcoeffs);
900  if(PhysSpaceForcing)
901  {
902  IProductWRTBase(inarray,wsp,eGlobal);
903  }
904  else
905  {
906  Assemble(inarray,wsp);
907  }
908  // Note -1.0 term necessary to invert forcing function to
909  // be consistent with matrix definition
910  Vmath::Neg(contNcoeffs, wsp, 1);
911 
912  // Fill weak boundary conditions
913  int i,j;
914  int bndcnt=0;
915  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
916 
917  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
918  {
919  if(m_bndConditions[i]->GetBoundaryConditionType() == SpatialDomains::eNeumann ||
920  m_bndConditions[i]->GetBoundaryConditionType() == SpatialDomains::eRobin)
921  {
922  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
923  {
924  gamma[m_locToGloMap
925  ->GetBndCondCoeffsToGlobalCoeffsMap(bndcnt++)]
926  += (m_bndCondExpansions[i]->GetCoeffs())[j];
927  }
928  }
929  else if (m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::ePeriodic)
930  {
931  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
932  }
933  }
934 
935  m_locToGloMap->UniversalAssemble(gamma);
936 
937  // Add weak boundary conditions to forcing
938  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
939 
940  GlobalLinSysKey key(StdRegions::eHelmholtz,m_locToGloMap,factors,varcoeff,varfactors);
941 
942  if(flags.isSet(eUseGlobal))
943  {
944  GlobalSolve(key,wsp,outarray,dirForcing);
945  }
946  else
947  {
948  Array<OneD,NekDouble> tmp(contNcoeffs);
949  LocalToGlobal(outarray,tmp);
950  GlobalSolve(key,wsp,tmp,dirForcing);
951  GlobalToLocal(tmp,outarray);
952  }
953  }
954 
955 
956  /**
957  * This is equivalent to the operation:
958  * \f[\boldsymbol{M\hat{u}}_g\f]
959  * where \f$\boldsymbol{M}\f$ is the global matrix of type specified by
960  * \a mkey. After scattering the global array \a inarray to local
961  * level, this operation is evaluated locally by the function
962  * ExpList#GeneralMatrixOp. The global result is then obtained by a
963  * global assembly procedure.
964  *
965  * @param mkey This key uniquely defines the type matrix
966  * required for the operation.
967  * @param inarray The vector \f$\boldsymbol{\hat{u}}_g\f$ of size
968  * \f$N_{\mathrm{dof}}\f$.
969  * @param outarray The resulting vector of size
970  * \f$N_{\mathrm{dof}}\f$.
971  */
973  const GlobalMatrixKey &gkey,
974  const Array<OneD,const NekDouble> &inarray,
975  Array<OneD, NekDouble> &outarray,
976  CoeffState coeffstate)
977  {
978  if(coeffstate == eGlobal)
979  {
980  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(
981  gkey.GetMatrixType());
982 
983  if(doGlobalOp)
984  {
986  mat->Multiply(inarray,outarray);
987  m_locToGloMap->UniversalAssemble(outarray);
988  }
989  else
990  {
992  Array<OneD,NekDouble> tmp2(tmp1+m_ncoeffs);
993  GlobalToLocal(inarray,tmp1);
994  GeneralMatrixOp_IterPerExp(gkey,tmp1,tmp2);
995  Assemble(tmp2,outarray);
996  }
997  }
998  else
999  {
1000  GeneralMatrixOp_IterPerExp(gkey,inarray,outarray);
1001  }
1002  }
1003 
1004  /**
1005  * First compute the inner product of forcing function with respect to
1006  * base, and then solve the system with the linear advection operator.
1007  * @param velocity Array of advection velocities in physical space
1008  * @param inarray Forcing function.
1009  * @param outarray Result.
1010  * @param lambda reaction coefficient
1011  * @param coeffstate State of Coefficients, Local or Global
1012  * @param dirForcing Dirichlet Forcing.
1013  */
1014 
1015  // could combine this with HelmholtzCG.
1017  const Array<OneD, const NekDouble> &inarray,
1018  Array<OneD, NekDouble> &outarray,
1019  const NekDouble lambda,
1020  CoeffState coeffstate,
1021  const Array<OneD, const NekDouble>& dirForcing)
1022  {
1023  // Inner product of forcing
1024  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
1025  Array<OneD,NekDouble> wsp(contNcoeffs);
1026  IProductWRTBase(inarray,wsp,eGlobal);
1027  // Note -1.0 term necessary to invert forcing function to
1028  // be consistent with matrix definition
1029  Vmath::Neg(contNcoeffs, wsp, 1);
1030 
1031  // Forcing function with weak boundary conditions
1032  int i,j;
1033  int bndcnt=0;
1034  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
1035  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
1036  {
1037  if(m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::eDirichlet)
1038  {
1039  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
1040  {
1041  gamma[m_locToGloMap
1042  ->GetBndCondCoeffsToGlobalCoeffsMap(bndcnt++)]
1043  += (m_bndCondExpansions[i]->GetCoeffs())[j];
1044  }
1045  }
1046  else
1047  {
1048  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
1049  }
1050  }
1051  m_locToGloMap->UniversalAssemble(gamma);
1052  // Add weak boundary conditions to forcing
1053  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
1054 
1055  // Solve the system
1057  factors[StdRegions::eFactorLambda] = lambda;
1058  StdRegions::VarCoeffMap varcoeffs;
1059  varcoeffs[StdRegions::eVarCoeffVelX] = velocity[0];
1060  varcoeffs[StdRegions::eVarCoeffVelY] = velocity[1];
1062 
1063  if(coeffstate == eGlobal)
1064  {
1065  GlobalSolve(key,wsp,outarray,dirForcing);
1066  }
1067  else
1068  {
1069  Array<OneD,NekDouble> tmp(contNcoeffs,0.0);
1070  GlobalSolve(key,wsp,tmp,dirForcing);
1071  GlobalToLocal(tmp,outarray);
1072  }
1073  }
1074 
1075  /**
1076  * First compute the inner product of forcing function with respect to
1077  * base, and then solve the system with the linear advection operator.
1078  * @param velocity Array of advection velocities in physical space
1079  * @param inarray Forcing function.
1080  * @param outarray Result.
1081  * @param lambda reaction coefficient
1082  * @param coeffstate State of Coefficients, Local or Global
1083  * @param dirForcing Dirichlet Forcing.
1084  */
1086  const Array<OneD, Array<OneD, NekDouble> > &velocity,
1087  const Array<OneD, const NekDouble> &inarray,
1088  Array<OneD, NekDouble> &outarray,
1089  const NekDouble lambda,
1090  CoeffState coeffstate,
1091  const Array<OneD, const NekDouble>& dirForcing)
1092  {
1093  // Inner product of forcing
1094  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
1095  Array<OneD,NekDouble> wsp(contNcoeffs);
1096  IProductWRTBase(inarray,wsp,eGlobal);
1097 
1098  // Solve the system
1100  factors[StdRegions::eFactorLambda] = lambda;
1101  StdRegions::VarCoeffMap varcoeffs;
1102  varcoeffs[StdRegions::eVarCoeffVelX] = velocity[0];
1103  varcoeffs[StdRegions::eVarCoeffVelY] = velocity[1];
1105 
1106  if(coeffstate == eGlobal)
1107  {
1108  GlobalSolve(key,wsp,outarray,dirForcing);
1109  }
1110  else
1111  {
1112  Array<OneD,NekDouble> tmp(contNcoeffs,0.0);
1113  GlobalSolve(key,wsp,tmp,dirForcing);
1114  GlobalToLocal(tmp,outarray);
1115  }
1116  }
1117 
1118 
1119  /**
1120  *
1121  */
1124  {
1125  return GetBndConditions();
1126  }
1127 
1128 
1129  /**
1130  * Reset the GlobalLinSys Manager
1131  */
1133  {
1134  m_globalLinSysManager.ClearManager("GlobalLinSys");
1135  }
1136 
1137  } // end of namespace
1138 } //end of namespace
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
Template method virtual forwarder for FwdTrans().
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
void LaplaceSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray, const Array< OneD, Array< OneD, NekDouble > > &variablecoeffs=NullNekDoubleArrayofArray, NekDouble time=0.0, CoeffState coeffstate=eLocal)
Solves the two-dimensional Laplace equation, subject to the boundary conditions specified.
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
AssemblyMapCGSharedPtr m_locToGloMap
(A shared pointer to) the object which contains all the required information for the transformation f...
Definition: ContField2D.h:166
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Performs the global forward transformation of a function , subject to the boundary conditions specifi...
#define sign(a, b)
return the sign(b)*a
Definition: Polylib.cpp:16
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1106
void v_LinearAdvectionReactionSolve(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)
const Array< OneD, const SpatialDomains::BoundaryConditionShPtr > & GetBndConditions()
Returns the boundary conditions.
Definition: ContField2D.h:460
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray)
Impose the Dirichlet Boundary Conditions on outarray.
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
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
void BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Performs the backward transformation of the spectral/hp element expansion.
Definition: ContField2D.h:424
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
STL namespace.
PeriodicMap m_periodicEdges
A map which identifies pairs of periodic edges.
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:294
PeriodicMap m_periodicVerts
A map which identifies groups of periodic vertices.
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:1052
LibUtilities::NekManager< GlobalLinSysKey, GlobalLinSys > m_globalLinSysManager
A manager which collects all the global linear systems being assembled, such that they should be cons...
Definition: ContField2D.h:176
Global coefficients.
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool useComm)
Gathers the global coefficients from the local coefficients .
bool SameTypeOfBoundaryConditions(const DisContField2D &In)
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
Definition: ContField2D.h:55
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
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.
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
Template method virtual forwarder for FwdTrans().
virtual void v_SmoothField(Array< OneD, NekDouble > &field)
Template method virtual forwarded for SmoothField().
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:1030
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: ContField2D.h:171
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void GlobalSolve(const GlobalLinSysKey &key, const Array< OneD, const NekDouble > &rhs, Array< OneD, NekDouble > &inout, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
Solves the linear system specified by the key key.
GlobalMatrixSharedPtr GetGlobalMatrix(const GlobalMatrixKey &mkey)
Returns the global matrix specified by mkey.
virtual ~ContField2D()
The default destructor.
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...
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:1023
ContField2D()
The default constructor.
Definition: ContField2D.cpp:87
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
virtual void v_GlobalToLocal(void)
void Assemble()
Assembles the global coefficients from the local coefficients .
Definition: ContField2D.h:316
double NekDouble
Defines a list of flags.
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
virtual const Array< OneD, const SpatialDomains ::BoundaryConditionShPtr > & v_GetBndConditions()
Template method virtual forwarder for GetBndConditions().
Describe a linear system.
void 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 ...
Definition: ContField2D.h:378
Describes a matrix with ordering defined by a local to global map.
virtual void v_MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate)
Template method virtual forwarder for MultiplyByInvMassMatrix().
void MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Multiply a solution by the inverse mass matrix.
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
std::shared_ptr< DNekMat > GenGlobalMatrixFull(const GlobalLinSysKey &mkey, const std::shared_ptr< AssemblyMapCG > &locToGloMap)
Definition: ExpList.cpp:1222
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
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 two-dimensional Helmholtz equation, subject to the boundary conditions specified...
GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey)
Returns the linear system specified by the key mkey.
void LinearAdvectionEigs(const NekDouble ax, const NekDouble ay, Array< OneD, NekDouble > &Real, Array< OneD, NekDouble > &Imag, Array< OneD, NekDouble > &Evecs=NullNekDouble1DArray)
Compute the eigenvalues of the linear advection operator.
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
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
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::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap