25 static constexpr const char*
name =
"psread";
33 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>());
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;
113 pp.
forbid(
"filename",
"use file.name instead");
138 std::ifstream datafile(filename);
140 if (datafile.is_open())
145 while (getline(datafile, line))
147 std::istringstream in(line);
149 std::string strx, stry, strz, strR;
150 in >> strx >> stry >> strz >> strR;
152 Set::Scalar x = (std::stod(strx) * unit).normalized_value();
153 Set::Scalar y = (std::stod(stry) * unit).normalized_value();
154 #if AMREX_SPACEDIM > 2
155 Set::Scalar z = (std::stod(strz) * unit).normalized_value();
157 Set::Scalar r = (std::stod(strR) * unit).normalized_value();
162 value.
X.push_back(
X);
163 value.
R.push_back(r);
176 std::vector<Set::Vector>
X;
177 std::vector<Set::Scalar>
R;
amrex::Vector< amrex::Geometry > & geom
PSRead(amrex::Vector< amrex::Geometry > &_geom, IO::ParmParse &pp, std::string name)
static void Parse(PSRead &value, IO::ParmParse &pp)
std::vector< Set::Vector > X
PSRead(amrex::Vector< amrex::Geometry > &_geom)
void Add(const int &lev, Set::Field< Set::Scalar > &a_phi, Set::Scalar)
static constexpr const char * name
std::vector< Set::Scalar > R
bool contains(std::string name)
int queryunit(std::string name, Unit &value)
int queryarr_default(std::string name, std::vector< std::string > &value, std::vector< std::string > defaultvalue)
void forbid(std::string name, std::string explanation)
int query_file(std::string name, std::string &value, bool copyfile, bool checkfile)
void queryclass(std::string name, T *value)
int query_default(std::string name, T &value, T defaultvalue)
Initialize a spherical inclusion.
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
AMREX_FORCE_INLINE Vector Position(const int &i, const int &j, const int &k, const amrex::Geometry &geom, const amrex::IndexType &ixType)
AMREX_FORCE_INLINE Vector Size(const amrex::Geometry &geom)
AMREX_FORCE_INLINE void AssertException(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
void Abort(const char *msg)
void Message(std::string file, std::string func, int line, Args const &... args)
bool isType(const Unit &test) const
std::string normalized_unitstring() const