@@ -38,13 +38,11 @@ Save the following as an `.html` file and open it through a local web server (fo
3838 <script type =" module" >
3939 import { FEAScriptModel , plotSolution } from " https://core.feascript.com/dist/feascript.esm.js" ;
4040
41- // 1. Create a model
41+ // 1. Create the model and select the physics
4242 const model = new FEAScriptModel ();
43-
44- // 2. Select the physical model
4543 model .setModelConfig (" heatConductionScript" );
4644
47- // 3 . Define the mesh: 8 × 4 quadratic quadrilaterals on 0 ≤ x ≤ 4, 0 ≤ y ≤ 2
45+ // 2 . Define the mesh: 8 × 4 quadratic quadrilaterals on 0 ≤ x ≤ 4, 0 ≤ y ≤ 2
4846 model .setMeshConfig ({
4947 meshDimension: " 2D" ,
5048 elementOrder: " quadratic" ,
@@ -54,17 +52,17 @@ Save the following as an `.html` file and open it through a local web server (fo
5452 maxY: 2 ,
5553 });
5654
57- // 4 . Apply the boundary conditions
55+ // 3 . Apply the boundary conditions
5856 model .addBoundaryCondition (" 0" , [" constantTemperature" , 200 ]); // Bottom
5957 model .addBoundaryCondition (" 1" , [" symmetry" ]); // Left
6058 model .addBoundaryCondition (" 2" , [" convection" , 1 , 20 ]); // Top
6159 model .addBoundaryCondition (" 3" , [" constantTemperature" , 200 ]); // Right
6260
63- // 5. Select the solver and solve
61+ // 4. Solve
6462 model .setSolverMethod (" lusolve" );
6563 const result = model .solve ();
6664
67- // 6 . Plot the temperature
65+ // 5 . Plot the results
6866 plotSolution (model, result, " contour" , " resultsCanvas" );
6967 </script >
7068 </body >
@@ -73,18 +71,17 @@ Save the following as an `.html` file and open it through a local web server (fo
7371
7472## Step by step
7573
76- 1 . ** Create a model.** [ ` FEAScriptModel ` ] ( ../api/feascript-model.md ) holds the whole configuration of the
77- simulation.
78- 2 . ** Select the physical model.** ` setModelConfig ` takes the model name and, optionally, its coefficients. Here
79- the defaults of the [ heat conduction] ( ../models/heat-conduction.md ) model are used ($k = 1$, $Q = 0$).
80- 3 . ** Define the mesh.** ` setMeshConfig ` generates a structured mesh from the size of the domain and the number of
74+ 1 . ** Create the model and select the physics.** [ ` FEAScriptModel ` ] ( ../api/feascript-model.md ) holds the whole
75+ configuration of the simulation. ` setModelConfig ` takes the model name and, optionally, its coefficients. Here the
76+ defaults of the [ heat conduction] ( ../models/heat-conduction.md ) model are used ($k = 1$, $Q = 0$).
77+ 2 . ** Define the mesh.** ` setMeshConfig ` generates a structured mesh from the size of the domain and the number of
8178 elements (see [ Mesh] ( ../fundamentals/mesh.md ) ), or uses a mesh imported from Gmsh.
82- 4 . ** Apply the boundary conditions.** The sides of a structured 2D mesh have the keys ` "0" ` (bottom), ` "1" `
79+ 3 . ** Apply the boundary conditions.** The sides of a structured 2D mesh have the keys ` "0" ` (bottom), ` "1" `
8380 (left), ` "2" ` (top) and ` "3" ` (right). See [ Boundary conditions] ( ../fundamentals/boundary-conditions.md ) for the
8481 condition types of every model.
85- 5 . ** Solve.** ` setSolverMethod ` is optional (the default is ` "lusolve" ` ). ` solve() ` returns the
82+ 4 . ** Solve.** ` setSolverMethod ` is optional (the default is ` "lusolve" ` ). ` solve() ` returns the
8683 ` solutionVector ` and the ` nodesCoordinates ` of the mesh (see [ Solvers] ( ../fundamentals/solvers.md ) ).
87- 6 . ** Post-process .** [ ` plotSolution ` ] ( ../api/visualization.md ) draws the result in the ` resultsCanvas ` element.
84+ 5 . ** Plot the results .** [ ` plotSolution ` ] ( ../api/visualization.md ) draws the result in the ` resultsCanvas ` element.
8885
8986## The result
9087
@@ -105,8 +102,11 @@ for (let i = 0; i < solutionVector.length; i++) {
105102``` javascript
106103import { FEAScriptModel } from " feascript" ;
107104
105+ // 1. Create the model and select the physics
108106const model = new FEAScriptModel ();
109107model .setModelConfig (" heatConductionScript" );
108+
109+ // 2. Define the mesh
110110model .setMeshConfig ({
111111 meshDimension: " 2D" ,
112112 elementOrder: " quadratic" ,
@@ -115,12 +115,17 @@ model.setMeshConfig({
115115 maxX: 4 ,
116116 maxY: 2 ,
117117});
118- model .addBoundaryCondition (" 0" , [" constantTemperature" , 200 ]);
119- model .addBoundaryCondition (" 1" , [" symmetry" ]);
120- model .addBoundaryCondition (" 2" , [" convection" , 1 , 20 ]);
121- model .addBoundaryCondition (" 3" , [" constantTemperature" , 200 ]);
122118
119+ // 3. Apply the boundary conditions
120+ model .addBoundaryCondition (" 0" , [" constantTemperature" , 200 ]); // Bottom
121+ model .addBoundaryCondition (" 1" , [" symmetry" ]); // Left
122+ model .addBoundaryCondition (" 2" , [" convection" , 1 , 20 ]); // Top
123+ model .addBoundaryCondition (" 3" , [" constantTemperature" , 200 ]); // Right
124+
125+ // 4. Solve
123126const { solutionVector , nodesCoordinates } = model .solve ();
127+
128+ // 5. Print the results
124129console .log (` Number of nodes: ${ nodesCoordinates .nodesXCoordinates .length } ` );
125130console .log (" Temperature:" , solutionVector);
126131```
0 commit comments