-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlidDrivenCavity2DCreepingFlow.js
More file actions
50 lines (40 loc) Β· 1.74 KB
/
lidDrivenCavity2DCreepingFlow.js
File metadata and controls
50 lines (40 loc) Β· 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
* FEAScript Core Library
* Lightweight Finite Element Simulation in JavaScript
* Version: 0.3.0 (RC) | https://feascript.com
* MIT License Β© 2023β2026 FEAScript
* ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
*/
// Import Math.js
import * as math from "mathjs";
global.math = math;
// Import FEAScript library
import { FEAScriptModel, printVersion } from "feascript";
console.log("FEAScript Version:", printVersion);
// Create a new FEAScript model
const model = new FEAScriptModel();
// Select physics/PDE
model.setModelConfig("creepingFlowScript");
// Define mesh configuration
model.setMeshConfig({
meshDimension: "2D",
elementOrder: "quadratic",
numElementsX: 12,
numElementsY: 6,
maxX: 4,
maxY: 2,
});
// Define boundary conditions
model.addBoundaryCondition("0", ["constantVelocity", 0, 0]); // Bottom boundary
model.addBoundaryCondition("1", ["constantVelocity", 0, 0]); // Left boundary
model.addBoundaryCondition("2", ["constantVelocity", 1, 0]); // Top boundary
model.addBoundaryCondition("3", ["constantVelocity", 0, 0]); // Right boundary
// Set solver method (optional)
model.setSolverMethod("lusolve");
// Solve the problem
const { solutionVector, nodesCoordinates } = model.solve();
// Print results
console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);
console.log("Node coordinates:", nodesCoordinates);
console.log("Solution vector:", solutionVector);