#ifndef MEDUSA_BITS_DOMAINS_GRIDFILL_HPP_ #define MEDUSA_BITS_DOMAINS_GRIDFILL_HPP_ /** * @file * Implementation of GridFill engine. */ #include "GridFill_fwd.hpp" #include #include #include #include namespace mm { template GridFill::GridFill(const vec_t &bot, const vec_t &top) : bot(bot), top(top) { for (int i = 0; i < dim; ++i) { assert_msg(bot[i] <= top[i], "Bottom bounds %s must be below top bounds %s.", bot, top); } } template void GridFill::operator()(DomainDiscretization &domain, const scalar_t &h, int type) const { if (type == 0) type = 1; Vec counts; for (int i = 0; i < dim; ++i) { counts[i] = iceil((top[i] - bot[i]) / h) + 1; } KDTree tree(domain.positions()); for (const auto &x : linspace(bot, top, counts)) { if (domain.contains(x) && (tree.size() == 0 || tree.query(x, 1).second[0] >= h * h)) { domain.addInternalNode(x, type); } } } } // namespace mm #endif // MEDUSA_BITS_DOMAINS_GRIDFILL_HPP_