Skip to content

Commit e772e30

Browse files
all variables used in computing the shape factor for the VB deposition, and corresponding gather, now have type double.
1 parent 38eaec1 commit e772e30

File tree

2 files changed

+99
-99
lines changed

2 files changed

+99
-99
lines changed

Source/Particles/Deposition/CurrentDeposition.H

+47-47
Original file line numberDiff line numberDiff line change
@@ -1738,8 +1738,8 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
17381738
// cell crossings are defined at cell centers if depos_order is even
17391739

17401740
int num_segments = 1;
1741-
amrex::Real shift = 0.0_rt;
1742-
if ( (depos_order % 2) == 0 ) { shift = 0.5_rt; }
1741+
double shift = 0.0;
1742+
if ( (depos_order % 2) == 0 ) { shift = 0.5; }
17431743

17441744
#if defined(WARPX_DIM_3D)
17451745

@@ -1763,21 +1763,21 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
17631763

17641764
// need to assert that the number of cell crossings in each direction
17651765
// is within the range permitted by the number of guard cells
1766-
// e.g., if (num_segments > 5) ...
1766+
// e.g., if (num_segments > 7) ...
17671767

17681768
// compute total change in particle position and the initial cell
17691769
// locations in each direction used to find the position at cell crossings.
17701770
const double dxp = x_new - x_old;
17711771
const double dyp = y_new - y_old;
17721772
const double dzp = z_new - z_old;
1773-
const auto dirX_sign = static_cast<int>(dxp < 0. ? -1 : 1);
1774-
const auto dirY_sign = static_cast<int>(dyp < 0. ? -1 : 1);
1775-
const auto dirZ_sign = static_cast<int>(dzp < 0. ? -1 : 1);
1773+
const auto dirX_sign = static_cast<double>(dxp < 0. ? -1. : 1.);
1774+
const auto dirY_sign = static_cast<double>(dyp < 0. ? -1. : 1.);
1775+
const auto dirZ_sign = static_cast<double>(dzp < 0. ? -1. : 1.);
17761776
double Xcell = 0., Ycell = 0., Zcell = 0.;
17771777
if (num_segments > 1) {
1778-
Xcell = i_old + shift + 0.5_rt*(1-dirX_sign);
1779-
Ycell = j_old + shift + 0.5_rt*(1-dirY_sign);
1780-
Zcell = k_old + shift + 0.5_rt*(1-dirZ_sign);
1778+
Xcell = static_cast<double>(i_old) + shift + 0.5*(1.-dirX_sign);
1779+
Ycell = static_cast<double>(j_old) + shift + 0.5*(1.-dirY_sign);
1780+
Zcell = static_cast<double>(k_old) + shift + 0.5*(1.-dirZ_sign);
17811781
}
17821782

17831783
// loop over the number of segments and deposit
@@ -1836,20 +1836,20 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
18361836
}
18371837

18381838
// compute the segment factors (each equal to dt_seg/dt for nonzero dxp, dyp, or dzp)
1839-
const auto seg_factor_x = static_cast<amrex::Real>(dxp == 0. ? 1. : dxp_seg/dxp);
1840-
const auto seg_factor_y = static_cast<amrex::Real>(dyp == 0. ? 1. : dyp_seg/dyp);
1841-
const auto seg_factor_z = static_cast<amrex::Real>(dzp == 0. ? 1. : dzp_seg/dzp);
1839+
const auto seg_factor_x = static_cast<double>(dxp == 0. ? 1. : dxp_seg/dxp);
1840+
const auto seg_factor_y = static_cast<double>(dyp == 0. ? 1. : dyp_seg/dyp);
1841+
const auto seg_factor_z = static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
18421842

18431843
// compute cell-based weights using the average segment position
18441844
double sx_cell[depos_order] = {0.};
18451845
double sy_cell[depos_order] = {0.};
18461846
double sz_cell[depos_order] = {0.};
1847-
double const x0_bar = (x0_new + x0_old)/2.0_rt;
1848-
double const y0_bar = (y0_new + y0_old)/2.0_rt;
1849-
double const z0_bar = (z0_new + z0_old)/2.0_rt;
1850-
const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5_rt );
1851-
const int j0_cell = compute_shape_factor_cell( sy_cell, y0_bar-0.5_rt );
1852-
const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5_rt );
1847+
double const x0_bar = (x0_new + x0_old)/2.0;
1848+
double const y0_bar = (y0_new + y0_old)/2.0;
1849+
double const z0_bar = (z0_new + z0_old)/2.0;
1850+
const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5 );
1851+
const int j0_cell = compute_shape_factor_cell( sy_cell, y0_bar-0.5 );
1852+
const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
18531853

18541854
if constexpr (depos_order >= 3) { // higher-order correction to the cell-based weights
18551855
Compute_shape_factor_pair<depos_order-1> compute_shape_factors_cell;
@@ -1859,14 +1859,14 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
18591859
double sy_new_cell[depos_order] = {0.};
18601860
double sz_old_cell[depos_order] = {0.};
18611861
double sz_new_cell[depos_order] = {0.};
1862-
const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5_rt, x0_new-0.5_rt );
1863-
const int j0_cell_2 = compute_shape_factors_cell( sy_old_cell, sy_new_cell, y0_old-0.5_rt, y0_new-0.5_rt );
1864-
const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5_rt, z0_new-0.5_rt );
1862+
const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5, x0_new-0.5 );
1863+
const int j0_cell_2 = compute_shape_factors_cell( sy_old_cell, sy_new_cell, y0_old-0.5, y0_new-0.5 );
1864+
const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
18651865
ignore_unused(i0_cell_2, j0_cell_2, k0_cell_2);
18661866
for (int m=0; m<depos_order; m++) {
1867-
sx_cell[m] = (4.0_rt*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0_rt;
1868-
sy_cell[m] = (4.0_rt*sy_cell[m] + sy_old_cell[m] + sy_new_cell[m])/6.0_rt;
1869-
sz_cell[m] = (4.0_rt*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0_rt;
1867+
sx_cell[m] = (4.0*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0;
1868+
sy_cell[m] = (4.0*sy_cell[m] + sy_old_cell[m] + sy_new_cell[m])/6.0;
1869+
sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
18701870
}
18711871
}
18721872

@@ -1948,18 +1948,18 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
19481948

19491949
// need to assert that the number of cell crossings in each direction
19501950
// is within the range permitted by the number of guard cells
1951-
// e.g., if (num_segments > 3) ...
1951+
// e.g., if (num_segments > 5) ...
19521952

19531953
// compute total change in particle position and the initial cell
19541954
// locations in each direction used to find the position at cell crossings.
19551955
const double dxp = x_new - x_old;
19561956
const double dzp = z_new - z_old;
1957-
const auto dirX_sign = static_cast<int>(dxp < 0. ? -1 : 1);
1958-
const auto dirZ_sign = static_cast<int>(dzp < 0. ? -1 : 1);
1957+
const auto dirX_sign = static_cast<double>(dxp < 0. ? -1. : 1.);
1958+
const auto dirZ_sign = static_cast<double>(dzp < 0. ? -1. : 1.);
19591959
double Xcell = 0., Zcell = 0.;
19601960
if (num_segments > 1) {
1961-
Xcell = i_old + shift + 0.5_rt*(1-dirX_sign);
1962-
Zcell = k_old + shift + 0.5_rt*(1-dirZ_sign);
1961+
Xcell = static_cast<double>(i_old) + shift + 0.5*(1.-dirX_sign);
1962+
Zcell = static_cast<double>(k_old) + shift + 0.5*(1.-dirZ_sign);
19631963
}
19641964

19651965
// loop over the number of segments and deposit
@@ -2001,29 +2001,29 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
20012001
}
20022002

20032003
// compute the segment factors (each equal to dt_seg/dt for nonzero dxp, or dzp)
2004-
const auto seg_factor_x = static_cast<amrex::Real>(dxp == 0. ? 1. : dxp_seg/dxp);
2005-
const auto seg_factor_z = static_cast<amrex::Real>(dzp == 0. ? 1. : dzp_seg/dzp);
2004+
const auto seg_factor_x = static_cast<double>(dxp == 0. ? 1. : dxp_seg/dxp);
2005+
const auto seg_factor_z = static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
20062006

20072007
// compute cell-based weights using the average segment position
20082008
double sx_cell[depos_order] = {0.};
20092009
double sz_cell[depos_order] = {0.};
2010-
double const x0_bar = (x0_new + x0_old)/2.0_rt;
2011-
double const z0_bar = (z0_new + z0_old)/2.0_rt;
2012-
const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5_rt );
2013-
const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5_rt );
2010+
double const x0_bar = (x0_new + x0_old)/2.0;
2011+
double const z0_bar = (z0_new + z0_old)/2.0;
2012+
const int i0_cell = compute_shape_factor_cell( sx_cell, x0_bar-0.5 );
2013+
const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
20142014

20152015
if constexpr (depos_order >= 3) { // higher-order correction to the cell-based weights
20162016
Compute_shape_factor_pair<depos_order-1> compute_shape_factors_cell;
20172017
double sx_old_cell[depos_order] = {0.};
20182018
double sx_new_cell[depos_order] = {0.};
20192019
double sz_old_cell[depos_order] = {0.};
20202020
double sz_new_cell[depos_order] = {0.};
2021-
const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5_rt, x0_new-0.5_rt );
2022-
const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5_rt, z0_new-0.5_rt );
2021+
const int i0_cell_2 = compute_shape_factors_cell( sx_old_cell, sx_new_cell, x0_old-0.5, x0_new-0.5 );
2022+
const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
20232023
ignore_unused(i0_cell_2, k0_cell_2);
20242024
for (int m=0; m<depos_order; m++) {
2025-
sx_cell[m] = (4.0_rt*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0_rt;
2026-
sz_cell[m] = (4.0_rt*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0_rt;
2025+
sx_cell[m] = (4.0*sx_cell[m] + sx_old_cell[m] + sx_new_cell[m])/6.0;
2026+
sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
20272027
}
20282028
}
20292029

@@ -2115,12 +2115,12 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
21152115

21162116
// need to assert that the number of cell crossings in each direction
21172117
// is within the range permitted by the number of guard cells
2118-
// e.g., if (num_segments > 2) ...
2118+
// e.g., if (num_segments > 3) ...
21192119

21202120
// compute dzp and the initial cell location used to find the cell crossings.
21212121
double const dzp = z_new - z_old;
2122-
const auto dirZ_sign = static_cast<int>(dzp < 0. ? -1 : 1);
2123-
double Zcell = k_old + shift + 0.5_rt*(1-dirZ_sign);
2122+
const auto dirZ_sign = static_cast<double>(dzp < 0. ? -1. : 1.);
2123+
double Zcell = static_cast<double>(k_old) + shift + 0.5*(1.-dirZ_sign);
21242124

21252125
// loop over the number of segments and deposit
21262126
Compute_shape_factor< depos_order-1 > compute_shape_factor_cell;
@@ -2142,21 +2142,21 @@ void doVillasenorDepositionShapeNImplicit (const amrex::ParticleReal * const xp_
21422142
}
21432143

21442144
// compute the segment factor (equal to dt_seg/dt for nonzero dzp)
2145-
const auto seg_factor = static_cast<amrex::Real>(dzp == 0. ? 1. : dzp_seg/dzp);
2145+
const auto seg_factor = static_cast<double>(dzp == 0. ? 1. : dzp_seg/dzp);
21462146

21472147
// compute cell-based weights using the average segment position
21482148
double sz_cell[depos_order] = {0.};
2149-
double const z0_bar = (z0_new + z0_old)/2.0_rt;
2150-
const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5_rt );
2149+
double const z0_bar = (z0_new + z0_old)/2.0;
2150+
const int k0_cell = compute_shape_factor_cell( sz_cell, z0_bar-0.5 );
21512151

21522152
if constexpr (depos_order >= 3) { // higher-order correction to the cell-based weights
21532153
Compute_shape_factor_pair<depos_order-1> compute_shape_factors_cell;
21542154
double sz_old_cell[depos_order] = {0.};
21552155
double sz_new_cell[depos_order] = {0.};
2156-
const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5_rt, z0_new-0.5_rt );
2156+
const int k0_cell_2 = compute_shape_factors_cell( sz_old_cell, sz_new_cell, z0_old-0.5, z0_new-0.5 );
21572157
ignore_unused(k0_cell_2);
21582158
for (int m=0; m<depos_order; m++) {
2159-
sz_cell[m] = (4.0_rt*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0_rt;
2159+
sz_cell[m] = (4.0*sz_cell[m] + sz_old_cell[m] + sz_new_cell[m])/6.0;
21602160
}
21612161
}
21622162

0 commit comments

Comments
 (0)