Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions flow360/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@
)
from flow360.component.simulation.outputs.outputs import (
AeroAcousticOutput,
ImportedSurfaceIntegralOutput,
ImportedSurfaceOutput,
IsosurfaceOutput,
MovingStatistic,
Observer,
Expand All @@ -130,7 +128,6 @@
SurfaceOutput,
SurfaceProbeOutput,
SurfaceSliceOutput,
TimeAverageImportedSurfaceOutput,
TimeAverageIsosurfaceOutput,
TimeAverageProbeOutput,
TimeAverageSliceOutput,
Expand Down Expand Up @@ -246,9 +243,6 @@
"ProbeOutput",
"SurfaceProbeOutput",
"AeroAcousticOutput",
"ImportedSurfaceOutput",
"TimeAverageImportedSurfaceOutput",
"ImportedSurfaceIntegralOutput",
"StreamlineOutput",
"TimeAverageStreamlineOutput",
"Observer",
Expand Down
16 changes: 9 additions & 7 deletions flow360/component/project_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
Slice,
)
from flow360.component.simulation.outputs.outputs import (
ImportedSurfaceIntegralOutput,
ImportedSurfaceOutput,
MonitorOutputType,
SurfaceIntegralOutput,
SurfaceOutput,
)
from flow360.component.simulation.primitives import (
Box,
Expand All @@ -34,6 +34,7 @@
Edge,
GeometryBodyGroup,
GhostSurface,
ImportedSurface,
Surface,
)
from flow360.component.simulation.simulation_params import SimulationParams
Expand Down Expand Up @@ -467,12 +468,13 @@ def _get_imported_surface_file_names(params, basename_only=False):
return []
imported_surface_files = []
for output in params.outputs:
if isinstance(output, (ImportedSurfaceOutput, ImportedSurfaceIntegralOutput)):
if isinstance(output, (SurfaceOutput, SurfaceIntegralOutput)):
for surface in output.entities.stored_entities:
if basename_only:
imported_surface_files.append(os.path.basename(surface.file_name))
else:
imported_surface_files.append(surface.file_name)
if isinstance(surface, ImportedSurface):
if basename_only:
imported_surface_files.append(os.path.basename(surface.file_name))
else:
imported_surface_files.append(surface.file_name)
return imported_surface_files


Expand Down
132 changes: 10 additions & 122 deletions flow360/component/simulation/outputs/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ class SurfaceOutput(_AnimationAndFileFormatSettings):
# TODO: entities is None --> use all surfaces. This is not implemented yet.

name: Optional[str] = pd.Field("Surface output", description="Name of the `SurfaceOutput`.")
entities: EntityListAllowingGhost[Surface, GhostSurface, GhostCircularPlane, GhostSphere] = (
pd.Field(
alias="surfaces",
description="List of boundaries where output is generated.",
)
entities: EntityListAllowingGhost[
Surface, GhostSurface, GhostCircularPlane, GhostSphere, ImportedSurface
] = pd.Field(
alias="surfaces",
description="List of boundaries where output is generated.",
)
write_single_file: bool = pd.Field(
default=False,
Expand Down Expand Up @@ -619,11 +619,11 @@ class SurfaceIntegralOutput(_OutputBase):
"""

name: str = pd.Field("Surface integral output", description="Name of integral.")
entities: EntityListAllowingGhost[Surface, GhostSurface, GhostCircularPlane, GhostSphere] = (
pd.Field(
alias="surfaces",
description="List of boundaries where the surface integral will be calculated.",
)
entities: EntityListAllowingGhost[
Surface, GhostSurface, GhostCircularPlane, GhostSphere, ImportedSurface
] = pd.Field(
alias="surfaces",
description="List of boundaries where the surface integral will be calculated.",
)
output_fields: UniqueItemList[Union[str, UserVariable]] = pd.Field(
description="List of output variables, only the :class:`UserDefinedField` is allowed."
Expand Down Expand Up @@ -1234,114 +1234,6 @@ class TimeAverageStreamlineOutput(StreamlineOutput):
)


class ImportedSurfaceOutput(_AnimationAndFileFormatSettings):
"""
:class:`ImportedSurfaceOutput` class for generating interpolated output on imported surfaces.

Example
-------
>>> fl.ImportedSurfaceOutput(
... name="Jet_cross_sections_output",
... entities=[
... geometry.imported_surfaces["*"],
... ],
... output_fields=[
... fl.solution.Cp,
... ]
... )

====
"""

name: Optional[str] = pd.Field(
"Imported surface output", description="Name of the `ImportedSurfaceOutput`."
)
entities: EntityList[ImportedSurface] = pd.Field(
alias="surfaces",
description="List of imported surfaces where output is generated.",
)
output_fields: UniqueItemList[UserVariable] = pd.Field(description="List of output variables.")
output_type: Literal["ImportedSurfaceOutput"] = pd.Field("ImportedSurfaceOutput", frozen=True)


class TimeAverageImportedSurfaceOutput(ImportedSurfaceOutput):
"""
:class:`TimeAverageImportedSurfaceOutput` class for generating **time-averaged**
output on imported surfaces.

Similar to :class:`ImportedSurfaceOutput`, this output type records user-specified
variables on imported geometry surfaces, but instead of instantaneous values,
it computes averages over a specified range of physical time steps.

Example
-------
>>> fl.TimeAverageImportedSurfaceOutput(
... name="Jet_cross_sections_output",
... entities=[
... geometry.imported_surfaces["*"],
... ],
... output_fields=[
... fl.solution.Cp,
... ],
... start_step=2000
... )

====
"""

name: Optional[str] = pd.Field(
"Time average imported surface output",
description="Name of the `TimeAverageImportedSurfaceOutput`.",
)
start_step: Union[pd.NonNegativeInt, Literal[-1]] = pd.Field(
default=-1, description="Physical time step to start calculating averaging"
)
output_type: Literal["TimeAverageImportedSurfaceOutput"] = pd.Field(
"TimeAverageImportedSurfaceOutput", frozen=True
)


class ImportedSurfaceIntegralOutput(_OutputBase):
"""
:class:`ImportedSurfaceIntegralOutput` class for computing integrals of
user-specified variables over imported surfaces.
Integrals are computed for each of the individual surfaces.

Example
-------
Define a :class:`ImportedSurfaceIntegralOutput` to compute the integrated
mass flow rate across an imported cross-section plane
placed downstream of a nozzle. These planes are provided only for
post-processing and are not part of the simulated mesh boundaries.

>>> fl.ImportedSurfaceIntegralOutput(
... name="Nozzle_exit_planes_integrals",
... entities=[
... geometry.imported_surfaces["*"],
... ],
... output_fields=[
... fl.UserVariable(
... name="MassFlowRate",
... value=fl.solution.density
... * fl.math.dot(fl.solution.velocity, fl.solution.node_unit_normal)
... ),
... ]
... )

====
"""

name: str = pd.Field("Imported surface integral output", description="Name of integral.")
entities: EntityList[ImportedSurface] = pd.Field(
alias="surfaces",
description="List of boundaries where the surface integral will be calculated.",
)
output_fields: UniqueItemList[UserVariable] = pd.Field(description="List of output variables.")
output_type: Literal["ImportedSurfaceIntegralOutput"] = pd.Field(
"ImportedSurfaceIntegralOutput", frozen=True
)


OutputTypes = Annotated[
Union[
SurfaceOutput,
Expand All @@ -1360,9 +1252,6 @@ class ImportedSurfaceIntegralOutput(_OutputBase):
TimeAverageSurfaceProbeOutput,
AeroAcousticOutput,
StreamlineOutput,
ImportedSurfaceOutput,
TimeAverageImportedSurfaceOutput,
ImportedSurfaceIntegralOutput,
TimeAverageStreamlineOutput,
],
pd.Field(discriminator="output_type"),
Expand All @@ -1375,7 +1264,6 @@ class ImportedSurfaceIntegralOutput(_OutputBase):
TimeAverageIsosurfaceOutput,
TimeAverageProbeOutput,
TimeAverageSurfaceProbeOutput,
TimeAverageImportedSurfaceOutput,
TimeAverageStreamlineOutput,
)

Expand Down
Loading
Loading