Skip to content

Commit a042a04

Browse files
committed
Add content to mesh page
1 parent 3eb38b2 commit a042a04

File tree

1 file changed

+105
-5
lines changed

1 file changed

+105
-5
lines changed

tutorial/meshing.rst

+105-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,109 @@
11
Meshing
22
=======
33

4-
To Do:
4+
The CFD numerical method used for the incompressible setup requires
5+
the discretization of the fluid domain, a process also known as meshing.
6+
In the Simscale platform, a mesh is an individual object that needs a model
7+
to specify its properties, such as sizing. The mesh also has to be computed
8+
before the simulation can be run.
59

6-
* How to create a mesh
7-
* How to setup mesh sizing, automatic
8-
* How to compute the mesh and check the progress
9-
* How to assing the mesh to the simulation
10+
Mesh Model
11+
----------
12+
13+
Similar to a simulation, we first need to specify the mesh parameters
14+
with a model object. It can be done as follows:
15+
16+
17+
.. code-block:: python
18+
19+
import simscale_sdk as sim
20+
21+
mesh_model = sim.SimmetrixMeshingFluid(
22+
sizing=sim.AutomaticMeshSizingSimmetrix(
23+
fineness=5,
24+
curvature=sim.AutomaticCurvature(),
25+
),
26+
automatic_layer_settings=sim.AutomaticLayerOn(
27+
number_of_layers=3,
28+
total_relative_thickness=0.4,
29+
growth_rate=1.5
30+
),
31+
pysics_based_meshing=True,
32+
hex_core=True,
33+
)
34+
35+
36+
Here we make use of the automatic sizing with fineness level 5. Also, physics-based
37+
meshing allows to take into account boundary conditions for layer creation. boundary
38+
layer settings are entered manually with 3 layers on walls. Finally, the hex_core
39+
is entered to improve the orthogonality of the mesh.
40+
41+
Mesh Operation
42+
--------------
43+
44+
Now that we have a proper mesh model, we can create the mesh operation, which links
45+
the project, the geometry and the model:
46+
47+
48+
.. code-block:: python
49+
50+
import simscale_sdk as sim
51+
52+
mesh_operation_api = sim.MeshOperationsApi(api_client)
53+
54+
mesh_operation = mesh_operation_api.create_mesh_operation(
55+
project_id,
56+
sim.MeshOperation(
57+
name="Pipe junction mesh",
58+
geometry_id=geometry_id,
59+
model=mesh_model,
60+
)
61+
)
62+
63+
64+
The mesh operation object is used to launch the computation and track its progress:
65+
66+
67+
.. code-block:: python
68+
69+
mesh_operation_api.start_mesh_operation(
70+
project_id,
71+
mesh_operation.mesh_operation_id,
72+
simulation_id=simulation_id,
73+
)
74+
75+
while mesh_operation.status not in ("FINISHED", "CANCELED", "FAILED"):
76+
77+
mesh_operation = mesh_operation_api.get_mesh_operation(
78+
project_id,
79+
mesh_operation.mesh_operation_id,
80+
)
81+
82+
time.sleep(30)
83+
84+
print(f"Mesh with id={mesh_operation.mesh_id} was completed with status {mesh_operation.status}")
85+
86+
87+
You should recognize this pattern from the geometry import process. Of course, it is
88+
possible to improve the loop, as was done there, to include a time limit or use
89+
parallel async computation of multiple meshes.
90+
91+
Link Mesh to simulation
92+
-----------------------
93+
94+
Finally, when the mesh is succesfully computed, we can link it to our simulation spec
95+
so the platform knows that it should use it as part of the simulation computation:
96+
97+
98+
.. code-block:: python
99+
100+
# Might not be needed if the simulation_spec object is updated
101+
simulation_spec = simulations_api.get_simulation(project_id, simulation_id)
102+
103+
simulation_spec.mesh_id = mesh_operation.mesh_id
104+
105+
simulations_api.update_simulation(project_id, simulation_id, simulation_spec)
106+
107+
108+
Now our simulation is ready for computation, with its physics model and a mesh
109+
completely defined.

0 commit comments

Comments
 (0)