From f26602ec57346cc84703fa5e06d378cbed2dad48 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 19 Mar 2025 13:59:44 +0100 Subject: Printing basic cavity setup now --- c++/examples/cavity_2d.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'c++/examples/cavity_2d.cpp') diff --git a/c++/examples/cavity_2d.cpp b/c++/examples/cavity_2d.cpp index f9353e9..ccb6433 100644 --- a/c++/examples/cavity_2d.cpp +++ b/c++/examples/cavity_2d.cpp @@ -176,12 +176,10 @@ void lbm_step( int main(){ using namespace kel::lbm; - saw::data< - sch::FixedArray< - sch::CavityFieldD2Q5, 2 - > - , saw::encode::Native - > lattices; //{dim_x, dim_y}; + saw::data> dim{{dim_x, dim_y}}; + + saw::data old_lattice{dim}; + saw::data new_lattice{dim}; // auto& df_field = lattices.at(0).template get<"dfs">(); //for(uint64_t i = 0; i < df_field.get_dim_size<0u>(); ++i){ @@ -191,11 +189,11 @@ int main(){ /** * Set meta information describing what this cell is */ - set_geometry(lattices.at(0)); + set_geometry(old_lattice); /** * */ - set_initial_conditions(lattices.at(0)); + set_initial_conditions(old_lattice); /** * Timeloop @@ -207,13 +205,13 @@ int main(){ apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ // Not needed (void) i; - std::cout<(cell.template get<"info">()({0}).get()); + std::cout<<(static_cast(cell.template get<"info">()({0}).get())); if( (j+1) < dim_y){ std::cout<<" "; }else{ std::cout<<"\n"; } - }, lattices.at(0)); + }, old_lattice); std::cout<<"\n"; apply_for_cells([](auto& cell, std::size_t i, std::size_t j){ @@ -225,16 +223,16 @@ int main(){ }else{ std::cout<<"\n"; } - }, lattices.at(0)); + }, old_lattice); uint64_t lattice_steps = 32; bool even_step = true; for(uint64_t step = 0; step < lattice_steps; ++step){ - uint64_t old_lattice_index = even_step ? 0 : 1; - uint64_t new_lattice_index = even_step ? 1 : 0; + auto& old_lat = even_step ? old_lattice : new_lattice; + auto& new_lat = even_step ? new_lattice : old_lattice; - lbm_step(lattices.at(old_lattice_index), lattices.at(new_lattice_index)); + lbm_step(old_lat, new_lat); even_step = !even_step; } -- cgit v1.2.3