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  const Collections::ImplementationType ImpType):
84  DisContField3D(pSession,graph3D,variable,false,ImpType),
85  m_globalMat(MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
86  m_globalLinSysManager(
87  boost::bind(&ContField3D::GenGlobalLinSys, this, _1),
88  std::string("GlobalLinSys"))
89  {
92  CheckIfSingularSystem, variable,
94 
95  if (m_session->DefinesCmdLineArgument("verbose"))
96  {
97  m_locToGloMap->PrintStats(std::cout, variable);
98  }
99  }
100 
101 
102  /**
103  * Given a mesh \a graph3D, containing information about the domain and
104  * the spectral/hp element expansion, this constructor fills the list
105  * of local expansions #m_exp with the proper expansions, calculates
106  * the total number of quadrature points \f$\boldsymbol{x}_i\f$ and
107  * local expansion coefficients \f$\hat{u}^e_n\f$ and allocates memory
108  * for the arrays #m_coeffs and #m_phys. Furthermore, it constructs the
109  * mapping array (contained in #m_locToGloMap) for the transformation
110  * between local elemental level and global level, it calculates the
111  * total number global expansion coefficients \f$\hat{u}_n\f$ and
112  * allocates memory for the array #m_coeffs. The constructor also
113  * discretises the boundary conditions, specified by the argument \a
114  * bcs, by expressing them in terms of the coefficient of the expansion
115  * on the boundary.
116  *
117  * @param In Existing ContField2D object used to provide the
118  * local to global mapping information and
119  * global solution type.
120  * @param graph3D A mesh, containing information about the domain
121  * and the spectral/hp element expansion.
122  * @param bcs The boundary conditions.
123  * @param bc_loc
124  */
126  const SpatialDomains::MeshGraphSharedPtr &graph3D,
127  const std::string &variable,
128  const bool CheckIfSingularSystem):
129  DisContField3D(In,graph3D,variable,false),
130  m_globalMat (MemoryManager<GlobalMatrixMap>::AllocateSharedPtr()),
131  m_globalLinSysManager(boost::bind(&ContField3D::GenGlobalLinSys, this, _1),
132  std::string("GlobalLinSys"))
133 
134  {
135  if(!SameTypeOfBoundaryConditions(In) || CheckIfSingularSystem)
136  {
140  CheckIfSingularSystem, variable,
142 
143  if (m_session->DefinesCmdLineArgument("verbose"))
144  {
145  m_locToGloMap->PrintStats(std::cout, variable);
146  }
147  }
148  else
149  {
151  }
152  }
153 
154 
156  DisContField3D(In),
157  m_locToGloMap(In.m_locToGloMap),
158  m_globalMat(In.m_globalMat),
159  m_globalLinSysManager(In.m_globalLinSysManager)
160  {
161  }
162 
163 
165  {
166  }
167 
168 
169  /**
170  * Given the coefficients of an expansion, this function evaluates the
171  * spectral/hp expansion \f$u^{\delta}(\boldsymbol{x})\f$ at the
172  * quadrature points \f$\boldsymbol{x}_i\f$. This operation is
173  * evaluated locally by the function ExpList#BwdTrans.
174  *
175  * The coefficients of the expansion should be contained in the variable
176  * #inarray of the ExpList object \a In. The resulting physical values
177  * at the quadrature points \f$u^{\delta}(\boldsymbol{x}_i)\f$ are
178  * stored in the array #outarray.
179  *
180  * @param In An ExpList, containing the local coefficients
181  * \f$\hat{u}_n^e\f$ in its array #m_coeffs.
182  */
184  const Array<OneD, const NekDouble> &inarray,
185  Array<OneD, NekDouble> &outarray,
186  CoeffState coeffstate)
187  {
188  if(coeffstate == eGlobal)
189  {
190  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(
192 
193  if(doGlobalOp)
194  {
197  mat->Multiply(inarray,outarray);
198  }
199  else
200  {
202  GlobalToLocal(inarray,wsp);
203  BwdTrans_IterPerExp(wsp,outarray);
204  }
205  }
206  else
207  {
208  BwdTrans_IterPerExp(inarray,outarray);
209  }
210  }
211 
212 
213  /**
214  * The operation is evaluated locally (i.e. with respect to all local
215  * expansion modes) by the function ExpList#IProductWRTBase. The inner
216  * product with respect to the global expansion modes is than obtained
217  * by a global assembly operation.
218  *
219  * The values of the function \f$f(\boldsymbol{x})\f$ evaluated at the
220  * quadrature points \f$\boldsymbol{x}_i\f$ should be contained in the
221  * variable #m_phys of the ExpList object \a in. The result is stored
222  * in the array #m_coeffs.
223  *
224  * @param In An ExpList, containing the discrete evaluation
225  * of \f$f(\boldsymbol{x})\f$ at the quadrature
226  * points in its array #m_phys.
227  */
229  Array<OneD, NekDouble> &outarray,
230  CoeffState coeffstate)
231  {
232  if(coeffstate == eGlobal)
233  {
234  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(
236 
237  if(doGlobalOp)
238  {
240  m_locToGloMap);
242  mat->Multiply(inarray,outarray);
243  m_locToGloMap->UniversalAssemble(outarray);
244  }
245  else
246  {
248  IProductWRTBase_IterPerExp(inarray,wsp);
249  Assemble(wsp,outarray);
250  }
251  }
252  else
253  {
254  IProductWRTBase_IterPerExp(inarray,outarray);
255  }
256  }
257 
258 
260  Array<OneD, NekDouble> &outarray,
261  CoeffState coeffstate)
262  {
263  // Inner product of forcing
264  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
265  Array<OneD,NekDouble> wsp(contNcoeffs);
266  IProductWRTBase(inarray,wsp,eGlobal);
267 
268  // Solve the system
270 
271  if(coeffstate == eGlobal)
272  {
273  GlobalSolve(key,wsp,outarray);
274  }
275  else
276  {
277  Array<OneD,NekDouble> tmp(contNcoeffs,0.0);
278  GlobalSolve(key,wsp,tmp);
279  GlobalToLocal(tmp,outarray);
280  }
281  }
282 
283 
285  const Array<OneD, const NekDouble> &inarray,
286  Array<OneD, NekDouble> &outarray,
287  CoeffState coeffstate)
288 
289  {
290  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
292 
293  if(coeffstate == eGlobal)
294  {
295  if(inarray.data() == outarray.data())
296  {
297  Array<OneD, NekDouble> tmp(contNcoeffs,0.0);
298  Vmath::Vcopy(contNcoeffs,inarray,1,tmp,1);
299  GlobalSolve(key,tmp,outarray);
300  }
301  else
302  {
303  GlobalSolve(key,inarray,outarray);
304  }
305  }
306  else
307  {
308  Array<OneD, NekDouble> globaltmp(contNcoeffs,0.0);
309 
310  if(inarray.data() == outarray.data())
311  {
312  Array<OneD,NekDouble> tmp(inarray.num_elements());
313  Vmath::Vcopy(inarray.num_elements(),inarray,1,tmp,1);
314  Assemble(tmp,outarray);
315  }
316  else
317  {
318  Assemble(inarray,outarray);
319  }
320 
321  GlobalSolve(key,outarray,globaltmp);
322  GlobalToLocal(globaltmp,outarray);
323  }
324  }
325 
326 
328  Array<OneD, NekDouble> &inout,
329  Array<OneD, NekDouble> &outarray)
330  {
331  int bndcnt=0;
332  const Array<OneD,const int>& map = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
333  NekDouble sign;
334 
335  for(int i = 0; i < m_bndCondExpansions.num_elements(); ++i)
336  {
337  if(m_bndConditions[i]->GetBoundaryConditionType() == SpatialDomains::eDirichlet)
338  {
339  const Array<OneD,const NekDouble>& coeffs = m_bndCondExpansions[i]->GetCoeffs();
340  for(int j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
341  {
342  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
343  if(sign)
344  {
345  inout[map[bndcnt++]] = sign * coeffs[j];
346  }
347  else
348  {
349  bndcnt++;
350  }
351  }
352  }
353  else
354  {
355  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
356  }
357  }
358  GeneralMatrixOp(key,inout,outarray,eGlobal);
359  }
360 
361 
362 
363  // Note inout contains initial guess and final output.
365  const GlobalLinSysKey &key,
366  const Array<OneD, const NekDouble> &rhs,
367  Array<OneD, NekDouble> &inout,
368  const Array<OneD, const NekDouble> &dirForcing)
369  {
370  int NumDirBcs = m_locToGloMap->GetNumGlobalDirBndCoeffs();
371  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
372 
373  // STEP 1: SET THE DIRICHLET DOFS TO THE RIGHT VALUE
374  // IN THE SOLUTION ARRAY
376 
377 
378  // STEP 2: CALCULATE THE HOMOGENEOUS COEFFICIENTS
379  if(contNcoeffs - NumDirBcs > 0)
380  {
382  LinSys->Solve(rhs,inout,m_locToGloMap,dirForcing);
383  }
384  }
385 
387  {
388  return m_globalLinSysManager[mkey];
389  }
390 
391 
393  {
395  "To use method must have a AssemblyMap "
396  "attached to key");
398  }
399 
400 
401  /**
402  * Returns the global matrix associated with the given GlobalMatrixKey.
403  * If the global matrix has not yet been constructed on this field,
404  * it is first constructed using GenGlobalMatrix().
405  * @param mkey Global matrix key.
406  * @returns Assocated global matrix.
407  */
409  {
411  "To use method must have a AssemblyMap "
412  "attached to key");
413 
414  GlobalMatrixSharedPtr glo_matrix;
415  GlobalMatrixMap::iterator matrixIter = m_globalMat->find(mkey);
416 
417  if(matrixIter == m_globalMat->end())
418  {
419  glo_matrix = GenGlobalMatrix(mkey,m_locToGloMap);
420  (*m_globalMat)[mkey] = glo_matrix;
421  }
422  else
423  {
424  glo_matrix = matrixIter->second;
425  }
426 
427  return glo_matrix;
428  }
429 
430 
432  {
433  int i,j;
434  int bndcnt = 0;
435  int nDir = m_locToGloMap->GetNumGlobalDirBndCoeffs();
436 
437  NekDouble sign;
438  const Array<OneD,const int> &bndMap =
439  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
440 
442  m_locToGloMap->GetNumGlobalBndCoeffs(), 0.0);
443 
444  // Fill in Dirichlet coefficients that are to be sent to other
445  // processors. This code block uses a tuple<int,int.NekDouble> which
446  // stores the local id of coefficent the global id of the data
447  // location and the inverse of the values of the data (arising from
448  // periodic boundary conditiosn)
449  map<int, vector<ExtraDirDof> > &extraDirDofs =
450  m_locToGloMap->GetExtraDirDofs();
451  map<int, vector<ExtraDirDof> >::iterator it;
452  for (it = extraDirDofs.begin(); it != extraDirDofs.end(); ++it)
453  {
454  for (i = 0; i < it->second.size(); ++i)
455  {
456  tmp[it->second.at(i).get<1>()] =
457  m_bndCondExpansions[it->first]->GetCoeffs()[
458  it->second.at(i).get<0>()]*it->second.at(i).get<2>();
459  }
460  }
461 
462  m_locToGloMap->UniversalAssembleBnd(tmp);
463 
464  // Now fill in all other Dirichlet coefficients.
465  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
466  {
467  if(m_bndConditions[i]->GetBoundaryConditionType() ==
469  {
470  const Array<OneD,const NekDouble>& coeffs =
471  m_bndCondExpansions[i]->GetCoeffs();
472  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
473  {
474  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(
475  bndcnt);
476  if (sign)
477  {
478  tmp[bndMap[bndcnt++]] = sign * coeffs[j];
479  }
480  else
481  {
482  bndcnt++;
483  }
484  }
485  }
486  else
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 = m_bndCondExpansions[i]->UpdateCoeffs();
509 
510  for(int j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); ++j)
511  {
512  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
513  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
514  }
515  }
516  }
517 
519  {
520  NekDouble sign;
521  int bndcnt = 0;
522  const Array<OneD,const int> &bndMap =
523  m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap();
524 
525  Array<OneD, NekDouble> tmp(m_locToGloMap->GetNumGlobalCoeffs());
526  LocalToGlobal(m_coeffs,tmp,false);
527 
528  ASSERTL1(nreg < m_bndCondExpansions.num_elements(),
529  "nreg is out or range since this many boundary "
530  "regions to not exist");
531 
532  // Now fill in all other Dirichlet coefficients.
533  Array<OneD, NekDouble>& coeffs = m_bndCondExpansions[nreg]->UpdateCoeffs();
534 
535  for(int j = 0; j < nreg; ++j)
536  {
537  bndcnt += m_bndCondExpansions[j]->GetNcoeffs();
538  }
539 
540  for(int j = 0; j < (m_bndCondExpansions[nreg])->GetNcoeffs(); ++j)
541  {
542  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
543  coeffs[j] = sign * tmp[bndMap[bndcnt++]];
544  }
545  }
546 
547 
548  void ContField3D::v_LocalToGlobal(bool useComm)
549  {
550  m_locToGloMap->LocalToGlobal(m_coeffs, m_coeffs,useComm);
551  }
552 
553 
555  const Array<OneD, const NekDouble> &inarray,
556  Array<OneD,NekDouble> &outarray,
557  bool useComm)
558  {
559  m_locToGloMap->LocalToGlobal(inarray, outarray, useComm);
560  }
561 
562 
564  {
565  m_locToGloMap->GlobalToLocal(m_coeffs, m_coeffs);
566  }
567 
568 
570  const Array<OneD, const NekDouble> &inarray,
571  Array<OneD,NekDouble> &outarray)
572  {
573  m_locToGloMap->GlobalToLocal(inarray, outarray);
574  }
575 
576 
578  const Array<OneD, const NekDouble> &inarray,
579  Array<OneD, NekDouble> &outarray,
580  const FlagList &flags,
581  const StdRegions::ConstFactorMap &factors,
582  const StdRegions::VarCoeffMap &varcoeff,
583  const Array<OneD, const NekDouble> &dirForcing,
584  const bool PhysSpaceForcing)
585  {
586  // Inner product of forcing
587  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
588  Array<OneD,NekDouble> wsp(contNcoeffs);
589  if(PhysSpaceForcing)
590  {
591  IProductWRTBase(inarray,wsp,eGlobal);
592  }
593  else
594  {
595  Assemble(inarray,wsp);
596  }
597 
598  // Note -1.0 term necessary to invert forcing function to
599  // be consistent with matrix definition
600  Vmath::Neg(contNcoeffs, wsp, 1);
601 
602  // Forcing function with weak boundary conditions
603  int i,j;
604  int bndcnt = 0;
605  NekDouble sign;
606  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
607  for(i = 0; i < m_bndCondExpansions.num_elements(); ++i)
608  {
609  if(m_bndConditions[i]->GetBoundaryConditionType() != SpatialDomains::eDirichlet)
610  {
611  for(j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
612  {
613  sign = m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
614  gamma[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(bndcnt++)] +=
615  sign * (m_bndCondExpansions[i]->GetCoeffs())[j];
616  }
617  }
618  else
619  {
620  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
621  }
622  }
623  m_locToGloMap->UniversalAssemble(gamma);
624 
625  // Add weak boundary conditions to forcing
626  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
627 
628  // Solve the system
629  GlobalLinSysKey key(StdRegions::eHelmholtz, m_locToGloMap, factors,varcoeff);
630 
631  if(flags.isSet(eUseGlobal))
632  {
633  GlobalSolve(key,wsp,outarray,dirForcing);
634  }
635  else
636  {
637  Array<OneD,NekDouble> tmp(contNcoeffs);
638  LocalToGlobal(outarray,tmp);
639  GlobalSolve(key,wsp,tmp,dirForcing);
640  GlobalToLocal(tmp,outarray);
641  }
642  }
643 
645  const GlobalMatrixKey &gkey,
646  const Array<OneD,const NekDouble> &inarray,
647  Array<OneD, NekDouble> &outarray,
648  CoeffState coeffstate)
649  {
650  if(coeffstate == eGlobal)
651  {
652  bool doGlobalOp = m_globalOptParam->DoGlobalMatOp(gkey.GetMatrixType());
653 
654  if(doGlobalOp)
655  {
657  mat->Multiply(inarray,outarray);
658  m_locToGloMap->UniversalAssemble(outarray);
659  }
660  else
661  {
663  Array<OneD,NekDouble> tmp2(tmp1+m_ncoeffs);
664  GlobalToLocal(inarray,tmp1);
665  GeneralMatrixOp_IterPerExp(gkey,tmp1,tmp2);
666  Assemble(tmp2,outarray);
667  }
668  }
669  else
670  {
671  GeneralMatrixOp_IterPerExp(gkey,inarray,outarray);
672  }
673  }
674 
675  /**
676  * First compute the inner product of forcing function with respect to
677  * base, and then solve the system with the linear advection operator.
678  * @param velocity Array of advection velocities in physical space
679  * @param inarray Forcing function.
680  * @param outarray Result.
681  * @param lambda reaction coefficient
682  * @param coeffstate State of Coefficients, Local or Global
683  * @param dirForcing Dirichlet Forcing.
684  */
685  // could combine this with HelmholtzCG.
687  const Array<OneD, Array<OneD, NekDouble> > &velocity,
688  const Array<OneD, const NekDouble> &inarray,
689  Array<OneD, NekDouble> &outarray,
690  const NekDouble lambda,
691  CoeffState coeffstate,
692  const Array<OneD, const NekDouble> &dirForcing)
693  {
694  // Inner product of forcing
695  int contNcoeffs = m_locToGloMap->GetNumGlobalCoeffs();
696  Array<OneD, NekDouble> wsp(contNcoeffs);
697  IProductWRTBase(inarray, wsp, eGlobal);
698  // Note -1.0 term necessary to invert forcing function to
699  // be consistent with matrix definition
700  Vmath::Neg(contNcoeffs, wsp, 1);
701 
702  // Forcing function with weak boundary conditions
703  int i, j;
704  int bndcnt = 0;
705  Array<OneD, NekDouble> gamma(contNcoeffs, 0.0);
706  for (i = 0; i < m_bndCondExpansions.num_elements(); ++i)
707  {
708  if (m_bndConditions[i]->GetBoundaryConditionType() !=
710  {
711  for (j = 0; j < (m_bndCondExpansions[i])->GetNcoeffs(); j++)
712  {
713  gamma[m_locToGloMap->GetBndCondCoeffsToGlobalCoeffsMap(
714  bndcnt++)] += (m_bndCondExpansions[i]->GetCoeffs())[j];
715  }
716  }
717  else
718  {
719  bndcnt += m_bndCondExpansions[i]->GetNcoeffs();
720  }
721  }
722  m_locToGloMap->UniversalAssemble(gamma);
723  // Add weak boundary conditions to forcing
724  Vmath::Vadd(contNcoeffs, wsp, 1, gamma, 1, wsp, 1);
725 
726  // Solve the system
728  factors[StdRegions::eFactorLambda] = lambda;
729  StdRegions::VarCoeffMap varcoeffs;
730  varcoeffs[StdRegions::eVarCoeffVelX] = velocity[0];
731  varcoeffs[StdRegions::eVarCoeffVelY] = velocity[1];
732  varcoeffs[StdRegions::eVarCoeffVelZ] = velocity[2];
735  factors,
736  varcoeffs);
737 
738  if (coeffstate == eGlobal)
739  {
740  GlobalSolve(key, wsp, outarray, dirForcing);
741  }
742  else
743  {
744  Array<OneD, NekDouble> tmp(contNcoeffs, 0.0);
745  GlobalSolve(key, wsp, tmp, dirForcing);
746  GlobalToLocal(tmp, outarray);
747  }
748  }
749 
750 
752  {
754  "To use method must have a AssemblyMap "
755  "attached to key");
756 
757  GlobalMatrixMap::iterator matrixIter = m_globalMat->find(gkey);
758 
759  if(matrixIter == m_globalMat->end())
760  {
761  return 0;
762  }
763  else
764  {
765  return matrixIter->second->GetNumNonZeroEntries();
766  }
767 
768  return 0;
769  }
770 
771 
772  /**
773  *
774  */
776  {
777  m_globalLinSysManager.ClearManager("GlobalLinSys");
778  }
779 
780  } //end of namespace
781 } //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:997
void LocalToGlobal(bool useComm=true)
Gathers the global coefficients from the local coefficients .
Definition: ExpList.h:1959
void GeneralMatrixOp_IterPerExp(const GlobalMatrixKey &gkey, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: ExpList.cpp:929
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:1052
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:2271
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:1702
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:1275
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:1652
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:104
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:109
void IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, CoeffState coeffstate=eLocal)
Definition: ExpList.h:1641
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:1485
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:114
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:1972
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.