Skip to content

Commit 7e5fac7

Browse files
nikoschamferrari212Ed6003
authored
Feature/spatially varying coefficients (#92)
Co-authored-by: ferrari212 <felipe.ferrari.212@gmail.com> Co-authored-by: Edoardo R <67373405+Ed6003@users.noreply.github.com>
1 parent c88ed35 commit 7e5fac7

22 files changed

Lines changed: 941 additions & 170 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- <b>Physics models:</b> creeping (Stokes) flow, Euler-Bernoulli beam bending, front propagation, heat conduction, general form PDE (linear and nonlinear)
2121
- <b>Meshing:</b> simple 1D/2D mesh generation, unstructured mesh import from Gmsh (`.msh`)
2222
- <b>Solvers:</b> frontal, Jacobi (CPU/WebGPU) and LU, Newton–Raphson for nonlinear systems
23+
- <b>Spatially varying coefficients:</b> `thermalConductivity(x, y)` and `heatSource(x, y)` can be scalars or functions, evaluated at each Gauss point
2324
- <b>Performance:</b> web worker support for multi-threaded computation
2425
- <b>Visualization:</b> interactive rendering with vtk.js and Plotly
2526

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: 24 additions & 25 deletions
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: 25 additions & 26 deletions
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: 16 additions & 17 deletions
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/heatConductionScript/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,37 @@ Implementation using a Gmsh-generated mesh for a rhomboid domain (the mesh file,
2828

2929
For detailed information on the model setup, refer to the corresponding [tutorial](https://feascript.com/tutorials/heat-conduction-2d-rhom-fin-gmsh.html) in the FEAScript website.
3030

31+
#### 5. Heat Conduction in a 1D Bi-Material Wall with Spatially Varying k(x) (`heatConduction1DVaryingK.js`)
32+
33+
Demonstrates passing `thermalConductivity` as a function of position `k(x)`. The wall consists of two layers with different conductivities separated at mid-length. This example exercises the `coefficientFunctions` API with the standard linear solver.
34+
35+
#### 6. Heat Conduction in a 2D Fin with Spatially Varying k(x,y) and Q(x,y) (`heatConduction2DVaryingKQ.js`)
36+
37+
Demonstrates both `thermalConductivity(x, y)` and `heatSource(x, y)` as functions of position on a 2D structured mesh. The domain is split into a high-conductivity metal half and a low-conductivity ceramic half, with a localised volumetric heat source in the upper strip.
38+
39+
## Spatially Varying Coefficients
40+
41+
Both `thermalConductivity` and `heatSource` can be provided either as constants (scalars) or as functions of the physical coordinates. They are evaluated at each Gauss point during the isoparametric mapping loop, so any piecewise or smooth spatial variation is fully supported.
42+
43+
```javascript
44+
model.setModelConfig("heatConductionScript", {
45+
coefficientFunctions: {
46+
// Scalar (uniform)
47+
thermalConductivity: 10,
48+
// Function of x only (1D or 2D)
49+
// thermalConductivity: (x) => x < 0.5 ? 10 : 1,
50+
// Function of x and y (2D)
51+
// thermalConductivity: (x, y) => x < 2.0 ? 10 : 1,
52+
// Uniform heat source
53+
// heatSource: 500,
54+
// Localised heat source (active only in upper strip)
55+
heatSource: (x, y) => (y > 1.5 ? 500 : 0),
56+
},
57+
});
58+
```
59+
60+
When `coefficientFunctions` is omitted or a coefficient is not provided, the defaults `thermalConductivity = 1` and `heatSource = 0` are used. Both the standard matrix assembler and the frontal solver assembler support this feature.
61+
3162
## Running the Node.js Examples
3263

3364
#### 1. Create package.json with ES module support:

0 commit comments

Comments
 (0)