MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
WallProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Buffers {
6
7/**
8 * @class WallProcessor
9 * @brief VolumeFieldProcessor zeroing the wall-normal component of a
10 * vector field on the six lattice faces.
11 *
12 * Free-slip: the component normal to each face is set to zero on that
13 * face's cells, tangential components pass through unchanged. Edge and
14 * corner cells belong to two or three faces and lose that many
15 * components. Interior cells are copied verbatim.
16 *
17 * Without this the lattice leaks. Semi-Lagrangian advection writes each
18 * cell from a backtraced source, so material whose forward trajectory
19 * exits the lattice is written nowhere and its mass is gone. With no net
20 * flow through a wall the error averages out; with a sustained normal
21 * velocity there, as buoyancy produces, the loss is one-directional and
22 * compounds. The pressure solve cannot correct it: zero-gradient pressure
23 * at the wall means the solenoidal correction's normal component vanishes
24 * there by construction, so the solve is structurally unable to touch the
25 * velocity that is doing the leaking.
26 *
27 * Runs after every stage that writes velocity. In a stable-fluids chain
28 * that is twice: once after self-advection, once after the projection.
29 * Use two instances; the stage carries no per-cycle state but a processor
30 * appears once in a chain.
31 *
32 * The condition is geometric, not physical. It says material cannot cross
33 * the lattice boundary. It does not model a surface, and nothing about it
34 * assumes which axis is up.
35 */
36class MAYAFLUX_API WallProcessor : public VolumeFieldProcessor {
37public:
38 /**
39 * @brief Construct a free-slip wall stage.
40 * @param velocity_field Name of the field constrained. Must have
41 * stride sizeof(glm::vec4) and be double-buffered.
42 * @param shader_path Path to the compute shader.
43 */
44 WallProcessor(std::string velocity_field, const std::string& shader_path);
45
46 /**
47 * @brief Construct a free-slip wall stage from a generated ShaderSpec.
48 * @param velocity_field Name of the field constrained.
49 * @param spec ShaderSpec implementing the condition.
50 */
51 WallProcessor(std::string velocity_field, const Portal::Graphics::ShaderSpec& spec);
52
53 /** @brief Name of the constrained field. */
54 [[nodiscard]] const std::string& get_velocity_field() const { return m_velocity_field; }
55
56private:
57 /**
58 * @brief Build the binding table for the field name.
59 * @param velocity_field Field bound in both slots.
60 * @return Table binding the read slot and the write slot.
61 */
62 static std::vector<FieldBinding> make_bindings(const std::string& velocity_field);
63
64 std::string m_velocity_field;
65};
66
67} // namespace MayaFlux::Buffers
ComputeProcessor operating on named fields of a VolumeGridBuffer.
const std::string & get_velocity_field() const
Name of the constrained field.
VolumeFieldProcessor zeroing the wall-normal component of a vector field on the six lattice faces.
Complete declarative description of a generated compute shader.