-
Hey I just saw there is a discussion section on Github here so this'd be a good place to ask some questions if anyone can help: I have a 125x stl sequence of a CH-53 helicopter which animates the moving rotor blades. Firstly, I don't suppose someone know's how to better code something that runs a revoxelisation loop than the 125 level deep if-else statement in the code below? 😢 Next thing is I've tried a number of different ways, but I don't know how to implement the voxel velocities in the boundary nodes, so I'm not sure if the spinning rotors are interacting with the airflow properly? The voxels are appearing pink, but I'm not sure if that means anything, or if it's just appearing that way because it's being displayed like that at this instant but the flags are wiped before they're calculated correctly... I have this video on YouTube here and I don't know if my output looks correct. Has anyone beel able to find an example in the setup.cpp section where something like this setup correctly? std::atomic_bool revoxelizing = false;
void revoxelize(LBM* lbm, Mesh* mesh) { // voxelize new frames in detached thread in parallel while LBM is running
for (uint n = 0u; n < lbm->get_N(); n++) lbm->flags[n] &= ~TYPE_S; // clear flags
voxelize_mesh_hull(*lbm, mesh, TYPE_S); // voxelize rotated mesh in lbm.flags
revoxelizing = false; // indicate new voxelizer thread has finished
}
void main_setup() {
// ######################################################### define simulation box size, viscosity and volume force ####################################
const uint L = 512+128u;
const float knots = 1.0f; // Initial speed of fluid
const float AoA = 0.0f; // Negative is nose down
const float kmh = knots * 1.852f;
const float si_u = kmh / 3.6f;
const float si_x = 20.0f; //Characteristic Length
const float si_rho = 1.225f; //Air Density
const float si_nu = 1.48E-5f;
const float Re = units.si_Re(si_x, si_u, si_nu); //Reynolds Number
print_info("Re = " + to_string(Re));
const float u = 0.08f;
LBM lbm(L, L*5u/4u , L / 2u, units.nu_from_Re(Re, (float)L, u)); // Proportions of containing box
// #####################################################################################################################################################
const float size = 1.0f * (float)L;
const float3 center = float3(lbm.center().x+0.0f*size, lbm.center().y+(-0.1f)*size, lbm.center().z+0.04f*size);
const float3x3 rotation = float3x3(float3(1, 0, 0), -radians(AoA)); //Set initial orientation of object (CHECK AXIS SET CORRECTLY: x, y, z)
float modelSize = size * 1.0f; //set relative model size here
// *************Allocate ALL of the meshes*************
Mesh* mesh1 = read_stl(get_exe_path() + "../stl/Sequence/1.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh2 = read_stl(get_exe_path() + "../stl/Sequence/2.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh3 = read_stl(get_exe_path() + "../stl/Sequence/3.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh4 = read_stl(get_exe_path() + "../stl/Sequence/4.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh5 = read_stl(get_exe_path() + "../stl/Sequence/5.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh6 = read_stl(get_exe_path() + "../stl/Sequence/6.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh7 = read_stl(get_exe_path() + "../stl/Sequence/7.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh8 = read_stl(get_exe_path() + "../stl/Sequence/8.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh9 = read_stl(get_exe_path() + "../stl/Sequence/9.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh10 = read_stl(get_exe_path() + "../stl/Sequence/10.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh11 = read_stl(get_exe_path() + "../stl/Sequence/11.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh12 = read_stl(get_exe_path() + "../stl/Sequence/12.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh13 = read_stl(get_exe_path() + "../stl/Sequence/13.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh14 = read_stl(get_exe_path() + "../stl/Sequence/14.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh15 = read_stl(get_exe_path() + "../stl/Sequence/15.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh16 = read_stl(get_exe_path() + "../stl/Sequence/16.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh17 = read_stl(get_exe_path() + "../stl/Sequence/17.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh18 = read_stl(get_exe_path() + "../stl/Sequence/18.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh19 = read_stl(get_exe_path() + "../stl/Sequence/19.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh20 = read_stl(get_exe_path() + "../stl/Sequence/20.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh21 = read_stl(get_exe_path() + "../stl/Sequence/21.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh22 = read_stl(get_exe_path() + "../stl/Sequence/22.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh23 = read_stl(get_exe_path() + "../stl/Sequence/23.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh24 = read_stl(get_exe_path() + "../stl/Sequence/24.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh25 = read_stl(get_exe_path() + "../stl/Sequence/25.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh26 = read_stl(get_exe_path() + "../stl/Sequence/26.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh27 = read_stl(get_exe_path() + "../stl/Sequence/27.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh28 = read_stl(get_exe_path() + "../stl/Sequence/28.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh29 = read_stl(get_exe_path() + "../stl/Sequence/29.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh30 = read_stl(get_exe_path() + "../stl/Sequence/30.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh31 = read_stl(get_exe_path() + "../stl/Sequence/31.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh32 = read_stl(get_exe_path() + "../stl/Sequence/32.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh33 = read_stl(get_exe_path() + "../stl/Sequence/33.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh34 = read_stl(get_exe_path() + "../stl/Sequence/34.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh35 = read_stl(get_exe_path() + "../stl/Sequence/35.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh36 = read_stl(get_exe_path() + "../stl/Sequence/36.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh37 = read_stl(get_exe_path() + "../stl/Sequence/37.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh38 = read_stl(get_exe_path() + "../stl/Sequence/38.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh39 = read_stl(get_exe_path() + "../stl/Sequence/39.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh40 = read_stl(get_exe_path() + "../stl/Sequence/40.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh41 = read_stl(get_exe_path() + "../stl/Sequence/41.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh42 = read_stl(get_exe_path() + "../stl/Sequence/42.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh43 = read_stl(get_exe_path() + "../stl/Sequence/43.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh44 = read_stl(get_exe_path() + "../stl/Sequence/44.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh45 = read_stl(get_exe_path() + "../stl/Sequence/45.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh46 = read_stl(get_exe_path() + "../stl/Sequence/46.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh47 = read_stl(get_exe_path() + "../stl/Sequence/47.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh48 = read_stl(get_exe_path() + "../stl/Sequence/48.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh49 = read_stl(get_exe_path() + "../stl/Sequence/49.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh50 = read_stl(get_exe_path() + "../stl/Sequence/50.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh51 = read_stl(get_exe_path() + "../stl/Sequence/51.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh52 = read_stl(get_exe_path() + "../stl/Sequence/52.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh53 = read_stl(get_exe_path() + "../stl/Sequence/53.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh54 = read_stl(get_exe_path() + "../stl/Sequence/54.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh55 = read_stl(get_exe_path() + "../stl/Sequence/55.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh56 = read_stl(get_exe_path() + "../stl/Sequence/56.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh57 = read_stl(get_exe_path() + "../stl/Sequence/57.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh58 = read_stl(get_exe_path() + "../stl/Sequence/58.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh59 = read_stl(get_exe_path() + "../stl/Sequence/59.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh60 = read_stl(get_exe_path() + "../stl/Sequence/60.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh61 = read_stl(get_exe_path() + "../stl/Sequence/61.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh62 = read_stl(get_exe_path() + "../stl/Sequence/62.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh63 = read_stl(get_exe_path() + "../stl/Sequence/63.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh64 = read_stl(get_exe_path() + "../stl/Sequence/64.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh65 = read_stl(get_exe_path() + "../stl/Sequence/65.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh66 = read_stl(get_exe_path() + "../stl/Sequence/66.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh67 = read_stl(get_exe_path() + "../stl/Sequence/67.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh68 = read_stl(get_exe_path() + "../stl/Sequence/68.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh69 = read_stl(get_exe_path() + "../stl/Sequence/69.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh70 = read_stl(get_exe_path() + "../stl/Sequence/70.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh71 = read_stl(get_exe_path() + "../stl/Sequence/71.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh72 = read_stl(get_exe_path() + "../stl/Sequence/72.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh73 = read_stl(get_exe_path() + "../stl/Sequence/73.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh74 = read_stl(get_exe_path() + "../stl/Sequence/74.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh75 = read_stl(get_exe_path() + "../stl/Sequence/75.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh76 = read_stl(get_exe_path() + "../stl/Sequence/76.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh77 = read_stl(get_exe_path() + "../stl/Sequence/77.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh78 = read_stl(get_exe_path() + "../stl/Sequence/78.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh79 = read_stl(get_exe_path() + "../stl/Sequence/79.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh80 = read_stl(get_exe_path() + "../stl/Sequence/80.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh81 = read_stl(get_exe_path() + "../stl/Sequence/81.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh82 = read_stl(get_exe_path() + "../stl/Sequence/82.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh83 = read_stl(get_exe_path() + "../stl/Sequence/83.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh84 = read_stl(get_exe_path() + "../stl/Sequence/84.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh85 = read_stl(get_exe_path() + "../stl/Sequence/85.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh86 = read_stl(get_exe_path() + "../stl/Sequence/86.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh87 = read_stl(get_exe_path() + "../stl/Sequence/87.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh88 = read_stl(get_exe_path() + "../stl/Sequence/88.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh89 = read_stl(get_exe_path() + "../stl/Sequence/89.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh90 = read_stl(get_exe_path() + "../stl/Sequence/90.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh91 = read_stl(get_exe_path() + "../stl/Sequence/91.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh92 = read_stl(get_exe_path() + "../stl/Sequence/92.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh93 = read_stl(get_exe_path() + "../stl/Sequence/93.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh94 = read_stl(get_exe_path() + "../stl/Sequence/94.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh95 = read_stl(get_exe_path() + "../stl/Sequence/95.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh96 = read_stl(get_exe_path() + "../stl/Sequence/96.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh97 = read_stl(get_exe_path() + "../stl/Sequence/97.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh98 = read_stl(get_exe_path() + "../stl/Sequence/98.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh99 = read_stl(get_exe_path() + "../stl/Sequence/99.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh100 = read_stl(get_exe_path() + "../stl/Sequence/100.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh101 = read_stl(get_exe_path() + "../stl/Sequence/101.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh102 = read_stl(get_exe_path() + "../stl/Sequence/102.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh103 = read_stl(get_exe_path() + "../stl/Sequence/103.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh104 = read_stl(get_exe_path() + "../stl/Sequence/104.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh105 = read_stl(get_exe_path() + "../stl/Sequence/105.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh106 = read_stl(get_exe_path() + "../stl/Sequence/106.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh107 = read_stl(get_exe_path() + "../stl/Sequence/107.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh108 = read_stl(get_exe_path() + "../stl/Sequence/108.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh109 = read_stl(get_exe_path() + "../stl/Sequence/109.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh110 = read_stl(get_exe_path() + "../stl/Sequence/110.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh111 = read_stl(get_exe_path() + "../stl/Sequence/111.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh112 = read_stl(get_exe_path() + "../stl/Sequence/112.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh113 = read_stl(get_exe_path() + "../stl/Sequence/113.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh114 = read_stl(get_exe_path() + "../stl/Sequence/114.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh115 = read_stl(get_exe_path() + "../stl/Sequence/115.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh116 = read_stl(get_exe_path() + "../stl/Sequence/116.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh117 = read_stl(get_exe_path() + "../stl/Sequence/117.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh118 = read_stl(get_exe_path() + "../stl/Sequence/118.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh119 = read_stl(get_exe_path() + "../stl/Sequence/119.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh120 = read_stl(get_exe_path() + "../stl/Sequence/120.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh121 = read_stl(get_exe_path() + "../stl/Sequence/121.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh122 = read_stl(get_exe_path() + "../stl/Sequence/122.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh123 = read_stl(get_exe_path() + "../stl/Sequence/123.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh124 = read_stl(get_exe_path() + "../stl/Sequence/124.stl", lbm.size(), center, rotation, modelSize);
Mesh* mesh125 = read_stl(get_exe_path() + "../stl/Sequence/125.stl", lbm.size(), center, rotation, modelSize);
int currentMesh = 1u;
voxelize_mesh_hull(lbm, mesh1, TYPE_S);
const uint N = lbm.get_N(), Nx = lbm.get_Nx(), Ny = lbm.get_Ny(), Nz = lbm.get_Nz(); for (uint n = 0u, x = 0u, y = 0u, z = 0u; n < N; n++, lbm.coordinates(n, x, y, z)) {
// ############################################################## ############# define geometry #############################################################################################
if (lbm.flags[n] != TYPE_S) lbm.u.y[n] = u; //SET THE DIRECTION OF THE FLOW HERE: lbm.u.*?
if (x == 0u || x == Nx - 1u || y == 0u || y == Ny - 1u || z == 0u || z == Nz - 1u) lbm.flags[n] = TYPE_E; // all non periodic
} // #########################################################################################################################################################################################
key_4 = true;
Clock clock;
lbm.run(0u);
while (lbm.get_t() < 120000u) {
lbm.update_moving_boundaries(); // This TYPE_S flag update may be in the wrong position
// *********** REVOXELISING / ROTATING SECTION ***********
while (revoxelizing.load()) sleep(0.01f); // wait for voxelizer thread to finish (ORIGINAL WAS 0.01f)
lbm.flags.write_to_device(); // lbm.flags on host is finished, write to device now
//Set the STL selection value (0-60) for the Ornithopter
if (currentMesh > 125) currentMesh = 1;
// Select which mesh in the sequence to use - OMG THIS NEEDS TO BE MORE ELEGANT
if (lbm.get_t() > 0u && lbm.get_t() < 80000) { //Set period of time which the revoxeliser is working
revoxelizing = true; // indicate new voxelizer thread is starting
if (currentMesh == 1) {
thread voxelizer(revoxelize, &lbm, mesh1); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 2) {
thread voxelizer(revoxelize, &lbm, mesh2); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 3) {
thread voxelizer(revoxelize, &lbm, mesh3); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 4) {
thread voxelizer(revoxelize, &lbm, mesh4); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 5) {
thread voxelizer(revoxelize, &lbm, mesh5); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 6) {
thread voxelizer(revoxelize, &lbm, mesh6); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 7) {
thread voxelizer(revoxelize, &lbm, mesh7); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 8) {
thread voxelizer(revoxelize, &lbm, mesh8); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 9) {
thread voxelizer(revoxelize, &lbm, mesh9); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 10) {
thread voxelizer(revoxelize, &lbm, mesh10); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 11) {
thread voxelizer(revoxelize, &lbm, mesh11); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 12) {
thread voxelizer(revoxelize, &lbm, mesh12); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 13) {
thread voxelizer(revoxelize, &lbm, mesh13); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 14) {
thread voxelizer(revoxelize, &lbm, mesh14); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 15) {
thread voxelizer(revoxelize, &lbm, mesh15); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 16) {
thread voxelizer(revoxelize, &lbm, mesh16); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 17) {
thread voxelizer(revoxelize, &lbm, mesh17); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 18) {
thread voxelizer(revoxelize, &lbm, mesh18); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 19) {
thread voxelizer(revoxelize, &lbm, mesh19); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 20) {
thread voxelizer(revoxelize, &lbm, mesh20); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 21) {
thread voxelizer(revoxelize, &lbm, mesh21); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 22) {
thread voxelizer(revoxelize, &lbm, mesh22); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 23) {
thread voxelizer(revoxelize, &lbm, mesh23); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 24) {
thread voxelizer(revoxelize, &lbm, mesh24); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 24) {
thread voxelizer(revoxelize, &lbm, mesh24); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 25) {
thread voxelizer(revoxelize, &lbm, mesh25); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 26) {
thread voxelizer(revoxelize, &lbm, mesh26); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 27) {
thread voxelizer(revoxelize, &lbm, mesh27); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 28) {
thread voxelizer(revoxelize, &lbm, mesh28); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 29) {
thread voxelizer(revoxelize, &lbm, mesh29); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 30) {
thread voxelizer(revoxelize, &lbm, mesh30); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 31) {
thread voxelizer(revoxelize, &lbm, mesh31); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 32) {
thread voxelizer(revoxelize, &lbm, mesh32); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 33) {
thread voxelizer(revoxelize, &lbm, mesh33); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 34) {
thread voxelizer(revoxelize, &lbm, mesh34); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 35) {
thread voxelizer(revoxelize, &lbm, mesh35); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 36) {
thread voxelizer(revoxelize, &lbm, mesh36); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 37) {
thread voxelizer(revoxelize, &lbm, mesh37); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 38) {
thread voxelizer(revoxelize, &lbm, mesh38); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 39) {
thread voxelizer(revoxelize, &lbm, mesh39); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 40) {
thread voxelizer(revoxelize, &lbm, mesh40); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 41) {
thread voxelizer(revoxelize, &lbm, mesh41); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 42) {
thread voxelizer(revoxelize, &lbm, mesh42); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 43) {
thread voxelizer(revoxelize, &lbm, mesh43); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 44) {
thread voxelizer(revoxelize, &lbm, mesh44); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 45) {
thread voxelizer(revoxelize, &lbm, mesh45); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 46) {
thread voxelizer(revoxelize, &lbm, mesh46); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 47) {
thread voxelizer(revoxelize, &lbm, mesh47); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 48) {
thread voxelizer(revoxelize, &lbm, mesh48); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 49) {
thread voxelizer(revoxelize, &lbm, mesh49); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 50) {
thread voxelizer(revoxelize, &lbm, mesh50); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 51) {
thread voxelizer(revoxelize, &lbm, mesh51); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 52) {
thread voxelizer(revoxelize, &lbm, mesh52); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 53) {
thread voxelizer(revoxelize, &lbm, mesh53); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 54) {
thread voxelizer(revoxelize, &lbm, mesh54); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 55) {
thread voxelizer(revoxelize, &lbm, mesh55); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 56) {
thread voxelizer(revoxelize, &lbm, mesh56); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 57) {
thread voxelizer(revoxelize, &lbm, mesh57); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 58) {
thread voxelizer(revoxelize, &lbm, mesh58); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 59) {
thread voxelizer(revoxelize, &lbm, mesh59); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 60) {
thread voxelizer(revoxelize, &lbm, mesh60); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 61) {
thread voxelizer(revoxelize, &lbm, mesh61); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 62) {
thread voxelizer(revoxelize, &lbm, mesh62); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 63) {
thread voxelizer(revoxelize, &lbm, mesh63); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 64) {
thread voxelizer(revoxelize, &lbm, mesh64); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
//Split IF function into two for error "Blocks nested too deeply"
if (currentMesh == 65) {
thread voxelizer(revoxelize, &lbm, mesh65); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 66) {
thread voxelizer(revoxelize, &lbm, mesh66); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 67) {
thread voxelizer(revoxelize, &lbm, mesh67); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 68) {
thread voxelizer(revoxelize, &lbm, mesh68); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 69) {
thread voxelizer(revoxelize, &lbm, mesh69); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 70) {
thread voxelizer(revoxelize, &lbm, mesh70); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 71) {
thread voxelizer(revoxelize, &lbm, mesh71); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 72) {
thread voxelizer(revoxelize, &lbm, mesh72); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 73) {
thread voxelizer(revoxelize, &lbm, mesh73); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 74) {
thread voxelizer(revoxelize, &lbm, mesh74); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 75) {
thread voxelizer(revoxelize, &lbm, mesh75); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 76) {
thread voxelizer(revoxelize, &lbm, mesh76); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 77) {
thread voxelizer(revoxelize, &lbm, mesh77); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 78) {
thread voxelizer(revoxelize, &lbm, mesh78); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 79) {
thread voxelizer(revoxelize, &lbm, mesh79); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 80) {
thread voxelizer(revoxelize, &lbm, mesh80); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 81) {
thread voxelizer(revoxelize, &lbm, mesh81); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 82) {
thread voxelizer(revoxelize, &lbm, mesh82); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 83) {
thread voxelizer(revoxelize, &lbm, mesh83); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 84) {
thread voxelizer(revoxelize, &lbm, mesh84); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 85) {
thread voxelizer(revoxelize, &lbm, mesh85); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 86) {
thread voxelizer(revoxelize, &lbm, mesh86); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 87) {
thread voxelizer(revoxelize, &lbm, mesh87); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 88) {
thread voxelizer(revoxelize, &lbm, mesh88); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 89) {
thread voxelizer(revoxelize, &lbm, mesh89); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 90) {
thread voxelizer(revoxelize, &lbm, mesh90); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 91) {
thread voxelizer(revoxelize, &lbm, mesh91); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 92) {
thread voxelizer(revoxelize, &lbm, mesh92); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 93) {
thread voxelizer(revoxelize, &lbm, mesh93); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 94) {
thread voxelizer(revoxelize, &lbm, mesh94); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 95) {
thread voxelizer(revoxelize, &lbm, mesh95); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 96) {
thread voxelizer(revoxelize, &lbm, mesh96); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 97) {
thread voxelizer(revoxelize, &lbm, mesh97); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 98) {
thread voxelizer(revoxelize, &lbm, mesh98); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 99) {
thread voxelizer(revoxelize, &lbm, mesh99); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 100) {
thread voxelizer(revoxelize, &lbm, mesh100); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 101) {
thread voxelizer(revoxelize, &lbm, mesh101); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 102) {
thread voxelizer(revoxelize, &lbm, mesh102); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 103) {
thread voxelizer(revoxelize, &lbm, mesh103); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 104) {
thread voxelizer(revoxelize, &lbm, mesh104); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 105) {
thread voxelizer(revoxelize, &lbm, mesh105); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 106) {
thread voxelizer(revoxelize, &lbm, mesh106); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 107) {
thread voxelizer(revoxelize, &lbm, mesh107); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 108) {
thread voxelizer(revoxelize, &lbm, mesh108); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 109) {
thread voxelizer(revoxelize, &lbm, mesh109); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 110) {
thread voxelizer(revoxelize, &lbm, mesh110); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 111) {
thread voxelizer(revoxelize, &lbm, mesh111); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 112) {
thread voxelizer(revoxelize, &lbm, mesh112); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 113) {
thread voxelizer(revoxelize, &lbm, mesh113); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 114) {
thread voxelizer(revoxelize, &lbm, mesh114); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 115) {
thread voxelizer(revoxelize, &lbm, mesh115); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 116) {
thread voxelizer(revoxelize, &lbm, mesh116); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 117) {
thread voxelizer(revoxelize, &lbm, mesh117); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 118) {
thread voxelizer(revoxelize, &lbm, mesh118); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 119) {
thread voxelizer(revoxelize, &lbm, mesh118); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 120) {
thread voxelizer(revoxelize, &lbm, mesh120); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 121) {
thread voxelizer(revoxelize, &lbm, mesh121); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 122) {
thread voxelizer(revoxelize, &lbm, mesh122); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 123) {
thread voxelizer(revoxelize, &lbm, mesh123); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 124) {
thread voxelizer(revoxelize, &lbm, mesh124); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
else if (currentMesh == 125) {
thread voxelizer(revoxelize, &lbm, mesh125); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
}
currentMesh++;
lbm.graphics.write_frame_png(get_exe_path() + "export/images/"); // Take screenshot
}
lbm.run(2u); // run LBM in parallel while CPU is voxelizing the next frame;
}
write_file(get_exe_path() + "time.txt", print_time(clock.stop()));
}
'''
EDIT: Also added the [stl sequence zip file here.](https://drive.google.com/file/d/1t7fDz6p01uyPYHtVzX-YfsER06DyvZ1I/view?usp=sharing) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Well I did manage to code that all correctly as an array (see below) if anyone is interested. It still relies on 'voxelize_mesh' which is much slower, obviously. But voxelizing a hull creates a hollow mesh and creates weird nternal flow/noise 🤷♂️ std::atomic_bool revoxelizing = false;
void revoxelize(LBM *lbm, Mesh* mesh) { // voxelize new frames in detached thread in parallel while LBM is running
for (uint n = 0u; n < lbm->get_N(); n++) lbm->flags[n] &= ~TYPE_S; // clear flags
lbm->voxelize_mesh(mesh, TYPE_S); // voxelize rotated mesh in lbm.flags
revoxelizing = false; // indicate new voxelizer thread has finished
}
void main_setup() {
const uint L = 512+128;
const float knots = 1000.0f;
const float si_u = knots / 0.5144f; // Velocity
const float si_x = 5.0f; // Characteristic Length
const float si_rho = 1.225f; // Air density
const float si_nu = 1.48E-5f; // Kinetic Viscosity
const float Re = units.si_Re(si_x, si_u, si_nu); // Calculated Reynolds number
const float u = 0.08f; // Sim speed
LBM lbm(L + 4u, L * 3u/2u, L/3u, units.nu_from_Re(Re, (float)L, u));
const float size = 1.0f * (float)L;
const float3 center = float3(lbm.center().x, 0.5f * size, 0.13f * size);
const float3x3 rotation = float3x3(float3(1, 0, 0), radians(0.0f));
// #### Setup Mesh ####
uint next_mesh = 0u;
const uint seq_length = 250u; // Number of STL frames in the sequence
Mesh* mesh[seq_length];
for (uint i = 1u; i <= seq_length; i++) {
Mesh* added_mesh = read_stl(get_exe_path() + "../stl/sequence/" + to_string(i) + ".stl", lbm.size(), center, rotation, size);
mesh[i - 1] = added_mesh;
}
lbm.voxelize_mesh(mesh[next_mesh], TYPE_S); // Get the first mesh ready
const uint N = lbm.get_N(), Nx = lbm.get_Nx(), Ny = lbm.get_Ny(), Nz = lbm.get_Nz();
for (uint n = 0u, x = 0u, y = 0u, z = 0u; n < N; n++, lbm.coordinates(n, x, y, z)) {
if (lbm.flags[n] != TYPE_S) lbm.u.y[n] = u;
if (x == 0u || x == Nx - 1u || y == 0u || y == Ny - 1u || z == 0u || z == Nz - 1u) lbm.flags[n] = TYPE_E;
}
key_4 = true;
lbm.run(0u);
while (lbm.get_t() < 140000u) {
lbm.graphics.write_frame_png(get_exe_path() + "export/frames/");
// First section of animation
if (lbm.get_t() > 1000u && lbm.get_t() < 4472) {
next_mesh++;
if (next_mesh >= seq_length) next_mesh = 0;
while (revoxelizing.load()) sleep(0.001f); // wait for voxelizer thread to finish
revoxelizing = true; // indicate new voxelizer thread is starting
thread voxelizer(revoxelize, &lbm, mesh[next_mesh]); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
lbm.run(28u);
}
// Second section of animation
else if (lbm.get_t() > 30000u && lbm.get_t() < 33472) {
next_mesh++;
if (next_mesh >= seq_length) next_mesh = 0;
while (revoxelizing.load()) sleep(0.001f); // wait for voxelizer thread to finish
revoxelizing = true; // indicate new voxelizer thread is starting
thread voxelizer(revoxelize, &lbm, mesh[next_mesh]); // start new voxelizer thread
voxelizer.detach(); // detatch voxelizer thread so LBM can run in parallel
lbm.run(28u);
}
// Leftover sections without any animation
else {
lbm.run(28u);
}
}
} |
Beta Was this translation helpful? Give feedback.
Well I did manage to code that all correctly as an array (see below) if anyone is interested. It still relies on 'voxelize_mesh' which is much slower, obviously. But voxelizing a hull creates a hollow mesh and creates weird nternal flow/noise 🤷♂️