XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Fem2p()

Sub Fem2p ( N As  Long,
Ne As  Long,
X() As  Double,
Y() As  Double,
Knc() As  Long,
P() As  Double,
Q() As  Double,
F() As  Double,
Nb1 As  Long,
Ib() As  Long,
Bv() As  Double,
Nb2 As  Long,
Ks2() As  Long,
Alpha() As  Double,
Beta() As  Double,
Val() As  Double,
Rowptr() As  Long,
Colind() As  Long,
B() As  Double,
Info As  Long,
Optional Base As  Long = 0 
)

Assemble finite element matrix of Poisson equation (2D) in CSR sparse matrix format [Experimental version]

Purpose
This routine assembles the finite element matrix of the generalized two dimensional Poisson equation as shown below.
-div(p(x,y) grad u(x,y)) + q(x,y)u(x,y) = f(x,y)
Dirichlet boundary condition: u(x,y) = g
Natural boundary condition: p(x,y)*du/dn + α(k,l)*u(x,y) + β(k,l) = 0
The output matrix is in CSR aparse matrix format.
Parameters
[in]NNumber of nodes. (N > 0)
[in]NeNumber of elements. (Ne > 0)
[in]X()Array X(LX - 1) (LX >= N)
X coordinates of the nodes.
[in]Y()Array Y(LY - 1) (LY >= N)
Y coordinates of the nodes.
[in]Knc()Array Knc(LKnc1 - 1, LKnc2 - 1) (LKnc1 >= Nn + 1, LKnc2 >= Ne)
Connection matrix: Knc(0, K-1) is the type of element K, Knc(1, K-1), ..., Knc(Nn, K-1) point to the nodes of element K (Nn is the number of nodes in the element).
The type of element value is as follows:
= 2: 3-node triangle.
= 3: 4-node quadrangle.
= 10: 9-node second order quadrangle.
[in]P()Array P(LP - 1) (LP >= N)
Coefficient p(x, y) at each node.
[in]Q()Array Q(LQ - 1) (LQ >= N)
Coefficient q(x, y) at each node.
[in]F()Array F(LF - 1) (LF >= N)
Coefficient f(x, y) at each node.
[in]Nb1Number of boundary nodes of the 1-st kind boundary condition. (Nb1 >= 0)
[in]Ib()Array Ib(LIb - 1) (LIb >= Nb1)
Node numbers of the boundary nodes of the first kind boundary conditions.
[in]Bv()Array Bv(LBv - 1) (LBv >= Nb1)
Boundary value at each boundary node.
[in]Nb2Number of boundary sides of the natural boundary conditions. (Nb2 >= 0)
[in]Ks2()Array Ks2(LKs21 - 1, LKs22 - 1) (LKs21 >= Nns + 1, LKs22 >= Nb2)
Connection matrix of boundary sides: Ks2(0, K-1) is the type of boundary element K, Ks(1, K-1), ..., Ks(Nns, K-1) point to the nodes of boundary element K of the natural boundary conditions (Nns is the number of nodes in the boundary element).
The type of element value is as follows:
= 1: 2-node line element.
= 8: 3-node second order line element.
[in]Alpha()Array Alpha(LAlpha1 - 1, LAlpha2 - 1) (LAlpha1 >= Nns, LAlpha2 >= Nb2)
Coefficient alpha of the natural boundary condition at the boundary node.
[in]Beta()Array Beta(LBeta1 - 1, LBeta2 - 1) (LBeta1 >= Nns, LBeta2 >= Nb2)
Coefficient beta of the natural boundary condition at the boundary node.
[out]Val()Array Val(LVal - 1) (LVal >= Nnz (Nnz must be severalfold larger than the actual number of non-zero elements of assembled coefficient matrix of the finite element equation))
Assembled coefficient matrix of the finite element equation (values).
[out]Rowptr()Array Rowptr(LRowptr - 1) As Long (LRowptr >= N + 1)
Assembled coefficient matrix of the finite element equation (pointers).
[out]Colind()Array Colind(LColind - 1) As Long (LColind >= Nnz)
Assembled coefficient matrix of the finite element equation (column indices).
[out]B()Array B(LB - 1) (LB >= N)
Right-hand side vector of the finite element equation.
[out]InfoReturn code.
= 0: Successful exit.
= i < 0: The (-i)-th argument is invalid or has an illegal value.
= 11: Invalid element type in Knc().
= 12: Area of a triangular element is zero or negative.
= 13: Invalid boundary element type in Ks2().
= 14: Invalid node number in Ks2().
= 16: Insufficient size of Val() and/or Colind().
= 17: Internal error occurred in assembling matrix.
[in]Base(Optional)
Indexing of Rowind() and Colind(). (default = 0)
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1.