![]() |
MarEnv 0.0.7
MarEnv - Simulation of a marine environment.
|
Calculations pertaining to marine environment processes and properties, such as waves, wind, seafloor and ocean currents. Particularly aimed at facilitating syncronised environment representations between models within distributed simulations.
When simulation models depending on a marine environment are distributed between multiple computers, several issues arise. Most notably, how can one keep time dependent processes, such as wave patterns, syncronised between exchange of information between models? This library seeks to solve this challenge by implementing predefined and deterministic environment models. This implementation includes methods for querying e.g. particle velocities, surface elevation for a given time and position. The main idea is that the environment is specified in terms of constant or slowly varying definitions, which the models feed their local marenv instance. Subsequent queries for e.g. particle velocities will then give the same results in the different models, without requiring further communication. These queries will then be valid and in sync until the environment is changed.
The current implementation does not include transitions between an existing and a new environment state, but this will be included in a future version.
The aim is for this implementation to be easy to use, with as few dependencies as possible and open source. It aims at providing a standard for the handling of marine environments in distributed simulations, but it should be well suited for use in other situations where marine environment calculations are needed. To support syncronised environments between computers and processes, a pseudorandom number generator is implemented.
The Marine Environment Agent System provides a single API to query marine environmental conditions — combining waves, currents, and seafloor data in one call.
Conan is the preferred way of using this library. The package is usually consumed using the conan install command or a conanfile.txt.
Add remote to conan's package remotes:
Using conanfile.txt in your project with cmake
Add conanfile.txt:
Insert into your CMakeLists.txt something like the following lines:
Install and build:
where <build_type> is e.g. Debug or Release. You can now continue with the usual cmake commands for configuration and compilation, provided that you point to the toolchain file when running the cmake commands. For details on how to use conan, please consult Conan.io docs
Marenv aims to provide a full set of interfaces, and a minimum set of implementations. This allows for proprietary implementations being used without its source code. Currently, the emphasis is placed on linear wave models. These create sea states by superpositioning of multiple wave components. There are three implementations:
The seafloor implementation defines the depths as a combination of harmonic variations.
There are three implementations of ocean currents:
This library uses a right-handed coordinate system with the x-axis pointing East, the y-axis pointing North and the z-axis pointing Down. Depths are therefore positive below mean sea level. Note that the wave elevation is positive upwards. Wave elevation is not the z-position of the surface, but rather the local elevation of the surface.
The units used are SI units if nothing else is obvious from the naming of variables or functions.
| Method | Description |
|---|---|
| GetSurfaceElevation() | Returns free-surface elevation (η). |
| GetParticleVelocity() | Returns total particle velocity (waves + currents). |
| GetPressure() | Returns dynamic pressure at depth. |
| GetSeadepth() | Returns seafloor depth at a position. |
| PointEnvironmentQuery() | Returns multiple quantities in one call. |
All agent functions return a status from the AgentReturn enum:
| Code | Meaning |
|---|---|
| AgentReturn::OK | Operation successful. |
| AgentReturn::OUT_OF_RANGE_INACCURATE | Query outside valid range — returned value may be approximate. |
| AgentReturn::NOT_APPLICABLE_NOT_SET | Data not applicable or not configured. |
| AgentReturn::ERROR_NOT_SET | Operation failed, no valid data available. |
| AgentReturn::NOT_IMPLEMENTED | Function not yet implemented in the agent. |
Building this repository locally can be done with conan using the following commands.
To build into subfolder folder of repository (marenv).
This builds the library without doc and tests into build (Windows) or build/<build_type> (Linux). Subsequent builds can be done using cmake commands.
To create a package in the local conan cache.
| Option | Allowed values | Default value |
|---|---|---|
| shared | [True, False] | False |
| fPIC | [True, False] | True |
| with_doc | [True, False] | True |
The marenv::agent namespace defines abstract interfaces and a composite agent architecture for modeling and querying marine environment data.
Each physical aspect of the environment is represented by a dedicated interface:
| Interface | Purpose |
|---|---|
| WaveInterface | Computes wave-induced quantities (e.g., surface elevation, velocities, pressures). |
| CurrentInterface | Provides current velocity fields. |
| BathymetryInterface | Represents seafloor geometry and material properties. |
| EnvironmentInterface | Unified interface combining waves, currents, and bathymetry. |
| EnvironmentAgent | Concrete class delegating calls to individual sub-agents. |
The most important part of the directory structure is shown below. The marenv/include/marenv directory contains the public API of the project.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.