Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Field definition for 3D domain with boundary conditions
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
38 
40 
41 using namespace std;
42 
43 namespace Nektar
44 {
45  namespace MultiRegions
46  {
47 
48  ContField3D::ContField3D():
50  m_locToGloMap(),
51  m_globalMat(),
52  m_globalLinSysManager(
53  boost::bind(&ContField3D::GenGlobalLinSys, this, _1),
54  std::string("GlobalLinSys"))
55  {
56  }
57 
58 
59  /**
60  * Given a mesh \a graph2D, containing information about the domain and
61  * the spectral/hp element expansion, this constructor fills the list
62  * of local expansions #m_exp with the proper expansions, calculates
63  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
64  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
65  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
66  * mapping array (contained in #m_locToGloMap) for the transformation
67  * between local elemental level and global level, it calculates the
68  * total number global expansion coefficients \f$\hat{u}_n\f$ and
69  * allocates memory for the array #m_coeffs. The constructor also
70  * discretises the boundary conditions, specified by the argument \a
71  * bcs, by expressing them in terms of the coefficient of the expansion
72  * on the boundary.
73  *
74  * @param pSession Session information.
75  * @param graph3D A mesh, containing information about the domain
76  * and the spectral/hp element expansion.
77  * @param variable The variable associated with this field.
78  */
81  const std::string &variable,
82  const bool CheckIfSingularSystem):
83  DisContField3D(pSession,graph3D,variable,false),
84  m_globalMat(MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
85  m_globalLinSysManager(
86  boost::bind(&ContField3D::GenGlobalLinSys, this, _1),
87  std::string("GlobalLinSys"))
88  {
91  CheckIfSingularSystem, variable,
93 
94  if (m_session->DefinesCmdLineArgument("verbose"))
95  {
96  m_locToGloMap->PrintStats(std::cout, variable);
97  }
98  }
99 
100 
101  /**
102  * Given a mesh \a graph3D, containing information about the domain and
103  * the spectral/hp element expansion, this constructor fills the list
104  * of local expansions #m_exp with the proper expansions, calculates
105  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
106  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
107  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
108  * mapping array (contained in #m_locToGloMap) for the transformation
109  * between local elemental level and global level, it calculates the
110  * total number global expansion coefficients \f$\hat{u}_n\f$ and
111  * allocates memory for the array #m_coeffs. The constructor also
112  * discretises the boundary conditions, specified by the argument \a
113  * bcs, by expressing them in terms of the coefficient of the expansion
114  * on the boundary.
115  *
116  * @param In Existing ContField2D object used to provide the
117  * local to global mapping information and
118  * global solution type.
119  * @param graph3D A mesh, containing information about the domain
120  * and the spectral/hp element expansion.
121  * @param bcs The boundary conditions.
122  * @param bc_loc
123  */
125  const SpatialDomains::MeshGraphSharedPtr &graph3D,
126  const std::string &variable,
127  const bool CheckIfSingularSystem):
128  DisContField3D(In,graph3D,variable,false),
129  m_globalMat (MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
130  m_globalLinSysManager(boost::bind(&ContField3D::GenGlobalLinSys, this, _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),
156  m_locToGloMap(In.m_locToGloMap),
157  m_globalMat(In.m_globalMat),
158  m_globalLinSysManager(In.m_globalLinSysManager)
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,
365  const Array<OneD, const NekDouble> &rhs,
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  GlobalMatrixMap::iterator 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  map<int, vector<ExtraDirDof> >::iterator it;
451  for (it = extraDirDofs.begin(); it != extraDirDofs.end(); ++it)
452  {
453  for (i = 0; i < it->second.size(); ++i)
454  {
455  tmp[it->second.at(i).get<1>()] =
456  m_bndCondExpansions[it->first]->GetCoeffs()[
457  it->second.at(i).get<0>()]*it->second.at(i).get<2>();
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
486  {
487  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
488  }
489  }
490 
491  Vmath::Vcopy(nDir, tmp, 1, outarray, 1);
492  }
493 
495  {
496  NekDouble sign;
497  int bndcnt = 0;
498  const Array<OneD,const int> &bndMap =
499  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
500 
501  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
502  LocalToGlobal(m_coeffs,tmp,false);
503 
504  // Now fill in all other Dirichlet coefficients.
505  for(int i = 0; i < m_bndCondExpansions.num_elements(); ++i)
506  {
507  Array<OneD, NekDouble>& coeffs = m_bndCondExpansions[i]->UpdateCoeffs();
508 
509  for(int j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
510  {
511  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
512  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
513  }
514  }
515  }
516 
518  {
519  NekDouble sign;
520  int bndcnt = 0;
521  const Array<OneD,const int> &bndMap =
522  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
523 
524  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
525  LocalToGlobal(m_coeffs,tmp,false);
526 
527  ASSERTL1(nreg < m_bndCondExpansions.num_elements(),
528  "nreg is out or range since this many boundary "
529  "regions to not exist");
530 
531  // Now fill in all other Dirichlet coefficients.
532  Array<OneD, NekDouble>& coeffs = m_bndCondExpansions[nreg]->UpdateCoeffs();
533 
534  for(int j = 0; j < nreg; ++j)
535  {
536  bndcnt += m_bndCondExpansions[j]->GetNcoeffs();
537  }
538 
539  for(int j = 0; j < (m_bndCondExpansions[nreg])->GetNcoeffs(); ++j)
540  {
541  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
542  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
543  }
544  }
545 
546 
547  void ContField3D::v_LocalToGlobal(bool useComm)
548  {
549  m_locToGloMap->LocalToGlobal(m_coeffs, m_coeffs,useComm);
550  }
551 
552 
554  const Array<OneD, const NekDouble> &inarray,
555  Array<OneD,NekDouble> &outarray,
556  bool useComm)
557  {
558  m_locToGloMap->LocalToGlobal(inarray, outarray, useComm);
559  }
560 
561 
563  {
564  m_locToGloMap->GlobalToLocal(m_coeffs, m_coeffs);
565  }
566 
567 
569  const Array<OneD, const NekDouble> &inarray,
570  Array<OneD,NekDouble> &outarray)
571  {
572  m_locToGloMap->GlobalToLocal(inarray, outarray);
573  }
574 
575 
577  const Array<OneD, const NekDouble> &inarray,
578  Array<OneD, NekDouble> &outarray,
579  const FlagList &flags,
580  const StdRegions::ConstFactorMap &factors,
581  const StdRegions::VarCoeffMap &varcoeff,
582  const Array<OneD, const NekDouble> &dirForcing,
583  const bool PhysSpaceForcing)
584  {
585  // Inner product of forcing
586  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
587  Array<OneD,NekDouble> wsp(contNcoeffs);
588  if(PhysSpaceForcing)
589  {
590  IProductWRTBase(inarray,wsp,eGlobal);
591  }
592  else
593  {
594  Assemble(inarray,wsp);
595  }
596 
597  // Note -1.0 term necessary to invert forcing function to
598  // be consistent with matrix definition
599  Vmath::Neg(contNcoeffs, wsp, 1);
600 
601  // Forcing function with weak boundary conditions
602  int i,j;
603  int bndcnt = 0;
604  NekDouble sign;
605  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
606  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
607  {
608  if(m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::eDirichlet)
609  {
610  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
611  {
612  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
613  gamma[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(bndcnt++)] +=
614  sign * (m_bndCondExpansions[i]->GetCoeffs())[j];
615  }
616  }
617  else
618  {
619  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
620  }
621  }
622  m_locToGloMap->UniversalAssemble(gamma);
623 
624  // Add weak boundary conditions to forcing
625  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
626 
627  // Solve the system
628  GlobalLinSysKey key(StdRegions::eHelmholtz, m_locToGloMap, factors,varcoeff);
629 
630  if(flags.isSet(eUseGlobal))
631  {
632  GlobalSolve(key,wsp,outarray,dirForcing);
633  }
634  else
635  {
636  Array<OneD,NekDouble> tmp(contNcoeffs);
637  LocalToGlobal(outarray,tmp);
638  GlobalSolve(key,wsp,tmp,dirForcing);
639  GlobalToLocal(tmp,outarray);
640  }
641  }
642 
644  const GlobalMatrixKey &gkey,
645  const Array<OneD,const NekDouble> &inarray,
646  Array<OneD, NekDouble> &outarray,
647  CoeffState coeffstate)
648  {
649  if(coeffstate == eGlobal)
650  {
651  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(gkey.GetMatrixType());
652 
653  if(doGlobalOp)
654  {
656  mat->Multiply(inarray,outarray);
657  m_locToGloMap->UniversalAssemble(outarray);
658  }
659  else
660  {
662  Array<OneD,NekDouble> tmp2(tmp1+m_ncoeffs);
663  GlobalToLocal(inarray,tmp1);
664  GeneralMatrixOp_IterPerExp(gkey,tmp1,tmp2);
665  Assemble(tmp2,outarray);
666  }
667  }
668  else
669  {
670  GeneralMatrixOp_IterPerExp(gkey,inarray,outarray);
671  }
672  }
673 
674  /**
675  * First compute the inner product of forcing function with respect to
676  * base, and then solve the system with the linear advection operator.
677  * @param velocity Array of advection velocities in physical space
678  * @param inarray Forcing function.
679  * @param outarray Result.
680  * @param lambda reaction coefficient
681  * @param coeffstate State of Coefficients, Local or Global
682  * @param dirForcing Dirichlet Forcing.
683  */
684  // could combine this with HelmholtzCG.
686  const Array<OneD, Array<OneD, NekDouble> > &velocity,
687  const Array<OneD, const NekDouble> &inarray,
688  Array<OneD, NekDouble> &outarray,
689  const NekDouble lambda,
690  CoeffState coeffstate,
691  const Array<OneD, const NekDouble> &dirForcing)
692  {
693  // Inner product of forcing
694  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
695  Array<OneD, NekDouble> wsp(contNcoeffs);
696  IProductWRTBase(inarray, wsp, eGlobal);
697  // Note -1.0 term necessary to invert forcing function to
698  // be consistent with matrix definition
699  Vmath::Neg(contNcoeffs, wsp, 1);
700 
701  // Forcing function with weak boundary conditions
702  int i, j;
703  int bndcnt = 0;
704  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
705  for (i = 0; i < m_bndCondExpansions.num_elements(); ++i)
706  {
707  if (m_bndConditions[i]->GetBoundaryConditionType() !=
709  {
710  for (j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
711  {
712  gamma[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(
713  bndcnt++)] += (m_bndCondExpansions[i]->GetCoeffs())[j];
714  }
715  }
716  else
717  {
718  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
719  }
720  }
721  m_locToGloMap->UniversalAssemble(gamma);
722  // Add weak boundary conditions to forcing
723  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
724 
725  // Solve the system
727  factors[StdRegions::eFactorLambda] = lambda;
728  StdRegions::VarCoeffMap varcoeffs;
729  varcoeffs[StdRegions::eVarCoeffVelX] = velocity[0];
730  varcoeffs[StdRegions::eVarCoeffVelY] = velocity[1];
731  varcoeffs[StdRegions::eVarCoeffVelZ] = velocity[2];
734  factors,
735  varcoeffs);
736 
737  if (coeffstate == eGlobal)
738  {
739  GlobalSolve(key, wsp, outarray, dirForcing);
740  }
741  else
742  {
743  Array<OneD, NekDouble> tmp(contNcoeffs, 0.0);
744  GlobalSolve(key, wsp, tmp, dirForcing);
745  GlobalToLocal(tmp, outarray);
746  }
747  }
748 
749 
751  {
753  "To use method must have a AssemblyMap "
754  "attached to key");
755 
756  GlobalMatrixMap::iterator matrixIter = m_globalMat->find(gkey);
757 
758  if(matrixIter == m_globalMat->end())
759  {
760  return 0;
761  }
762  else
763  {
764  return matrixIter->second->GetNumNonZeroEntries();
765  }
766 
767  return 0;
768  }
769 
770 
771  /**
772  *
773  */
775  {
776  m_globalLinSysManager.ClearManager("GlobalLinSys");
777  }
778 
779  } //end of namespace
780 } //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)
boost::shared_ptr< GlobalMatrix > GenGlobalMatrix(const GlobalMatrixKey &mkey, const boost::shared_ptr< AssemblyMapCG > &locToGloMap)
Generates a global matrix from the given key and map.
Definition: ExpList.cpp:973
void LocalToGlobal(bool useComm=true)
Gathers the global coefficients from the local coefficients .
Definition: ExpList.h:1967
void GeneralMatrixOp_IterPerExp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: ExpList.cpp:905
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.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
#define sign(a, b)
return the sign(b)*a
Definition: Polylib.cpp:27
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam
Definition: ExpList.h:1060
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:91
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 ...
STL namespace.
PeriodicMap m_periodicFaces
A map which identifies pairs of periodic faces.
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:252
virtual void v_GlobalToLocal(void)
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:998
boost::shared_ptr< GlobalMatrix > GlobalMatrixSharedPtr
Shared pointer to a GlobalMatrix object.
Definition: GlobalMatrix.h:89
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray)
Impose the Dirichlet Boundary Conditions on outarray.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
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:2287
bool isSet(const FlagType &key) const
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:1710
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:227
boost::shared_ptr< GlobalLinSys > GenGlobalLinSys(const GlobalLinSysKey &mkey, const boost::shared_ptr< AssemblyMapCG > &locToGloMap)
This operation constructs the global linear system of type mkey.
Definition: ExpList.cpp:1251
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:1660
int m_ncoeffs
The total number of local degrees of freedom. m_ncoeffs .
Definition: ExpList.h:976
LibUtilities::SessionReaderSharedPtr m_session
Session.
Definition: ExpList.h:969
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:396
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.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
Describes a matrix with ordering defined by a local to global map.
AssemblyMapCGSharedPtr m_locToGloMap
Definition: ContField3D.h:102
GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey)
void GenerateDirBndCondForcing(const GlobalLinSysKey &key, Array< OneD, NekDouble > &inout, Array< OneD, NekDouble > &outarray)
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
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.
bool LocToGloMapIsDefined() const
Returns true if a local to global map is defined.
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:107
void IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Definition: ExpList.h:1649
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition on the different boundary region...
int GetNcoeffs(void) const
Returns the total number of local degrees of freedom .
Definition: ExpList.h:1493
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:112
virtual void v_LocalToGlobal(bool useComm)
boost::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:52
virtual void v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const FlagList &flags, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing)
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:228
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:442
void GlobalToLocal(void)
Scatters from the global coefficients to the local coefficients .
Definition: ExpList.h:1980
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
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:299
PeriodicMap m_periodicEdges
A map which identifies groups of periodic edges.