Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8a1df9f
add mesh_config
kivvix Aug 28, 2025
5b66ff9
set default value to non-zero values
kivvix Sep 8, 2025
db4e6b0
fix config
kivvix Sep 8, 2025
d355015
add graduation_width in mesh_config
kivvix Sep 8, 2025
dee8260
add graduation_width in mesh_config
kivvix Sep 8, 2025
8f68eb3
dynamic ghost_width and max_stencil_size (radius)
kivvix Sep 16, 2025
55f3e61
fix lid_driven_cavity
kivvix Sep 16, 2025
dbe5133
fix disable_args_parse
kivvix Sep 19, 2025
5d46f16
update demos
kivvix Sep 24, 2025
147bc8d
fix cpp-check error
kivvix Sep 24, 2025
30d6e63
fix errors
kivvix Sep 24, 2025
8567040
fix errors
kivvix Sep 24, 2025
9c463dd
fox errors
kivvix Sep 24, 2025
9f52b41
fix cppcheck
kivvix Sep 24, 2025
d4c086f
fix amr mesh
kivvix Sep 24, 2025
c1aa3dd
fix compilation
kivvix Sep 25, 2025
84dd5a5
fix tests and demos
kivvix Sep 25, 2025
a697940
fix demos
kivvix Sep 30, 2025
ab30c27
fix demos
kivvix Sep 30, 2025
8de741c
fix demos
kivvix Sep 30, 2025
087bc16
fix demos
kivvix Sep 30, 2025
472b956
fix demos
kivvix Sep 30, 2025
7c4c456
add factories fo meshes
kivvix Oct 3, 2025
c37e5d4
fix capture this
kivvix Oct 3, 2025
6d733fd
fix capture this
kivvix Oct 3, 2025
125dc0a
fix update_sub_mesh_impl
kivvix Oct 3, 2025
ad1304e
fix demos
kivvix Oct 6, 2025
f95da71
add some documentation
kivvix Oct 7, 2025
4add122
fix codacy
kivvix Oct 7, 2025
695cefb
add disable minimal ghost width
kivvix Oct 7, 2025
c7a293f
fix demos
kivvix Oct 7, 2025
5f38d61
fix demos
kivvix Oct 7, 2025
1303e14
refactoring
kivvix Oct 13, 2025
3881fae
add start_level in mesh_config
kivvix Oct 13, 2025
f186264
typo
kivvix Oct 13, 2025
b478604
fix start_level
kivvix Oct 13, 2025
869cc3c
fix start_level
kivvix Oct 13, 2025
e62c521
fix start_level
kivvix Oct 13, 2025
943e330
fix start_level
kivvix Oct 13, 2025
d045752
fix start_level
kivvix Oct 13, 2025
a685ec5
fix start_level
kivvix Oct 13, 2025
8091626
fix start_level
kivvix Oct 13, 2025
ebf1042
fix start_level with copy of mesh_config
kivvix Oct 13, 2025
cdd3b94
fix cppcheck
kivvix Oct 13, 2025
eafab17
remove const hack and fix start_level
kivvix Oct 14, 2025
3618e56
clean code
kivvix Oct 15, 2025
8f5e443
remove useless file
kivvix Oct 15, 2025
97e092f
remove m_periodic
kivvix Oct 15, 2025
77993a4
add make_empty_Mesh and remove unconst mesh_config
kivvix Oct 15, 2025
95eeb9c
fix cppcheck
kivvix Oct 15, 2025
8a0e1d7
fix start-level option
kivvix Oct 16, 2025
46ebaca
fix ghost_width in test for_each_cell
kivvix Oct 16, 2025
d528846
fix demos
kivvix Oct 20, 2025
9868ebb
fix demos
kivvix Oct 20, 2025
84d176f
change unsing typename
kivvix Oct 20, 2025
1621d03
fix level_set_from_scratch
kivvix Oct 20, 2025
a770232
fix ldc
kivvix Oct 20, 2025
0d79784
remove parse_args in Mesh_base constructor
kivvix Oct 20, 2025
c76910c
fix snippets with new interface
kivvix Oct 21, 2025
d8e878a
fix restart test
kivvix Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions demos/FiniteVolume/AMR_Burgers_Hat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ int main(int argc, char* argv[])
auto& app = samurai::initialize("Finite volume example for the Burgers equation in 2d using AMR", argc, argv);

constexpr std::size_t dim = 1; // cppcheck-suppress unreadVariable
using Config = samurai::amr::Config<dim>;

// Simulation parameters
double left_box = -3;
Expand All @@ -208,10 +207,7 @@ int main(int argc, char* argv[])
std::string restart_file;

// AMR parameters
std::size_t start_level = 7;
std::size_t min_level = 2;
std::size_t max_level = 7;
bool correction = false;
bool correction = false;

// Output parameters
fs::path path = fs::current_path();
Expand All @@ -224,9 +220,6 @@ int main(int argc, char* argv[])
app.add_option("--Ti", t, "Initial time")->capture_default_str()->group("Simulation parameters");
app.add_option("--Tf", Tf, "Final time")->capture_default_str()->group("Simulation parameters");
app.add_option("--restart-file", restart_file, "Restart file")->capture_default_str()->group("Simulation parameters");
app.add_option("--start-level", start_level, "Start level of AMR")->capture_default_str()->group("AMR parameters");
app.add_option("--min-level", min_level, "Minimum level of AMR")->capture_default_str()->group("AMR parameters");
app.add_option("--max-level", max_level, "Maximum level of AMR")->capture_default_str()->group("AMR parameters");
app.add_option("--with-correction", correction, "Apply flux correction at the interface of two refinement levels")
->capture_default_str()
->group("AMR parameters");
Expand All @@ -236,12 +229,13 @@ int main(int argc, char* argv[])
SAMURAI_PARSE(argc, argv);

const samurai::Box<double, dim> box({left_box}, {right_box});
samurai::amr::Mesh<Config> mesh;
auto phi = samurai::make_scalar_field<double>("phi", mesh);
auto config = samurai::mesh_config<dim>().min_level(2).max_level(7).max_stencil_size(2).start_level(7).disable_minimal_ghost_width();
auto mesh = samurai::amr::make_empty_Mesh(config);
auto phi = samurai::make_scalar_field<double>("phi", mesh);

if (restart_file.empty())
{
mesh = {box, start_level, min_level, max_level};
mesh = samurai::amr::make_Mesh(config, box);
init_solution(phi);
}
else
Expand All @@ -256,7 +250,7 @@ int main(int argc, char* argv[])
auto tag = samurai::make_scalar_field<int>("tag", mesh);
const xt::xtensor_fixed<int, xt::xshape<2, 1>> stencil_grad{{1}, {-1}};

const double dx = mesh.cell_length(max_level);
const double dx = mesh.min_cell_length();
double dt = 0.99 * dx;
const double dt_save = Tf / static_cast<double>(nfiles);

Expand Down
4 changes: 2 additions & 2 deletions demos/FiniteVolume/BZ/bz_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ int main()
const double regularity = 1.; // Regularity guess for multiresolution
const double epsilon_MR = 2.e-4; // Threshold used by multiresolution

using Config = samurai::MRConfig<dim, 2>;
samurai::MRMesh<Config> mesh(box, min_level, max_level); // Constructing mesh from the box
auto config = samurai::mesh_config<dim>().min_level(min_level).max_level(max_level).max_stencil_radius(2);
auto mesh = samurai::make_MRMesh(config, box); // Constructing mesh from the box

using mesh_id_t = typename decltype(mesh)::mesh_id_t;

Expand Down
17 changes: 6 additions & 11 deletions demos/FiniteVolume/advection_1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ int main(int argc, char* argv[])
auto& app = samurai::initialize("Finite volume example for the advection equation in 1d using multiresolution", argc, argv);

constexpr std::size_t dim = 1; // cppcheck-suppress unreadVariable
using Config = samurai::MRConfig<dim>;

// Simulation parameters
double left_box = -2;
Expand All @@ -74,10 +73,6 @@ int main(int argc, char* argv[])
double t = 0.;
std::string restart_file;

// Multiresolution parameters
std::size_t min_level = 6;
std::size_t max_level = 12;

// Output parameters
fs::path path = fs::current_path();
std::string filename = "FV_advection_1d";
Expand All @@ -91,29 +86,29 @@ int main(int argc, char* argv[])
app.add_option("--Ti", t, "Initial time")->capture_default_str()->group("Simulation parameters");
app.add_option("--Tf", Tf, "Final time")->capture_default_str()->group("Simulation parameters");
app.add_option("--restart-file", restart_file, "Restart file")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--path", path, "Output path")->capture_default_str()->group("Output");
app.add_option("--filename", filename, "File name prefix")->capture_default_str()->group("Output");
app.add_option("--nfiles", nfiles, "Number of output files")->capture_default_str()->group("Output");

SAMURAI_PARSE(argc, argv);

const samurai::Box<double, dim> box({left_box}, {right_box});
samurai::MRMesh<Config> mesh;
auto u = samurai::make_scalar_field<double>("u", mesh);

auto config = samurai::mesh_config<dim>().min_level(6).max_level(12).periodic(is_periodic).max_stencil_size(2).disable_minimal_ghost_width();
auto mesh = samurai::make_empty_MRMesh(config);
auto u = samurai::make_scalar_field<double>("u", mesh);

if (restart_file.empty())
{
mesh = {box, min_level, max_level, std::array<bool, dim>{is_periodic}};
mesh = samurai::make_MRMesh(config, box);
init(u);
}
else
{
samurai::load(restart_file, mesh, u);
}

double dt = cfl * mesh.cell_length(max_level);
double dt = cfl * mesh.min_cell_length();
const double dt_save = Tf / static_cast<double>(nfiles);

if (!is_periodic)
Expand Down
16 changes: 5 additions & 11 deletions demos/FiniteVolume/advection_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ int main(int argc, char* argv[])
auto& app = samurai::initialize("Finite volume example for the advection equation in 2d using multiresolution", argc, argv);

constexpr std::size_t dim = 2;
using Config = samurai::MRConfig<dim>;

// Simulation parameters
xt::xtensor_fixed<double, xt::xshape<dim>> min_corner = {0., 0.};
Expand All @@ -76,10 +75,6 @@ int main(int argc, char* argv[])
double t = 0.;
std::string restart_file;

// Multiresolution parameters
std::size_t min_level = 4;
std::size_t max_level = 10;

// Output parameters
fs::path path = fs::current_path();
std::string filename = "FV_advection_2d";
Expand All @@ -92,21 +87,20 @@ int main(int argc, char* argv[])
app.add_option("--Ti", t, "Initial time")->capture_default_str()->group("Simulation parameters");
app.add_option("--Tf", Tf, "Final time")->capture_default_str()->group("Simulation parameters");
app.add_option("--restart-file", restart_file, "Restart file")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--path", path, "Output path")->capture_default_str()->group("Output");
app.add_option("--filename", filename, "File name prefix")->capture_default_str()->group("Output");
app.add_option("--nfiles", nfiles, "Number of output files")->capture_default_str()->group("Output");

SAMURAI_PARSE(argc, argv);

const samurai::Box<double, dim> box(min_corner, max_corner);
samurai::MRMesh<Config> mesh;
auto u = samurai::make_scalar_field<double>("u", mesh);
auto config = samurai::mesh_config<dim>().min_level(4).max_level(10).max_stencil_size(2).disable_minimal_ghost_width();
auto mesh = samurai::make_empty_MRMesh(config);
auto u = samurai::make_scalar_field<double>("u", mesh);

if (restart_file.empty())
{
mesh = {box, min_level, max_level};
mesh = samurai::make_MRMesh(config, box);
init(u);
}
else
Expand All @@ -115,7 +109,7 @@ int main(int argc, char* argv[])
}
samurai::make_bc<samurai::Dirichlet<1>>(u, 0.);

double dt = cfl * mesh.cell_length(max_level);
double dt = cfl * mesh.min_cell_length();
const double dt_save = Tf / static_cast<double>(nfiles);

auto unp1 = samurai::make_scalar_field<double>("unp1", mesh);
Expand Down
16 changes: 5 additions & 11 deletions demos/FiniteVolume/advection_2d_user_bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ int main(int argc, char* argv[])
auto& app = samurai::initialize("Finite volume example for the advection equation in 2d using multiresolution", argc, argv);

constexpr std::size_t dim = 2;
using Config = samurai::MRConfig<dim>;

// Simulation parameters
xt::xtensor_fixed<double, xt::xshape<dim>> min_corner = {0., 0.};
Expand All @@ -108,10 +107,6 @@ int main(int argc, char* argv[])
double t = 0.;
std::string restart_file;

// Multiresolution parameters
std::size_t min_level = 4;
std::size_t max_level = 10;

// Output parameters
fs::path path = fs::current_path();
std::string filename = "FV_advection_2d";
Expand All @@ -124,21 +119,20 @@ int main(int argc, char* argv[])
app.add_option("--Ti", t, "Initial time")->capture_default_str()->group("Simulation parameters");
app.add_option("--Tf", Tf, "Final time")->capture_default_str()->group("Simulation parameters");
app.add_option("--restart-file", restart_file, "Restart file")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--path", path, "Output path")->capture_default_str()->group("Output");
app.add_option("--filename", filename, "File name prefix")->capture_default_str()->group("Output");
app.add_option("--nfiles", nfiles, "Number of output files")->capture_default_str()->group("Output");

SAMURAI_PARSE(argc, argv);

const samurai::Box<double, dim> box(min_corner, max_corner);
samurai::MRMesh<Config> mesh;
auto u = samurai::make_scalar_field<double>("u", mesh);
auto config = samurai::mesh_config<dim>().min_level(4).max_level(10).max_stencil_size(2).disable_minimal_ghost_width();
auto mesh = samurai::make_empty_MRMesh(config);
auto u = samurai::make_scalar_field<double>("u", mesh);

if (restart_file.empty())
{
mesh = {box, min_level, max_level};
mesh = samurai::make_MRMesh(config, box);
init(u);
}
else
Expand All @@ -147,7 +141,7 @@ int main(int argc, char* argv[])
}
samurai::make_bc<Mybc>(u, 0.);

double dt = cfl * mesh.cell_length(max_level);
double dt = cfl * mesh.min_cell_length();
const double dt_save = Tf / static_cast<double>(nfiles);

auto unp1 = samurai::make_scalar_field<double>("unp1", mesh);
Expand Down
11 changes: 5 additions & 6 deletions demos/FiniteVolume/burgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ int main_dim(int argc, char* argv[])
{
auto& app = samurai::initialize("Finite volume example for the Burgers equation", argc, argv);

using Config = samurai::MRConfig<dim, 3>;
using Box = samurai::Box<double, dim>;
using point_t = typename Box::point_t;

Expand Down Expand Up @@ -91,8 +90,6 @@ int main_dim(int argc, char* argv[])
app.add_option("--restart-file", restart_file, "Restart file")->capture_default_str()->group("Simulation parameters");
app.add_option("--dt", dt, "Time step")->capture_default_str()->group("Simulation parameters");
app.add_option("--cfl", cfl, "The CFL")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--path", path, "Output path")->capture_default_str()->group("Output");
app.add_option("--filename", filename, "File name prefix")->capture_default_str()->group("Output");
app.add_option("--nfiles", nfiles, "Number of output files")->capture_default_str()->group("Output");
Expand All @@ -108,7 +105,9 @@ int main_dim(int argc, char* argv[])
box_corner1.fill(left_box);
box_corner2.fill(right_box);
Box box(box_corner1, box_corner2);
samurai::MRMesh<Config> mesh;

auto config = samurai::mesh_config<dim>().min_level(min_level).max_level(max_level).max_stencil_size(6);
auto mesh = samurai::make_empty_MRMesh(config);

auto u = samurai::make_vector_field<n_comp>("u", mesh);
auto u1 = samurai::make_vector_field<n_comp>("u1", mesh);
Expand All @@ -117,7 +116,7 @@ int main_dim(int argc, char* argv[])

if (restart_file.empty())
{
mesh = {box, min_level, max_level};
mesh = samurai::make_MRMesh(config, box);
u.resize();

// Initial solution
Expand Down Expand Up @@ -221,7 +220,7 @@ int main_dim(int argc, char* argv[])
// Time iteration //
//--------------------//

double dx = mesh.cell_length(max_level);
double dx = mesh.min_cell_length();
dt = cfl * dx / pow(2, dim);

auto MRadaptation = samurai::make_MRAdapt(u);
Expand Down
13 changes: 4 additions & 9 deletions demos/FiniteVolume/burgers_mra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ void run_simulation(Field& u,
int main(int argc, char* argv[])
{
constexpr std::size_t dim = 1;
using Config = samurai::MRConfig<dim, 2, 2>;
using Box = samurai::Box<double, dim>;

auto& app = samurai::initialize("Finite volume example for the Burgers equation in 1d", argc, argv);
Expand All @@ -245,19 +244,13 @@ int main(int argc, char* argv[])
// Time integration
double cfl = 0.95;

// Multiresolution parameters
std::size_t min_level = 1;
std::size_t max_level = 7;

// Output parameters
fs::path path = fs::current_path();
std::string filename = "burgers_mra";
std::size_t nfiles = 50;

app.add_option("--init-sol", init_sol, "Initial solution: hat/gaussian")->capture_default_str()->group("Simulation parameters");
app.add_option("--cfl", cfl, "The CFL")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--path", path, "Output path")->capture_default_str()->group("Ouput");
app.add_option("--filename", filename, "File name prefix")->capture_default_str()->group("Ouput");
app.add_option("--nfiles", nfiles, "Number of output files")->capture_default_str()->group("Ouput");
Expand All @@ -270,8 +263,10 @@ int main(int argc, char* argv[])
//--------------------//

Box box({left_box}, {right_box});
samurai::MRMesh<Config> mesh{box, min_level, max_level};
samurai::MRMesh<Config> max_level_mesh{box, max_level, max_level};
auto config = samurai::mesh_config<dim>().min_level(1).max_level(7).max_stencil_radius(2).graduation_width(2);
auto mesh = samurai::make_MRMesh(config, box);
auto max_level_config = samurai::mesh_config<dim>().min_level(mesh.max_level()).max_level(mesh.max_level()).max_stencil_radius(2);
auto max_level_mesh = samurai::make_MRMesh(max_level_config, box);

auto u = samurai::make_scalar_field<double>("u", mesh);
auto unp1 = samurai::make_scalar_field<double>("unp1", mesh);
Expand Down
27 changes: 14 additions & 13 deletions demos/FiniteVolume/burgers_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ int main(int argc, char* argv[])
auto& app = samurai::initialize("Finite volume example for the linear convection equation", argc, argv);

static constexpr std::size_t dim = 1;
using Config = samurai::MRConfig<dim, 2, 2>;
using Box = samurai::Box<double, dim>;
using point_t = typename Box::point_t;

using Box = samurai::Box<double, dim>;
using point_t = typename Box::point_t;

std::cout << "------------------------- Burgers 1D -------------------------" << std::endl;

Expand Down Expand Up @@ -125,17 +125,13 @@ int main(int argc, char* argv[])
app.add_option("--Tf", Tf, "Final time")->capture_default_str()->group("Simulation parameters");
app.add_option("--dt", dt, "Time step")->capture_default_str()->group("Simulation parameters");
app.add_option("--cfl", cfl, "The CFL")->capture_default_str()->group("Simulation parameters");
app.add_option("--min-level", min_level, "Minimum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--max-level", max_level, "Maximum level of the multiresolution")->capture_default_str()->group("Multiresolution");
app.add_option("--path", path, "Output path")->capture_default_str()->group("Output");
app.add_option("--filename", filename, "File name prefix")->capture_default_str()->group("Output");
app.add_option("--nfiles", nfiles, "Number of output files")->capture_default_str()->group("Output");
app.allow_extras();

SAMURAI_PARSE(argc, argv);

std::cout << " max_level = " << max_level << " min_level = " << min_level << std::endl;

//--------------------//
// Problem definition //
//--------------------//
Expand All @@ -148,13 +144,18 @@ int main(int argc, char* argv[])
Box box_left(box_corner1, 0.5 * (box_corner1 + box_corner2));
Box box_right(0.5 * (box_corner1 + box_corner2), box_corner2);

samurai::LevelCellArray<1> lca_left(max_level, box_left, {-1}, 0.05, 2);
samurai::LevelCellArray<1> lca_right(max_level, box_right, {-1}, 0.05, 2);
samurai::LevelCellArray<1> lca_left(max_level, box_left, {-1}, -1., 2);
samurai::LevelCellArray<1> lca_right(max_level, box_right, {-1}, -1., 2);

std::array<bool, dim> periodic;
periodic.fill(true);
samurai::MRMesh<Config> mesh{box, min_level, max_level, periodic, 0.05, 2};
auto config = samurai::mesh_config<dim>()
.min_level(min_level)
.max_level(max_level)
.periodic(true)
.scaling_factor(2)
.max_stencil_radius(1)
.graduation_width(2);

auto mesh = samurai::make_MRMesh(config, box);
auto u = samurai::make_scalar_field<double>("u", mesh);
auto unp1 = samurai::make_scalar_field<double>("unp1", mesh);

Expand Down Expand Up @@ -187,7 +188,7 @@ int main(int argc, char* argv[])
// Time iteration //
//--------------------//

double dx = mesh.cell_length(max_level);
double dx = mesh.min_cell_length();
dt = cfl * dx / velocity(0);

while (t != Tf)
Expand Down
Loading
Loading