From 5c708bb3a0c9faec82a0deb32478370f9d780ea8 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 9 Nov 2026 15:13:37 +0100 Subject: Throat Clog is shit --- examples/throat_clog_2d/sim.cpp | 74 +++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 44 deletions(-) (limited to 'examples/throat_clog_2d/sim.cpp') diff --git a/examples/throat_clog_2d/sim.cpp b/examples/throat_clog_2d/sim.cpp index 118e1b1..89741ca 100644 --- a/examples/throat_clog_2d/sim.cpp +++ b/examples/throat_clog_2d/sim.cpp @@ -2,30 +2,17 @@ #include "init.hpp" #include "step.hpp" -#include +#include /** - * For deciding what parameters to use maybe? + * The coupling method is the only thing this example takes from the command + * line, so it is read straight from argv rather than through a codec -- the + * args codec is forstio's and would need a schema round trip for one string. */ -namespace args { - -using LbmArgsStruct = Struct< - Member - //,Member ->; - -using LbmArgs = Args< - LbmArgsStruct, - Tuple<> ->; -} - template -kel::lbm::error_or lbm_main(const kel::lbm::data& args){ +kel::lbm::error_or lbm_main(std::string_view coupling){ using namespace kel::lbm; - auto& an = args.template get<"args">(); - using dfi = df_info; auto eo_lbm_dir = output_directory(); @@ -34,7 +21,7 @@ kel::lbm::error_or lbm_main(const kel::lbm::data& args){ } auto& lbm_dir = eo_lbm_dir.get_value(); - auto out_dir = lbm_dir / "throat_clog_2d" / an.template get<"coupling">().stl_view(); + auto out_dir = lbm_dir / "throat_clog_2d" / coupling; { std::error_code ec; @@ -151,7 +138,7 @@ kel::lbm::error_or lbm_main(const kel::lbm::data& args){ } } { - auto eov = write_vtk_file(out_dir,std::string{"throat_clog_2d_"}+an.template get<"coupling">().stl_string(),i.get(), *lbm_macro_data_ptr); + auto eov = write_vtk_file(out_dir,std::string{"throat_clog_2d_"}+std::string{coupling},i.get(), *lbm_macro_data_ptr); if(eov.is_error()){ return eov; } @@ -191,7 +178,7 @@ kel::lbm::error_or lbm_main(const kel::lbm::data& args){ } } { - auto eov = write_vtk_file(out_dir,std::string{"throat_clog_2d_"}+an.template get<"coupling">().stl_string(),time_steps.get(), *lbm_macro_data_ptr); + auto eov = write_vtk_file(out_dir,std::string{"throat_clog_2d_"}+std::string{coupling},time_steps.get(), *lbm_macro_data_ptr); if(eov.is_error()){ return eov; } @@ -211,37 +198,36 @@ using DescT = kel::lbm::sch::D2Q9; kel::lbm::error_or k_main(int argc, char** argv){ using namespace kel::lbm; - - kel::lbm::data args; - { - auto eov = saw::parse_args(args,argc,argv); - if(eov.is_error()){ - return eov; - } + + // Default to fplbm so the example runs with no arguments at all. + std::string_view coupling{"fplbm"}; + if(argc > 1){ + coupling = argv[1]; } - auto& an = args.template get<"args">(); - auto& coupling = an.template get<"coupling">(); auto resolution_resolve = [&]() -> kel::lbm::error_or{ - return lbm_main(args); - }; - - auto coupling_resolve = [&]() -> kel::lbm::error_or { - if(coupling.stl_view() == "hlbm"){ - return resolution_resolve.template operator()(); - } else if(coupling.stl_view() == "fplbm"){ - return resolution_resolve.template operator()(); - } else if(coupling.stl_view() == "psm"){ - return resolution_resolve.template operator()(); - } + return lbm_main(coupling); }; - return coupling_resolve(); + if(coupling == "hlbm"){ + return resolution_resolve.template operator()(); + } + if(coupling == "fplbm"){ + return resolution_resolve.template operator()(); + } + if(coupling == "psm"){ + return resolution_resolve.template operator()(); + } - return kel::lbm::make_error("Invalid coupling"); + /** + * Previously the dispatch lambda had no return on the unmatched path, so + * an unknown coupling fell off the end of a non-void function. + */ + return kel::lbm::make_error( + std::string{"Unknown coupling '"} + std::string{coupling} + + "', expected one of hlbm, fplbm, psm"); } - int main(int argc, char** argv){ auto eov = k_main(argc, argv); if(eov.is_error()){ -- cgit v1.3.1