@@ -27,9 +27,9 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
2727 const {
2828 meshDimension, // The dimension of the mesh
2929 numElementsX, // Number of elements in x-direction
30- numElementsY, // Number of elements in y-direction
30+ numElementsY, // Number of elements in y-direction (only for 2D)
3131 maxX, // Max x-coordinate (m) of the domain
32- maxY, // Max y-coordinate (m) of the domain
32+ maxY, // Max y-coordinate (m) of the domain (only for 2D)
3333 elementOrder, // The order of elements
3434 } = meshConfig ;
3535
@@ -66,24 +66,24 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
6666 let boundaryElements = nodesCoordinatesAndNumbering . boundaryElements ;
6767
6868 // Initialize variables for matrix assembly
69- const totalElements = numElementsX * numElementsY ; // Total number of elements
70- const totalNodes = totalNodesX * totalNodesY ; // Total number of nodes
69+ const totalElements = numElementsX * ( meshDimension === '2D' ? numElementsY : 1 ) ; // Total number of elements
70+ const totalNodes = totalNodesX * ( meshDimension === '2D' ? totalNodesY : 1 ) ; // Total number of nodes
7171 let localNodalNumbers = [ ] ; // Local nodal numbering
7272 let gaussPoints = [ ] ; // Gauss points
7373 let gaussWeights = [ ] ; // Gauss weights
7474 let basisFunction = [ ] ; // Basis functions
7575 let basisFunctionDerivKsi = [ ] ; // Derivatives of basis functions with respect to ksi
76- let basisFunctionDerivEta = [ ] ; // Derivatives of basis functions with respect to eta
76+ let basisFunctionDerivEta = [ ] ; // Derivatives of basis functions with respect to eta (only for 2D)
7777 let basisFunctionDerivX = [ ] ; // The x-derivative of the basis function
78- let basisFunctionDerivY = [ ] ; // The y-derivative of the basis function
78+ let basisFunctionDerivY = [ ] ; // The y-derivative of the basis function (only for 2D)
7979 let residualVector = [ ] ; // Galerkin residuals
8080 let jacobianMatrix = [ ] ; // Jacobian matrix
8181 let xCoordinates ; // x-coordinate (physical coordinates)
82- let yCoordinates ; // y-coordinate (physical coordinates)
82+ let yCoordinates ; // y-coordinate (physical coordinates) (only for 2D)
8383 let ksiDerivX ; // ksi-derivative of xCoordinates
84- let etaDerivX ; // eta-derivative of xCoordinates (ksi and eta are natural coordinates that vary within a reference element)
85- let ksiDerivY ; // ksi-derivative of yCoordinates
86- let etaDerivY ; // eta-derivative of yCoordinates
84+ let etaDerivX ; // eta-derivative of xCoordinates (ksi and eta are natural coordinates that vary within a reference element) (only for 2D)
85+ let ksiDerivY ; // ksi-derivative of yCoordinates (only for 2D)
86+ let etaDerivY ; // eta-derivative of yCoordinates (only for 2D)
8787 let detJacobian ; // The jacobian of the isoparametric mapping
8888
8989 // Initialize jacobianMatrix and residualVector arrays
@@ -155,7 +155,7 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
155155 nodesYCoordinates [ localNodalNumbers [ localNodeIndex ] ] * basisFunctionDerivKsi [ localNodeIndex ] ;
156156 etaDerivY +=
157157 nodesYCoordinates [ localNodalNumbers [ localNodeIndex ] ] * basisFunctionDerivEta [ localNodeIndex ] ;
158- detJacobian = ksiDerivX * etaDerivY - etaDerivX * ksiDerivY ;
158+ detJacobian = meshDimension === '2D' ? ksiDerivX * etaDerivY - etaDerivX * ksiDerivY : ksiDerivX ;
159159 }
160160
161161 // Compute x-derivative and y-derivative of basis functions
0 commit comments