Skip to content

Commit 8c73335

Browse files
authored
Return named result fields for creeping flow and the beam (#106) (#108)
solve() now also returns `fields` for models with more than one unknown per node, each a Float64Array with one value per mesh node: - creeping flow: velocityMagnitude, u, v, p (the pressure, solved at the corner nodes, is interpolated linearly to the mid-side and centre nodes) - Euler–Bernoulli beam: w, theta The plotting functions take a `field` option (plotSolution and plotInterpolatedSolution in the options argument, the vtk.js functions in renderOptions) and default to velocityMagnitude and w, so the result of solve() can be plotted directly. solutionVector is unchanged, and FEAScriptWorker.solve() passes the fields through. The private _creepingFlowMetadata and _eulerBernoulliBeamMetadata properties are removed. Tests: check the fields against the solution vector in the creeping flow and beam regression tests. Examples: use the fields. Closes #106
1 parent 83f2917 commit 8c73335

19 files changed

Lines changed: 223 additions & 50 deletions

File tree

‎dist/feascript-worker.esm.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript-worker.esm.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.cjs.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.cjs.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.esm.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.esm.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.umd.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/feascript.umd.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/creepingFlowScript/lidDrivenCavity2DCreepingFlow/lidDrivenCavity2DCreepingFlow.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ model.addBoundaryCondition("3", ["constantVelocity", 0, 0]); // Right
3434

3535
// 4. Solve
3636
model.setSolverMethod("lusolve");
37-
const { solutionVector, nodesCoordinates } = model.solve();
37+
const { nodesCoordinates, fields } = model.solve();
3838

39-
// 5. Print the results
39+
// 5. Print the results (one value per mesh node for each field)
4040
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);
4141
console.log("Node coordinates:", nodesCoordinates);
42-
console.log("Solution vector:", solutionVector);
42+
console.log("x-velocity u:", fields.u);
43+
console.log("y-velocity v:", fields.v);
44+
console.log("Pressure p:", fields.p);

‎examples/eulerBernoulliBeamScript/clampedSpringSupportedBeam1D/clampedSpringSupportedBeam1D.js‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,16 @@ model.addBoundaryCondition("3", [
3939

4040
// 4. Solve
4141
model.setSolverMethod("lusolve");
42-
const { solutionVector } = model.solve();
42+
const { nodesCoordinates, fields } = model.solve();
4343

4444
// 5. Print the results
45-
const flatSolution = solutionVector.map((entry) => (Array.isArray(entry) ? entry[0] : entry));
46-
47-
const nodeXCoordinates = [0, 5, 10];
45+
const { nodesXCoordinates } = nodesCoordinates;
4846
console.log("\nNode | x (m) | Deflection w (m) | Rotation theta (rad)");
4947
console.log("-----|----------|-------------------|----------------------");
50-
for (let nodeIndex = 0; nodeIndex < nodeXCoordinates.length; nodeIndex++) {
51-
const w = flatSolution[2 * nodeIndex];
52-
const theta = flatSolution[2 * nodeIndex + 1];
48+
for (let nodeIndex = 0; nodeIndex < nodesXCoordinates.length; nodeIndex++) {
5349
console.log(
54-
` ${nodeIndex + 1} | ${nodeXCoordinates[nodeIndex].toFixed(2).padStart(8)} | ${w
50+
` ${nodeIndex + 1} | ${nodesXCoordinates[nodeIndex].toFixed(2).padStart(8)} | ${fields.w[nodeIndex]
5551
.toExponential(4)
56-
.padStart(17)} | ${theta.toExponential(4).padStart(20)}`,
52+
.padStart(17)} | ${fields.theta[nodeIndex].toExponential(4).padStart(20)}`,
5753
);
5854
}

0 commit comments

Comments
 (0)