- Move C++ sources to core/ subdirectory (T05) - Add pnpm workspaces + Turborepo pipeline (T06) - Add Emscripten CMake target and build-wasm.sh (T07) - Implement Embind bindings via YmirBindings.cpp (T08) - Add packages/types with TypeBox schemas for VesselDTO, ScenarioDTO, SimulationStateDTO (T09) - Create apps/api: Fastify v4 + Drizzle ORM + SQLite with vessels/scenarios CRUD (T10-T13) - Create apps/web: Vite + React 18 + COOP/COEP headers (T14) - Add simulation.worker.ts for WASM loop in Web Worker (T15) - Add Zustand simulationStore (T16) - Add TelemetryPanel component (T17) - Verified: pnpm build 3/3 tasks, 21ms cached; ctest 211/211 pass (T18-T19) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
67 lines
2.1 KiB
C++
67 lines
2.1 KiB
C++
#include <catch2/catch_test_macros.hpp>
|
|
#include <catch2/catch_approx.hpp>
|
|
|
|
#include <ymir/world/wave/WaveForces.h>
|
|
#include <ymir/world/wave/WaveSpectrum.h>
|
|
#include <ymir/vessel/NavalContext.h>
|
|
#include <ymir/physics/BodyState.h>
|
|
|
|
using Catch::Approx;
|
|
using namespace ymir::naval;
|
|
|
|
static NavalContext makeCtx()
|
|
{
|
|
ymir::Vector6 q{};
|
|
ymir::Vector6 qdot{};
|
|
ymir::BodyState bs(q, qdot, 0.0, 0.1);
|
|
NavalContext ctx{};
|
|
ctx.state = bs;
|
|
return ctx;
|
|
}
|
|
|
|
static WaveSpectrum makeSpectrum()
|
|
{
|
|
WaveSpectrum::Config cfg{};
|
|
cfg.spectrumType = WaveSpectrumType::REGULAR;
|
|
cfg.significantWaveHeight = 1.0;
|
|
cfg.peakPeriod = 8.0;
|
|
cfg.mainDirection_deg = 0.0;
|
|
cfg.seed = 0;
|
|
cfg.n_frequencies = 1;
|
|
cfg.n_directions = 1;
|
|
return WaveSpectrum(cfg);
|
|
}
|
|
|
|
TEST_CASE("WaveForces constructs with WAMIT tables")
|
|
{
|
|
WaveForces::Config cfg{};
|
|
cfg.wavesOriginPosition = {0.0, 0.0, 0.0};
|
|
// Minimal 1x1 RAO table (1 frequency, 1 direction)
|
|
cfg.wamitFrequencies = {0.785}; // rad/s (8s period)
|
|
cfg.wamitDirections = {0.0};
|
|
// RAO magnitude and phase for 6 DOF x 1 freq x 1 dir
|
|
cfg.raoMagnitude.assign(6, std::vector<std::vector<double>>(1, std::vector<double>(1, 0.0)));
|
|
cfg.raoPhase.assign(6, std::vector<std::vector<double>>(1, std::vector<double>(1, 0.0)));
|
|
// Set heave RAO = 1.0 (unit response)
|
|
cfg.raoMagnitude[2][0][0] = 1.0;
|
|
|
|
WaveForces model(cfg, makeSpectrum());
|
|
REQUIRE(true); // construction succeeds
|
|
}
|
|
|
|
TEST_CASE("WaveForces compute does not throw")
|
|
{
|
|
WaveForces::Config cfg{};
|
|
cfg.wavesOriginPosition = {0.0, 0.0, 0.0};
|
|
cfg.wamitFrequencies = {0.785};
|
|
cfg.wamitDirections = {0.0};
|
|
cfg.raoMagnitude.assign(6, std::vector<std::vector<double>>(1, std::vector<double>(1, 0.0)));
|
|
cfg.raoPhase.assign(6, std::vector<std::vector<double>>(1, std::vector<double>(1, 0.0)));
|
|
|
|
WaveForces model(cfg, makeSpectrum());
|
|
NavalContext ctx = makeCtx();
|
|
model.bindContext(&ctx);
|
|
|
|
REQUIRE_NOTHROW(model.compute(ctx.state));
|
|
}
|