Skip to content

Commit 81c49ac

Browse files
committed
Enhance thermal boundary conditions handling for 1D meshes by implementing convection type
1 parent 3a766fd commit 81c49ac

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/solvers/solidHeatTransferScript.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
151151
// Computation of Galerkin's residuals and Jacobian matrix
152152
for (let localNodeIndex1 = 0; localNodeIndex1 < numNodes; localNodeIndex1++) {
153153
let globalNodeIndex1 = localNodalNumbers[localNodeIndex1];
154-
residualVector[globalNodeIndex1] +=
155-
gaussWeights[gaussPointIndex1] * detJacobian * basisFunction[localNodeIndex1];
154+
// residualVector is zero for this case
156155

157156
for (let localNodeIndex2 = 0; localNodeIndex2 < numNodes; localNodeIndex2++) {
158157
let globalNodeIndex2 = localNodalNumbers[localNodeIndex2];
@@ -213,11 +212,7 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
213212
// Computation of Galerkin's residuals and Jacobian matrix
214213
for (let localNodeIndex1 = 0; localNodeIndex1 < numNodes; localNodeIndex1++) {
215214
let globalNodeIndex1 = localNodalNumbers[localNodeIndex1];
216-
residualVector[globalNodeIndex1] +=
217-
gaussWeights[gaussPointIndex1] *
218-
gaussWeights[gaussPointIndex2] *
219-
detJacobian *
220-
basisFunction[localNodeIndex1];
215+
// residualVector is zero for this case
221216

222217
for (let localNodeIndex2 = 0; localNodeIndex2 < numNodes; localNodeIndex2++) {
223218
let globalNodeIndex2 = localNodalNumbers[localNodeIndex2];

src/solvers/thermalBoundaryConditionsScript.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,36 @@ export class ThermalBoundaryConditions {
154154
});
155155

156156
if (this.meshDimension === "1D") {
157-
// 1D code
157+
Object.keys(this.boundaryConditions).forEach((boundaryKey) => {
158+
if (this.boundaryConditions[boundaryKey][0] === "convection") {
159+
const convectionCoeff = convectionHeatTranfCoeff[boundaryKey];
160+
const extTemp = convectionExtTemp[boundaryKey];
161+
this.boundaryElements[boundaryKey].forEach(([elementIndex, side]) => {
162+
let nodeIndex;
163+
if (this.elementOrder === "linear") {
164+
if (side === 0) {
165+
// Node at the left side of the reference element
166+
nodeIndex = 0;
167+
} else {
168+
// Node at the right side of the reference element
169+
nodeIndex = 1;
170+
}
171+
} else if (this.elementOrder === "quadratic") {
172+
if (side === 0) {
173+
// Node at the left side of the reference element
174+
nodeIndex = 0;
175+
} else {
176+
// Node at the right side of the reference element
177+
nodeIndex = 2;
178+
}
179+
}
180+
181+
const globalNodeIndex = this.nop[elementIndex][nodeIndex] - 1;
182+
residualVector[globalNodeIndex] += -convectionCoeff * extTemp;
183+
jacobianMatrix[globalNodeIndex][globalNodeIndex] += convectionCoeff;
184+
});
185+
}
186+
});
158187
} else if (this.meshDimension === "2D") {
159188
Object.keys(this.boundaryConditions).forEach((boundaryKey) => {
160189
if (this.boundaryConditions[boundaryKey][0] === "convection") {

0 commit comments

Comments
 (0)