46 int ncomp = a_phi[lev]->nComp();
48 for (amrex::MFIter mfi(*a_phi[lev], amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
51 amrex::IndexType type = a_phi[lev]->ixType();
52 if (type == amrex::IndexType::TheCellType()) bx = mfi.growntilebox();
53 else if (type == amrex::IndexType::TheNodeType()) bx = mfi.grownnodaltilebox();
56 amrex::Array4<Set::Scalar>
const& phi = a_phi[lev]->array(mfi);
57 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
62 for (
unsigned int n = 0; n <
X.size(); n++)
65 Set::Scalar d1 = std::numeric_limits<Set::Scalar>::infinity();
67 d = (x -
X[n]).lpNorm<2>();
69 if (
geom[0].isPeriodic(0))
71 d1 = std::min((x -
X[n] + size(0) * Set::Vector::Unit(0)).lpNorm<2>(),
72 (x -
X[n] - size(0) * Set::Vector::Unit(0)).lpNorm<2>());
75 if (
geom[0].isPeriodic(1))
77 d1 = std::min((x -
X[n] + size(1) * Set::Vector::Unit(1)).lpNorm<2>(),
78 (x -
X[n] - size(1) * Set::Vector::Unit(1)).lpNorm<2>());
82 if (
geom[0].isPeriodic(2))
84 d1 = std::min((x -
X[n] + size(2) * Set::Vector::Unit(2)).lpNorm<2>(),
85 (x -
X[n] - size(2) * Set::Vector::Unit(2)).lpNorm<2>());
91 if (d <= (
R[n] +
eps))
95 min_grain_id = min_grain_id + m * (1. - min_grain_id);
99 phi(i, j, k, 0) = min_grain_id;
100 if (
invert) phi(i,j,k,0) = 1.0 - min_grain_id;
101 if (ncomp > 1) phi(i, j, k, 1) = 1.0 - min_grain_id;
108 std::string filename;
114 pp.query(
"invert",value.
invert);
117 std::ifstream datafile(filename);
119 if (datafile.is_open())
124 while (getline(datafile, line))
126 std::istringstream in(line);
128 std::string strx, stry, strz, strR;
129 in >> strx >> stry >> strz >> strR;
130 value.
X.push_back(value.
x0 + value.
mult*
Set::Vector(AMREX_D_DECL(std::stod(strx), std::stod(stry), std::stod(strz))));
131 value.
R.push_back(value.
mult*std::stod(strR));