add tracking for pressurecell
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
058aff6b31
commit
67238f0648
2
src/main/c/includes/fluid/env/environment.h
vendored
2
src/main/c/includes/fluid/env/environment.h
vendored
@ -41,6 +41,8 @@ typedef struct {
|
|||||||
jfieldID homogenousId;
|
jfieldID homogenousId;
|
||||||
jfieldID normalizationRatioId;
|
jfieldID normalizationRatioId;
|
||||||
jfieldID massCountId;
|
jfieldID massCountId;
|
||||||
|
jfieldID pressureTotalId;
|
||||||
|
jfieldID velocityMagTotalId;
|
||||||
} ServerFluidChunkLookupTable;
|
} ServerFluidChunkLookupTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -75,6 +75,16 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
double recaptureDensity;
|
double recaptureDensity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The total pressure of the chunk
|
||||||
|
*/
|
||||||
|
double pressureTotal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total velocity magnitude of the chunk
|
||||||
|
*/
|
||||||
|
double velocityMagTotal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The density outgoing to neighbors
|
* The density outgoing to neighbors
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
/**
|
/**
|
||||||
* Set to 1 to clamp small density values to 0
|
* Set to 1 to clamp small density values to 0
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_ENABLE_CLAMP_MIN_DENSITY 0
|
#define FLUID_PRESSURECELL_ENABLE_CLAMP_MIN_DENSITY 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cutoff after which density is clamped to zero while diffusing
|
* Cutoff after which density is clamped to zero while diffusing
|
||||||
|
|||||||
17
src/main/c/includes/fluid/sim/pressurecell/tracking.h
Normal file
17
src/main/c/includes/fluid/sim/pressurecell/tracking.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef FLUID_PRESSURECELL_TRACKING_H
|
||||||
|
#define FLUID_PRESSURECELL_TRACKING_H
|
||||||
|
|
||||||
|
#include "public.h"
|
||||||
|
#include "fluid/queue/chunk.h"
|
||||||
|
#include "fluid/queue/chunkmask.h"
|
||||||
|
#include "fluid/env/environment.h"
|
||||||
|
#include "fluid/env/utilities.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the tracking data for this chunk
|
||||||
|
*/
|
||||||
|
LIBRARY_API void pressurecell_update_tracking(Environment * environment, Chunk * chunk);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -143,6 +143,8 @@ JNIEXPORT void JNICALL Java_electrosphere_server_fluid_simulator_FluidAccelerate
|
|||||||
environment->lookupTable.serverFluidChunkTable.homogenousId = (*env)->GetFieldID(env,fluidSimStorageClass,"isHomogenous","Z");
|
environment->lookupTable.serverFluidChunkTable.homogenousId = (*env)->GetFieldID(env,fluidSimStorageClass,"isHomogenous","Z");
|
||||||
environment->lookupTable.serverFluidChunkTable.normalizationRatioId = (*env)->GetStaticFieldID(env,fluidSimStorageClass,"normalizationRatio","F");
|
environment->lookupTable.serverFluidChunkTable.normalizationRatioId = (*env)->GetStaticFieldID(env,fluidSimStorageClass,"normalizationRatio","F");
|
||||||
environment->lookupTable.serverFluidChunkTable.massCountId = (*env)->GetStaticFieldID(env,fluidSimStorageClass,"massCount","F");
|
environment->lookupTable.serverFluidChunkTable.massCountId = (*env)->GetStaticFieldID(env,fluidSimStorageClass,"massCount","F");
|
||||||
|
environment->lookupTable.serverFluidChunkTable.pressureTotalId = (*env)->GetFieldID(env,fluidSimStorageClass,"totalPressure","F");
|
||||||
|
environment->lookupTable.serverFluidChunkTable.velocityMagTotalId = (*env)->GetFieldID(env,fluidSimStorageClass,"totalVelocityMag","F");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -106,6 +106,27 @@ LIBRARY_API void updateMetadata(JNIEnv * env, int numChunks, Chunk ** passedInCh
|
|||||||
massCount
|
massCount
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//set non-static metadata in each chunk
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = passedInChunks[i];
|
||||||
|
//total pressure
|
||||||
|
float pressureTotal = (float)currentChunk->pressureCellData.pressureTotal;
|
||||||
|
(*env)->SetFloatField(
|
||||||
|
env,
|
||||||
|
currentChunk->chunkJRaw,
|
||||||
|
environment->lookupTable.serverFluidChunkTable.pressureTotalId,
|
||||||
|
pressureTotal
|
||||||
|
);
|
||||||
|
//total velocity magnitude
|
||||||
|
float velocityMagTotal = (float)currentChunk->pressureCellData.velocityMagTotal;
|
||||||
|
(*env)->SetFloatField(
|
||||||
|
env,
|
||||||
|
currentChunk->chunkJRaw,
|
||||||
|
environment->lookupTable.serverFluidChunkTable.velocityMagTotalId,
|
||||||
|
velocityMagTotal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//update frame state
|
//update frame state
|
||||||
environment->state.frame = environment->state.frame + 1;
|
environment->state.frame = environment->state.frame + 1;
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include "fluid/sim/pressurecell/pressure.h"
|
#include "fluid/sim/pressurecell/pressure.h"
|
||||||
#include "fluid/sim/pressurecell/solver_consts.h"
|
#include "fluid/sim/pressurecell/solver_consts.h"
|
||||||
#include "fluid/sim/pressurecell/normalization.h"
|
#include "fluid/sim/pressurecell/normalization.h"
|
||||||
|
#include "fluid/sim/pressurecell/tracking.h"
|
||||||
#include "fluid/sim/pressurecell/velocity.h"
|
#include "fluid/sim/pressurecell/velocity.h"
|
||||||
|
|
||||||
|
|
||||||
@ -156,6 +157,15 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update tracking
|
||||||
|
//
|
||||||
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
Chunk * currentChunk = chunks[i];
|
||||||
|
pressurecell_update_tracking(environment,currentChunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setup for next iteration
|
// Setup for next iteration
|
||||||
//
|
//
|
||||||
|
|||||||
33
src/main/c/src/fluid/sim/pressurecell/tracking.c
Normal file
33
src/main/c/src/fluid/sim/pressurecell/tracking.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include<math.h>
|
||||||
|
|
||||||
|
#include "fluid/sim/pressurecell/tracking.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the tracking data for this chunk
|
||||||
|
*/
|
||||||
|
LIBRARY_API void pressurecell_update_tracking(Environment * environment, Chunk * chunk){
|
||||||
|
int x, y, z;
|
||||||
|
double pressureSum = 0;
|
||||||
|
double velocitySum = 0;
|
||||||
|
float * u = chunk->u[CENTER_LOC];
|
||||||
|
float * v = chunk->v[CENTER_LOC];
|
||||||
|
float * w = chunk->w[CENTER_LOC];
|
||||||
|
float * pressure = chunk->pressureCache[CENTER_LOC];
|
||||||
|
for(x = 0; x < DIM; x++){
|
||||||
|
for(y = 0; y < DIM; y++){
|
||||||
|
for(z = 0; z < DIM; z++){
|
||||||
|
float velocityMagnitude = sqrt(u[IX(x,y,z)] * u[IX(x,y,z)] + v[IX(x,y,z)] * v[IX(x,y,z)] + w[IX(x,y,z)] * w[IX(x,y,z)]);
|
||||||
|
velocitySum = velocitySum + velocityMagnitude;
|
||||||
|
pressureSum = pressureSum + pressure[IX(x,y,z)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chunk->pressureCellData.pressureTotal = pressureSum;
|
||||||
|
chunk->pressureCellData.velocityMagTotal = velocitySum;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -45,6 +45,11 @@ public class ImGuiFluidMonitor {
|
|||||||
ImGui.text("Broadcast Size (This Frame): " + fluidManager.getBroadcastSize());
|
ImGui.text("Broadcast Size (This Frame): " + fluidManager.getBroadcastSize());
|
||||||
ImGui.text("Normalization Ratio: " + ServerFluidChunk.getNormalizationRatio());
|
ImGui.text("Normalization Ratio: " + ServerFluidChunk.getNormalizationRatio());
|
||||||
ImGui.text("Mass: " + ServerFluidChunk.getMassCount());
|
ImGui.text("Mass: " + ServerFluidChunk.getMassCount());
|
||||||
|
if(fluidManager.getChunk(0, 0, 0) != null){
|
||||||
|
ServerFluidChunk chunk = fluidManager.getChunk(0, 0, 0);
|
||||||
|
ImGui.text("Pressure: " + chunk.getTotalPressure());
|
||||||
|
ImGui.text("Velocity magnitude: " + chunk.getTotalVelocityMag());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ImGui.collapsingHeader("Client Data")){
|
if(ImGui.collapsingHeader("Client Data")){
|
||||||
|
|
||||||
|
|||||||
@ -196,6 +196,16 @@ public class ServerFluidChunk {
|
|||||||
*/
|
*/
|
||||||
public float totalDensity = 0;
|
public float totalDensity = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total pressure of this chunk
|
||||||
|
*/
|
||||||
|
public float totalPressure = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total velocity magnitude of this chunk
|
||||||
|
*/
|
||||||
|
public float totalVelocityMag = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The normalization ratio used to smooth fluid simulation steps
|
* The normalization ratio used to smooth fluid simulation steps
|
||||||
*/
|
*/
|
||||||
@ -658,6 +668,22 @@ public class ServerFluidChunk {
|
|||||||
return massCount;
|
return massCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total pressure of this chunk
|
||||||
|
* @return The total pressure of this chunk
|
||||||
|
*/
|
||||||
|
public float getTotalPressure(){
|
||||||
|
return totalPressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total velocity magnitude of this chunk
|
||||||
|
* @return The total velocity magnitude of this chunk
|
||||||
|
*/
|
||||||
|
public float getTotalVelocityMag(){
|
||||||
|
return totalVelocityMag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user