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:
# Define a user variable to compute local mass flux at each surface node
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 file to the cloud and registers it with the project. Thenameargument is the key used to reference the surface inside the draft context.Imported surfaces must be passed to
fl.create_draft()via theimported_surfacesargument before they can be referenced.Inside the draft context, use
draft.imported_surfaces["name"]to retrieve a reference to an imported surface for use in any output type.Supported surface file formats are STL, CGNS, and UGRID.
For a complete example that includes boundary conditions and user-defined surface integral variables, see the Flow360 GitHub example.