incidence_matrices.py

Building incidence matrices, \mathsf{E}_{(\nabla)}, \mathsf{E}_{(\nabla\times)} and \mathsf{E}_{(\nabla\cdot)} in the 3d reference domain \Omega_{\mathrm{ref}}=\left[-1,1\right]^3. We build them through the local numberings which are also implemented here in this script.

⭕ To access the source code, click on the [source] button at the right side or click on [incidence_matrices.py]. Dependence may exist. In case of error, check import and install required packages or download required scripts. © mathischeap.com

incidence_matrices.E_curl(N_xi, N_et, N_sg)[source]

The incidence matrix \mathsf{E}_{(\nabla\times)} for mimetic polynomials constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A csc_matrix \mathsf{E}_{(\nabla\times)}.

Example:

>>> E = E_curl(1,1,1)
>>> E.toarray()
array([[ 0,  0,  0,  0,  1,  0, -1,  0, -1,  0,  1,  0],
       [ 0,  0,  0,  0,  0,  1,  0, -1,  0, -1,  0,  1],
       [-1,  0,  1,  0,  0,  0,  0,  0,  1, -1,  0,  0],
       [ 0, -1,  0,  1,  0,  0,  0,  0,  0,  0,  1, -1],
       [ 1, -1,  0,  0, -1,  1,  0,  0,  0,  0,  0,  0],
       [ 0,  0,  1, -1,  0,  0, -1,  1,  0,  0,  0,  0]], dtype=int32)
incidence_matrices.E_div(N_xi, N_et, N_sg)[source]

The incidence matrix \mathsf{E}_{(\nabla\cdot)} for mimetic polynomials constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A csc_matrix \mathsf{E}_{(\nabla\cdot)}.

Example:

>>> E = E_div(1,1,1)
>>> E.toarray()
array([[-1,  1, -1,  1, -1,  1]], dtype=int32)
incidence_matrices.E_grad(N_xi, N_et, N_sg)[source]

The incidence matrix \mathsf{E}_{(\nabla)} for mimetic polynomials constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A csc_matrix \mathsf{E}_{(\nabla)}.

Example:

>>> E = E_grad(1,1,1)
>>> E.toarray()
array([[-1,  1,  0,  0,  0,  0,  0,  0],
       [ 0,  0, -1,  1,  0,  0,  0,  0],
       [ 0,  0,  0,  0, -1,  1,  0,  0],
       [ 0,  0,  0,  0,  0,  0, -1,  1],
       [-1,  0,  1,  0,  0,  0,  0,  0],
       [ 0, -1,  0,  1,  0,  0,  0,  0],
       [ 0,  0,  0,  0, -1,  0,  1,  0],
       [ 0,  0,  0,  0,  0, -1,  0,  1],
       [-1,  0,  0,  0,  1,  0,  0,  0],
       [ 0, -1,  0,  0,  0,  1,  0,  0],
       [ 0,  0, -1,  0,  0,  0,  1,  0],
       [ 0,  0,  0, -1,  0,  0,  0,  1]], dtype=int32)
incidence_matrices.local_numbering_EP(N_xi, N_et, N_sg)[source]

Generating the local numbering for a vector of 3D edge polynomials in \text{EP}_{N-1}(\Omega_{\mathrm{ref}}) constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A tuple of three outputs:

  1. A 3d np.array contain the local numbering for the first

    componement of the vector. Its three dimensions refer to three axes \left(\xi,\eta, \varsigma\right).

  2. A 3d np.array contain the local numbering for the second

    componement of the vector. Its three dimensions refer to three axes \left(\xi,\eta, \varsigma\right).

  3. A 3d np.array contain the local numbering for the third

    componement of the vector. Its three dimensions refer to three axes \left(\xi,\eta, \varsigma\right).

Example:

>>> ln0, ln1, ln2 = local_numbering_EP(2,2,2)
>>> ln0[:,:,0]
array([[0, 2, 4],
       [1, 3, 5]])
>>> ln0[:,:,1]
array([[ 6,  8, 10],
       [ 7,  9, 11]])
>>> ln0[:,:,2]
array([[12, 14, 16],
       [13, 15, 17]])
>>> ln1[:,:,0]
array([[18, 21],
       [19, 22],
       [20, 23]])
>>> ln1[:,:,1]
array([[24, 27],
       [25, 28],
       [26, 29]])
>>> ln1[:,:,2]
array([[30, 33],
       [31, 34],
       [32, 35]])
>>> ln2[:,:,0]
array([[36, 39, 42],
       [37, 40, 43],
       [38, 41, 44]])
>>> ln2[:,:,1]
array([[45, 48, 51],
       [46, 49, 52],
       [47, 50, 53]])
incidence_matrices.local_numbering_FP(N_xi, N_et, N_sg)[source]

Generating the local numbering for a vector of 3D face polynomials in \text{FP}_{N-1}(\Omega_{\mathrm{ref}}) constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A tuple of three outputs:

  1. A 3d np.array contain the local numbering for the first

    componement of the vector. Its three dimensions refer to three axes \left(\xi,\eta, \varsigma\right).

  2. A 3d np.array contain the local numbering for the second

    componement of the vector. Its three dimensions refer to three axes \left(\xi,\eta, \varsigma\right).

  3. A 3d np.array contain the local numbering for the third

    componement of the vector. Its three dimensions refer to three axes \left(\xi,\eta, \varsigma\right).

Example:

>>> ln0, ln1, ln2 = local_numbering_FP(2,2,2)
>>> ln0[:,:,0]
array([[0, 3],
       [1, 4],
       [2, 5]])
>>> ln0[:,:,1]
array([[ 6,  9],
       [ 7, 10],
       [ 8, 11]])
>>> ln1[:,:,0]
array([[12, 14, 16],
       [13, 15, 17]])
>>> ln1[:,:,1]
array([[18, 20, 22],
       [19, 21, 23]])
>>> ln2[:,:,0]
array([[24, 26],
       [25, 27]])
>>> ln2[:,:,1]
array([[28, 30],
       [29, 31]])
>>> ln2[:,:,2]
array([[32, 34],
       [33, 35]])
incidence_matrices.local_numbering_NP(N_xi, N_et, N_sg)[source]

Generating the local numbering for a node polynomials in \text{NP}_{N}(\Omega_{\mathrm{ref}}) constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A 3d np.array contain the local numbering. Its three dimensions refer to three axes \left(\xi,\eta,
\varsigma\right).

Example:

>>> ln = local_numbering_NP(3,3,3)
>>> ln[:,:,0]
array([[ 0,  4,  8, 12],
       [ 1,  5,  9, 13],
       [ 2,  6, 10, 14],
       [ 3,  7, 11, 15]])
>>> ln[:,:,1]
array([[16, 20, 24, 28],
       [17, 21, 25, 29],
       [18, 22, 26, 30],
       [19, 23, 27, 31]])
>>> ln[:,:,2]
array([[32, 36, 40, 44],
       [33, 37, 41, 45],
       [34, 38, 42, 46],
       [35, 39, 43, 47]])
>>> ln[:,:,3]
array([[48, 52, 56, 60],
       [49, 53, 57, 61],
       [50, 54, 58, 62],
       [51, 55, 59, 63]])
incidence_matrices.local_numbering_VP(N_xi, N_et, N_sg)[source]

Generating the local numbering for a volume polynomials in \text{VP}_{N-1}(\Omega_{\mathrm{ref}}) constructed on three sets of nodes, \left\lbrace\xi_0,\xi_1,\cdots, \xi_{N0}
\right\rbrace, \left\lbrace\eta_0,\eta_1,\cdots,
\eta_{N1}\right\rbrace and \left\lbrace\varsigma_0,
\varsigma_1,\cdots, \varsigma_{N2}\right\rbrace.

Parameters:
  • N_xi (positive integer) – N_xi + 1 nodes in set \left\lbrace\xi_0,
\xi_1,\cdots, \xi_{N_\xi} \right\rbrace.

  • N_et (positive integer) – N_et + 1 nodes in set \left\lbrace\eta_0,
\eta_1,\cdots, \eta_{N_\eta} \right\rbrace.

  • N_sg (positive integer) – N_sg + 1 nodes in set \left\lbrace
\varsigma_0, \varsigma_1,\cdots, \varsigma_{N_\varsigma}
\right\rbrace.

Returns:

A 3d np.array contain the local numbering. Its three dimensions refer to three axes \left(\xi,\eta,
\varsigma\right).

Example:

>>> ln = local_numbering_VP(3,3,3)
>>> ln[:,:,0]
array([[0, 3, 6],
       [1, 4, 7],
       [2, 5, 8]])
>>> ln[:,:,1]
array([[ 9, 12, 15],
       [10, 13, 16],
       [11, 14, 17]])
>>> ln[:,:,2]
array([[18, 21, 24],
       [19, 22, 25],
       [20, 23, 26]])

↩️ Back to Ph.D. thesis complements (ptc).