Skip to content

Commit

Permalink
Geometry: Doc Strings
Browse files Browse the repository at this point in the history
Add more argument names and doc strings.
  • Loading branch information
ax3l committed Apr 25, 2024
1 parent 28897d2 commit b62d4a6
Showing 1 changed file with 62 additions and 36 deletions.
98 changes: 62 additions & 36 deletions src/Base/Geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,27 @@ void init_Geometry(py::module& m)
}
)
.def(py::init<>())
.def_readonly("prob_domain", &GeometryData::prob_domain)
.def_readonly("domain", &GeometryData::domain)
.def_readonly("coord", &GeometryData::coord)
.def_readonly("prob_domain", &GeometryData::prob_domain, "The problem domain (real).")
.def_readonly("domain", &GeometryData::domain, "The index domain.")
.def_readonly("coord", &GeometryData::coord, "The Coordinates type.")
.def_property_readonly("dx",
[](const GeometryData& gd){
std::array<Real,AMREX_SPACEDIM> dx {AMREX_D_DECL(
gd.dx[0], gd.dx[1], gd.dx[2]
)};
return dx;
})
},
"The cellsize for each coordinate direction."
)
.def_property_readonly("is_periodic",
[](const GeometryData& gd){
std::array<int,AMREX_SPACEDIM> per {AMREX_D_DECL(
gd.is_periodic[0], gd.is_periodic[1], gd.is_periodic[2]
)};
return per;})
return per;
},
"Returns whether the domain is periodic in each coordinate direction."
)
// ,
// [](GeometryData& gd, std::vector<Real> per_in) {
// AMREX_D_TERM(gd.is_periodic[0] = per_in[0];,
Expand Down Expand Up @@ -128,16 +133,18 @@ void init_Geometry(py::module& m)

.def("define", py::overload_cast<const Box&, const RealBox&,
int, Array<int,AMREX_SPACEDIM> const&>
(&Geometry::define), "Set geometry")

(&Geometry::define),
py::arg("dom"), py::arg("rb"), py::arg("coord"), py::arg("is_per"),
"Set geometry"
)

.def("ProbDomain", py::overload_cast<>(&Geometry::ProbDomain, py::const_),
"Return problem domain")
.def("ProbDomain", [](Geometry& gm, const RealBox& rb) {
if(gm.Ok()) { gm.ProbDomain(rb);}
else { throw std::runtime_error("Can't call ProbDomain on undefined Geometry; use Define");}
})
.def_property("prob_domain",
py::overload_cast<>(&Geometry::ProbDomain, py::const_),
py::overload_cast<RealBox const &>(&Geometry::ProbDomain),
"The problem domain (real)."
)
.def("ProbLo", py::overload_cast<int>(&Geometry::ProbLo, py::const_),
py::arg("dir"),
"Get the lo end of the problem domain in specified direction")
.def("ProbLo",
[](const Geometry& gm) {
Expand All @@ -147,6 +154,7 @@ void init_Geometry(py::module& m)
"Get the list of lo ends of the problem domain"
)
.def("ProbHi", py::overload_cast<int>(&Geometry::ProbHi, py::const_),
py::arg("dir"),
"Get the hi end of the problem domain in specified direction")
.def("ProbHi",
[](const Geometry& gm) {
Expand All @@ -157,11 +165,12 @@ void init_Geometry(py::module& m)
)
.def("ProbSize", &Geometry::ProbSize, "the overall size of the domain")
.def("ProbLength", &Geometry::ProbLength, "length of problem domain in specified dimension")
.def("Domain", py::overload_cast<>(&Geometry::Domain, py::const_), "Return rectangular domain")
// .def("Domain", py::overload_cast<const Box&>(&Geometry::Domain), "Set rectangular domain")
.def("Domain", [](Geometry& gm, const Box& bx) {
if(gm.Ok()) { gm.Domain(bx);}
else { throw std::runtime_error("Can't call Domain on undefined Geometry; use Define");}})

.def_property("domain",
py::overload_cast<>(&Geometry::Domain, py::const_),
py::overload_cast<Box const &>(&Geometry::Domain),
"The rectangular domain (index space)."
)

// GetVolume
// .def("GetVolume", py::overload_cast<MultiFab&>(&Geometry::GetVolume, py::const_))
Expand All @@ -178,30 +187,47 @@ void init_Geometry(py::module& m)
"Is domain periodic in all directions?")
.def("isPeriodic", py::overload_cast<>(&Geometry::isPeriodic, py::const_),
"Return list indicating whether domain is periodic in each direction")
.def("period", [](const Geometry& gm, const int dir) {
if(gm.isPeriodic(dir)){ return gm.period(dir); }
else { throw std::runtime_error("Geometry is not periodic in this direction."); }
}, "Return the period in the specified direction")
.def("periodicity", py::overload_cast<>(&Geometry::periodicity, py::const_)
)
.def("periodicity", py::overload_cast<const Box&>(&Geometry::periodicity, py::const_),
.def("period",
[](const Geometry& gm, const int dir) {
if(gm.isPeriodic(dir)){ return gm.period(dir); }
else { throw std::runtime_error("Geometry is not periodic in this direction."); }
},
py::arg("dir"),
"Return the period in the specified direction")
.def("periodicity",
py::overload_cast<>(&Geometry::periodicity, py::const_)
)
.def("periodicity",
py::overload_cast<const Box&>(&Geometry::periodicity, py::const_),
py::arg("b"),
"Return Periodicity object with lengths determined by input Box"
)
)

// .def("periodicShift", &Geometry::periodicShift)
.def("growNonPeriodicDomain", py::overload_cast<IntVect const&>(&Geometry::growNonPeriodicDomain, py::const_))
.def("growNonPeriodicDomain", py::overload_cast<int>(&Geometry::growNonPeriodicDomain, py::const_))
.def("growPeriodicDomain", py::overload_cast<IntVect const&>(&Geometry::growPeriodicDomain, py::const_))
.def("growPeriodicDomain", py::overload_cast<int>(&Geometry::growPeriodicDomain, py::const_))

.def("setPeriodicity", &Geometry::setPeriodicity)
.def("coarsen", &Geometry::coarsen)
.def("refine", &Geometry::refine)
.def("growNonPeriodicDomain", py::overload_cast<IntVect const&>(&Geometry::growNonPeriodicDomain, py::const_),
py::arg("ngrow"))
.def("growNonPeriodicDomain", py::overload_cast<int>(&Geometry::growNonPeriodicDomain, py::const_),
py::arg("ngrow"))
.def("growPeriodicDomain", py::overload_cast<IntVect const&>(&Geometry::growPeriodicDomain, py::const_),
py::arg("ngrow"))
.def("growPeriodicDomain", py::overload_cast<int>(&Geometry::growPeriodicDomain, py::const_),
py::arg("ngrow"))

.def("setPeriodicity",
&Geometry::setPeriodicity,
py::arg("period"),
"Set periodicity flags and return the old flags.\n"
"Note that, unlike Periodicity class, the flags are just boolean."
)
.def("coarsen", &Geometry::coarsen, py::arg("rr"))
.def("refine", &Geometry::refine, py::arg("rr"))
.def("outsideRoundOffDomain", py::overload_cast<AMREX_D_DECL(ParticleReal, ParticleReal, ParticleReal)>
(&Geometry::outsideRoundoffDomain, py::const_),
(&Geometry::outsideRoundoffDomain, py::const_),
AMREX_D_DECL(py::arg("x"), py::arg("y"), py::arg("z")),
"Returns true if a point is outside the roundoff domain. All particles with positions inside the roundoff domain are sure to be mapped to cells inside the Domain() box. Note that the same need not be true for all points inside ProbDomain()")
.def("insideRoundOffDomain", py::overload_cast<AMREX_D_DECL(ParticleReal, ParticleReal, ParticleReal)>
(&Geometry::insideRoundoffDomain, py::const_),
(&Geometry::insideRoundoffDomain, py::const_),
AMREX_D_DECL(py::arg("x"), py::arg("y"), py::arg("z")),
"Returns true if a point is inside the roundoff domain. All particles with positions inside the roundoff domain are sure to be mapped to cells inside the Domain() box. Note that the same need not be true for all points inside ProbDomain()")

// .def("computeRoundoffDomain")
Expand Down

0 comments on commit b62d4a6

Please sign in to comment.