Generate Multiple Meshes

Contents

Generate Multiple Meshes#

This example demonstrates the procedure for generating multiple surface meshes from a single geometry using the Flow360 Python API. It illustrates uploading geometry via the Project interface, defining initial meshing parameters within SimulationParams, and subsequently modifying these parameters to create distinct meshes within the same project context.

 1import flow360 as fl
 2from flow360.examples import Airplane
 3
 4project = fl.Project.from_geometry(
 5    Airplane.geometry,
 6    name="Python Project (Geometry, from file, multiple runs)",
 7)
 8
 9geometry = project.geometry
10geometry.show_available_groupings(verbose_mode=True)
11geometry.group_faces_by_tag("groupName")
12
13with fl.SI_unit_system:
14    params = fl.SimulationParams(
15        meshing=fl.MeshingParams(
16            defaults=fl.MeshingDefaults(
17                boundary_layer_first_layer_thickness=0.001, surface_max_edge_length=1
18            ),
19            volume_zones=[fl.AutomatedFarfield()],
20            refinements=[
21                fl.UniformRefinement(
22                    entities=[
23                        fl.Box.from_principal_axes(
24                            name="MyBox",
25                            center=(0, 1, 2),
26                            size=(4, 5, 6),
27                            axes=((2, 2, 0), (-2, 2, 0)),
28                        ),
29                    ],
30                    spacing=1.5,
31                ),
32            ],
33        ),
34        reference_geometry=fl.ReferenceGeometry(),
35        operating_condition=fl.AerospaceCondition(velocity_magnitude=100, alpha=5 * fl.u.deg),
36        time_stepping=fl.Steady(max_steps=1000),
37        models=[
38            fl.Wall(
39                surfaces=[geometry["*"]],
40            ),
41            fl.Freestream(surfaces=[fl.AutomatedFarfield().farfield]),
42        ],
43        outputs=[
44            fl.SurfaceOutput(surfaces=geometry["*"], output_fields=["Cp", "Cf", "yPlus", "CfVec"])
45        ],
46    )
47
48# Run the mesher once
49project.generate_surface_mesh(params=params, name="Surface mesh 1")
50surface_mesh_1 = project.surface_mesh
51
52# Tweak some parameter in the params
53params.meshing.defaults.surface_max_edge_length = 2 * fl.u.m
54
55# Run the mesher again
56project.generate_surface_mesh(params=params, name="Surface mesh 2")
57surface_mesh_2 = project.surface_mesh
58
59# Check available surface mesh IDs in the project
60ids = project.get_surface_mesh_ids()
61print(ids)

Notes#

  • Meshing parameters, contained within the MeshingParams class nested in SimulationParams, can be adjusted between calls to project.generate_surface_mesh to explore different mesh configurations.

  • Helpers such as fl.AutomatedFarfield and refinement objects (e.g., fl.UniformRefinement with geometric primitives like fl.Box) facilitate the definition of volume mesh zones and local refinement criteria.