Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use AMReX floor function in shape functions #5606

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
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
28 changes: 14 additions & 14 deletions Source/Particles/ShapeFactors.H
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ struct Compute_shape_factor
T xmid) const
{
if constexpr (depos_order == 0){
const auto j = static_cast<int>(xmid + T(0.5));
const auto j = static_cast<int>(amrex::Math::floor(xmid + T(0.5)));
sx[0] = T(1.0);
return j;
}
else if constexpr (depos_order == 1){
const auto j = static_cast<int>(xmid);
const auto j = static_cast<int>(amrex::Math::floor(xmid));
const T xint = xmid - T(j);
sx[0] = T(1.0) - xint;
sx[1] = xint;
return j;
}
else if constexpr (depos_order == 2){
const auto j = static_cast<int>(xmid + T(0.5));
const auto j = static_cast<int>(amrex::Math::floor(xmid + T(0.5)));
const T xint = xmid - T(j);
sx[0] = T(0.5)*(T(0.5) - xint)*(T(0.5) - xint);
sx[1] = T(0.75) - xint*xint;
Expand All @@ -55,7 +55,7 @@ struct Compute_shape_factor
return j-1;
}
else if constexpr (depos_order == 3){
const auto j = static_cast<int>(xmid);
const auto j = static_cast<int>(amrex::Math::floor(xmid));
const T xint = xmid - T(j);
sx[0] = (T(1.0))/(T(6.0))*(T(1.0) - xint)*(T(1.0) - xint)*(T(1.0) - xint);
sx[1] = (T(2.0))/(T(3.0)) - xint*xint*(T(1.0) - xint/(T(2.0)));
Expand All @@ -65,7 +65,7 @@ struct Compute_shape_factor
return j-1;
}
else if constexpr (depos_order == 4){
const auto j = static_cast<int>(xmid + T(0.5));
const auto j = static_cast<int>(amrex::Math::floor(xmid + T(0.5)));
const T xint = xmid - T(j);
sx[0] = (T(1.0))/(T(24.0))*(T(0.5) - xint)*(T(0.5) - xint)*(T(0.5) - xint)*(T(0.5) - xint);
sx[1] = (T(1.0))/(T(24.0))*(T(4.75) - T(11.0)*xint + T(4.0)*xint*xint*(T(1.5) + xint - xint*xint));
Expand Down Expand Up @@ -101,21 +101,21 @@ struct Compute_shifted_shape_factor
const int i_new) const
{
if constexpr (depos_order == 0){
const auto i = static_cast<int>(std::floor(x_old + T(0.5)));
const auto i = static_cast<int>(amrex::Math::floor(x_old + T(0.5)));
const int i_shift = i - i_new;
sx[1+i_shift] = T(1.0);
return i;
}
else if constexpr (depos_order == 1){
const auto i = static_cast<int>(std::floor(x_old));
const auto i = static_cast<int>(amrex::Math::floor(x_old));
const int i_shift = i - i_new;
const T xint = x_old - T(i);
sx[1+i_shift] = T(1.0) - xint;
sx[2+i_shift] = xint;
return i;
}
else if constexpr (depos_order == 2){
const auto i = static_cast<int>(x_old + T(0.5));
const auto i = static_cast<int>(amrex::Math::floor(x_old + T(0.5)));
const int i_shift = i - (i_new + 1);
const T xint = x_old - T(i);
sx[1+i_shift] = T(0.5)*(T(0.5) - xint)*(T(0.5) - xint);
Expand All @@ -125,7 +125,7 @@ struct Compute_shifted_shape_factor
return i - 1;
}
else if constexpr (depos_order == 3){
const auto i = static_cast<int>(x_old);
const auto i = static_cast<int>(amrex::Math::floor(x_old));
const int i_shift = i - (i_new + 1);
const T xint = x_old - T(i);
sx[1+i_shift] = (T(1.0))/(T(6.0))*(T(1.0) - xint)*(T(1.0) - xint)*(T(1.0) - xint);
Expand All @@ -136,7 +136,7 @@ struct Compute_shifted_shape_factor
return i - 1;
}
else if constexpr (depos_order == 4){
const auto i = static_cast<int>(x_old + T(0.5));
const auto i = static_cast<int>(amrex::Math::floor(x_old + T(0.5)));
const int i_shift = i - (i_new + 2);
const T xint = x_old - T(i);
sx[1+i_shift] = (T(1.0))/(T(24.0))*(T(0.5) - xint)*(T(0.5) - xint)*(T(0.5) - xint)*(T(0.5) - xint);
Expand Down Expand Up @@ -176,7 +176,7 @@ struct Compute_shape_factor_pair
{
const T xmid = T(0.5)*(xnew + xold);
if constexpr (depos_order == 1){
const auto j = static_cast<int>(xmid);
const auto j = static_cast<int>(amrex::Math::floor(xmid));
const T xint_old = xold - T(j);
sx_old[0] = T(1.0) - xint_old;
sx_old[1] = xint_old;
Expand All @@ -187,7 +187,7 @@ struct Compute_shape_factor_pair
return j;
}
else if constexpr (depos_order == 2){
const auto j = static_cast<int>(xmid + T(0.5));
const auto j = static_cast<int>(amrex::Math::floor(xmid + T(0.5)));
const T xint_old = xold - T(j);
sx_old[0] = T(0.5)*(T(0.5) - xint_old)*(T(0.5) - xint_old);
sx_old[1] = T(0.75) - xint_old*xint_old;
Expand All @@ -201,7 +201,7 @@ struct Compute_shape_factor_pair
return j-1;
}
else if constexpr (depos_order == 3){
const auto j = static_cast<int>(xmid);
const auto j = static_cast<int>(amrex::Math::floor(xmid));
const T xint_old = xold - T(j);
sx_old[0] = T(1.0)/T(6.0)*(T(1.0) - xint_old)*(T(1.0) - xint_old)*(T(1.0) - xint_old);
sx_old[1] = T(2.0)/T(3.0) - xint_old*xint_old*(T(1.0) - xint_old/(T(2.0)));
Expand All @@ -217,7 +217,7 @@ struct Compute_shape_factor_pair
return j-1;
}
else if constexpr (depos_order == 4){
const auto j = static_cast<int>(xmid + T(0.5));
const auto j = static_cast<int>(amrex::Math::floor(xmid + T(0.5)));
const T xint_old = xold - T(j);
sx_old[0] = (T(1.0))/(T(24.0))*(T(0.5) - xint_old)*(T(0.5) - xint_old)*(T(0.5) - xint_old)*(T(0.5) - xint_old);
sx_old[1] = (T(1.0))/(T(24.0))*(T(4.75) - T(11.0)*xint_old + T(4.0)*xint_old*xint_old*(T(1.5) + xint_old - xint_old*xint_old));
Expand Down
Loading