flow 1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
traj.cpp
Go to the documentation of this file.
1// Deterministic single-shape trajectory dump: proves the Layer-1 shape-registry refactor left the
2// existing (shapeId == 0) path bit-identical. Uses ONLY the pre-Layer-1 API so it compiles against
3// both revisions.
4#include <cstdint>
5#include <cstdio>
6#include <cstdlib>
7#include <cstring>
8#include <vector>
9
10#include "sim.hpp"
11using namespace peclet::dem;
12int main(int argc, char** argv) {
13 Kokkos::initialize(argc, argv);
14 std::vector<std::uint32_t> bits;
15 {
16 for (int shape : {(int)SPHERE, (int)BOX, (int)HOLLOW_CYLINDER}) {
17 Simulation s(128);
18 s.setDomain(1.f, 1.f, 1.f, true, true, true);
19 s.initializeShape(shape, 0.045f, 0.08f, 0.02f);
20 std::uint32_t st = 0x5EED01u;
21 auto u = [&](float lo, float hi) {
22 st = st * 1664525u + 1013904223u;
23 return lo + (hi - lo) * ((float)((st >> 8) & 0xFFFFFFu) / (float)0x1000000u);
24 };
25 std::vector<float> pos(3 * 60);
26 for (auto& v : pos)
27 v = u(0.15f, 0.85f);
28 s.setPositions(pos);
29 s.setGravity(0.f, -9.81f, 0.f);
30 s.setDt(2e-4f);
31 const int NSTEP = std::atoi(argv[2]);
32 for (int k = 0; k < NSTEP; ++k)
33 s.step(2e-4f);
34 s.computeOverlaps(); // narrow-phase ONLY on the given configuration -- no dynamics
35 std::printf(" shape=%d static overlap probe: contacts=%d maxOverlap=%.9g\n", shape,
36 s.numContacts(), (double)s.maxOverlap());
37 for (const std::vector<float>& arr : {s.getPositions(), s.getVelocities(), s.getInvInertia()})
38 for (float v : arr) {
39 std::uint32_t b;
40 std::memcpy(&b, &v, 4);
41 bits.push_back(b);
42 }
43 }
44 }
45 Kokkos::finalize();
46 std::FILE* f = std::fopen(argv[1], "wb");
47 std::fwrite(bits.data(), 4, bits.size(), f);
48 std::fclose(f);
49 std::printf("wrote %zu values\n", bits.size());
50 return 0;
51}
int main()
Definition dbg_scene.cpp:13
static const std::array< int, 6 > BOX[2]