To build and solve the linear system for the Poisson problem using the DG P1 2-D triangle element. More...

#include <LaplaceDG2DP1.h>

Inheritance diagram for LaplaceDG2DP1:
DG Equation< 3, 3, 2, 2 > Equa

Public Member Functions

 LaplaceDG2DP1 (Mesh &ms, Vect< real_t > &f, Vect< real_t > &Dbc, Vect< real_t > &Nbc, Vect< real_t > &u)
 Constructor with mesh and vector data.
 
 ~LaplaceDG2DP1 ()
 Destructor.
 
void set (real_t sigma, real_t eps)
 Set parameters for the DG method.
 
void set (const LocalMatrix< real_t, 2, 2 > &K)
 Set diffusivity matrix.
 
void build ()
 Build global matrix and right-hand side.
 
void Smooth (Vect< real_t > &u)
 Perform post calculations.
 
int run ()
 Build and solve the linear system of equations using an iterative method.
 
- Public Member Functions inherited from DG
 DG (Mesh &ms, size_t degree=1)
 Constructor with mesh and degree of the method.
 
 ~DG ()
 Destructor.
 
int setGraph ()
 Set matrix graph.
 
- Public Member Functions inherited from Equation< 3, 3, 2, 2 >
 Equation ()
 
 Equation (Mesh &mesh)
 Constructor with mesh instance.
 
 Equation (Mesh &mesh, Vect< real_t > &u)
 Constructor with mesh instance and solution vector.
 
 Equation (Mesh &mesh, Vect< real_t > &u, real_t &init_time, real_t &final_time, real_t &time_step)
 Constructor with mesh instance, matrix and right-hand side.
 
 ~Equation ()
 Destructor.
 
void updateBC (const Element &el, const Vect< real_t > &bc)
 Update Right-Hand side by taking into account essential boundary conditions.
 
void DiagBC (DOFSupport dof_type=NODE_DOF, int dof=0)
 Update element matrix to impose bc by diagonalization technique.
 
void LocalNodeVector (Vect< real_t > &b)
 Localize element vector from a Vect instance.
 
void ElementNodeVector (const Vect< real_t > &b, LocalVect< real_t, NEE_ > &be)
 Localize element vector from a Vect instance.
 
void ElementNodeVector (const Vect< real_t > &b, LocalVect< real_t, NEN_ > &be, int dof)
 Localize Element Vector from a Vect instance.
 
void SideNodeVector (const Vect< real_t > &b, LocalVect< real_t, NSE_ > &bs)
 Localize side vector from a Vect instance.
 
void SideSideVector (const Vect< real_t > &b, vector< real_t > &bs)
 Localize side vector from a Vect instance.
 
void ElementNodeVectorSingleDOF (const Vect< real_t > &b, LocalVect< real_t, NEN_ > &be)
 Localize Element Vector from a Vect instance.
 
void ElementSideVector (const Vect< real_t > &b, LocalVect< real_t, NSE_ > &be)
 Localize Element Vector from a Vect instance.
 
void ElementVector (const Vect< real_t > &b, DOFSupport dof_type=NODE_DOF, int flag=0)
 Localize element vector.
 
void SideVector (const Vect< real_t > &b, vector< real_t > &sb)
 Localize side vector.
 
void ElementNodeCoordinates ()
 Localize coordinates of element nodes.
 
void SideNodeCoordinates ()
 Localize coordinates of side nodes.
 
void ElementAssembly (Matrix< real_t > *A)
 Assemble element matrix into global one.
 
void ElementAssembly (BMatrix< real_t > &A)
 Assemble element matrix into global one.
 
void ElementAssembly (SkSMatrix< real_t > &A)
 Assemble element matrix into global one.
 
void ElementAssembly (SkMatrix< real_t > &A)
 Assemble element matrix into global one.
 
void ElementAssembly (SpMatrix< real_t > &A)
 Assemble element matrix into global one.
 
void ElementAssembly (TrMatrix< real_t > &A)
 Assemble element matrix into global one.
 
void ElementAssembly (Vect< real_t > &v)
 Assemble element vector into global one.
 
void DGElementAssembly (Matrix< real_t > *A)
 Assemble element matrix into global one for the Discontinuous Galerkin approximation.
 
void DGElementAssembly (SkSMatrix< real_t > &A)
 Assemble element matrix into global one for the Discontinuous Galerkin approximation.
 
void DGElementAssembly (SkMatrix< real_t > &A)
 Assemble element matrix into global one for the Discontinuous Galerkin approximation.
 
void DGElementAssembly (SpMatrix< real_t > &A)
 Assemble element matrix into global one for the Discontinuous Galerkin approximation.
 
void DGElementAssembly (TrMatrix< real_t > &A)
 Assemble element matrix into global one for the Discontinuous Galerkin approximation.
 
void SideAssembly (Matrix< real_t > *A)
 Assemble side (edge or face) matrix into global one.
 
void SideAssembly (SkSMatrix< real_t > &A)
 Assemble side (edge or face) matrix into global one.
 
void SideAssembly (SkMatrix< real_t > &A)
 Assemble side (edge or face) matrix into global one.
 
void SideAssembly (SpMatrix< real_t > &A)
 Assemble side (edge or face) matrix into global one.
 
void SideAssembly (Vect< real_t > &v)
 Assemble side (edge or face) vector into global one.
 
void AxbAssembly (const Element &el, const Vect< real_t > &x, Vect< real_t > &b)
 Assemble product of element matrix by element vector into global vector.
 
void AxbAssembly (const Side &sd, const Vect< real_t > &x, Vect< real_t > &b)
 Assemble product of side matrix by side vector into global vector.
 
size_t getNbNodes () const
 Return number of element nodes.
 
size_t getNbEq () const
 Return number of element equations.
 
real_t setMaterialProperty (const string &exp, const string &prop)
 Define a material property by an algebraic expression.
 
- Public Member Functions inherited from Equa
 Equa ()
 Default constructor.
 
virtual ~Equa ()
 Destructor.
 
void setMesh (Mesh &m)
 Define mesh and renumber DOFs after removing imposed ones.
 
MeshgetMesh () const
 Return reference to Mesh instance.
 
LinearSolvergetLinearSolver ()
 Return reference to linear solver instance.
 
Matrix< real_t > * getMatrix () const
 Return pointer to matrix.
 
void setSolver (Iteration ls, Preconditioner pc=IDENT_PREC)
 Choose solver for the linear system.
 
void setMatrixType (int t)
 Choose type of matrix.
 
int solveLinearSystem (Matrix< real_t > *A, Vect< real_t > &b, Vect< real_t > &x)
 Solve the linear system with given matrix and right-hand side.
 
int solveLinearSystem (Vect< real_t > &b, Vect< real_t > &x)
 Solve the linear system with given right-hand side.
 
void LinearSystemInfo ()
 Print info on linear system solver.
 

Detailed Description

To build and solve the linear system for the Poisson problem using the DG P1 2-D triangle element.

This class build the linear system of equations for a standard elliptic equation using the Discontinuous Galerkin P1 finite element method.

Author
Rachid Touzani

Constructor & Destructor Documentation

◆ LaplaceDG2DP1()

LaplaceDG2DP1 ( Mesh ms,
Vect< real_t > &  f,
Vect< real_t > &  Dbc,
Vect< real_t > &  Nbc,
Vect< real_t > &  u 
)

Constructor with mesh and vector data.

Parameters
[in]msMesh instance
[in]fVector containing the right-hand side of the elliptic equation at triangle vertices
[in]DbcVector containing prescribed values of the solution (Dirichlet boundary condition) at nodes having a positive code
[in]NbcVector containing prescribed values of the flux (Neumann boundary condition) at each side having a positive code
[in]uVector where the solution is stored once the linear system is solved

Member Function Documentation

◆ build()

void build ( )

Build global matrix and right-hand side.

The problem matrix and right-hand side are the ones used in the constructor. They are updated in this member function.

◆ run()

int run ( )

Build and solve the linear system of equations using an iterative method.

The matrix is preconditioned by the diagonal ILU method. The linear system is solved either by the Conjugate Gradient method if the matrix is symmetric positive definite (eps=-1) or the GMRES method if not. The solution is stored in the vector u given in the constructor.

Returns
Number of performed iterations. Note that the maximal number is 1000 and the tolerance is 1.e-8

◆ set() [1/2]

void set ( const LocalMatrix< real_t, 2, 2 > &  K)

Set diffusivity matrix.

This function provides the diffusivity matrix as instance of class LocalMatrix. The default diffusivity matrix is the identity matrix

Parameters
[in]KDiffusivity matrix

◆ set() [2/2]

void set ( real_t  sigma,
real_t  eps 
)

Set parameters for the DG method.

Parameters
[in]sigmaPenalty parameters to enforce continuity at nodes (Must be positive) [Default: 100]
[in]epsEpsilon value of the DG method to choose among the values:
  • 0 Incomplete Interior Penalty Galerkin method (IIPG)
  • -1 Symmetric Interior Penalty Galerkin method (SIPG)
  • 1 Non symmetric interior penalty Galerkin method (NIPG)
For a user not familiar with the method, please choose the value of eps=-1 and sigma>100 which leads to a symmetric positive definite matrix [Default: -1]

◆ Smooth()

void Smooth ( Vect< real_t > &  u)

Perform post calculations.

This function gives an averaged solution given at mesh nodes (triangle vertices) by a standard L2-projection method.

Parameters
[in]uSolution at nodes