25 static constexpr const char*
name =
"pointlist";
33 PointList(amrex::Vector<amrex::Geometry>& _geom) :
IC(_geom) {}
45 for (amrex::MFIter mfi(*a_phi[lev], amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
47 if (AMREX_SPACEDIM != 2)
49 amrex::Abort(
"This code only supports 2D (AMREX_SPACEDIM must be 2)");
53 amrex::IndexType type = a_phi[lev]->ixType();
54 if (type == amrex::IndexType::TheCellType()) bx = mfi.growntilebox();
55 else if (type == amrex::IndexType::TheNodeType()) bx = mfi.grownnodaltilebox();
57 amrex::Array4<Set::Scalar>
const& phi = a_phi[lev]->array(mfi);
59 for (
unsigned int n = 0; n <
X.size(); n++)
61 for (
unsigned int n = 0; n <
X.size(); n++)
71 double cos_t = std::cos(theta);
72 double sin_t = std::sin(theta);
74 double x_shifted = x - cx;
75 double y_shifted = y - cy;
77 X[n][0] = cx + x_shifted * cos_t - y_shifted * sin_t;
78 X[n][1] = cy + x_shifted * sin_t + y_shifted * cos_t;
82 if (
X.back() !=
X.front())
85 X.push_back(
X.front());
88 amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
92 Set::Scalar min_dist_to_edge = std::numeric_limits<Set::Scalar>::max();
108 for (
unsigned int n = 0; n <
X.size()-1; n++)
116 if ((y1 > x(1)) != (y2 > x(1)))
118 x_cross = x1 + (x(1) - y1) * (x2 - x1) / (y2 - y1);
143 len2 = dx*dx + dy*dy;
144 t = ((px - x1)*dx + (py - y1)*dy) / len2;
158 x_int(0) = x1 +
t*dx;
159 x_int(1) = y1 +
t*dy;
162 dist_to_edge =
dist(x(0), x(1), x_int(0), x_int(1));
163 min_dist_to_edge = std::min(min_dist_to_edge, dist_to_edge);
166 if (num_cross % 2 == 0)
168 min_dist_to_edge = 1*min_dist_to_edge;
171 min_dist_to_edge = -1*min_dist_to_edge;
174 phi(i,j,k) = 0.5 * (1.0 - std::tanh(min_dist_to_edge /(std::sqrt(2.0) *
eps)));
177 phi(i,j,k) = 1 - phi(i,j,k);
186 std::string filename;
191 pp.
forbid(
"filename",
"use file.name instead");
223 std::ifstream datafile(filename);
225 if (datafile.is_open())
229 while (getline(datafile, line))
231 std::istringstream in(line);
233 std::string strx, stry, strz, strR;
234 in >> strx >> stry >> strz >> strR;
236 Set::Scalar x = (std::stod(strx) * unit).normalized_value();
237 Set::Scalar y = (std::stod(stry) * unit).normalized_value();
238 #if AMREX_SPACEDIM > 2
239 Set::Scalar z = (std::stod(strz) * unit).normalized_value();
245 value.
X.push_back(
X);
258 std::vector<Set::Vector>
X;
269 double dist(
double x1,
double y1,
double x2,
double y2)
275 return std::sqrt(dx*dx + dy*dy);
amrex::Vector< amrex::Geometry > & geom
double dist(double x1, double y1, double x2, double y2)
PointList(amrex::Vector< amrex::Geometry > &_geom, IO::ParmParse &pp, std::string name)
void Add(const int &lev, Set::Field< Set::Scalar > &a_phi, Set::Scalar)
std::vector< Set::Vector > X
static void Parse(PointList &value, IO::ParmParse &pp)
PointList(amrex::Vector< amrex::Geometry > &_geom)
static constexpr const char * name
struct IC::PointList::@0 rotation
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 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