LifeV
AssemblyElemental.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief File containing the procedures for the local assembly of the differential operators
30 
31  @contributor Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @mantainer Samuel Quinodoz <samuel.quinodoz@epfl.ch>
33 
34  To delete:
35  L. 195 : stiff_curl
36  L. 271 : grad_div
37  L. 326 : stab_stokes
38  L. 434 : grad_ss
39  L. 493 : source_fhn
40  L. 617 : choldc
41  L. 618 : cholsl
42  */
43 
44 
45 #ifndef _ELEMOPER_H_INCLUDED
46 #define _ELEMOPER_H_INCLUDED
47 
48 
49 #include <boost/numeric/ublas/matrix.hpp>
50 
51 
52 #include <lifev/core/LifeV.hpp>
53 
54 #include <lifev/core/array/MatrixElemental.hpp>
55 #include <lifev/core/array/VectorElemental.hpp>
56 
57 #include <lifev/core/fem/CurrentFEManifold.hpp>
58 #include <lifev/core/fem/ReferenceFEHybrid.hpp>
59 #include <lifev/core/fem/CurrentFE.hpp>
60 #include <lifev/core/fem/DOF.hpp>
61 
62 namespace LifeV
63 {
64 //! @name Public typedefs
65 //@{
67 typedef boost::numeric::ublas::vector<Real> Vector;
69 //@}
70 
71 /*! /namespace AssemblyElemental
72 
73  This namespace is specially designed to contain the elementary
74  operations (corresponding to differential operators) that build
75  the local contributions to be used in the assembly procedures.
76 
77  */
78 namespace AssemblyElemental
79 {
80 //! @name Public typedefs
81 //@{
82 //! Use the portable syntax of the boost function
83 typedef std::function < const Real (const Real&, const Real&,
84  const Real&, const Real&, const ID&) > function_Type;
85 //@}
86 
87 //! Elementary mass for constant mass coefficient
88 /*!
89  This function assembles the local mass matrix when the mass coefficient is constant.
90 
91  @param localMass The local matrix to be filled (not cleaned by this function)
92  @param massCFE The currentFE structure already updated for the assembly. It requires
93  phi and wDetJacobian to be accessible.
94  @param coefficient The mass coefficient
95  @param fieldDim The dimension of the FE space (scalar/vectorial)
96  */
97 void mass (MatrixElemental& localMass,
98  const CurrentFE& massCFE,
99  const Real& coefficient,
100  const UInt& fieldDim);
101 
102 //! Elementary weighted mass for constant mass coefficient
103 /*!
104  This function assembles the local mass matrix when the mass coefficient is constant.
105 
106  @param localMass The local matrix to be filled (not cleaned by this function)
107  @param massCFE The currentFE structure already updated for the assembly. It requires
108  phi and wDetJacobian to be accessible.
109  @param coefficient The mass coefficient
110  @param fieldDim The dimension of the FE space (scalar/vectorial)
111  */
112 template<typename localVector>
113 void weightedMass (MatrixElemental& localMass,
114  const CurrentFE& massCFE,
115  const Real& coefficient,
116  const localVector& localValues,
117  const UInt& fieldDim)
118 {
119  const UInt nbFEDof (massCFE.nbFEDof() );
120  const UInt nbQuadPt (massCFE.nbQuadPt() );
121  Real localValue (0);
122  Real localCoefficient (0);
123 
124  // Assemble the local mass
125  for (UInt iterFDim (0); iterFDim < fieldDim; ++iterFDim)
126  {
127  // Extract the view of the matrix
128  MatrixElemental::matrix_view localView = localMass.block (iterFDim, iterFDim);
129 
130  // Loop over the basis functions
131  for (UInt iDof (0); iDof < nbFEDof ; ++iDof)
132  {
133  // Build the local matrix only where needed:
134  // Lower triangular + diagonal parts
135  for (UInt jDof (0); jDof <= iDof; ++jDof)
136  {
137  localValue = 0.0;
138 
139  //Loop on the quadrature nodes
140  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
141  {
142  localCoefficient = 0.0;
143  for (UInt iterDim (0); iterDim < fieldDim; ++iterDim)
144  {
145  localCoefficient += localValues[iQuadPt][iterDim] * localValues[iQuadPt][iterDim];
146  }
147 
148  localValue += coefficient * localCoefficient
149  * massCFE.phi (iDof, iQuadPt)
150  * massCFE.phi (jDof, iQuadPt)
151  * massCFE.wDetJacobian (iQuadPt);
152  }
153 
154  // Add on the local matrix
155  localView (iDof, jDof) += localValue;
156 
157  if (iDof != jDof)
158  {
159  localView (jDof, iDof) += localValue;
160  }
161  }
162  }
163  }
164 }
165 
166 
167 //! Elementary stiffness for constant coefficient
168 /*!
169  This function assembles the local stiffness matrix when the coefficient is constant.
170 
171  @param localStiff The local matrix to be filled (not cleaned by this function)
172  @param stiffCFE The currentFE structure already updated for the assembly. It requires
173  dphi and wDetJacobian to be accessible.
174  @param coefficient The coefficient
175  @param fieldDim The dimension of the FE space (scalar/vectorial)
176  */
177 void stiffness (MatrixElemental& localStiff,
178  const CurrentFE& stiffCFE,
179  const Real& coefficient,
180  const UInt& fieldDim);
181 
182 
183 //! Interpolation procedure
184 template<typename localVector, typename globalVector>
185 void interpolate (localVector& localValues,
186  const CurrentFE& interpCFE,
187  const UInt& spaceDim,
188  const DOF& betaDof,
189  const UInt& elementID,
190  const globalVector& beta)
191 {
192  const UInt nbQuadPt (interpCFE.nbQuadPt() );
193  const UInt nbFEDof (interpCFE.nbFEDof() );
194  const UInt totalDof (betaDof.numTotalDof() );
195 
196  for (UInt iterDim (0); iterDim < spaceDim; ++iterDim)
197  {
198  // Loop on the quadrature nodes
199  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
200  {
201  localValues[iQuadPt][iterDim] = 0.0;
202 
203  // Loop over the basis functions
204  for (UInt iDof (0); iDof < nbFEDof ; ++iDof)
205  {
206  localValues[iQuadPt][iterDim] +=
207  beta[ betaDof.localToGlobalMap (elementID, iDof) + iterDim * totalDof]
208  * interpCFE.phi (iDof, iQuadPt);
209  }
210  }
211  }
212 }
213 
214 //! Interpolation of the gradient
215 template<typename localVector, typename globalVector>
216 void interpolateGradient (localVector& localGradient,
217  const CurrentFE& interpCFE,
218  const UInt& spaceDim,
219  const DOF& betaDof,
220  const UInt& elementID,
221  const globalVector& beta)
222 {
223  const UInt nbQuadPt (interpCFE.nbQuadPt() );
224  const UInt nbFEDof (interpCFE.nbFEDof() );
225  const UInt totalDof (betaDof.numTotalDof() );
226 
227  for (UInt iterDim (0); iterDim < spaceDim; ++iterDim)
228  {
229  // Loop on the quadrature nodes
230  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
231  {
232 
233  for (UInt jDim (0); jDim < nDimensions; ++jDim)
234  //for ( jcoor = 0; jcoor < fe.nbLocalCoor(); ++jcoor )
235  {
236  localGradient[ iQuadPt ][ iterDim ][ jDim ] = 0.0;
237  for ( UInt i = 0; i < nbFEDof; ++i )
238  localGradient[ iQuadPt ][ iterDim ][ jDim ] += interpCFE.phiDer ( i, jDim, iQuadPt ) *
239  beta[ betaDof.localToGlobalMap (elementID, i) + iterDim * totalDof];
240  }
241  }
242  }
243 
244 }
245 
246 
247 //! Interpolation of the divergence
248 template<typename localVector, typename globalVector>
249 void interpolateDivergence (localVector& localDivergence,
250  const CurrentFE& interpCFE,
251  const DOF& betaDof,
252  const UInt& elementID,
253  const globalVector& beta)
254 {
255  const UInt nbQuadPt (interpCFE.nbQuadPt() );
256  const UInt nbFEDof (interpCFE.nbFEDof() );
257  const UInt totalDof (betaDof.numTotalDof() );
258 
259  // Loop on the quadrature nodes
260  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
261  {
262  localDivergence[ iQuadPt ] = 0.0;
263 
264  for ( UInt i = 0; i < nbFEDof; ++i )
265  {
266  for (UInt jDim (0); jDim < nDimensions; ++jDim)
267  localDivergence[ iQuadPt ] += interpCFE.phiDer ( i, jDim, iQuadPt ) *
268  // here we are assuming that beta belongs to the FE space of interpCFE
269  beta[ betaDof.localToGlobalMap (elementID, i) + jDim * totalDof ];
270  }
271  }
272 
273 }
274 
275 
276 template<typename localVector>
277 void massDivW (MatrixElemental& localMass,
278  const CurrentFE& massCFE,
279  const Real& coefficient,
280  const localVector& localValues,
281  const UInt& fieldDim)
282 {
283  const UInt nbFEDof (massCFE.nbFEDof() );
284  const UInt nbQuadPt (massCFE.nbQuadPt() );
285  Real localValue (0);
286 
287  // Assemble the local mass
288  for (UInt iterFDim (0); iterFDim < fieldDim; ++iterFDim)
289  {
290  // Extract the view of the matrix
291  MatrixElemental::matrix_view localView = localMass.block (iterFDim, iterFDim);
292 
293  // Loop over the basis functions
294  for (UInt iDof (0); iDof < nbFEDof ; ++iDof)
295  {
296  // Build the local matrix only where needed:
297  // Lower triangular + diagonal parts
298  for (UInt jDof (0); jDof <= iDof; ++jDof)
299  {
300  localValue = 0.0;
301 
302  // Loop on the quadrature nodes
303  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
304  {
305  localValue += localValues[iQuadPt]
306  * massCFE.phi (iDof, iQuadPt)
307  * massCFE.phi (jDof, iQuadPt)
308  * massCFE.wDetJacobian (iQuadPt);
309  }
310 
311  localValue *= coefficient;
312 
313  // Add on the local matrix
314  localView (iDof, jDof) += localValue;
315 
316  if (iDof != jDof)
317  {
318  localView (jDof, iDof) += localValue;
319  }
320  }
321  }
322  }
323 }
324 
325 //! Elementary advection \beta \grad u v
326 template<typename localVector>
327 void advection (MatrixElemental& localAdv,
328  const CurrentFE& advCFE,
329  const Real& coefficient,
330  const localVector& localValues,
331  const UInt& fieldDim)
332 {
333  const UInt nbFEDof (advCFE.nbFEDof() );
334  const UInt nbQuadPt (advCFE.nbQuadPt() );
335  Real localValue (0.0), advGrad (0.0);
336  MatrixElemental matTmp ( nbFEDof, 1, 1 );
337  matTmp.zero();
338  MatrixElemental::matrix_view matTmpView = matTmp.block (0, 0);
339 
340  // Loop over the basis functions
341  for (UInt iDof (0); iDof < nbFEDof ; ++iDof)
342  {
343  // Build the local matrix
344  for (UInt jDof (0); jDof < nbFEDof; ++jDof)
345  {
346  localValue = 0.0;
347 
348  // Loop on the quadrature nodes
349  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
350  {
351  advGrad = 0.;
352  for (UInt iDim (0); iDim < advCFE.nbLocalCoor(); ++iDim)
353  {
354  advGrad += localValues[iQuadPt][iDim]
355  * advCFE.dphi (jDof, iDim, iQuadPt);
356  }
357 
358  localValue += advGrad * advCFE.phi (iDof, iQuadPt)
359  * advCFE.wDetJacobian (iQuadPt);
360  }
361  // Add on the local matrix
362  matTmpView (iDof, jDof) = coefficient * localValue;
363  }
364  }
365  for (UInt iterFDim (0); iterFDim < fieldDim; ++iterFDim)
366  {
367  // Extract the view of the matrix
368  MatrixElemental::matrix_view localView = localAdv.block (iterFDim, iterFDim);
369 
370  // Copy on the components
371  localView = matTmpView;
372  }
373 }
374 
375 /*
376  * Added by Gwenol Grandperrin, August 2011
377  */
378 //! Assemble the term \f$ \int_\Omega \phi_j\cdot\mathbf{u}\phi_i\f$
379 void advectionNewton ( Real coef, VectorElemental& vel,
380  MatrixElemental& elmat, const CurrentFE& fe,
381  int iblock, int jblock );
382 
383 //! Elementary advection, term u\grad \beta v
384 template<typename localTensor>
386  const CurrentFE& advCFE,
387  const Real& coefficient,
388  const localTensor& localGradient,
389  const UInt& fieldDim)
390 {
391  const UInt nbFEDof (advCFE.nbFEDof() );
392  const UInt nbQuadPt (advCFE.nbQuadPt() );
393  Real localValue (0.0);
394 
395  ASSERT (fieldDim == nDimensions, "Symmetrized operator works only with vectors of the same dimension as the space" );
396 
397 
398  for (UInt iCoor (0); iCoor < fieldDim; ++iCoor)
399  {
400  for (UInt jCoor (0); jCoor < fieldDim; ++jCoor)
401  {
402  // Extract the view of the matrix
403  MatrixElemental::matrix_view localView = localAdv.block (iCoor, jCoor);
404 
405  // Loop over the basis functions
406  for (UInt iDof (0); iDof < nbFEDof ; ++iDof)
407  {
408  // Build the local matrix
409  for (UInt jDof (0); jDof < nbFEDof; ++jDof)
410  {
411  localValue = 0.0;
412 
413  // Loop on the quadrature nodes
414  for (UInt iQuadPt (0); iQuadPt < nbQuadPt; ++iQuadPt)
415  {
416  localValue +=
417  localGradient[iQuadPt][iCoor][jCoor]
418  * advCFE.phi (jDof, iQuadPt)
419  * advCFE.phi (iDof, iQuadPt)
420  * advCFE.wDetJacobian (iQuadPt);
421 
422  }
423 
424  // Add on the local matrix
425  localView (iDof, jDof) = coefficient * localValue;
426  }
427  }
428  }
429  }
430 }
431 
432 void grad (MatrixElemental& localGrad,
433  const CurrentFE& uCFE,
434  const CurrentFE& pCFE,
435  const UInt& fieldDim);
436 
437 void divergence (MatrixElemental& localDivergence,
438  const CurrentFE& uCFE,
439  const CurrentFE& pCFE,
440  const UInt& fieldDim,
441  const Real& coefficient = 1.0);
442 
443 void stiffStrain (MatrixElemental& localStiff,
444  const CurrentFE& stiffCFE,
445  const Real& coefficient,
446  const UInt& fieldDim);
447 
448 void bodyForces (VectorElemental& localForce,
449  const CurrentFE& massRhsCFE,
450  const function_Type& fun,
451  const Real& t,
452  const UInt& fieldDim);
453 
454 //----------------------------------------------------------------------
455 //
456 //!@name Operators for classical finite elements
457 //@{
458 //----------------------------------------------------------------------
459 //!coef(t,x,y,z,u)
460 
461 void mass ( Real coef, MatrixElemental& elmat, const CurrentFE& fe,
462  int iblock = 0, int jblock = 0 );
463 void mass ( Real coef, MatrixElemental& elmat, const CurrentFE& fe,
464  int iblock, int jblock, UInt nb );
465 //! Mass term with coefficients given for each quadrature point
466 void mass ( const std::vector<Real>& qpt_coef, MatrixElemental& elmat, const CurrentFE& fe,
467  int iblock, int jblock, UInt nb );
468 
469 void stiff ( Real coef, MatrixElemental& elmat, const CurrentFE& fe,
470  int iblock = 0, int jblock = 0 );
471 void stiff ( Real coef, Real ( *fct ) ( Real, Real, Real ), MatrixElemental& elmat,
472  const CurrentFE& fe, int iblock, int jblock );
473 void stiff ( Real coef, MatrixElemental& elmat, const CurrentFE& fe,
474  int iblock, int jblock, int nb );
475 //! Stiff term with coefficient given for each quadrature node
476 void stiff ( const std::vector<Real>& qpt_coef, MatrixElemental& elmat, const CurrentFE& fe,
477  int iblock, int jblock, int nb );
478 void stiff_curl ( Real coef, MatrixElemental& elmat, const CurrentFE& fe,
479  int iblock, int jblock, int nb );
480 
481 
482 
483 
484 
485 //! \f$ coef \cdot ( e(u) , e(v) )\f$
486 void stiff_strain ( Real coef, MatrixElemental& elmat, const CurrentFE& fe );
487 
488 //! \f$ coef \cdot ( div u , div v )\f$
489 void stiff_div ( Real coef, MatrixElemental& elmat, const CurrentFE& fe );
490 
491 //! \f$ coef \cdot ( [\nabla u^k]^T \nabla u : \nabla v )\f$
492 void stiff_dergradbis ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
493 
494 //! \f$ coef \cdot ( [\nabla u]^T \nabla u^k + [\nabla u^k]^T \nabla u : \nabla v )\f$ for Newton on St-Venant
495 void stiff_dergrad ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
496 
497 //! \f$ coef \cdot ( trace { [\nabla u^k]^T \nabla u }, \nabla\cdot v ) \f$ for Newton on St-Venant
498 void stiff_derdiv ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
499 
500 // -----------added Rita 2008 for non linear St-Venant----------------------------------------------------------
501 
502 // coef * ( (\div u_k) \grad u : \grad v )--------------------------------------------------------------------controllato!!!
503 void stiff_divgrad ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
504 
505 // coef * ( (\div u) \grad u_k : \grad v )
506 // part of the jacobian of stiff_divgrad
507 void stiff_divgrad_2 ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
508 
509 // coef * ( \grad u_k : \grad u_k) * ( \grad u : \grad v )---------------------------------------------controllato!!!
510 void stiff_gradgrad ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
511 
512 // coef * ( \grad u_k : \grad u) *( \grad u_k : \grad v )
513 // part of the jacobian stiff_gradgrad
514 void stiff_gradgrad_2 ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
515 
516 // coef * ( \grad u^k \grad u : \grad v )------------------------------------------------------------------controllato!!!
517 void stiff_dergrad_gradbis ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
518 
519 // coef * ( \grad \delta u \grad u^k : \grad v )
520 // part of the jacobian of stiff_dergrad_gradbis
521 void stiff_dergrad_gradbis_2 ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
522 
523 // coef * ( \grad u^k [\grad u]^T : \grad v )------------------------------------------------------------controllato!!!
524 void stiff_dergrad_gradbis_Tr ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
525 
526 // coef * ( \grad \delta u [\grad u^k]^T : \grad v )------------------------------------------------------------controllato!!!
527 // part of the jacobian of stiff_dergrad_gradbis_Tr
528 void stiff_dergrad_gradbis_Tr_2 ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
529 
530 // coef * ( \grad u^k [\grad u^k]^T \grad u : \grad v )------------------------------------------------------------controllato!!!
531 void stiff_gradgradTr_gradbis ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
532 
533 // coef * ( \grad u^k [\grad u]^T \grad u^k : \grad v )------------------------------------------------------------controllato!!!
534 // part of the jacobian of stiff_gradgradTr_gradbis
535 void stiff_gradgradTr_gradbis_2 ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
536 
537 // coef * ( \grad u [\grad u^k]^T \grad u^k : \grad v )------------------------------------------------------------controllato!!!
538 // secondo part of the jacobian of stiff_gradgradTr_gradbis
539 void stiff_gradgradTr_gradbis_3 ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat, const CurrentFE& fe );
540 
541 //------------------------------------------------------------------------------------------------------------------------------------------
542 
543 
544 void grad ( const int icoor, Real coef, MatrixElemental& elmat,
545  const CurrentFE& fe_u, const CurrentFE& fe_p,
546  int iblock = 0, int jblock = 0 );
547 void div ( const int icoor, Real coef, MatrixElemental& elmat,
548  const CurrentFE& fe_u, const CurrentFE& fe_p,
549  int iblock = 0, int jblock = 0 );
550 void grad_div ( Real coef_grad, Real coef_div, MatrixElemental& elmat,
551  const CurrentFE& fe_u, const CurrentFE& fe_p,
552  int block_pres );
553 
554 template<typename UsrFct>
555 void advection ( Real coef, const UsrFct& beta,
556  MatrixElemental& elmat, const CurrentFE& fe, int iblock, int jblock, int nb, Real t = 0. )
557 {
558  Matrix mat_tmp ( fe.nbFEDof(), fe.nbFEDof() );
559  Real v, s;
560  Real x, y, z;
561  Matrix v_grad (ZeroMatrix (fe.nbFEDof(), fe.nbQuadPt() ) );
562 
563  //Evaluate the velocity field at the quadrature nodes
564  for ( UInt iq = 0; iq < fe.nbQuadPt(); iq++ )
565  {
566  fe.coorQuadPt (x, y, z, iq);
567  for ( UInt icoor = 0; icoor < nDimensions; icoor++ )
568  {
569  v = beta (t, x, y, z, icoor);
570  for ( UInt j = 0; j < fe.nbFEDof(); ++j)
571  {
572  v_grad (j, iq) += v * fe.phiDer (j, icoor, iq );
573  }
574  }
575  }
576 
577 
578  //Assemble the local matrix
579  for ( UInt i = 0; i < fe.nbFEDof(); i++ )
580  {
581  for ( UInt j = 0; j < fe.nbFEDof(); j++ )
582  {
583  s = 0.;
584  for ( UInt iq = 0; iq < fe.nbQuadPt(); iq++ )
585  {
586  s += v_grad (j, iq) * fe.phi ( i, iq ) * fe.weightDet ( iq );
587  }
588  mat_tmp ( i, j ) = s * coef;
589  }
590  }
591 
592  // copy on the components
593  for ( int icomp = 0; icomp < nb; icomp++ )
594  {
595  MatrixElemental::matrix_view mat_icomp = elmat.block ( iblock + icomp, jblock + icomp );
596  for ( UInt i = 0; i < fe.nbDiag(); i++ )
597  {
598  for ( UInt j = 0; j < fe.nbDiag(); j++ )
599  {
600  mat_icomp ( i, j ) += mat_tmp ( i, j );
601  }
602  }
603  }
604 }
605 
606 void stab_stokes ( Real visc, Real coef_stab, MatrixElemental& elmat,
607  const CurrentFE& fe, int block_pres );
608 void advection ( Real coef, VectorElemental& vel, MatrixElemental& elmat,
609  const CurrentFE& fe, int iblock, int jblock, int nb );
610 
611 void source ( Real constant, VectorElemental& elvec, const CurrentFE& fe, int iblock );
612 
613 void source ( Real constant, VectorElemental& elvec, const CurrentFE& fe, Real t, int iblock );
614 
615 
616 // right-hand sides for Chorin-Teman projection scheme
617 void source_divuq (Real alpha, VectorElemental& uLoc, VectorElemental& elvec, const CurrentFE& fe_u, const CurrentFE& fe_p, int iblock = 0 );
618 void source_gradpv (Real alpha, VectorElemental& pLoc, VectorElemental& elvec, const CurrentFE& fe_p, const CurrentFE& fe_u, int iblock );
619 
620 //! Assembly for the source term \f$ \int c v \f$ where \f$c\f$ is a given by the values in the quadrature nodes.
621 /*!
622  This function add in the elementary vector the term \f$ \int c v \f$.
623  The function \f$c\f$ is given by its values in the quadrature nodes.
624 
625  @param constant Values of the function in the quadrature nodes
626  @param elvec The local vector where to add the values
627  @param currentFe The currentFE associated to the cell where to assemble
628  @param iblock The component of v that is concerned
629 */
630 void source_mass (const std::vector<Real>& constant, VectorElemental& elvec, const CurrentFE& currentFe, const int& iblock);
631 
632 //! Assembly for the source term \f$ \int \nabla c \cdot \nabla v \f$ where \f$c\f$ is a given by the values in the quadrature nodes.
633 /*!
634  The function \f$\nabla c\f$ is given by its values in the quadrature nodes, coordinate after coordinate (first,
635  the values for the first componant of the gradient in all the quadrature nodes, then second component,...).
636 
637  @param constant Values of the gradient in the quadrature nodes
638  @param elvec The local vector where to add the values
639  @param currentFe The currentFE associated to the cell where to assemble
640  @param iblock The component of v that is concerned
641 */
642 void source_stiff (const std::vector<Real>& constant, VectorElemental& elvec, const CurrentFE& currentFe, const int& iblock);
643 
644 //!@}
645 //!@name Elementary operations for the interior penalty stabilization
646 //!@{
647 //
648 
649 //! \f$ coef < \nabla p1, \nabla q2 >\f$
650 void ipstab_grad ( const Real coef, MatrixElemental& elmat,
651  const CurrentFE& fe1, const CurrentFE& fe2,
652  const CurrentFEManifold& bdfe, int iblock = 0, int jblock = 0 );
653 
654 //! \f$ coef < \nabla u1, \nabla v2 >\f$
655 void ipstab_grad ( const Real coef, MatrixElemental& elmat,
656  const CurrentFE& fe1, const CurrentFE& fe2,
657  const CurrentFEManifold& bdfe, int iblock, int jblock, int nb );
658 
659 //! \f$ coef < \nabla\cdot u1, \nabla\cdot v2 >\f$
660 void ipstab_div ( const Real coef, MatrixElemental& elmat,
661  const CurrentFE& fe1, const CurrentFE& fe2,
662  const CurrentFEManifold& bdfe, int iblock = 0, int jblock = 0 );
663 //! \f$ coef < \beta1 . \nabla u1, \beta2 . \nabla v2 >\f$
664 void ipstab_bgrad ( const Real coef, MatrixElemental& elmat,
665  const CurrentFE& fe1, const CurrentFE& fe2,
666  const VectorElemental& beta, const CurrentFEManifold& bdfe,
667  int iblock, int jblock, int nb );
668 //! \f$ coef < |\beta . n|^2 / |\beta| \nabla p1, \nabla q2 >\f$
669 void ipstab_bagrad ( const Real coef, MatrixElemental& elmat,
670  const CurrentFE& fe1, const CurrentFE& fe2,
671  const VectorElemental& beta, const CurrentFEManifold& bdfe,
672  int iblock = 0, int jblock = 0 );
673 
674 //!\f$ coef < |\beta\cdot n| \nabla p1, \nabla q2 >\f$
675 //! p1 lives in fe1
676 //! q2 lives in fe2
677 //! beta lives in fe3
678 
679 void ipstab_bagrad ( const Real coef,
680  MatrixElemental& elmat,
681  const CurrentFE& fe1,
682  const CurrentFE& fe2,
683  const CurrentFE& fe3,
684  const VectorElemental& beta,
685  const CurrentFEManifold& bdfe,
686  int iblock = 0, int jblock = 0 );
687 
688 //!@}
689 ///////////////////////////////////////
690 
691 
692 ////////////////////////////////////////
693 //! Convective term with a local vector coefficient (useful for Navier-Stokes problem)
694 void grad ( const int icoor, const VectorElemental& vec_loc, MatrixElemental& elmat,
695  const CurrentFE& fe1, const CurrentFE& fe2,
696  int iblock, int jblock );
697 
698 //! Convective term with a local vector coefficient (useful for Navier-Stokes problem+adv-diff)
699 void grad ( const int icoor, const VectorElemental& vec_loc, MatrixElemental& elmat,
700  const CurrentFE& fe1, const CurrentFE& fe2, const CurrentFE& fe3,
701  int iblock = 0, int jblock = 0 );
702 
703 //! Conective term with a local vector given by quadrature node
704 /*!
705  To use this function, we must ensure that the velocity is stored in a good way in the std::vector:
706  If there are nQ quadrature nodes, the i-th component (starting from 0) of the velocity in the iq-th quadrature node
707  (also starting from 0) has to be stored in the ( i*nQ + iq)-th element of the std::vector.
708 */
709 void grad ( const int& icoor, const std::vector<Real>& localVector, MatrixElemental& elmat,
710  const CurrentFE& currentFE1, const CurrentFE& currentFE2,
711  const int& iblock = 0, const int& jblock = 0);
712 
713 //! Convective term with a local vector coefficient for Navier-Stokes problem in Skew-Symmetric form
714 void grad_ss ( const int icoor, const VectorElemental& vec_loc, MatrixElemental& elmat,
715  const CurrentFE& fe1, const CurrentFE& fe2,
716  int iblock = 0, int jblock = 0 );
717 
718 //! StreamLine Diffusion
719 void stiff_sd ( Real coef, const VectorElemental& vec_loc, MatrixElemental& elmat, const CurrentFE& fe,
720  const CurrentFE& fe2, int iblock = 0, int jblock = 0, int nb = 1 );
721 
722 /////////////////////////////////////////////
723 //
724 //! source \f$ \int fct \phi_i \f$
725 //
726 template <typename UsrFct>
727 void source ( const UsrFct& fct, VectorElemental& elvec, const CurrentFE& fe, int iblock = 0 )
728 {
729  UInt i, ig;
730  VectorElemental::vector_view vec = elvec.block ( iblock );
731  Real s;
732  for ( i = 0; i < fe.nbFEDof(); i++ )
733  {
734  s = 0;
735  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
736  {
737  s += fe.phi ( i, ig ) * fct ( fe.quadPt ( ig, 0 ), fe.quadPt ( ig, 1 ), fe.quadPt ( ig, 2 ),
738  iblock) * fe.weightDet ( ig );
739  }
740  vec ( i ) += s;
741  }
742 }
743 
744 /////////////////////////////////////////////
745 //
746 //! source \f$ \int fct(t) \phi_i\f$
747 //
748 template <typename UsrFct>
749 void source ( const UsrFct& fct, VectorElemental& elvec, const CurrentFE& fe, Real t, int iblock = 0 )
750 {
751  UInt i, ig;
752  VectorElemental::vector_view vec = elvec.block ( iblock );
753  Real s;
754  for ( i = 0; i < fe.nbFEDof(); i++ )
755  {
756  s = 0;
757  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
758  {
759  s += fe.phi ( i, ig ) * fct (t, fe.quadPt ( ig, 0 ), fe.quadPt ( ig, 1 ), fe.quadPt ( ig, 2 ),
760  iblock ) * fe.weightDet ( ig );
761  }
762  vec ( i ) += s;
763  }
764 }
765 
766 
767 void source ( Real coef, VectorElemental& f, VectorElemental& elvec, const CurrentFE& fe,
768  int fblock = 0, int eblock = 0 );
769 
770 void source_fhn ( Real coef_f, Real coef_a, VectorElemental& u, VectorElemental& elvec, const CurrentFE& fe,
771  int fblock = 0, int eblock = 0 );
772 
773 //! \f$( beta\cdot\nabla u^k, v )\f$
774 void source_advection ( const Real& coefficient, const VectorElemental& beta_loc, const VectorElemental& uk_loc,
775  VectorElemental& elvec, const CurrentFE& fe );
776 
777 //!@name Shape derivative terms for Newton FSI
778 //!@{
779 //
780 //! \f$ coef \cdot ( \nabla (-w^k):[I\nabla\cdot d - (\nabla d)^T] u^k + convect^T[I\nabla\cdot d - (\nabla d)^T] (\nabla u^k)^T , v ) \f$ for Newton FSI
781 //
782 //! Remark: convect = \f$u^n-w^k\f$
783 //
784 void source_mass1 ( Real coef,
785  const VectorElemental& uk_loc,
786  const VectorElemental& wk_loc,
787  const VectorElemental& convect_loc,
788  const VectorElemental& d_loc,
789  VectorElemental& elvec,
790  const CurrentFE& fe );
791 
792 //
793 //! \f$coef \cdot ( \nabla u^k dw, v )\f$ for Newton FSI
794 //
795 //
796 void source_mass2 ( Real coef, const VectorElemental& uk_loc, const VectorElemental& dw_loc,
797  VectorElemental& elvec, const CurrentFE& fe );
798 
799 
800 
801 void source_mass3 ( Real coef, const VectorElemental& un_loc, const VectorElemental& uk_loc, const VectorElemental& d_loc,
802  VectorElemental& elvec, const CurrentFE& fe );
803 
804 
805 
806 
807 
808 //
809 //! \f$coef \cdot ( [-p^k I + 2\mu e(u^k)] [I\nabla\cdot d - (\nabla d)^T] , \nabla v )\f$ for Newton FSI
810 //
811 void source_stress ( Real coef, Real mu, const VectorElemental& uk_loc, const VectorElemental& pk_loc,
812  const VectorElemental& d_loc, VectorElemental& elvec, const CurrentFE& fe_u,
813  const CurrentFE& fe_p );
814 
815 //
816 //! \f$+ \mu ( \nabla u^k \nabla d + [\nabla d]^T[\nabla u^k]^T : \nabla v )\f$
817 //
818 void source_stress2 ( Real coef, const VectorElemental& uk_loc, const VectorElemental& d_loc, VectorElemental& elvec, const CurrentFE& fe_u );
819 
820 
821 
822 /**
823  *Shape terms for the CE system in FSI Newton. It is the sum of the terms \c source_mass1\c, \c source_stress\c and \c source_stress2\c.
824  *the difference between this method and the previous ones is that here the shape terms are assembled in a matrix, instead
825  *of a vector. This implies some extra loop and the explicit construction of the tensor \f$[I\nabla\cdot d - (\nabla d)^T]\f$
826  *instead of it's multiplication times a vector. However the computation of these terms need to be done once per Newton
827  *iterations, instead of once per Jacobian-vector multiplication.
828 
829  *Note that the term \c source_mass2\c is not considered if the fluid domain velocity \f w\f is trated explicitly.
830  *This method is currently tested only for the P1-P1 stabilized space discretization.
831  */
832 void shape_terms (
833  //const VectorElemental& d_loc,
834  Real coef,
835  Real mu,
836  const VectorElemental& un_loc,
837  const VectorElemental& uk_loc,
838  const VectorElemental& wk_loc,
839  const VectorElemental& convect_loc,
840  const VectorElemental& pk_loc,
841  MatrixElemental& elmat,
842  const CurrentFE& fe,
843  const CurrentFE& fe_p,
844  ID mmDim,
845  MatrixElemental& /*elmatP*/,
846  int iblock = 0,
847  bool wImplicit = false,
848  Real alpha = 0.,
849  std::shared_ptr<MatrixElemental> elmat_convect = std::shared_ptr<MatrixElemental>()
850 );
851 
852 //
853 //! \f$coef * ( (\nabla u^k):[I\nabla\cdot d - (\nabla d)^T] , q )\f$ for Newton FSI
854 //
855 void source_press ( Real coef, const VectorElemental& uk_loc, MatrixElemental& elmat,
856  const CurrentFE& fe_u, const CurrentFE& fe_p, ID mmDim, int iblock = 0 );
857 
858 
859 
860 //
861 //! \f$coef * ( (\nabla u^k):[I\nabla\cdot d - (\nabla d)^T] , q )\f$ for Newton FSI
862 //
863 void source_press ( Real coef, const VectorElemental& uk_loc, const VectorElemental& d_loc, VectorElemental& elvec,
864  const CurrentFE& fe_u, const CurrentFE& fe_p, int iblock = 0 );
865 
866 
867 void source_press2 ( Real coef, const VectorElemental& p_loc, const VectorElemental& d_loc, VectorElemental& elvec,
868  const CurrentFE& fe, int iblock = 0 );
869 //@}
870 //!@name Mass matrix
871 //!@{
872 //-------------Mass matrix---------------------------------------
873 /*!
874  Weighted Mass matrix with a permeability tensor which is a constant scalar matrix
875  (i.e. \f$K^{-1} = coef \cdot Id\f$, coef being the inverse of the permeability).
876 */
877 
878 void mass_divw ( Real coef, const VectorElemental& w_loc, MatrixElemental& elmat, const CurrentFE& fe,
879  int iblock, int jblock, UInt nb );
880 
881 //! Idem \c mass_divw \c, but with coefficient given by quadrature node
882 void mass_divw (const std::vector<Real>& coef, const VectorElemental& w_loc, MatrixElemental& elmat, const CurrentFE& fe,
883  int iblock, int jblock, UInt nb );
884 
885 
886 void mass_gradu ( Real coef, const VectorElemental& u0_loc, MatrixElemental& elmat, const CurrentFE& fe );
887 
888 
889 
890 //!@}
891 
892 //!@name Cholesky
893 //!@{
894 //-------------Cholesky---------------------------------------
895 /*!
896  Cholesky decomposition and solution for a KNM matrix.
897 */
898 void choldc ( KNM<Real>& a, KN<Real>& p );
899 void cholsl ( KNM<Real>& a, KN<Real>& p, KN<Real>& b, KN<Real>& x );
900 //!@}
901 
902 
903 //!@name Operators for H(div) finite elements
904 //!@{
905 //-------------Operators for H(div) finite elements------------
906 
907 // Gradient matrix.
908 /*!
909 Compute the gradient of an element in \f$ H(div, K ) \f$ space, i.e. the opposite of the transpose divergence
910 matrix, with \f$ K \f$ the current element. In formula
911 \f[
912 \mathrm{coef} < \nabla q, w > \equiv - \mathrm{coef} < q, \nabla \cdot w > \,,
913 \f]
914 for \f$ q \in L^2(K) \f$, \f$ w \in H(div, K) \f$ and \f$ \mathrm{coef} \f$ a real scalar.
915 @param coef Constant real coefficient.
916 @param elmat Mixed element matrix.
917 @param dualFE Current dual finite element in \f$ H(div, K) \f$.
918 @param primalFE Current primal finite element in \f$ L^2(K) \f$.
919 @param iblock Subarray index where to store the integral just computed.
920 @param jblock Subarray index where to store the integral just computed.
921 */
922 void grad_Hdiv ( Real coef, MatrixElemental& elmat, const CurrentFE& dualFE, const CurrentFE& primalFE,
923  int iblock = 0, int jblock = 0 );
924 
925 // Divergence matrix.
926 /*!
927 Compute the divergence of an element in \f$ H(div,K ) \f$, with \f$ K \f$ the current element.
928 In formula
929 \f[
930 \mathrm{coef} < q, \nabla \cdot w > \,,
931 \f]
932 for \f$ q \in L^2(K) \f$, \f$ w \in H(div, K) \f$ and \f$ \mathrm{coef} \f$ a real scalar.
933 @param coef Constant real coefficient.
934 @param elmat Mixed element matrix.
935 @param dualFE Current dual finite element in \f$ H(div, K) \f$.
936 @param primalFE Current primal finite element in \f$ L^2(K) \f$.
937 @param iblock Subarray index where to store the integral just computed.
938 @param jblock Subarray index where to store the integral just computed.
939 */
940 void div_Hdiv ( Real coef, MatrixElemental& elmat, const CurrentFE& dualFE, const CurrentFE& primalFE,
941  int iblock = 0, int jblock = 0 );
942 
943 // Hybrid variable times dual dot product outward unit normal.
944 /*!
945 Compute the product between an hybrid variable and a dual variable dot product outward unit
946 normal, in the current element \f$ K \f$. In formula
947 \f[
948 \mathrm{coef} < \lambda, v \cdot n >\,,
949 \f]
950 for \f$ \lambda \in H^{1/2}(\partial K) \f$, \f$ v \in H(div, K) \f$, \f$ coef \f$ a real scalar and \f$ n \f$
951 the normal unit vector oriented outward of the current element \f$ K \f$.
952 <BR>
953 The \f$ \lambda \f$ are the Lagrange multiplier basis functions that enforce continuity
954 of the normal component of the vectorial functions across two neighbouring elements.
955 They can be interprated as trace of primal variable.
956 <BR>
957 See Hybridization for Mixed Hybrid Finite Element Method.
958 <BR>
959 Thanks to the Piola transform, the computation is performed on the boundary of the reference element.
960 But in general, the boundary of a 3D reference element is not a 2D reference element.
961 <BR>
962 Example:
963 REFERENCE TETRA -> 3 REFERENCE TRIA + 1 EQUILATERAL TRIANGLE...
964 REFERENCE PRISM -> 2 TRIA + 3 QUAD...?
965 REFERENCE HEXA -> 6 REFERENCE QUAD.
966 
967 @param coef Constant real coefficient.
968 @param elmat Mixed element matrix.
969 @param hybridFE Reference hybrid finite element.
970 @param dualDotNFE Reference dual dot product outward unit normal finite element.
971 @param iblock Subarray index where to store the integral just computed.
972 @param jblock Subarray index where to store the integral just computed.
973 @note The previous way of construction, worked only for RTO hexa, calls
974 \code
975 TP_TP_Hdiv(coef, elmat, hybridFE, iblock, jblock);
976 \endcode
977 */
978 void TP_VdotN_Hdiv ( Real coef, MatrixElemental& elmat, const ReferenceFEHybrid& hybridFE,
979  const ReferenceFEHybrid& dualDotNFE, int iblock = 0, int jblock = 0 );
980 
981 // Mass matrix for the hybrid variable.
982 /*!
983 Compute the mass matrix for the hybrid variable, in the current element \f$ K \f$.
984 In formula
985 \f[
986 \mathrm{coef} < \lambda, \mu > \,,
987 \f]
988 for \f$ \lambda, \mu \in H^{1/2}(\partial K) \f$ and \f$ coef \f$ a real scalar.
989 <BR>
990 The \f$ \lambda \f$ and \f$ \mu \f$ are the Lagrange multiplier basis functions that enforce continuity
991 of the normal component of the vectorial functions across two neighbouring elements.
992 They can be interprated as trace of primal variable.
993 <BR>
994 See Hybridization for Mixed Hybrid Finite Element Method.
995 <BR>
996 Thanks to the Piola transform, the computation is performed on the boundary of the reference element.
997 But in general, the boundary of a 3D Reference element is not a 2D reference element.
998 <BR>
999 Example:
1000 REFERENCE TETRA -> 3 REFERENCE TRIA + 1 EQUILATERAL TRIANGLE...
1001 REFERENCE PRISM -> 2 TRIA + 3 QUAD...?
1002 REFERENCE HEXA -> 6 REFERENCE QUAD.
1003 @param coef Constant real coefficient.
1004 @param elmat Mixed element matrix.
1005 @param hybridFE Reference hybrid finite element.
1006 @param iblock Subarray index where to store the integral just computed.
1007 @param jblock Subarray index where to store the integral just computed.
1008 @note This is an obsolete function, call TP_VdotN_Hdiv instead.
1009 */
1010 void TP_TP_Hdiv ( Real coef, MatrixElemental& elmat, const ReferenceFEHybrid& hybridFE, int iblock = 0, int jblock = 0);
1011 
1012 // Mass matrix for dual variable with constant real permeability.
1013 /*!
1014 Compute the mass matrix in \f$ H(div, K ) \f$ with constant real permeability, with \f$ K \f$ the
1015 current element. In formula
1016 \f[
1017 \mathrm{coef} < u, w > \,,
1018 \f]
1019 for \f$ u, w \in H(div, K) \f$ and \f$ coef \f$ a real scalar.
1020 <BR>
1021 Weighted Mass matrix with a permeability tensor which is a constant scalar matrix, i.e.
1022 \f$ K^{-1} = \mathrm{coef} \, I \f$, \f$ \mathrm{coef} \f$ being the inverse of the permeability.
1023 \attention It is \f$ \mathrm{coef} \f$ that is used, and not its inverse.
1024 @param coef Constant real coefficient.
1025 @param elmat Mixed element matrix.
1026 @param dualFE Current dual finite element in \f$ H(div, K) \f$.
1027 @param iblock Subarray index where to store the integral just computed.
1028 @param jblock Subarray index where to store the integral just computed.
1029 @note \f$ \mathrm{coeff} \f$ is the inverse of the permeability coefficient.
1030 */
1031 void mass_Hdiv ( Real coef, MatrixElemental& elmat, const CurrentFE& dualFE, int iblock = 0, int jblock = 0 );
1032 
1033 // Mass matrix for dual variable with constant matrix permeability.
1034 /*!
1035 Compute the mass matrix in \f$ H(div, K ) \f$ with constant matrix permeability, with \f$ K \f$ the
1036 current element. In formula
1037 \f[
1038 < \mathrm{Invperm}\, u, w > \,,
1039 \f]
1040 for \f$ u, w \in H(div, K) \f$ and \f$ \mathrm{Invperm} \f$ a real constant matrix.
1041 <BR>
1042 Weighted mass matrix in \f$ H(div, K) \f$ with permeability matrix which is a constant
1043 per element symmetric positive definite matrix, non diagonal a priori,
1044 and already inverted, with Lapack LU or Choleski for instance.
1045 @param Invperm Constant coefficient tensor, constant means constant over the current element.
1046 @param elmat Mixed element matrix.
1047 @param dualFE Current dual finite element in \f$ H(div, K) \f$.
1048 @param iblock Subarray index where to store the integral just computed.
1049 @param jblock Subarray index where to store the integral just computed.
1050 @note \f$ \mathrm{Invperm} \f$ is the inverse of the permeability matrix.
1051 */
1052 void mass_Hdiv ( Matrix const& Invperm, MatrixElemental& elmat, const CurrentFE& dualFE,
1053  int iblock = 0, int jblock = 0 );
1054 
1055 // Mass matrix for dual variable with real function permeability.
1056 /*!
1057 Compute the mass matrix in \f$ H(div, K ) \f$ with real function permeability, with \f$ K \f$ the
1058 current element. In formula
1059 \f[
1060 < \mathrm{InvpermFun}\, u, w > \,,
1061 \f]
1062 for \f$ u, w \in H(div, K) \f$ and \f$ \mathrm{InvpermFun} \f$ a real function.
1063 <BR>
1064 Weighted mass matrix with a permeability that is a scalar function. The inverse function
1065 of the permeability should be provided. We note again that it is the inverse of the
1066 permeability that is provided directly \f$ \mathrm{InvpermFun} = K^{-1} \f$.
1067 @param InvpermFun Scalar function inverse of the permeability.
1068 @param elmat Mixed element matrix.
1069 @param dualFE Current dual finite element in \f$ H(div, K) \f$.
1070 @param iblock Subarray index where to store the integral just computed.
1071 @param jblock Subarray index where to store the integral just computed.
1072 @note \f$ \mathrm{InvpermFun} \f$ is the inverse of the permeability function.
1073 */
1074 void mass_Hdiv ( Real ( *InvpermFun ) ( const Real&, const Real&, const Real& ),
1075  MatrixElemental& elmat, const CurrentFE& dualFE, int iblock = 0, int jblock = 0 );
1076 
1077 // Source vector for dual variable with constant vector source.
1078 /*!
1079 Compute the source vector in \f$ H(div, K ) \f$ with constant vector permeability, with \f$ K \f$ the
1080 current element. In formula
1081 \f[
1082 < g, w > \,,
1083 \f]
1084 for \f$ w \in H(div, K) \f$ and \f$ g \f$ a constant vector.
1085 <BR>
1086 @param source constant vector as the source.
1087 @param elvect element vector.
1088 @param dualFE Current dual finite element in \f$ H(div, K) \f$.
1089 @param iblock Subarray index where to store the integral just computed.
1090 */
1091 void source_Hdiv ( const Vector& source , VectorElemental& elvec, const CurrentFE& dualFE, int iblock = 0 );
1092 
1093 //!@}
1094 
1095 } // end namespace AssemblyElemental
1096 
1097 } // namespace LifeV
1098 #endif
void source_gradpv(Real alpha, VectorElemental &pLoc, VectorElemental &elvec, const CurrentFE &fe_p, const CurrentFE &fe_u, int iblock)
void grad_ss(const int icoor, const VectorElemental &vec_loc, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, int iblock, int jblock)
Convective term with a local vector coefficient for Navier-Stokes problem in Skew-Symmetric form...
void advection(Real coef, VectorElemental &vel, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, int nb)
void source(const UsrFct &fct, VectorElemental &elvec, const CurrentFE &fe, Real t, int iblock=0)
source
void interpolateGradient(localVector &localGradient, const CurrentFE &interpCFE, const UInt &spaceDim, const DOF &betaDof, const UInt &elementID, const globalVector &beta)
Interpolation of the gradient.
void source(Real constant, VectorElemental &elvec, const CurrentFE &fe, Real t, int iblock)
void stiff_curl(Real coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, int)
void mass(Real coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock)
coef(t,x,y,z,u)
void stiff_gradgrad(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void mass(MatrixElemental &localMass, const CurrentFE &massCFE, const Real &coefficient, const UInt &fieldDim)
Elementary mass for constant mass coefficient.
void stiff(Real coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, int nb)
void ipstab_bagrad(const Real coef, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const CurrentFE &fe3, const VectorElemental &beta, const CurrentFEManifold &bdfe, int iblock, int jblock)
p1 lives in fe1 q2 lives in fe2 beta lives in fe3
void cholsl(KNM< Real > &a, KN< Real > &p, KN< Real > &b, KN< Real > &x)
void source_advection(const Real &coefficient, const VectorElemental &beta_loc, const VectorElemental &uk_loc, VectorElemental &elvec, const CurrentFE &fe)
void ipstab_grad(const Real coef, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const CurrentFEManifold &bdfe, int iblock, int jblock, int nb)
void stiff_gradgradTr_gradbis_2(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void ipstab_bagrad(const Real coef, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const VectorElemental &beta, const CurrentFEManifold &bdfe, int iblock, int jblock)
A class for a finite element on a manifold.
void source_fhn(Real coef_f, Real coef_a, VectorElemental &u, VectorElemental &elvec, const CurrentFE &fe, int fblock, int eblock)
void mass(const std::vector< Real > &coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, UInt nb)
Mass term with coefficients given for each quadrature point.
void TP_VdotN_Hdiv(Real coef, MatrixElemental &elmat, const ReferenceFEHybrid &hybridFE, const ReferenceFEHybrid &dualDotNFE, int iblock, int jblock)
void source_mass2(Real coef, const VectorElemental &uk_loc, const VectorElemental &dw_loc, VectorElemental &elvec, const CurrentFE &fe)
for Newton FSI
void source_divuq(Real alpha, VectorElemental &uLoc, VectorElemental &elvec, const CurrentFE &fe_u, const CurrentFE &fe_p, int iblock)
void stiff_divgrad_2(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void stiff_sd(Real coef, const VectorElemental &vec_loc, MatrixElemental &elmat, const CurrentFE &fe, const CurrentFE &fe2, int iblock, int jblock, int nb)
StreamLine Diffusion.
void weightedMass(MatrixElemental &localMass, const CurrentFE &massCFE, const Real &coefficient, const localVector &localValues, const UInt &fieldDim)
Elementary weighted mass for constant mass coefficient.
void stiff_dergrad(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
for Newton on St-Venant
void stiff_div(Real coef, MatrixElemental &elmat, const CurrentFE &fe)
void stiff_dergradbis(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void grad(const int &icoor, const std::vector< Real > &localVector, MatrixElemental &elmat, const CurrentFE &currentFE1, const CurrentFE &currentFE2, const int &iblock, const int &jblock)
Conective term with a local vector given by quadrature node.
void stiff_dergrad_gradbis_Tr_2(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void advectionNewton(Real coef, VectorElemental &vel, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock)
Assemble the term .
void stiff(const std::vector< Real > &coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, int nb)
Stiff term with coefficient given for each quadrature node.
void shape_terms(Real rho, Real mu, const VectorElemental &un_loc, const VectorElemental &uk_loc, const VectorElemental &wk_loc, const VectorElemental &convect_loc, const VectorElemental &pk_loc, MatrixElemental &elmat, const CurrentFE &fe, const CurrentFE &fe_p, ID, MatrixElemental &, int, bool wImplicit, Real alpha, std::shared_ptr< MatrixElemental > elmat_convect)
Shape terms for the CE system in FSI Newton.
void ipstab_grad(const Real coef, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const CurrentFEManifold &bdfe, int iblock, int jblock)
boost::numeric::ublas::zero_matrix< Real > ZeroMatrix
void symmetrizedAdvection(MatrixElemental &localAdv, const CurrentFE &advCFE, const Real &coefficient, const localTensor &localGradient, const UInt &fieldDim)
Elementary advection, term u v.
void mass_Hdiv(Real coef, MatrixElemental &elmat, const CurrentFE &dualFE, int iblock, int jblock)
void stiff_gradgradTr_gradbis_3(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
UInt nbDiag() const
Getter for the diagonal entries in the pattern.
Definition: CurrentFE.hpp:407
void stab_stokes(Real visc, Real coef_stab, MatrixElemental &elmat, const CurrentFE &fe, int block_pres)
void source(const UsrFct &fct, VectorElemental &elvec, const CurrentFE &fe, int iblock=0)
source
void mass_divw(Real coef, const VectorElemental &w_loc, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, UInt nb)
void updateInverseJacobian(const UInt &iQuadPt)
void source(Real coef, VectorElemental &f, VectorElemental &elvec, const CurrentFE &fe, int fblock, int eblock)
void source_Hdiv(const Vector &source, VectorElemental &elvec, const CurrentFE &dualFE, int iblock)
void mass_Hdiv(Matrix const &Invperm, MatrixElemental &elmat, const CurrentFE &dualFE, int iblock, int jblock)
void stiff_dergrad_gradbis_2(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void source_mass1(Real coef, const VectorElemental &uk_loc, const VectorElemental &wk_loc, const VectorElemental &convect_loc, const VectorElemental &d_loc, VectorElemental &elvec, const CurrentFE &fe)
for Newton FSI
void grad_div(Real coef_grad, Real coef_div, MatrixElemental &elmat, const CurrentFE &fe_u, const CurrentFE &fe_p, int block_pres)
void grad(const int icoor, const VectorElemental &vec_loc, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, int iblock, int jblock)
Convective term with a local vector coefficient (useful for Navier-Stokes problem) ...
void interpolate(localVector &localValues, const CurrentFE &interpCFE, const UInt &spaceDim, const DOF &betaDof, const UInt &elementID, const globalVector &beta)
Interpolation procedure.
UInt nbLocalCoor() const
Getter for the number of local coordinates.
Definition: CurrentFE.hpp:425
void ipstab_bgrad(const Real coef, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const VectorElemental &beta, const CurrentFEManifold &bdfe, int iblock, int jblock, int nb)
void bodyForces(VectorElemental &localForce, const CurrentFE &massRhsCFE, const function_Type &fun, const Real &t, const UInt &fieldDim)
Real phiDer(UInt node, UInt derivative, UInt quadNode) const
Old accessor, use dphi instead.
Definition: CurrentFE.hpp:548
Real dphi(UInt node, UInt derivative, UInt quadNode) const
Getter for the derivatives of the basis functions.
Definition: CurrentFE.hpp:486
void advection(MatrixElemental &localAdv, const CurrentFE &advCFE, const Real &coefficient, const localVector &localValues, const UInt &fieldDim)
Elementary advection u v.
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
uint32_type ID
IDs.
Definition: LifeV.hpp:194
void mass(Real coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, UInt nb)
void coorQuadPt(Real &x, Real &y, Real &z, int ig) const
Definition: CurrentFE.hpp:710
void stiff_gradgrad_2(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void source_stiff(const std::vector< Real > &constant, VectorElemental &elvec, const CurrentFE &currentFe, const int &iblock)
Assembly for the source term where is a given by the values in the quadrature nodes.
void massDivW(MatrixElemental &localMass, const CurrentFE &massCFE, const Real &coefficient, const localVector &localValues, const UInt &fieldDim)
void grad(const int icoor, Real coef, MatrixElemental &elmat, const CurrentFE &fe_u, const CurrentFE &fe_p, int iblock, int jblock)
const ID & localToGlobalMap(const ID ElId, const ID localNode) const
Return the specified entries of the localToGlobal table.
Definition: DOF.hpp:195
void stiffStrain(MatrixElemental &localStiff, const CurrentFE &stiffCFE, const Real &coefficient, const UInt &fieldDim)
void stiff_strain(Real coef, MatrixElemental &elmat, const CurrentFE &fe)
void stiff_derdiv(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
for Newton on St-Venant
std::function< const Real(const Real &, const Real &, const Real &, const Real &, const ID &) > function_Type
Use the portable syntax of the boost function.
const UInt & numTotalDof() const
The total number of Dof.
Definition: DOF.hpp:177
void TP_TP_Hdiv(Real coef, MatrixElemental &elmat, const ReferenceFEHybrid &hybridFE, int iblock, int jblock)
void mass_Hdiv(Real(*InvpermFun)(const Real &, const Real &, const Real &), MatrixElemental &elmat, const CurrentFE &dualFE, int iblock, int jblock)
void stiff_gradgradTr_gradbis(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
double Real
Generic real data.
Definition: LifeV.hpp:175
CurrentFE - A primordial class for the assembly of the local matrices/vectors retaining the values on...
Definition: CurrentFE.hpp:243
void ipstab_div(const Real coef, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const CurrentFEManifold &bdfe, int iblock, int jblock)
void source_stress2(Real coef, const VectorElemental &uk_loc, const VectorElemental &d_loc, VectorElemental &elvec, const CurrentFE &fe_u)
MatrixElemental(UInt nNode1, UInt nbr1, UInt nbc1)
void interpolateDivergence(localVector &localDivergence, const CurrentFE &interpCFE, const DOF &betaDof, const UInt &elementID, const globalVector &beta)
Interpolation of the divergence.
UInt nbFEDof() const
Getter for the number of nodes.
Definition: CurrentFE.hpp:377
void divergence(MatrixElemental &elmat, const CurrentFE &uCFE, const CurrentFE &pCFE, const UInt &fieldDim, const Real &coefficient)
void div(const int icoor, Real coef, MatrixElemental &elmat, const CurrentFE &fe_u, const CurrentFE &fe_p, int iblock, int jblock)
Real wDetJacobian(UInt quadNode) const
Getter for the weighted jacobian determinant.
Definition: CurrentFE.hpp:458
const UInt nDimensions(NDIM)
void choldc(KNM< Real > &a, KN< Real > &p)
Real phi(UInt node, UInt quadNode) const
Getter for basis function values (scalar FE case)
Definition: CurrentFE.hpp:472
void source_press(Real coef, const VectorElemental &uk_loc, const VectorElemental &d_loc, VectorElemental &elvec, const CurrentFE &fe_u, const CurrentFE &fe_p, int iblock)
for Newton FSI
void stiff_dergrad_gradbis_Tr(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void source_press2(Real coef, const VectorElemental &p_loc, const VectorElemental &d_loc, VectorElemental &elvec, const CurrentFE &fe, int iblock)
void stiff(Real coef, Real(*fct)(Real, Real, Real), MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock)
void mass_divw(const std::vector< Real > &coef, const VectorElemental &w_loc, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, UInt nb)
Idem mass_divw , but with coefficient given by quadrature node.
void stiffness(MatrixElemental &localStiff, const CurrentFE &stiffCFE, const Real &coefficient, const UInt &fieldDim)
Elementary stiffness for constant coefficient.
void stiff_divgrad(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
void advection(Real coef, const UsrFct &beta, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock, int nb, Real t=0.)
void grad(const int icoor, const VectorElemental &vec_loc, MatrixElemental &elmat, const CurrentFE &fe1, const CurrentFE &fe2, const CurrentFE &fe3, int iblock, int jblock)
Convective term with a local vector coefficient (useful for Navier-Stokes problem+adv-diff) ...
Real weightDet(UInt quadNode) const
Old accessor, use wDetJacobian instead.
Definition: CurrentFE.hpp:527
void source_mass(const std::vector< Real > &constant, VectorElemental &elvec, const CurrentFE &currentFe, const int &iblock)
Assembly for the source term where is a given by the values in the quadrature nodes.
void source_stress(Real coef, Real mu, const VectorElemental &uk_loc, const VectorElemental &pk_loc, const VectorElemental &d_loc, VectorElemental &elvec, const CurrentFE &fe_u, const CurrentFE &fe_p)
for Newton FSI
void grad(MatrixElemental &elmat, const CurrentFE &uCFE, const CurrentFE &pCFE, const UInt &fieldDim)
void mass_gradu(Real coef, const VectorElemental &u0_loc, MatrixElemental &elmat, const CurrentFE &fe)
void grad_Hdiv(Real coef, MatrixElemental &elmat, const CurrentFE &dualFE, const CurrentFE &primalFE, int iblock, int jblock)
void div_Hdiv(Real coef, MatrixElemental &elmat, const CurrentFE &dualFE, const CurrentFE &primalFE, int iblock, int jblock)
void source(Real constant, VectorElemental &elvec, const CurrentFE &fe, int iblock)
UInt nbQuadPt() const
Getter for the number of quadrature nodes.
Definition: CurrentFE.hpp:365
void stiff(Real coef, MatrixElemental &elmat, const CurrentFE &fe, int iblock, int jblock)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void source_mass3(Real coef, const VectorElemental &un_loc, const VectorElemental &uk_loc, const VectorElemental &d_loc, VectorElemental &elvec, const CurrentFE &fe)
boost::numeric::ublas::matrix< Real > Matrix
void source_press(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe_u, const CurrentFE &fe_p, ID mmDim, int iblock)
for Newton FSI
void stiff_dergrad_gradbis(Real coef, const VectorElemental &uk_loc, MatrixElemental &elmat, const CurrentFE &fe)
Real quadPt(UInt node, UInt coordinate) const
Old accessor, use quadNode instead.
Definition: CurrentFE.hpp:520