Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a766fd

Browse filesBrowse files
committed
Improve convection boundary conditions handling and perform nested array check for the line plot
1 parent b2cc5a6 commit 3a766fd
Copy full SHA for 3a766fd

File tree

3 files changed

+25
-22
lines changed
Filter options

3 files changed

+25
-22
lines changed

‎src/solvers/solidHeatTransferScript.js

Copy file name to clipboardExpand all lines: src/solvers/solidHeatTransferScript.js
+6-15Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,11 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
3636
elementOrder, // The order of elements
3737
} = meshConfig;
3838

39-
debugLog(`Mesh configuration: ${meshDimension}, Elements: ${numElementsX}x${numElementsY || 1}, Size: ${maxX}x${maxY || 0}, Order: ${elementOrder}`);
40-
41-
// Extract boundary conditions from the configuration object
42-
let convectionHeatTranfCoeff = [];
43-
let convectionExtTemp = [];
44-
Object.keys(boundaryConditions).forEach((key) => {
45-
const boundaryCondition = boundaryConditions[key];
46-
if (boundaryCondition[0] === "convection") {
47-
convectionHeatTranfCoeff[key] = boundaryCondition[1];
48-
convectionExtTemp[key] = boundaryCondition[2];
49-
}
50-
});
39+
debugLog(
40+
`Mesh configuration: ${meshDimension}, Elements: ${numElementsX}x${numElementsY || 1}, Size: ${maxX}x${
41+
maxY || 0
42+
}, Order: ${elementOrder}`
43+
);
5144

5245
// Create a new instance of the meshGeneration class
5346
debugLog("Generating mesh...");
@@ -259,9 +252,7 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
259252
gaussWeights,
260253
nodesXCoordinates,
261254
nodesYCoordinates,
262-
basisFunctionsData,
263-
convectionHeatTranfCoeff,
264-
convectionExtTemp
255+
basisFunctionsData
265256
);
266257
debugLog("Convection boundary conditions applied");
267258

‎src/solvers/thermalBoundaryConditionsScript.js

Copy file name to clipboardExpand all lines: src/solvers/thermalBoundaryConditionsScript.js
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ export class ThermalBoundaryConditions {
132132
* @param {array} nodesXCoordinates - Array of x-coordinates of nodes
133133
* @param {array} nodesYCoordinates - Array of y-coordinates of nodes
134134
* @param {object} basisFunctionsData - Object containing basis functions and their derivatives
135-
* @param {array} convectionHeatTranfCoeff - Array of convection heat transfer coefficients
136-
* @param {array} convectionExtTemp - Array of external temperatures for convection
137135
*/
138136
imposeConvectionBoundaryConditions(
139137
residualVector,
@@ -142,10 +140,19 @@ export class ThermalBoundaryConditions {
142140
gaussWeights,
143141
nodesXCoordinates,
144142
nodesYCoordinates,
145-
basisFunctionsData,
146-
convectionHeatTranfCoeff,
147-
convectionExtTemp
143+
basisFunctionsData
148144
) {
145+
// Extract convection parameters from boundary conditions
146+
let convectionHeatTranfCoeff = [];
147+
let convectionExtTemp = [];
148+
Object.keys(this.boundaryConditions).forEach((key) => {
149+
const boundaryCondition = this.boundaryConditions[key];
150+
if (boundaryCondition[0] === "convection") {
151+
convectionHeatTranfCoeff[key] = boundaryCondition[1];
152+
convectionExtTemp[key] = boundaryCondition[2];
153+
}
154+
});
155+
149156
if (this.meshDimension === "1D") {
150157
// 1D code
151158
} else if (this.meshDimension === "2D") {

‎src/visualization/plotSolutionScript.js

Copy file name to clipboardExpand all lines: src/visualization/plotSolutionScript.js
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ export function plotSolution(
3030
const { nodesXCoordinates, nodesYCoordinates } = nodesCoordinates;
3131

3232
if (meshDimension === "1D" && plotType === "line") {
33-
// Flatten solutionVector
34-
let yData = solutionVector.map(arr => arr[0]);
33+
// Check if solutionVector is a nested array
34+
let yData;
35+
if (solutionVector.length > 0 && Array.isArray(solutionVector[0])) {
36+
yData = solutionVector.map(arr => arr[0]);
37+
} else {
38+
yData = solutionVector;
39+
}
3540
let xData = Array.from(nodesXCoordinates);
3641

3742
let lineData = {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.