Improve physical geometry, fluid solvers, audio, and profiling
This commit is contained in:
13
include/FluidSim/MeshResolution.hpp
Normal file
13
include/FluidSim/MeshResolution.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
namespace fluidsim::port {
|
||||
inline int mesh_cell_count(float length,float cells_per_meter) {
|
||||
if(!std::isfinite(cells_per_meter) || cells_per_meter<1 || cells_per_meter>500 || !std::isfinite(length) || length<=0)
|
||||
throw std::invalid_argument("cells_per_meter must be in 1..500 with positive pipe length");
|
||||
const double count=double(length)*cells_per_meter;
|
||||
if(count>4096.001) throw std::invalid_argument("pipe mesh exceeds 4096 cells");
|
||||
return std::max(1,int(std::ceil(count-1e-6*std::max(1.,count))));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user