diff --git a/examples/frontPropagationScript/SolidificationFront2D/README.md b/examples/frontPropagationScript/SolidificationFront2D/README.md new file mode 100644 index 0000000..5cf9b51 --- /dev/null +++ b/examples/frontPropagationScript/SolidificationFront2D/README.md @@ -0,0 +1,29 @@ +FEAScript Logo + +## Solidification Front Propagation in a Two-Dimensional Domain + +This example demonstrates solving an eikonal equation in a two-dimensional domain using the FEAScript library. The problem represents a typical solidification front propagation scenario, where the objective is to track the movement of an interface, such as in metal cooling or crystal growth processes. + +### Instructions + +This example requires the `feascript` npm package and its peer dependencies (`mathjs`). It imports FEAScript directly from the npm package and runs the simulation in a Node.js environment. To run the example, follow these instructions: + +1. **Create package.json with ES module support:** + + ```bash + echo '{"type":"module"}' > package.json + ``` + +2. **Install dependencies:** + + ```bash + npm install feascript mathjs + ``` + +3. **Run the example:** + + ```bash + node SolidificationFront2D.js + ``` + +**Note:** For detailed information on the model setup, boundary conditions, and simulation results, refer to the comments in the JavaScript files and the corresponding standard [tutorial](https://feascript.com/tutorials/SolidificationFront2D.html). diff --git a/examples/frontPropagationScript/SolidificationFront2D/SolidificationFront2D.js b/examples/frontPropagationScript/SolidificationFront2D/SolidificationFront2D.js new file mode 100644 index 0000000..3a4513e --- /dev/null +++ b/examples/frontPropagationScript/SolidificationFront2D/SolidificationFront2D.js @@ -0,0 +1,51 @@ +// ______ ______ _____ _ _ // +// | ____| ____| /\ / ____| (_) | | // +// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ // +// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| // +// | | | |____ / ____ \ ____) | (__| | | | |_) | | // +// |_| |______/_/ \_\_____/ \___|_| |_| __/| | // +// | | | | // +// |_| | |_ // +// Website: https://feascript.com/ \__| // + +// Import Math.js +import * as math from "mathjs"; +global.math = math; + +// Import FEAScript library +import { FEAScriptModel, logSystem, VERSION } from "feascript"; + +console.log("FEAScript Version:", VERSION); + +// Create a new FEAScript model +const model = new FEAScriptModel(); + +// Set solver configuration for front propagation +model.setSolverConfig("frontPropagationScript"); + +// Define mesh configuration +model.setMeshConfig({ + meshDimension: "2D", + elementOrder: "quadratic", + numElementsX: 12, + numElementsY: 8, + maxX: 4, + maxY: 2, +}); + +// Define boundary conditions +model.addBoundaryCondition("0", ["constantValue", 0]); // Bottom +model.addBoundaryCondition("1", ["constantValue", 0]); // Left +model.addBoundaryCondition("2", ["zeroGradient"]); // Top +model.addBoundaryCondition("3", ["constantValue", 0]); // Right + +// Set solver method (optional) +model.setSolverMethod("lusolve"); + +// Solve the problem and get the solution +const { solutionVector, nodesCoordinates } = model.solve(); + +// Print results to console +console.log("Solution vector:", solutionVector); +console.log("Node coordinates:", nodesCoordinates); +console.log(`Number of nodes in mesh: ${nodesCoordinates.nodesXCoordinates.length}`);