Skip to content

Commit

Permalink
fix: clang-tidy fix (hpc-maths#43)
Browse files Browse the repository at this point in the history
<!-- Thank you for your contribution to ponio! -->
<!-- ༊彡 -->

<!-- Please check the following before submitting your PR -->
- [x] I have installed [pre-commit](https://pre-commit.com/) locally and
use it to validate my commits.
- [x] The PR title follows the [conventional
commits](https://www.conventionalcommits.org/en/v1.0.0/) convention.
Available tags: 'build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf',
'refactor', 'revert', 'style', 'test'
- [x] This new PR is documented.
- [x] This new PR is tested.

## Description
<!-- A clear and concise description of what you have done in this PR.
-->

Fix clang-tidy warnings.

## Related issue
<!-- List the issues solved by this PR, if any. -->

## How has this been tested?
<!-- Give the list of files used to test this new implementation. -->

## Code of Conduct
By submitting this PR, you agree to follow our [Code of
Conduct](https://github.com/hpc-maths/ponio/blob/master/solver/doc/CODE_OF_CONDUCT.md)
- [x] I agree to follow this project's Code of Conduct
  • Loading branch information
kivvix authored Mar 4, 2024
1 parent 7caaa9d commit 1334b7c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions solver/demos/heat_rock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class heat_model
}

std::valarray<double>
fundamental_sol( double t, std::valarray<double> const& x )
fundamental_sol( double t, std::valarray<double> const& x ) const
{
double const xmid = 0.5 * ( m_xmax + m_xmin );
double const pi = std::numbers::pi;
Expand Down Expand Up @@ -135,7 +135,7 @@ main()

for ( std::size_t N = 1; N < 513; N *= 2 )
{
double dt = ( t_end - t_ini ) / static_cast<double>( N );
double const dt = ( t_end - t_ini ) / static_cast<double>( N );

y2_end = ponio::solve( pb_heat, ponio::runge_kutta::rock::rock2( eigmax_computer ), y_ini, tspan, dt, observer::null_observer() );
y4_end = ponio::solve( pb_heat, ponio::runge_kutta::rock::rock4(), y_ini, tspan, dt, observer::null_observer() );
Expand Down
31 changes: 15 additions & 16 deletions solver/demos/heat_samurai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
#include <solver/solver.hpp>

#include <filesystem>
namespace fs = std::filesystem;

template <class Field>
void
save( fs::path const& path, std::string const& filename, Field& u, std::string const& suffix = "" )
save( std::filesystem::path const& path, std::string const& filename, Field& u, std::string const& suffix = "" )
{
auto mesh = u.mesh();
auto level_ = samurai::make_field<std::size_t, 1>( "level", mesh );
u.name() = "u";

if ( !fs::exists( path ) )
if ( !std::filesystem::exists( path ) )
{
fs::create_directory( path );
std::filesystem::create_directory( path );
}

samurai::for_each_cell( mesh,
Expand Down Expand Up @@ -71,22 +70,22 @@ main( int argc, char** argv )
using Config = samurai::MRConfig<dim>;

// Simulation parameters
double left_box = -5;
double right_box = 5;
bool is_periodic = false;
double Tf = 0.5;
double cfl = 0.5;
double const left_box = -5;
double const right_box = 5;
bool const is_periodic = false;
double const Tf = 0.5;
double const cfl = 0.5;

// Multiresolution parameters
std::size_t min_level = 2;
std::size_t max_level = 5;
double mr_epsilon = 2.e-4; // Threshold used by multiresolution
double mr_regularity = 1.; // Regularity guess for multiresolution
std::size_t const min_level = 2;
std::size_t const max_level = 5;
double const mr_epsilon = 2.e-4; // Threshold used by multiresolution
double const mr_regularity = 1.; // Regularity guess for multiresolution

// Output parameters
std::string const dirname = "heat_samurai_data";
fs::path path = std::filesystem::path( dirname );
std::string filename = "sol_1d";
std::string const dirname = "heat_samurai_data";
std::filesystem::path path = std::filesystem::path( dirname );
std::string filename = "sol_1d";

// Define mesh
samurai::Box<double, dim> const box( { left_box }, { right_box } );
Expand Down
5 changes: 3 additions & 2 deletions solver/include/solver/linear_algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <cmath>
#include <concepts>

namespace ponio::linear_algebra
Expand Down Expand Up @@ -68,7 +69,7 @@ namespace ponio::linear_algebra
auto op_xn = op( xn );
auto op_xnm1 = op( xnm1 );

scalar_t residual = std::abs( op_xn - rhs );
scalar_t residual = abs( op_xn - rhs );

std::size_t iter = 0;
while ( iter < max_iter && residual > tol )
Expand All @@ -82,7 +83,7 @@ namespace ponio::linear_algebra
xn = xnp1;
op_xn = op( xn );

residual = std::abs( op_xn - rhs );
residual = abs( op_xn - rhs );
iter += 1;
}
}
Expand Down
4 changes: 2 additions & 2 deletions solver/include/solver/runge_kutta/exprk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace ponio::runge_kutta::exponential_runge_kutta
tpl_inner_product_impl( tuple_t const& a,
array_t const& k,
state_t const& init,
linear_t const& linear_part,
value_t mul_coeff,
[[maybe_unused]] linear_t const& linear_part,
[[maybe_unused]] value_t mul_coeff,
std::index_sequence<Is...> )
{
return (
Expand Down
7 changes: 4 additions & 3 deletions solver/include/solver/runge_kutta/rock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ namespace ponio::runge_kutta::rock
static std::pair<std::size_t, std::size_t>
optimal_degree( std::size_t& mdeg )
{
std::size_t mz = 1, mr = 1;
std::size_t mz = 1;
std::size_t mr = 1;

std::size_t iter = 1;
while ( iter < rock_coeff::ms.size() + 1 && rock_coeff::ms[iter - 1] / mdeg <= 1 )
Expand All @@ -151,8 +152,8 @@ namespace ponio::runge_kutta::rock
static std::size_t
compute_n_stages( eig_computer_t&& eig_computer, problem_t& f, value_t tn, state_t& un, value_t& dt )
{
double eigmax = eig_computer( f, tn, un, dt );
std::size_t mdeg = static_cast<std::size_t>( std::ceil( std::sqrt( ( 1.5 + dt * eigmax ) / 0.811 ) ) );
double eigmax = eig_computer( f, tn, un, dt );
auto mdeg = static_cast<std::size_t>( std::ceil( std::sqrt( ( 1.5 + dt * eigmax ) / 0.811 ) ) );
if ( mdeg > 200 )
{
mdeg = 200;
Expand Down

0 comments on commit 1334b7c

Please sign in to comment.