|
FhSim
3.1.0
Marine systems simulation
|
The main purpose of fhsim_environment is to provide one single, shared source of truth when it comes to the environment which FhSim models interact with. It contains methods for both querying and change this environment. This means that if one simObject incorporates a change (e.g. a wake field or a transition in sea state), all other simObjects are affected. They all operate in the same environment, and they don't need to know about each other or share any knowledge about each others implementations.
This codebase contains a collection of SimObjects and classes to this end, as well as some simObjects for testing (and demonstrating) its abilities. The set of available SimObjects can be found in modules; known review issues are listed in Review issues — fhsim_environment. Test coverage and Jacobian verification are summarised in Testing report. The most fundamental ones are:
When the simObject Environment is created, it creates an instance of EnvironmentProvider and registers it within FhSim for use by other simObjects. Other simObjects can then access the environment through the EnvironmentProvider. This enables them to both query the environment and to change it.
Two simObjects draw a registered scalar field on the GPU. Both evaluate the field once, at startup, into a texture the shaders read per fragment, so the cost of a high resolution is paid once instead of every frame. Because the value is frozen at the bake, both refuse a field that is not time-invariant unless VisualiseAsConstant says to show it as it is at time zero; a field that must follow the simulation belongs on VisualFlowPlane, which re-evaluates it every frame.
Position and tilted freely through LocalX and LocalY, so a vertical section is configured as readily as a horizontal one, and Size sets how much water it covers. The bake grid is stated either as Resolution or as Spacing, never both.BoxCentre and BoxSize place the box, ReferenceLength is the path length AlphaRange is stated over, and CentreOnCamera lets the box follow the camera, re-baking on a worker thread once it has moved a RebakeFraction of BoxSize.Both take FieldName, the name the field was registered under in the ScalarField.* group, and share the colour parameters ColorRange, VisibleRange and AlphaRange. Changing either range changes the encoding the bake uses, so the field is baked again.
No field provider offers a gradient or any other derivative, and this is by design. A simObject that needs a spatial sensitivity computes it itself, by finite differences of the field's value. Two normals are already available: the sea surface's through GetSurfaceUnitNormal on the environment, and the seabed's through ComputeSurfaceUnitNormal on its bathymetry field.