Skip to content

Commit 7c3ebab

Browse files
committed
Simplify the wording of the FEAScriptModel API page
Shorter sentences, lists for the geometry forms and the two times a boundary condition is checked. No change of meaning. Signed-off-by: Nikos Chamakos <nikoscham@gmail.com>
1 parent 1e0f816 commit 7c3ebab

1 file changed

Lines changed: 50 additions & 34 deletions

File tree

‎docs/api/feascript-model.md‎

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ supported by each model.
6969
The top-level `maxIterations` and `tolerance` apply to the Newton–Raphson method in nonlinear models, and to the
7070
Jacobi solvers when `solver` does not set them; see [Solvers](../fundamentals/solvers.mdx) for their defaults.
7171

72-
The model names of FEAScript 0.3, with a `Script` suffix (for example `"heatConductionScript"`), still work, with a
73-
warning; they will be removed in a future version, in 0.7.0 at the earliest.
72+
The model names of FEAScript 0.3 have a `Script` suffix, for example `"heatConductionScript"`. They still work,
73+
with a warning. They will be removed in a future version, in 0.7.0 at the earliest.
7474

7575
```javascript
7676
model.setModelConfig("heatConduction", {
@@ -84,14 +84,23 @@ model.setModelConfig("heatConduction", {
8484

8585
### `setGeometry(geometry)`
8686

87-
Sets the domain and names its boundaries: `{ line: length }`, `{ rectangle: [width, height] }` or
88-
`{ shape, holes, points }`, a polygon with holes whose boundaries are named, written as a path `{ start, boundaries: [{ name, to }] }`. See [Mesh](../fundamentals/mesh.md#geometry) for the forms and the boundary names. The geometry is
89-
checked at once: a polygon that is not simple, a hole outside the shape or inside another hole, or a point
90-
outside the domain throws a `FEAScriptError` of code `"INVALID_INPUT"` listing every problem.
87+
Sets the domain and names its boundaries. The geometry has one of these forms:
88+
89+
- `{ line: length }`;
90+
- `{ rectangle: [width, height] }`;
91+
- `{ shape, holes, points }`: a polygon with holes and named boundaries, written as a path
92+
`{ start, boundaries: [{ name, to }] }`.
93+
94+
For the forms and the boundary names, see [Mesh](../fundamentals/mesh.md#geometry).
95+
96+
FEAScript checks the geometry immediately. A polygon that is not simple, a hole outside the shape or inside
97+
another hole, or a point outside the domain throws a `FEAScriptError` with the code `INVALID_INPUT`. The error
98+
lists every problem.
9199

92100
### `setMeshConfig(meshConfig)`
93101

94-
Sets how the geometry is meshed. The mesh is generated at the first solve (or by `getMesh()`).
102+
Sets how to mesh the geometry. FEAScript generates the mesh at the first solve, or at the first call to
103+
`getMesh()`.
95104

96105
| Property | Type | Description |
97106
| -------------- | ---------------------- | -------------------------------------------------------------------------------------------------------------- |
@@ -109,13 +118,13 @@ The mesh settings of FEAScript 0.3 (`meshDimension`, `numElementsX`, `maxX`, `nu
109118
### `setMesh(mesh)`
110119

111120
Sets the mesh directly: a mesh imported with [`importGmshMesh`](./gmsh-import.md), or generated with
112-
[`generateTriangleMesh` or `generateQuadrilateralMesh`](./mesh-generators.md). The geometry and the mesh
113-
configuration are then not used. The boundaries of the mesh are keyed by their names.
121+
[`generateTriangleMesh` or `generateQuadrilateralMesh`](./mesh-generators.md). The model then does not use the
122+
geometry and the mesh configuration. The boundary names of the mesh are the keys for the boundary conditions.
114123

115124
### `getMesh()`
116125

117-
Returns the [mesh object](../fundamentals/mesh.md#meshes-as-objects) of the model, generating it from the
118-
geometry and the mesh configuration at the first call. `getMeshDimension()` returns `"1D"` or `"2D"`.
126+
Returns the [mesh object](../fundamentals/mesh.md#meshes-as-objects) of the model. At the first call, it
127+
generates the mesh from the geometry and the mesh configuration. `getMeshDimension()` returns `"1D"` or `"2D"`.
119128

120129
### `addBoundaryCondition(boundaryKey, condition)`
121130

@@ -126,18 +135,21 @@ Adds a boundary condition, or replaces the condition of a boundary that already
126135
| `boundaryKey` | `string` | The name of a boundary of the geometry or the mesh (for example `"top"`, see [Boundary names](../fundamentals/mesh.md#boundary-names)), or the node number for the Euler–Bernoulli beam |
127136
| `condition` | `object` | The condition type and its named parameters, for example `{ type: "convection", h: 1, ambientTemperature: 20 }`; for the Euler–Bernoulli beam, one such object or a list of them |
128137

129-
See [Boundary conditions](../fundamentals/boundary-conditions.md) for the condition types of each model. A
130-
condition object with no or an unknown type, or with a missing or unknown parameter, throws a `FEAScriptError`
131-
with the code `INVALID_INPUT` when it is added; the other problems (a type that the selected model does not
132-
have, a value that is not a number, a boundary that is not in the mesh) are reported when `solve()` runs (see
133-
[Checks](../fundamentals/boundary-conditions.md#checks)). The array form of FEAScript 0.3, for example
134-
`["convection", 1, 20]`, still works, with a warning.
138+
For the condition types of each model, see [Boundary conditions](../fundamentals/boundary-conditions.md).
139+
FEAScript checks a condition at two times (see [Checks](../fundamentals/boundary-conditions.md#checks)):
140+
141+
- When the condition is added: a condition object with no type or an unknown type, or with a missing or unknown
142+
parameter, throws a `FEAScriptError` with the code `INVALID_INPUT`.
143+
- When `solve()` runs: the other problems are reported, such as a type that the selected model does not have, a
144+
value that is not a number, or a boundary that is not in the mesh.
145+
146+
The array form of FEAScript 0.3, for example `["convection", 1, 20]`, still works, with a warning.
135147

136148
### `setSolverMethod(solverMethod)`
137149

138-
Deprecated: use the `solver` option of `setModelConfig`, for example
150+
Deprecated. Use the `solver` option of `setModelConfig` instead, for example
139151
`setModelConfig("heatConduction", { solver: { method: "jacobi" } })`. `setSolverMethod` still selects the
140-
linear system solver, with a warning, and will be removed in a future version.
152+
linear system solver, with a warning. It will be removed in a future version.
141153

142154
### `solve(options)`
143155

@@ -159,12 +171,14 @@ Returns an object with:
159171
| `info` | `object` | The run report (see below) |
160172

161173
For scalar models (heat conduction, general-form PDE, front propagation), `solutionVector` has one value per
162-
node, in the order of `nodesCoordinates`, and there is no `fields` property. The
163-
[creeping flow](../models/creeping-flow.md#results) (`velocityMagnitude`, `u`, `v`, `p`) and
174+
node, in the order of `nodesCoordinates`. These models have no `fields` property.
175+
176+
The [creeping flow](../models/creeping-flow.md#results) (`velocityMagnitude`, `u`, `v`, `p`) and
164177
[Euler–Bernoulli beam](../models/euler-bernoulli-beam.md#results) (`w`, `theta`) models have more unknowns per
165-
node: `fields` holds each of them as a `Float64Array` with one value per node, ready to plot or post-process.
178+
node. For these models, `fields` holds each named field as a `Float64Array` with one value per node, ready to
179+
plot or post-process.
166180

167-
`info` reports how the solve went, with the same properties for every model and solver method:
181+
`info` reports the result of the solve. It has the same properties for every model and solver method:
168182

169183
| Property | Type | Description |
170184
| ------------ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -180,9 +194,11 @@ const { info } = model.solve();
180194
console.log(`${info.method}: ${info.iterations ?? "direct"} iterations, residual ${info.residual}`);
181195
```
182196
183-
The frontal solver eliminates the equations element by element without assembling the system matrix, so it has
184-
no residual to report. For a nonlinear model, the last linear system solves for the converged, nearly zero
185-
increment, so its relative residual says nothing about the solution; `newton.increment` is the measure there.
197+
The frontal solver eliminates the equations element by element and does not assemble the system matrix. For
198+
this reason, it has no residual to report.
199+
200+
For a nonlinear model, the last linear system solves for the increment after convergence, which is nearly zero.
201+
Its relative residual gives no information about the solution. For these models, use `newton.increment`.
186202
187203
### `solveAsync(computeEngine, options)`
188204
@@ -197,7 +213,7 @@ const { solutionVector, nodesCoordinates } = await model.solveAsync();
197213
198214
| Parameter | Type | Description |
199215
| --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
200-
| `computeEngine` | `object` | Optional. An initialized WebGPU compute engine to reuse across solves. When omitted or `null`, FEAScript creates one for the solve and terminates it afterwards; a provided engine is left running |
216+
| `computeEngine` | `object` | Optional. An initialized WebGPU compute engine to reuse across solves. If it is omitted or `null`, FEAScript creates an engine for the solve and terminates it after the solve. An engine that you provide stays running |
201217
| `options` | `object` | Optional `{ maxIterations, tolerance }` |
202218
203219
:::caution
@@ -208,8 +224,8 @@ with WebGPU support. For other models or solver methods, it throws a `FEAScriptE
208224
209225
## Error handling
210226
211-
An input that FEAScript cannot use, or a solve that would return an empty or a wrong result, throws a
212-
`FEAScriptError`, exported by the library, with one of these codes in `error.code`:
227+
FEAScript throws a `FEAScriptError` for an input that it cannot use, or for a solve that would return an empty or
228+
a wrong result. The library exports `FEAScriptError`. `error.code` holds one of these codes:
213229
214230
| Code | Meaning |
215231
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -222,9 +238,9 @@ An input that FEAScript cannot use, or a solve that would return an empty or a w
222238
| `MESH_TOO_FINE` | The triangle mesh generator passed its `maxNodes` limit ([mesh generators](./mesh-generators.md)) |
223239
| `INTERNAL_ERROR` | A step of the frontal solver failed |
224240
225-
The checks run before the solve, so all the input mistakes are reported at once, in `error.details`. Through
226-
`FEAScriptWorker` the error keeps its `code` and `details`.
241+
The checks run before the solve. Because of this, FEAScript reports all the input mistakes at once, in
242+
`error.details`. An error from `FEAScriptWorker` keeps its `code` and `details`.
227243
228-
Problems that do not stop the solve, for example a mesh setting that conflicts with an imported mesh (the value of
229-
the mesh is used), are reported as `[WARN]` messages in the console. See [Logging](./utilities.md#logsystem) to
230-
control the amount of output.
244+
Problems that do not stop the solve show as `[WARN]` messages in the console. An example is a mesh setting that
245+
conflicts with an imported mesh; FEAScript then uses the value of the mesh. To control the amount of output, see
246+
[Logging](./utilities.md#logsystem).

0 commit comments

Comments
 (0)