/** This is based on a nearest node criterion to all boundaries. @todo Improve efficiency. In most cases, we should be able to specify boundaries as planes @todo Somewhat dependent on the resolution of the model boundary */ bool OmegaBDistanceConfigurator::configure(Model& m) const { Point<3> ebc; m.UpdateIndices(); vector<size_t> omega_ids; omega_ids.reserve(m.Region("Model").Elements()); for (const auto& eit : m.Region("Model").ElementVector()) { ebc = eit->BaryCenter(); double dmin = numeric_limits<double>::max(); for (Model::boundaryIterator bit = m.BoundariesBegin(); bit != m.BoundariesEnd(); ++bit) { if (!is_main_boundary_id(bit->first.second)) continue; for (const auto& bnit : bit->second.NodeVector()) { double const dist = ebc.DistanceTo(bnit->Coordinate()); if (dist < dmin) dmin = dist; } } if (dmin >= dist_) omega_ids.push_back(eit->Idx()); } if (omega_ids.size()) { m.FormRegionFrom("omega", omega_ids); return true; } return false; }
/// Removes line element regions for 3D models void make_dfn_boundaries(csmp::Model<3> &m) { vector<string> bregions; // loop over regions for (auto it = m.UniqueRegionsBegin(); it != m.UniqueRegionsEnd(); ++it) if (is_main_boundary_id(it->first)) // identify boundary names bregions.push_back(it->first); // converting for (auto br : bregions) m.InsertBoundary(br.c_str(), IRREGULAR, true, true); // make boundaries }