LifeV
ADRAssembler< mesh_type, matrix_type, vector_type > Class Template Reference

ADRAssembler - This class add into given matrices terms corresponding to the space discretization of the ADR problem. More...

#include <ADRAssembler.hpp>

+ Collaboration diagram for ADRAssembler< mesh_type, matrix_type, vector_type >:

Private Types

typedef CurrentFE currentFE_type
 
typedef std::unique_ptr< currentFE_typecurrentFE_ptrType
 
typedef MatrixElemental localMatrix_type
 
typedef std::unique_ptr< localMatrix_typelocalMatrix_ptrType
 
typedef VectorElemental localVector_type
 
typedef std::unique_ptr< localVector_typelocalVector_ptrType
 

Private Attributes

fespace_ptrType M_fespace
 
fespace_ptrType M_betaFESpace
 
currentFE_ptrType M_massCFE
 
currentFE_ptrType M_diffCFE
 
currentFE_ptrType M_advCFE
 
currentFE_ptrType M_advBetaCFE
 
currentFE_ptrType M_massRhsCFE
 
localMatrix_ptrType M_localMass
 
localMatrix_ptrType M_localAdv
 
localMatrix_ptrType M_localDiff
 
localVector_ptrType M_localMassRhs
 
chrono_type M_diffusionAssemblyChrono
 
chrono_type M_advectionAssemblyChrono
 
chrono_type M_massAssemblyChrono
 
chrono_type M_setupChrono
 
chrono_type M_massRhsAssemblyChrono
 

Public Types

typedef MapEpetra map_Type
 
typedef FESpace< mesh_type, map_Typefespace_type
 
typedef std::shared_ptr< fespace_typefespace_ptrType
 
typedef std::shared_ptr< matrix_typematrix_ptrType
 
typedef LifeChrono chrono_type
 
typedef std::function< Real(const Real &, const Real &, const Real &, const Real &, const ID &) > function_type
 

Constructor & Destructor

 ADRAssembler ()
 Empty Constructor. More...
 
virtual ~ADRAssembler ()
 Destructor. More...
 

Methods

void setup (const fespace_ptrType &fespace, const fespace_ptrType &betaFESpace)
 Setup for the class (fill the members) More...
 
void addMass (matrix_ptrType matrix, const Real &coefficient=1.0)
 Assembling for the mass. More...
 
void addMass (matrix_ptrType matrix, const Real &coefficient, const UInt &offsetLeft, const UInt &offsetUp)
 Assembling for the mass using offsets. More...
 
void addAdvection (matrix_ptrType matrix, const vector_type &beta)
 Assembling for the advection. More...
 
void addAdvection (matrix_ptrType matrix, const vector_type &beta, const UInt &offsetLeft, const UInt &offsetUp)
 Assembling for the advection using offsets. More...
 
void addDiffusion (matrix_ptrType matrix, const Real &coefficient=1.0)
 Assembling for the diffusion. More...
 
void addDiffusion (matrix_ptrType matrix, const Real &coefficient, const UInt &offsetLeft, const UInt &offsetUp)
 Assembling for the diffusion using offsets. More...
 
void addStiffStrain (matrix_ptrType &matrix, const Real &coefficient=1.0)
 Add the stiff strain in the standard block. More...
 
void addStiffStrain (matrix_ptrType &matrix, const Real &coefficient, const UInt &offsetLeft, const UInt &offsetUp)
 Add the stiff strain using the given offsets. More...
 
void addMassRhs (vector_type &rhs, const vector_type &f)
 Assembly for the right hand side (mass) with f given in vectorial form. More...
 
void addMassRhs (vector_type &rhs, const function_type &f, const Real &t)
 Assembly for the right hand side (mass) with f given in functional form. More...
 

Set Methods

void setFespace (const fespace_ptrType &fespace)
 Setter for the finite element space used for the unknown (reset the quadratures as well!) More...
 
void setBetaFespace (const fespace_ptrType &betaFESpace)
 Setter for the finite element space used for the advection field (reset the quadratures as well!) More...
 
void setQuadRuleForMassMatrix (const QuadratureRule &qr)
 Setter for the quadrature used for the mass matrix. More...
 
void setQuadRuleForDiffusionMatrix (const QuadratureRule &qr)
 Setter for the quadrature used for the diffusion matrix. More...
 
void setQuadRuleForAdvectionMatrix (const QuadratureRule &qr)
 Setter for the quadrature used for the advection matrix. More...
 
void setQuadRuleForMassRhs (const QuadratureRule &qr)
 Setter for the quadrature used for the right hand side. More...
 

Get Methods

chrono_typemassAssemblyChrono ()
 Getter for the chrono of the assembly of the mass term. More...
 
chrono_typeadvectionAssemblyChrono ()
 Getter for the chrono of the assembly of the advection term. More...
 
chrono_typediffusionAssemblyChrono ()
 Getter for the chrono of the assembly of the diffusion term. More...
 
chrono_typesetupChrono ()
 Getter for the chrono of the setup of the assembler. More...
 
chrono_typemassRhsAssemblyChrono ()
 Getter for the chrono of the assembly of the rhs (mass) More...
 

Private Methods

 ADRAssembler (const ADRAssembler &)
 

Detailed Description

template<typename mesh_type, typename matrix_type, typename vector_type>
class LifeV::ADRAssembler< mesh_type, matrix_type, vector_type >

ADRAssembler - This class add into given matrices terms corresponding to the space discretization of the ADR problem.

Scope

This class has been designed for assembling the terms arising from the space discretization with finite elements of the advection-diffusion-reaction problem, i.e. of the PDE

$ - \alpha \Delta u + \beta \cdot \nabla u + \sigma u = f $

where $\alpha$ and $\sigma$ are constants, $\beta$ a vectorial field.

Time discretization of the parabolic version of this equation is not in the scope of this assembler (it is usually not a finite element discretization) and has to be treated outside of the class.

This class is also not supposed to provide any stabilization for the discretization.

Good Practice

Here is the way this class is intended to be used. First, one should define the assembler. Only the empty constructor is available, so there is no choice.

ADRAssembler<mesh_type,matrix_type,vector_type> myAssembler;

Then, one should setup the assembler by providing the finite element spaces required, namely the space for the unknown and the space where the advection field $\beta$ is defined

std::shared_ptr<FESpace< mesh_type, MapEpetra > > uFESpace( new FESpace< mesh_type, MapEpetra >( ... ));
std::shared_ptr<FESpace< mesh_type, MapEpetra > > betaFESpace( new FESpace< mesh_type, MapEpetra >( ... ));
myAssembler.setup(uFESpace,betaFESpace);

When this setup method is used, the quadrature rules are set as the one stored in the FESpace of the unknown. One should then change them if one wants to have a more precise or a faster assembly (usually, the default quadrature is too precise for diffusion and the advection terms, so one should consider this option to make the assembly faster without affecting the results).

myAssembler.setQuadRuleForDiffusionMatrix( ... );
myAssembler.setQuadRuleForAdvectionMatrix( ... );

Now that everything has been set up, one can assemble the terms:

std::shared_ptr<matrix_type> systemMatrix(new matrix_type( uFESpace->map() ));
*systemMatrix*=0.0;
myAssembler.addDiffusion(systemMatrix,4.0);
myAssembler.addMass(systemMatrix);

These two last lines have added the required terms into the matrix. Here one should be aware that the matrix is NOT finalized after the assembly of any of the terms. Therefore, before passing the matrix to a linear solver (and before applying boundary conditions), one should close the matrix using

systemMatrix->GlobalAssemble();

Remarks

  1. Changing the quadratures of the assembler is in many case a good idea. However, try to avoid calling the setters for the quadratures when it is not necessary, as these methods change some internal containers and are then more expensive than "simple setters".
  2. In case the FESpace for the unknown is vectorial (and not scalar), the problem is assembled for each component of the FESpace.
  3. The matrices assembled are NOT stored in this class, so calling twice the same assembly method will not make it faster. If your code calles repeatedly the assembly procedures, consider storing the matrices outside the class.

Troubleshooting

Empty FE Space cannot setup the ADR assembler You are passing a nul pointer as FE Space in the setup method.

Empty beta FE Space cannot setup the ADR assembler You are passing a nul pointer as FE Space for the advection field in the setup method.

Setting the FE space for the unknown to 0 is not permitted You are passing a nul pointer as FE Space in the setFespace method.

No FE space for the unknown! Use setFespace before setBetaFespace! You are trying to use the method setBetaFespace before having set the FE space for the unknown.

No FE space for assembling the mass! You are trying to use the addMass method without having set a FE Space for the unknown. Use the setup or the setFespace methods before calling addMass.

No FE space for assembling the advection! You are trying to use the addAdvection method without having set a FE Space for the unknown. Use the setup or the setFespace methods before calling addAdvection.

No FE space for assembling the diffusion! You are trying to use the addDiffusion method without having set a FE Space for the unknown. Use the setup or the setFespace methods before calling addDiffusion.

No FE space (beta) for assembling the advection! You are trying to add advection without having set the FE space for the advection field. Use the setup of the setBetaFespace methods before calling addAdvection.

Author
Samuel Quinodoz
Version
1.1

Definition at line 166 of file ADRAssembler.hpp.

Member Typedef Documentation

◆ map_Type

Definition at line 173 of file ADRAssembler.hpp.

◆ fespace_type

Definition at line 175 of file ADRAssembler.hpp.

◆ fespace_ptrType

typedef std::shared_ptr<fespace_type> fespace_ptrType

Definition at line 176 of file ADRAssembler.hpp.

◆ matrix_ptrType

typedef std::shared_ptr<matrix_type> matrix_ptrType

Definition at line 178 of file ADRAssembler.hpp.

◆ chrono_type

Definition at line 180 of file ADRAssembler.hpp.

◆ function_type

typedef std::function<Real (const Real&, const Real&, const Real&, const Real&, const ID&) > function_type

Definition at line 183 of file ADRAssembler.hpp.

◆ currentFE_type

typedef CurrentFE currentFE_type
private

Definition at line 404 of file ADRAssembler.hpp.

◆ currentFE_ptrType

typedef std::unique_ptr<currentFE_type> currentFE_ptrType
private

Definition at line 405 of file ADRAssembler.hpp.

◆ localMatrix_type

Definition at line 407 of file ADRAssembler.hpp.

◆ localMatrix_ptrType

typedef std::unique_ptr<localMatrix_type> localMatrix_ptrType
private

Definition at line 408 of file ADRAssembler.hpp.

◆ localVector_type

Definition at line 410 of file ADRAssembler.hpp.

◆ localVector_ptrType

typedef std::unique_ptr<localVector_type> localVector_ptrType
private

Definition at line 411 of file ADRAssembler.hpp.

Constructor & Destructor Documentation

◆ ADRAssembler() [1/2]

Empty Constructor.

Definition at line 468 of file ADRAssembler.hpp.

◆ ~ADRAssembler()

virtual ~ADRAssembler ( )
inlinevirtual

Destructor.

Definition at line 195 of file ADRAssembler.hpp.

◆ ADRAssembler() [2/2]

Member Function Documentation

◆ setup()

void setup ( const fespace_ptrType fespace,
const fespace_ptrType betaFESpace 
)

Setup for the class (fill the members)

This method can be called either when the class is empty or when is already (partially) setup. It changes the internal containers to fit with the FESpace given in argument. All the quadrature rules are overriden by the one given in fespace.

Parameters
fespaceThe FESpace for the unknown
betaFESpaceThe FESpace for the advection field
Remarks
Nul pointers cannot be passed to this method. Use a more specific setter if you want to do that.

Definition at line 498 of file ADRAssembler.hpp.

◆ addMass() [1/2]

void addMass ( matrix_ptrType  matrix,
const Real coefficient = 1.0 
)
inline

Assembling for the mass.

This method adds the mass matrix times the coefficient (whose default value is 1.0) to the matrix passed in argument. The matrix is NOT finalized, you have to call globalAssemble outside this method when the matrix is finished.

Definition at line 223 of file ADRAssembler.hpp.

◆ addMass() [2/2]

void addMass ( matrix_ptrType  matrix,
const Real coefficient,
const UInt offsetLeft,
const UInt offsetUp 
)

Assembling for the mass using offsets.

This method adds the mass in the given matrix. Additional arguements are provided so that one can chose where to add the mass in the matrix, i.e. somewhere else than in the upper left block.

Definition at line 518 of file ADRAssembler.hpp.

◆ addAdvection() [1/2]

void addAdvection ( matrix_ptrType  matrix,
const vector_type beta 
)
inline

Assembling for the advection.

This method adds the advection (with respect to the given vector field) matrix to the matrix passed in argument. beta represents a finite element function with the beta FE space of this assembler. The matrix is NOT finalized, you have to call globalAssemble outside this method when the matrix is finished.

Definition at line 245 of file ADRAssembler.hpp.

◆ addAdvection() [2/2]

void addAdvection ( matrix_ptrType  matrix,
const vector_type beta,
const UInt offsetLeft,
const UInt offsetUp 
)

Assembling for the advection using offsets.

This method adds the advection in the given matrix. Additional arguements are provided so that one can chose where to add the mass in the matrix, i.e. somewhere else than in the upper left block.

Definition at line 563 of file ADRAssembler.hpp.

◆ addDiffusion() [1/2]

void addDiffusion ( matrix_ptrType  matrix,
const Real coefficient = 1.0 
)
inline

Assembling for the diffusion.

This method adds the diffusion matrix times the coefficient (whose default value is 1.0) to the matrix passed in argument. The matrix is NOT finalized, you have to call globalAssemble outside this method when the matrix is finished.

Definition at line 265 of file ADRAssembler.hpp.

◆ addDiffusion() [2/2]

void addDiffusion ( matrix_ptrType  matrix,
const Real coefficient,
const UInt offsetLeft,
const UInt offsetUp 
)

Assembling for the diffusion using offsets.

This method adds the diffusion in the given matrix. Additional arguements are provided so that one can chose where to add the mass in the matrix, i.e. somewhere else than in the upper left block.

Definition at line 626 of file ADRAssembler.hpp.

◆ addStiffStrain() [1/2]

void addStiffStrain ( matrix_ptrType matrix,
const Real coefficient = 1.0 
)
inline

Add the stiff strain in the standard block.

Definition at line 279 of file ADRAssembler.hpp.

◆ addStiffStrain() [2/2]

void addStiffStrain ( matrix_ptrType matrix,
const Real coefficient,
const UInt offsetLeft,
const UInt offsetUp 
)

Add the stiff strain using the given offsets.

Definition at line 670 of file ADRAssembler.hpp.

◆ addMassRhs() [1/2]

void addMassRhs ( vector_type rhs,
const vector_type f 
)

Assembly for the right hand side (mass) with f given in vectorial form.

This method assembles the right hand side for the ADR problem where the forcing term is given in the FE space of the unknown.

Definition at line 718 of file ADRAssembler.hpp.

◆ addMassRhs() [2/2]

void addMassRhs ( vector_type rhs,
const function_type f,
const Real t 
)

Assembly for the right hand side (mass) with f given in functional form.

This method assembles the right hand side for the ADR problem where f is given as a function of space and time (t,x,y,z,component)

Definition at line 806 of file ADRAssembler.hpp.

◆ setFespace()

void setFespace ( const fespace_ptrType fespace)

Setter for the finite element space used for the unknown (reset the quadratures as well!)

Definition at line 889 of file ADRAssembler.hpp.

◆ setBetaFespace()

void setBetaFespace ( const fespace_ptrType betaFESpace)

Setter for the finite element space used for the advection field (reset the quadratures as well!)

Beware that a FE space for the unknown has to be set before calling this method.

Definition at line 917 of file ADRAssembler.hpp.

◆ setQuadRuleForMassMatrix()

void setQuadRuleForMassMatrix ( const QuadratureRule qr)
inline

Setter for the quadrature used for the mass matrix.

Beware that calling this function might be quite heavy, so avoid using it when it is not necessary.

Definition at line 322 of file ADRAssembler.hpp.

◆ setQuadRuleForDiffusionMatrix()

void setQuadRuleForDiffusionMatrix ( const QuadratureRule qr)
inline

Setter for the quadrature used for the diffusion matrix.

Beware that calling this function might be quite heavy, so avoid using it when it is not necessary.

Definition at line 333 of file ADRAssembler.hpp.

◆ setQuadRuleForAdvectionMatrix()

void setQuadRuleForAdvectionMatrix ( const QuadratureRule qr)
inline

Setter for the quadrature used for the advection matrix.

Beware that calling this function might be quite heavy, so avoid using it when it is not necessary.

Definition at line 344 of file ADRAssembler.hpp.

◆ setQuadRuleForMassRhs()

void setQuadRuleForMassRhs ( const QuadratureRule qr)
inline

Setter for the quadrature used for the right hand side.

Beware that calling this function might be quite heavy, so avoid using it when it is not necessary.

Definition at line 357 of file ADRAssembler.hpp.

◆ massAssemblyChrono()

chrono_type& massAssemblyChrono ( )
inline

Getter for the chrono of the assembly of the mass term.

Definition at line 370 of file ADRAssembler.hpp.

◆ advectionAssemblyChrono()

chrono_type& advectionAssemblyChrono ( )
inline

Getter for the chrono of the assembly of the advection term.

Definition at line 376 of file ADRAssembler.hpp.

◆ diffusionAssemblyChrono()

chrono_type& diffusionAssemblyChrono ( )
inline

Getter for the chrono of the assembly of the diffusion term.

Definition at line 382 of file ADRAssembler.hpp.

◆ setupChrono()

chrono_type& setupChrono ( )
inline

Getter for the chrono of the setup of the assembler.

Definition at line 388 of file ADRAssembler.hpp.

◆ massRhsAssemblyChrono()

chrono_type& massRhsAssemblyChrono ( )
inline

Getter for the chrono of the assembly of the rhs (mass)

Definition at line 394 of file ADRAssembler.hpp.

Field Documentation

◆ M_fespace

fespace_ptrType M_fespace
private

Definition at line 422 of file ADRAssembler.hpp.

◆ M_betaFESpace

fespace_ptrType M_betaFESpace
private

Definition at line 425 of file ADRAssembler.hpp.

◆ M_massCFE

currentFE_ptrType M_massCFE
private

Definition at line 428 of file ADRAssembler.hpp.

◆ M_diffCFE

currentFE_ptrType M_diffCFE
private

Definition at line 431 of file ADRAssembler.hpp.

◆ M_advCFE

currentFE_ptrType M_advCFE
private

Definition at line 434 of file ADRAssembler.hpp.

◆ M_advBetaCFE

currentFE_ptrType M_advBetaCFE
private

Definition at line 437 of file ADRAssembler.hpp.

◆ M_massRhsCFE

currentFE_ptrType M_massRhsCFE
private

Definition at line 440 of file ADRAssembler.hpp.

◆ M_localMass

localMatrix_ptrType M_localMass
private

Definition at line 444 of file ADRAssembler.hpp.

◆ M_localAdv

localMatrix_ptrType M_localAdv
private

Definition at line 447 of file ADRAssembler.hpp.

◆ M_localDiff

localMatrix_ptrType M_localDiff
private

Definition at line 450 of file ADRAssembler.hpp.

◆ M_localMassRhs

localVector_ptrType M_localMassRhs
private

Definition at line 453 of file ADRAssembler.hpp.

◆ M_diffusionAssemblyChrono

chrono_type M_diffusionAssemblyChrono
private

Definition at line 456 of file ADRAssembler.hpp.

◆ M_advectionAssemblyChrono

chrono_type M_advectionAssemblyChrono
private

Definition at line 457 of file ADRAssembler.hpp.

◆ M_massAssemblyChrono

chrono_type M_massAssemblyChrono
private

Definition at line 458 of file ADRAssembler.hpp.

◆ M_setupChrono

chrono_type M_setupChrono
private

Definition at line 459 of file ADRAssembler.hpp.

◆ M_massRhsAssemblyChrono

chrono_type M_massRhsAssemblyChrono
private

Definition at line 460 of file ADRAssembler.hpp.


The documentation for this class was generated from the following file: