Comments (6)
Yes everything you need is implemented already. Quick guide through the setup:
void main_setup() {
// make a list of all variables you have in SI units (m, kg, s)
const float si_x = 2.0f; // 2m wingspan
const float si_u = 3.0f; // 3m/s wind speed
const float si_rho = 1.225f; // 1.225kg/m^3 air density
const float si_nu = 1.48E-5f; // 1.48E-5f m^2/s kinematic shear viscosity of air
// set velocity in LBM units, should be between 0.01-0.2
const float lbm_u = 0.1f;
const float lbm_rho = 1.0f; // density in LBM units always has to be 1
// set unit conversion factors between SI units and LBM units
units.set_m_kg_s(lbm_x, lbm_u, lbm_rho, si_x, si_u, si_rho);
// compute kinematic shear viscosity ion LBM units
const float lbm_nu = units.nu(si_nu);
// set grid resolution based on lbm_x
const uint Nx = to_uint(lbm_x);
const uint Ny = to_uint(lbm_x);
const uint Nz = to_uint(lbm_x);
LBM lbm(Nx, Ny, Nz, lbm_nu ); // create LBM object
// load geometry from stl file, mark all grid points that belong to your wing geometry with (TYPE_S|TYPE_X)
lbm.voxelize_stl(get_exe_path()+"../stl/wing.stl", center, size, TYPE_S|TYPE_X);
// set box boundary conditions
for(uint n=0u, x=0u, y=0u, z=0u; n<lbm.get_N(); n++, lbm.coordinates(n, x, y, z)) {
if(!(lbm.flags[n]&TYPE_S)) lbm.u.y[n] = lbm_u; // initial velocity
if(x==0u||x==Nx-1u||y==0u||y==Ny-1u||z==0u||z==Nz-1u) lbm.flags[n] = TYPE_E;
if(z==0u) lbm.flags[n] = TYPE_S;
}
// run simulation
lbm.run(units.t(0.4f)); // run for 0.4 seconds
// calculate forces on boundaries on GPU, then copy force field to CPU memory
lbm.calculate_force_on_boundaries();
lbm.F.read_from_device();
// optional: export force field as .vtk file
lbm.F.write_host_to_vtk(); // F is already copied from GPU memory to host memory, no need for ..._write_device_to_vtk() here
// sum force over all boundary nodes marked with (TYPE_S|TYPE_X)
const float3 lbm_force = lbm.calculate_force_on_object(TYPE_S|TYPE_X);
// transition back to SI units
const float si_force_x = units.si_F(lbm_force.x); // force in Newton
const float si_force_y = units.si_F(lbm_force.y);
const float si_force_z = units.si_F(lbm_force.z);
// print lift/drag force components
print_info("lift force = "to_string(si_force_z)+" N");
print_info("drag force = "to_string(si_force_y)+" N");
}
from fluidx3d.
// transition back to SI units
const float si_force_x = units.si_F(lbm_force.x); // force in Newton
const float si_force_y = units.si_F(lbm_force.x);
const float si_force_z = units.si_F(lbm_force.x);
Is this a typo or something that I don't know?
// transition back to SI units
const float si_force_x = units.si_F(lbm_force.x); // force in Newton
const float si_force_y = units.si_F(lbm_force.y);
const float si_force_z = units.si_F(lbm_force.z);
from fluidx3d.
constg float lbm_nu = units.nu(si_nu);
should be?
const float lbm_nu = units.nu(si_nu);
from fluidx3d.
@randomwangran yep was typos, thanks! Fixed it.
from fluidx3d.
Also:
print_info("lift force = "to_string(si_force_z)+" N");
print_info("drag force = "to_string(si_force_y)+" N");
should be:
print_info("lift force = " + std::to_string(si_force_z) + " N");
print_info("drag force = " + std::to_string(si_force_y) + " N");
from fluidx3d.
@randomwangran thanks, the to_string
is correct, I'm using my own conversion functions.
from fluidx3d.
Related Issues (20)
- Code fails in interactive mode sending "xcb_xlib_threads_sequence_lost". HOT 1
- Status file and Images not generated on a Linux Server HOT 5
- FR: Cubed Sphere Lattice HOT 4
- Calculation of liquid that does not fit in memory HOT 1
- neural network liquids HOT 1
- LBM has no member "graphics" HOT 1
- C2084 function 'int main(int,char* {})' already has a body............in file graphics. cpp HOT 4
- D3Q15 Dam Breaking Expanding Water HOT 3
- (Not an issue) - Porting to Perl and Python; first steps... making code a bit more standalone and general-purpose... HOT 1
- Wierdly behaving 3D objects / Meshes HOT 2
- Visualizing rho and u in Paraview HOT 3
- Less brittle Linux OpenCL setup instructions HOT 3
- No progress - stuck at Step 0 (benchmark works) HOT 2
- cannot find file "FluidX3D.exe" HOT 2
- Including the scale, frame-info, and copyright notice inside the output PNG files ? HOT 1
- INTERACTIVE_GRAPHICS_ASCII broken by the "Made camera movement/rotation/zoom behavior independent of framerate" feature? HOT 1
- Struct of Arrays vs Arrays of Structs: Possible Oversight? HOT 2
- Connection to flow5 possible?
- Order of pairs is non uniform between Lattice sets HOT 2
- Applying a force during simulation to simulate main line water pressure HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluidx3d.