#include "../c++/lbm.hpp" #include "../c++/collision.hpp" #include "../c++/boundary.hpp" #include namespace kel { namespace lbm { namespace sch { using namespace saw::schema; /** * Basic distribution function * Base type * D * Q * Scalar factor * D factor * Q factor */ using T = Float32; using D2Q5 = Descriptor<2u,5u>; using D2Q9 = Descriptor<2u,9u>; template using DfCell = Cell; template using CellInfo = Cell; /** * Basic type for simulation */ template using CellStruct = Struct< Member, "dfs">, Member, "dfs_old">, Member, "info"> >; using CavityFieldD2Q9 = CellField>; } } } void set_geometry(saw::data& latt){ using namespace kel::lbm; auto meta = latt.meta(); for(saw::data i{0u}; i < meta.at(0u); ++i){ for(saw::data j{0u}; j < meta.at(1u); ++j ){ auto& cell = latt({{i,j}}); auto& info = cell.template get<"info">(); // if() } } } void set_initial_conditions(saw::data& latt){ using namespace kel::lbm; typename saw::native_data_type::type rho = 1.0; auto meta = latt.meta(); // Collide for(saw::data i{0u}; i < meta.at(0u); ++i){ for(saw::data j{0u}; j < meta.at(1u); ++j ){ auto& cell = latt({{i,j}}); auto& info = cell.template get<"info">(); } } /* { std::array::type, sch::D2Q9::D> vel = {0.0, 0.0}; auto eq = equilibrium(rho, vel); apply_for_cells([&eq](auto& cell, std::size_t i, std::size_t j){ (void) i; (void) j; auto& dfs = cell.template get<"dfs">(); auto& dfs_old = cell.template get<"dfs_old">(); auto info = cell.template get<"info">()(0u).get(); for(uint64_t k = 0; k < sch::D2Q9::Q; ++k){ dfs(k).set(eq[k]); dfs_old(k).set(eq[k]); } }, latt); } */ } int main(int argc, char** argv){ using namespace kel::lbm; std::string_view cfg_file_name = "config.json"; if(argc > 1){ cfg_file_name = argv[1]; } auto eo_conf = load_lbm_config>(cfg_file_name); if(eo_conf.is_error()){ auto& err = eo_conf.get_error(); std::cerr<<"[Error]: "< conv{ {conf.template get<"delta_x">()}, {conf.template get<"delta_t">()} }; print_lbm_meta>(conv, {conf.template get<"kinematic_viscosity">()}); saw::data> dim{{1024, 128}}; saw::data lattice{dim}; saw::data,sch::D2Q9::D>> macros{dim}; for(uint64_t i = 0u; i < 256u; ++i){ { std::string vtk_f_name{"tmp/poiseulle_2d_"}; vtk_f_name += std::to_string(i) + ".vtk"; write_vtk_file(vtk_f_name, macros); } lbm_step(lattice, even_step, step); } return 0; }