Skip to content

Commit

Permalink
feat: Add direction on bc function (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
gouarin authored Oct 2, 2023
1 parent cb50d4b commit 2d9ae52
Show file tree
Hide file tree
Showing 42 changed files with 159 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .cppcheck
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
noExplicitConstructor
duplInheritedMember
missingInclude
missingIncludeSystem
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
path: |
~/.cache/ccache
~/micromamba-root/envs/samurai-env
~/micromamba/envs/samurai-env
key: cppcheck

- name: Mamba and samurai env installation
Expand All @@ -39,21 +39,19 @@ jobs:
cache-environment: true

- name: cppcheck installation
shell: bash -l {0}
shell: bash -el {0}
run: |
conda install -y cppcheck cxx-compiler
pip install compdb
- name: Configure
shell: bash -l {0}
shell: bash -el {0}
run: |
cmake . -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_DEMOS=ON
compdb -p build list > compile_commands.json
- name: Run cppcheck on samurai
shell: bash -l {0}
shell: bash -el {0}
run: |
cppcheck --enable=all -q --project=compile_commands.json --suppressions-list=.cppcheck --inline-suppr 2> cppcheck_err.txt
cppcheck --enable=all -q --project=./build/compile_commands.json --suppressions-list=.cppcheck --inline-suppr 2> cppcheck_err.txt
- name: Check for errors
run: |
Expand Down
4 changes: 2 additions & 2 deletions demos/FiniteVolume/AMR_Burgers_Hat.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <fmt/format.h>
#include <iostream>

Expand Down Expand Up @@ -171,7 +171,7 @@ void flux_correction(Field& phi_np1, const Field& phi_n, double dt)

int main(int argc, char* argv[])
{
constexpr std::size_t dim = 1;
constexpr std::size_t dim = 1; // cppcheck-suppress unreadVariable
using Config = samurai::amr::Config<dim>;

// Simulation parameters
Expand Down
4 changes: 2 additions & 2 deletions demos/FiniteVolume/advection_1d.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <xtensor/xfixed.hpp>

Expand Down Expand Up @@ -111,7 +111,7 @@ void save(const fs::path& path, const std::string& filename, const Field& u, con

int main(int argc, char* argv[])
{
constexpr std::size_t dim = 1;
constexpr std::size_t dim = 1; // cppcheck-suppress unreadVariable
using Config = samurai::MRConfig<dim>;

// Simulation parameters
Expand Down
6 changes: 3 additions & 3 deletions demos/FiniteVolume/advection_2d.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <array>

#include <xtensor/xfixed.hpp>
Expand Down Expand Up @@ -165,8 +165,8 @@ void save(const fs::path& path, const std::string& filename, const Field& u, con

int main(int argc, char* argv[])
{
constexpr size_t dim = 2;
using Config = samurai::MRConfig<dim>;
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 Down
6 changes: 3 additions & 3 deletions demos/FiniteVolume/advection_2d_user_bc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <array>

#include <xtensor/xfixed.hpp>
Expand Down Expand Up @@ -211,8 +211,8 @@ void save(const fs::path& path, const std::string& filename, const Field& u, con

int main(int argc, char* argv[])
{
constexpr size_t dim = 2;
using Config = samurai::MRConfig<dim>;
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 Down
6 changes: 3 additions & 3 deletions demos/FiniteVolume/burgers.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
Expand Down Expand Up @@ -186,7 +186,7 @@ int main_dim(int argc, char* argv[])
if (dim == 1 && init_sol == "linear")

Check warning on line 186 in demos/FiniteVolume/burgers.cpp

View workflow job for this annotation

GitHub Actions / vcpkg (windows-2022, msvc, Visual Studio 17 2022)

conditional expression is constant [D:\a\samurai\samurai\build\demos\FiniteVolume\finite-volume-burgers.vcxproj]
{
samurai::make_bc<samurai::Dirichlet>(u,
[&](const auto&, const auto& coord)
[&](const auto&, const auto&, const auto& coord)
{
return exact_solution(coord, 0);
});
Expand Down Expand Up @@ -272,7 +272,7 @@ int main_dim(int argc, char* argv[])
{
u.get_bc().clear();
samurai::make_bc<samurai::Dirichlet>(u,
[&](const auto&, const auto& coord)
[&](const auto&, const auto&, const auto& coord)
{
return exact_solution(coord, t - dt);
});
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/heat.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/heat_heterogeneous.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/level_set.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <samurai/algorithm/graduation.hpp>
#include <samurai/algorithm/update.hpp>
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/level_set_from_scratch.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <samurai/algorithm/update.hpp>
#include <samurai/algorithm/utils.hpp>
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/lid_driven_cavity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <iostream>
#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/linear_convection.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
Expand Down
2 changes: 1 addition & 1 deletion demos/FiniteVolume/scalar_burgers_2d.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <xtensor/xfixed.hpp>

#include <samurai/algorithm.hpp>
Expand Down
3 changes: 1 addition & 2 deletions demos/FiniteVolume/stencil_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ namespace samurai
template <class Field>
inline auto operator()(Dim<2>, const Field& phi, const Field& phi_0, const std::size_t max_level) const
{
double dx = this->dx();

auto out = xt::empty<double>({i.size()});

out.fill(0.);

if (level == max_level)
{
double dx = this->dx();
// // First order one sided
// auto dxp = (phi(level, i + 1, j) - phi(level, i , j))/dx;
// auto dxm = (phi(level, i , j) - phi(level, i - 1, j))/dx;
Expand Down
14 changes: 7 additions & 7 deletions demos/FiniteVolume/stokes_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <iostream>
#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
Expand Down Expand Up @@ -236,7 +236,7 @@ int main(int argc, char* argv[])

// Boundary conditions
samurai::make_bc<samurai::Dirichlet>(velocity,
[](const auto&, const auto& coord)
[](const auto&, const auto&, const auto& coord)
{
const auto& x = coord[0];
const auto& y = coord[1];
Expand All @@ -246,7 +246,7 @@ int main(int argc, char* argv[])
});

samurai::make_bc<samurai::Neumann>(pressure,
[](const auto&, const auto& coord)
[](const auto&, const auto&, const auto& coord)
{
const auto& x = coord[0];
const auto& y = coord[1];
Expand Down Expand Up @@ -404,12 +404,12 @@ int main(int argc, char* argv[])

// Boundary conditions
samurai::make_bc<samurai::Dirichlet>(velocity_np1,
[&](const auto&, const auto& coord)
[&](const auto&, const auto&, const auto& coord)
{
return exact_velocity(0, coord);
});
samurai::make_bc<samurai::Neumann>(pressure_np1,
[&](const auto&, const auto& coord)
[&](const auto&, const auto&, const auto& coord)
{
return exact_normal_grad_pressure(0, coord);
});
Expand Down Expand Up @@ -497,13 +497,13 @@ int main(int argc, char* argv[])
// Boundary conditions
velocity_np1.get_bc().clear();
samurai::make_bc<samurai::Dirichlet>(velocity_np1,
[&](const auto&, const auto& coord)
[&](const auto&, const auto&, const auto& coord)
{
return exact_velocity(t_np1, coord);
});
pressure_np1.get_bc().clear();
samurai::make_bc<samurai::Neumann>(pressure_np1,
[&](const auto&, const auto& coord)
[&](const auto&, const auto&, const auto& coord)
{
return exact_normal_grad_pressure(t_np1, coord);
});
Expand Down
2 changes: 1 addition & 1 deletion demos/from_obj/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>

#include <filesystem>
namespace fs = std::filesystem;
Expand Down
4 changes: 2 additions & 2 deletions demos/highorder/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <samurai/hdf5.hpp>
#include <samurai/mr/adapt.hpp>
#include <samurai/mr/mesh.hpp>
Expand Down Expand Up @@ -266,7 +266,7 @@ int main(int argc, char* argv[])

auto u = samurai::make_field<double, 1>("u", mesh);
samurai::make_bc<samurai::Dirichlet>(u,
[](const auto&, const auto& coord)
[](const auto&, const auto&, const auto& coord)
{
const auto& x = coord[0];
const auto& y = coord[1];
Expand Down
10 changes: 5 additions & 5 deletions demos/multigrid/test_cases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class TestCase
{
if (solution_is_known())
{
return [&](const auto&, const auto& coords)
return [&](const auto&, const auto&, const auto& coords)
{
return solution()(coords);
};
}
return [](const cell_t&, const coords_t&)
return [](const auto&, const cell_t&, const coords_t&)
{
if constexpr (Field::size == 1)
{
Expand Down Expand Up @@ -150,7 +150,7 @@ class PolynomialTestCase : public TestCase<Field>

boundary_cond_t dirichlet() override
{
return [](const cell_t&, const coords_t&)
return [](const auto&, const cell_t&, const coords_t&)
{
if constexpr (Field::size == 1)
{
Expand All @@ -169,7 +169,7 @@ class PolynomialTestCase : public TestCase<Field>
{
if constexpr (dim == 1)
{
return [](const auto&, const coords_t& coord)
return [](const auto&, const auto&, const coords_t& coord)
{
const auto& x = coord[0];
if (x == 0 || x == 1)
Expand All @@ -185,7 +185,7 @@ class PolynomialTestCase : public TestCase<Field>
}
else if constexpr (dim == 2)
{
return [](const auto&, const auto& coord)
return [](const auto&, const auto&, const auto& coord)
{
const auto& x = coord[0];
const auto& y = coord[1];
Expand Down
2 changes: 1 addition & 1 deletion demos/p4est/simple_2d.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <iostream>

#include <filesystem>
Expand Down
4 changes: 2 additions & 2 deletions demos/pablo/bubble_2d.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021 SAMURAI TEAM. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "CLI/CLI.hpp"
#include <CLI/CLI.hpp>
#include <iostream>

#include <filesystem>
Expand Down Expand Up @@ -227,7 +227,7 @@ void make_graduation(samurai::CellArray<dim>& ca)

int main(int argc, char* argv[])
{
constexpr std::size_t dim = 2;
constexpr std::size_t dim = 2; // cppcheck-suppress unreadVariable

// Simulation parameters
std::vector<double> min_corner_v = {0., 0.};
Expand Down
2 changes: 1 addition & 1 deletion demos/tutorial/2D_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace fs = std::filesystem;

int main(int argc, char* argv[])
{
constexpr std::size_t dim = 2;
constexpr std::size_t dim = 2; // cppcheck-suppress unreadVariable
samurai::CellList<dim> cl;

// Output parameters
Expand Down
Loading

0 comments on commit 2d9ae52

Please sign in to comment.