Skip to content

Commit

Permalink
Merge pull request #129 from streeve/fixup_pi
Browse files Browse the repository at this point in the history
fixup: use pi constant
  • Loading branch information
streeve authored Aug 20, 2024
2 parents 299365c + 3680c29 commit 33057ff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/CabanaPD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <CabanaPD_BodyTerm.hpp>
#include <CabanaPD_Boundary.hpp>
#include <CabanaPD_Comm.hpp>
#include <CabanaPD_Constants.hpp>
#include <CabanaPD_DisplacementProfile.hpp>
#include <CabanaPD_Fields.hpp>
#include <CabanaPD_Force.hpp>
Expand Down
24 changes: 24 additions & 0 deletions src/CabanaPD_Constants.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/****************************************************************************
* Copyright (c) 2022 by Oak Ridge National Laboratory *
* All rights reserved. *
* *
* This file is part of CabanaPD. CabanaPD is distributed under a *
* BSD 3-clause license. For the licensing terms see the LICENSE file in *
* the top-level directory. *
* *
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/

#ifndef CONSTANTS_H
#define CONSTANTS_H

#include "mpi.h"

namespace CabanaPD
{

// FIXME: Kokkos::numbers::pi_v<double> when minimum 4.0 is required.
constexpr double pi = M_PI;

} // namespace CabanaPD
#endif
4 changes: 2 additions & 2 deletions src/CabanaPD_Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <nlohmann/json.hpp>

#include <CabanaPD_Constants.hpp>
#include <CabanaPD_Output.hpp>

namespace CabanaPD
Expand Down Expand Up @@ -125,8 +126,7 @@ class Inputs
double K = inputs["bulk_modulus"]["value"];
double delta = inputs["horizon"]["value"];
// FIXME: this is copied from the forces
double c =
18.0 * K / ( 3.141592653589793 * delta * delta * delta * delta );
double c = 18.0 * K / ( pi * delta * delta * delta * delta );

for ( int i = -( m + 1 ); i < m + 2; i++ )
{
Expand Down
3 changes: 2 additions & 1 deletion src/force/CabanaPD_ForceModels_PMB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef FORCE_MODELS_PMB_H
#define FORCE_MODELS_PMB_H

#include <CabanaPD_Constants.hpp>
#include <CabanaPD_ForceModels.hpp>
#include <CabanaPD_Types.hpp>

Expand Down Expand Up @@ -48,7 +49,7 @@ struct ForceModel<PMB, Elastic, TemperatureIndependent> : public BaseForceModel
{
delta = _delta;
K = _K;
c = 18.0 * K / ( 3.141592653589793 * delta * delta * delta * delta );
c = 18.0 * K / ( pi * delta * delta * delta * delta );
}
};

Expand Down

0 comments on commit 33057ff

Please sign in to comment.