UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PressureProjection.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Chaos/ArrayFaceND.h"
5#include "Chaos/ArrayND.h"
7#include "Chaos/UniformGrid.h"
8
9namespace Chaos
10{
11template<class T, int d>
13{
14 public:
17
19 {
20 TArrayND<T, d> Pressure(Grid), Divergence(Grid);
21 // compute divergence
22 PhysicsParallelFor(Grid.GetNumCells(), [&](int32 Index) {
23 const TVector<int32, d> CellIndex = Grid.GetIndex(Index);
24 Divergence(CellIndex) = 0;
25 for (int32 Axis = 0; Axis < d; ++Axis)
26 {
27 Divergence(CellIndex) += (Velocity(MakePair(Axis, CellIndex + TVector<int32, d>::AxisVector(Axis))) - Velocity(MakePair(Axis, CellIndex))) / Grid.Dx()[Axis];
28 }
29 });
30 check(false);
31 MPressureRule(Grid, Pressure, Divergence, Dirichlet, Neumann, dt);
32 PhysicsParallelFor(Grid.GetNumFaces(), [&](int32 Index) {
33 const auto FaceIndex = Grid.GetFaceIndex(Index);
34 const auto Axis = FaceIndex.First;
35 const auto PrevIndex = FaceIndex.Second - TVector<int32, d>::AxisVector(Axis);
36 const auto NextIndex = FaceIndex.Second;
37 // Currently we assume that if no boundary is set on the boarder it must be dirichlet
38 T PrevPressure = 0;
39 T NextPressure = 0;
40 if (NextIndex[Axis] < Grid.Counts()[Axis])
41 {
42 NextPressure = Pressure(NextIndex);
43 }
44 if (PrevIndex[Axis] >= 0)
45 {
46 PrevPressure = Pressure(PrevIndex);
47 }
48 if (!Neumann(FaceIndex))
49 {
51 }
52 });
53 }
54
55 private:
56 TFunction<void(const TUniformGrid<T, d>&, TArrayND<T, d>&, const TArrayND<T, d>&, const TArrayND<bool, d>&, const TArrayFaceND<bool, d>&, const T)> MPressureRule;
57};
58}
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
if(Failed) console_printf("Failed.\n")
Definition ArrayFaceND.h:14
Definition ArrayND.h:194
Definition PressureProjection.h:13
TPressureProjection()
Definition PressureProjection.h:15
~TPressureProjection()
Definition PressureProjection.h:16
void Apply(const TUniformGrid< T, d > &Grid, TArrayFaceND< T, d > &Velocity, const TArrayND< bool, d > &Dirichlet, const TArrayFaceND< bool, d > &Neumann, const T dt)
Definition PressureProjection.h:18
Definition UniformGrid.h:267
Definition AndroidPlatformMisc.h:14
Definition SkeletalMeshComponent.h:307
void CHAOS_API PhysicsParallelFor(int32 InNum, TFunctionRef< void(int32)> InCallable, bool bForceSingleThreaded=false)
Definition Parallel.cpp:55
@ Velocity
Definition SimulationModuleBase.h:147
U16 Index
Definition radfft.cpp:71