24 static constexpr
const char* name =
"psread";
32 PSRead(amrex::Vector<amrex::Geometry>& _geom) :
IC(_geom) {}
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>());
74 #if AMREX_SPACEDIM > 1
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>());
81 #if AMREX_SPACEDIM > 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))
94 Set::Scalar m = 0.5 * (1 + erf((-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;
114 pp.query(
"invert",value.
invert);
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;
131 value.
R.push_back(value.
mult*std::stod(strR));
144 std::vector<Set::Vector>
X;
145 std::vector<Set::Scalar>
R;