10class VolumeSurfaceProcessor;
11class SDFMeshProcessor;
13class VolumeGridBuffer;
15class BuoyancyProcessor;
17class DivergenceProcessor;
18class DiffuseProcessor;
19class PressureProcessor;
20class SolenoidalProcessor;
42 std::weak_ptr<VolumeGridBuffer>
owner;
44 static constexpr size_t stride =
sizeof(float);
46 operator const std::string&()
const {
return name; }
54 auto o =
owner.lock();
55 return o && o.get() == volume;
68 std::weak_ptr<VolumeGridBuffer>
owner;
70 static constexpr size_t stride =
sizeof(glm::vec4);
72 operator const std::string&()
const {
return name; }
80 auto o =
owner.lock();
81 return o && o.get() == volume;
151 bool double_buffered =
true;
189 float dissipation { 1.0F };
199 glm::vec3 direction { 0.0F, 1.0F, 0.0F };
211 float viscosity { 0.0F };
212 uint32_t jacobi_iterations { 32 };
236 std::vector<std::shared_ptr<AdvectProcessor>>
carriers;
248 std::initializer_list<FieldDecl> fields,
249 std::optional<SurfaceConfig> surface = std::nullopt);
259 std::vector<FieldDecl> fields,
260 std::optional<SurfaceConfig> surface = std::nullopt);
274 std::optional<SurfaceConfig> surface = std::nullopt);
328 [[nodiscard]] std::shared_ptr<VolumeSurfaceProcessor>
surface_processor()
const {
return m_surface_processor; }
331 [[nodiscard]] std::shared_ptr<SDFMeshProcessor>
mesh_processor()
const {
return m_mesh_processor; }
337 [[nodiscard]] uint32_t
get_width()
const {
return m_lattice.resolution.x; }
340 [[nodiscard]] uint32_t
get_height()
const {
return m_lattice.resolution.y; }
343 [[nodiscard]] uint32_t
get_depth()
const {
return m_lattice.resolution.z; }
346 [[nodiscard]] uint32_t
get_cell_count()
const {
return static_cast<uint32_t
>(m_lattice.cell_count()); }
352 [[nodiscard]] glm::vec3
get_cell_size()
const {
return m_lattice.cell_size(); }
355 [[nodiscard]]
bool has_field(
const std::string& name)
const;
358 [[nodiscard]]
size_t get_field_bytes(
const std::string& name)
const;
361 [[nodiscard]] std::vector<std::string> get_field_names()
const;
368 [[nodiscard]] vk::Buffer read_handle(
const std::string& name)
const;
377 [[nodiscard]] vk::Buffer write_handle(
const std::string& name)
const;
388 void swap_field(
const std::string& name);
396 ScalarRef declare_scalar(std::string name);
410 ScalarRef declare_scratch(std::string name);
422 VectorRef declare_vector(std::string name);
449 void seed_raw(
const std::string& name,
const void* data,
size_t size);
481 void read_field(
const std::string& name,
void* data,
size_t size);
495 void allocate_fields(
const std::vector<FieldDecl>& decls);
504 bool allocate_field(
const std::string& name,
size_t stride_bytes,
bool double_buffered);
512 [[nodiscard]]
const Field* find_field(
const std::string& name,
const char* context)
const;
532 static size_t surface_storage_bytes(
const std::optional<SurfaceConfig>& surface);
Vulkan-backed buffer wrapper used in processing chains.
uint32_t get_width() const
Cell count along X.
const Kinesis::Lattice3D & get_lattice() const
The lattice every field is discretized over.
std::unordered_map< std::string, Field > m_fields
void accumulate(const std::string &name, const Kinesis::VectorField &field)
Add sampled values into a vector field.
TransferHandle m_pending_transfer
In-flight seed upload, resolved before the next transfer.
uint32_t get_cell_count() const
Total cell count.
uint32_t get_depth() const
Cell count along Z.
const Kinesis::AABB3D & get_bounds() const
World-space extent the lattice covers.
Kinesis::Lattice3D m_lattice
glm::vec3 get_cell_size() const
World-space size of one cell along each axis.
std::optional< SurfaceConfig > m_surface
std::shared_ptr< SDFMeshProcessor > mesh_processor() const
The marching cubes stage, valid after setup_rendering.
std::shared_ptr< VolumeSurfaceProcessor > surface_processor() const
The surface extraction stage, valid after setup_rendering.
std::shared_ptr< VKBuffer > m_transfer_staging
Reused across seed and read calls.
std::shared_ptr< VolumeSurfaceProcessor > m_surface_processor
std::vector< std::string > m_field_order
void seed(const std::string &name, const Kinesis::VectorField &field)
Write initial values into a vector field from a Kinesis field.
std::shared_ptr< VKBuffer > m_counter_buf
Atomic vertex counter for the extraction stage.
std::shared_ptr< SDFMeshProcessor > m_mesh_processor
uint32_t get_height() const
Cell count along Y.
GPU-resident state for multi-field simulations evaluated over a fixed 3D topology: incompressible flu...
std::shared_ptr< void > TransferHandle
Opaque handle to an in-flight transfer.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
std::weak_ptr< VolumeGridBuffer > owner
static constexpr size_t stride
bool issued_by(const VolumeGridBuffer *volume) const
Whether this ref was issued by the given volume.
A scalar field's name, issued by the volume that owns it.
static constexpr size_t stride
bool issued_by(const VolumeGridBuffer *volume) const
Whether this ref was issued by the given volume.
std::weak_ptr< VolumeGridBuffer > owner
A vector field's name, issued by the volume that owns it.
std::string name
Lookup key, unique within the volume.
size_t stride_bytes
Bytes per cell.
One field's declaration within a volume.
ScalarRef density
Drives motion against it.
ScalarRef temperature
Drives motion along direction.
Body force accumulated into velocity from two scalars.
ScalarRef field
Field advected.
A scalar transported by the velocity field.
ScalarRef pressure
Required.
VectorRef velocity
Required.
VectorRef scratch
Required only when viscosity is above zero.
std::optional< Buoyancy > buoyancy
std::vector< Carried > carried
ScalarRef divergence
Required. Single-slot is correct.
Parameters for the incompressible flow stage arrangement.
std::shared_ptr< AdvectProcessor > self_advect
std::shared_ptr< PressureProcessor > pressure
std::shared_ptr< WallProcessor > wall_projected
std::vector< std::shared_ptr< AdvectProcessor > > carriers
Parallel to config.carried.
std::shared_ptr< DiffuseProcessor > diffuse
std::shared_ptr< DivergenceProcessor > divergence
std::shared_ptr< SolenoidalProcessor > solenoidal
std::shared_ptr< BuoyancyProcessor > buoyancy
std::shared_ptr< WallProcessor > wall_advected
Every stage setup_flow built, in no particular order.
std::string field_name
Scalar field surfaced. Stride must be sizeof(float).
glm::uvec3 resolution
Extraction cell count per axis, over the volume's own bounds.
float threshold
Field value the surface is placed at.
Isosurface extraction parameters for a scalar field.
Axis-aligned bounding box in 3D world space.
A regular subdivision of an AABB3D into a cell count per axis.
Typed, composable, stateless callable from domain D to range R.
Unified rendering configuration for graphics buffers.