Import Sample Surface

Contents

Import Sample Surface#

This snippet demonstrates how to import external surface mesh files into a Flow360 project and use them as output surfaces to extract flow field data and compute surface integrals.

import flow360 as fl

# Load an existing project that already has a volume mesh
project = fl.Project.from_cloud("YOUR_PROJECT_ID")
volume_mesh = project.volume_mesh

# Import one or more surface mesh files (STL, CGNS, or UGRID)
surface_a = project.import_surface_mesh("surface_a.stl", name="surface_a")
surface_b = project.import_surface_mesh("surface_b.stl", name="surface_b")

with fl.create_draft(
    new_run_from=volume_mesh,
    imported_surfaces=[surface_a, surface_b],
) as draft:
    with fl.SI_unit_system:
        # Local mass flux at each surface node. The surface integral below
        # applies the area weighting itself, so this variable is the local
        # (per unit area) quantity and must not include an area factor.
        mass_flux = fl.UserVariable(
            name="MassFlux",
            value=fl.solution.density
            * fl.math.dot(fl.solution.velocity, fl.solution.node_unit_normal),
        )

        params = fl.SimulationParams(
            operating_condition=fl.AerospaceCondition(velocity_magnitude=10*fl.u.m/fl.u.s),
            models=[...],
            time_stepping=fl.Steady(),
            outputs=[
                # Extract flow field quantities on the imported surfaces
                fl.SurfaceOutput(
                    output_fields=[fl.solution.velocity, fl.solution.Cp],
                    surfaces=[
                        draft.imported_surfaces["surface_a"],
                        draft.imported_surfaces["surface_b"],
                    ],
                ),
                # Integrate the mass flux over each imported surface
                fl.SurfaceIntegralOutput(
                    name="MassFluxIntegral",
                    output_fields=[mass_flux],
                    surfaces=[
                        draft.imported_surfaces["surface_a"],
                        draft.imported_surfaces["surface_b"],
                    ],
                ),
            ],
        )
    project.run_case(params, name="imported_surface_outputs")

Notes#

  • project.import_surface_mesh(filename, name=) uploads the surface and registers it with the project. Pass the returned surfaces to fl.create_draft() through imported_surfaces before referencing them as draft.imported_surfaces["name"].

  • Define the integral variable as the local quantity, as MassFlux does below. The area weighting is applied for you.

See also

Sample Surfaces for the supported file formats, which outputs accept a sample surface, the field restrictions, and the treatment of nodes outside the fluid domain.

A fuller example with boundary conditions and user-defined integral variables: import_surface_field_and_integral.py.