16 static constexpr const char*
name =
"voronoi";
20 Voronoi (amrex::Vector<amrex::Geometry> &_geom) :
IC(_geom) {}
25 Define(_number_of_grains,a_alpha);
27 Voronoi (amrex::Vector<amrex::Geometry> &a_geom,
int a_number_of_grains) :
IC(a_geom)
29 Define(a_number_of_grains,1.0);
38 std::vector<Set::Scalar> a_alpha,
45 if (a_alpha.size() == 1 && a_number_of_grains > 1)
46 alpha.resize(a_number_of_grains,a_alpha[0]);
61 AMREX_D_TERM(size(0) =
geom[0].ProbHi()[0] -
geom[0].ProbLo()[0];,
62 size(1) =
geom[0].ProbHi()[1] -
geom[0].ProbLo()[1];,
63 size(2) =
geom[0].ProbHi()[2] -
geom[0].ProbLo()[2];)
65 for (amrex::MFIter mfi(*a_field[lev],amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
68 amrex::IndexType ixtype = a_field[lev]->ixType();
69 if (ixtype == amrex::IndexType::TheCellType()) bx = mfi.growntilebox();
70 else if (ixtype == amrex::IndexType::TheNodeType()) bx = mfi.grownnodaltilebox();
72 int ncomp = a_field[lev]->nComp();
73 amrex::Array4<Set::Scalar>
const& field = a_field[lev]->array(mfi);
74 amrex::ParallelFor (bx,[=] AMREX_GPU_DEVICE(
int i,
int j,
int k) {
77 AMREX_D_TERM(x(0) =
geom[lev].ProbLo()[0] + ((amrex::Real)(i) + 0.5) *
geom[lev].CellSize()[0];,
78 x(1) =
geom[lev].ProbLo()[1] + ((amrex::Real)(j) + 0.5) *
geom[lev].CellSize()[1];,
79 x(2) =
geom[lev].ProbLo()[2] + ((amrex::Real)(k) + 0.5) *
geom[lev].CellSize()[2];);
81 amrex::Real min_distance = std::numeric_limits<amrex::Real>::infinity();
82 int min_grain_id = -1;
88 if (
geom[0].isPeriodic(0))
91 std::min( (x-
voronoi[n] + size(0)*Set::Vector::Unit(0)).lpNorm<2>(),
92 (x-
voronoi[n] - size(0)*Set::Vector::Unit(0)).lpNorm<2>()));
95 if (
geom[0].isPeriodic(1))
98 std::min( (x-
voronoi[n] + size(0)*Set::Vector::Unit(1)).lpNorm<2>(),
99 (x-
voronoi[n] - size(0)*Set::Vector::Unit(1)).lpNorm<2>()));
103 if (
geom[0].isPeriodic(2))
106 std::min( (x-
voronoi[n] + size(0)*Set::Vector::Unit(2)).lpNorm<2>(),
107 (x-
voronoi[n] - size(0)*Set::Vector::Unit(2)).lpNorm<2>()));
#define pp_queryclass(...)
amrex::Vector< amrex::Geometry > & geom
void Add(const int &lev, Set::Field< Set::Scalar > &a_field, Set::Scalar)
static void Parse(Voronoi &value, IO::ParmParse &pp)
std::vector< Set::Scalar > alpha
static constexpr const char * name
Voronoi(amrex::Vector< amrex::Geometry > &_geom, int _number_of_grains, Set::Scalar a_alpha)
void Define(int a_number_of_grains, std::vector< Set::Scalar > a_alpha, Type a_type=Type::Values)
Voronoi(amrex::Vector< amrex::Geometry > &_geom)
Voronoi(amrex::Vector< amrex::Geometry > &a_geom, int a_number_of_grains)
void Define(int a_number_of_grains, Set::Scalar a_alpha)
std::vector< Set::Vector > voronoi
Voronoi(amrex::Vector< amrex::Geometry > &_geom, IO::ParmParse &pp, std::string name)
int query(std::string name, T &value, const std::source_location &location=std::source_location::current())
int query_switch(std::string name, std::initializer_list< std::pair< std::string, std::function< void()> > > cases, const std::source_location &location=std::source_location::current())
static bool InTraversalMode()
int queryarr_default(std::string name, std::vector< std::string > &value, std::vector< std::string > defaultvalue, const std::source_location &location=std::source_location::current())
Initialize a spherical inclusion.
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector