@@ -34,7 +34,48 @@ export class ThermalBoundaryConditions {
3434 * @param {array } jacobianMatrix - The Jacobian matrix to be modified
3535 */
3636 imposeConstantTempBoundaryConditions ( residualVector , jacobianMatrix ) {
37- if ( this . meshDimension === "2D" ) {
37+ if ( this . meshDimension === "1D" ) {
38+ Object . keys ( this . boundaryConditions ) . forEach ( ( boundaryKey ) => {
39+ if ( this . boundaryConditions [ boundaryKey ] [ 0 ] === "constantTemp" ) {
40+ const tempValue = this . boundaryConditions [ boundaryKey ] [ 1 ] ;
41+ this . boundaryElements [ boundaryKey ] . forEach ( ( [ elementIndex , side ] ) => {
42+ if ( this . elementOrder === "linear" ) {
43+ const boundarySides = {
44+ 0 : [ 0 ] , // Node at the left side of the reference element
45+ 1 : [ 1 ] , // Node at the right side of the reference element
46+ } ;
47+ boundarySides [ boundaryKey ] . forEach ( ( nodeIndex ) => {
48+ const globalNodeIndex = this . nop [ elementIndex ] [ nodeIndex ] - 1 ;
49+ // Set the residual vector to the ConstantTemp value
50+ residualVector [ globalNodeIndex ] = tempValue ;
51+ // Set the Jacobian matrix row to zero
52+ for ( let colIndex = 0 ; colIndex < residualVector . length ; colIndex ++ ) {
53+ jacobianMatrix [ globalNodeIndex ] [ colIndex ] = 0 ;
54+ }
55+ // Set the diagonal entry of the Jacobian matrix to one
56+ jacobianMatrix [ globalNodeIndex ] [ globalNodeIndex ] = 1 ;
57+ } ) ;
58+ } else if ( this . elementOrder === "quadratic" ) {
59+ const boundarySides = {
60+ 0 : [ 0 ] , // Node at the left side of the reference element
61+ 2 : [ 2 ] , // Node at the right side of the reference element
62+ } ;
63+ boundarySides [ boundaryKey ] . forEach ( ( nodeIndex ) => {
64+ const globalNodeIndex = this . nop [ elementIndex ] [ nodeIndex ] - 1 ;
65+ // Set the residual vector to the ConstantTemp value
66+ residualVector [ globalNodeIndex ] = tempValue ;
67+ // Set the Jacobian matrix row to zero
68+ for ( let colIndex = 0 ; colIndex < residualVector . length ; colIndex ++ ) {
69+ jacobianMatrix [ globalNodeIndex ] [ colIndex ] = 0 ;
70+ }
71+ // Set the diagonal entry of the Jacobian matrix to one
72+ jacobianMatrix [ globalNodeIndex ] [ globalNodeIndex ] = 1 ;
73+ } ) ;
74+ }
75+ } ) ;
76+ }
77+ } ) ;
78+ } else if ( this . meshDimension === "2D" ) {
3879 Object . keys ( this . boundaryConditions ) . forEach ( ( boundaryKey ) => {
3980 if ( this . boundaryConditions [ boundaryKey ] [ 0 ] === "constantTemp" ) {
4081 const tempValue = this . boundaryConditions [ boundaryKey ] [ 1 ] ;
@@ -157,11 +198,9 @@ export class ThermalBoundaryConditions {
157198 xCoordinates +=
158199 nodesXCoordinates [ this . nop [ elementIndex ] [ nodeIndex ] - 1 ] * basisFunction [ nodeIndex ] ;
159200 ksiDerivX +=
160- nodesXCoordinates [ this . nop [ elementIndex ] [ nodeIndex ] - 1 ] *
161- basisFunctionDerivKsi [ nodeIndex ] ;
201+ nodesXCoordinates [ this . nop [ elementIndex ] [ nodeIndex ] - 1 ] * basisFunctionDerivKsi [ nodeIndex ] ;
162202 etaDerivY +=
163- nodesYCoordinates [ this . nop [ elementIndex ] [ nodeIndex ] - 1 ] *
164- basisFunctionDerivEta [ nodeIndex ] ;
203+ nodesYCoordinates [ this . nop [ elementIndex ] [ nodeIndex ] - 1 ] * basisFunctionDerivEta [ nodeIndex ] ;
165204 }
166205 for (
167206 let localNodeIndex = firstNodeIndex ;
@@ -172,11 +211,7 @@ export class ThermalBoundaryConditions {
172211 if ( side === 0 || side === 2 ) {
173212 // Horizontal boundaries of the domain (assuming a rectangular domain)
174213 residualVector [ globalNodeIndex ] +=
175- - gaussWeights [ 0 ] *
176- ksiDerivX *
177- basisFunction [ localNodeIndex ] *
178- convectionCoeff *
179- extTemp ;
214+ - gaussWeights [ 0 ] * ksiDerivX * basisFunction [ localNodeIndex ] * convectionCoeff * extTemp ;
180215 for (
181216 let localNodeIndex2 = firstNodeIndex ;
182217 localNodeIndex2 < lastNodeIndex ;
@@ -193,11 +228,7 @@ export class ThermalBoundaryConditions {
193228 } else if ( side === 1 || side === 3 ) {
194229 // Vertical boundaries of the domain (assuming a rectangular domain)
195230 residualVector [ globalNodeIndex ] +=
196- - gaussWeights [ 0 ] *
197- etaDerivY *
198- basisFunction [ localNodeIndex ] *
199- convectionCoeff *
200- extTemp ;
231+ - gaussWeights [ 0 ] * etaDerivY * basisFunction [ localNodeIndex ] * convectionCoeff * extTemp ;
201232 for (
202233 let localNodeIndex2 = firstNodeIndex ;
203234 localNodeIndex2 < lastNodeIndex ;
0 commit comments