diff --git a/dune/iga/hierarchicpatch/patchgrid.hh b/dune/iga/hierarchicpatch/patchgrid.hh index 446e467e..f3bba72d 100644 --- a/dune/iga/hierarchicpatch/patchgrid.hh +++ b/dune/iga/hierarchicpatch/patchgrid.hh @@ -158,7 +158,7 @@ namespace Dune::IGANEW { */ explicit PatchGrid(const NURBSPatchData& patchData, const std::optional& patchTrimData = std::nullopt, - const typename Trimmer::ParameterType& par = {}) + const typename Trimmer::ParameterType& par = {}) : patchGeometries_(1, GeometryKernel::NURBSPatch(patchData)), trimmer_(std::make_unique(*this, patchTrimData, par)) { patchGeometriesUnElevated = patchGeometries_; diff --git a/dune/iga/hierarchicpatch/patchgridfactory.hh b/dune/iga/hierarchicpatch/patchgridfactory.hh index dcb2c8d0..0be98d97 100644 --- a/dune/iga/hierarchicpatch/patchgridfactory.hh +++ b/dune/iga/hierarchicpatch/patchgridfactory.hh @@ -18,12 +18,11 @@ namespace Dune { using PatchTrimData = typename TrimmerType::PatchTrimData; public: - using TrimParameterType = typename TrimmerType::ParameterType; + using TrimParameterType = typename TrimmerType::ParameterType; /** @brief Type used by the grid for coordinates */ typedef typename PatchGrid::ctype ctype; - /** @brief Insert a patch into the grid @param patchData The patch data @param patchTrimData Trimming data for this patch @@ -41,10 +40,7 @@ namespace Dune { // @todo this does not really add the trimming curve to anything void insertTrimmingCurve(const IGANEW::NURBSPatchData& curve) { trimCurves.push_back(curve); } - - void insertTrimParameters(const TrimParameterType& par) { - parameters_ = par; - } + void insertTrimParameters(const TrimParameterType& par) { parameters_ = par; } /** @brief Insert a patch into the grid @param patchData The patch data diff --git a/dune/iga/test/testibrareader.cpp b/dune/iga/test/testibrareader.cpp index b3e094c8..2e297db2 100644 --- a/dune/iga/test/testibrareader.cpp +++ b/dune/iga/test/testibrareader.cpp @@ -28,9 +28,8 @@ auto testIbraReader() { auto gridFactory = GridFactory(); gridFactory.insertTrimParameters(GridFactory::TrimParameterType{120}); - // gridFactory.insertJson("auxiliaryfiles/trim_2edges.ibra", true, {0, 0}); // gridFactory.insertJson("auxiliaryfiles/element_trim.ibra", true, {1, 1}); - + gridFactory.insertJson("auxiliaryfiles/trim_2edges.ibra", true, {0, 0}); // gridFactory.insertJson("auxiliaryfiles/trim_multi.ibra", true, {1, 1}); gridFactory.insertJson("auxiliaryfiles/element_trim_xb.ibra", true, {1, 1}); // gridFactory.insertJson("auxiliaryfiles/pipe_trim.ibra", true, {1, 1}); diff --git a/dune/iga/test/trimtest.cpp b/dune/iga/test/trimtest.cpp index 9fe8f36b..dbcf46c6 100644 --- a/dune/iga/test/trimtest.cpp +++ b/dune/iga/test/trimtest.cpp @@ -15,17 +15,17 @@ #include #include -#include #include +#include using namespace Dune::IGANEW; -auto testExample1(){ +auto testExample1() { Dune::TestSuite t("", Dune::TestSuite::ThrowPolicy::ThrowOnRequired); // Setup - using GridFactory = Dune::GridFactory>; - using Trimmer = DefaultTrim::TrimmerImpl<2, 2, double>; + using GridFactory = Dune::GridFactory>; + using Trimmer = DefaultTrim::TrimmerImpl<2, 2, double>; using ElementTrimData = Trimmer::ElementTrimData; auto gridFactory = GridFactory(); @@ -34,12 +34,12 @@ auto testExample1(){ const Dune::YaspGrid grid{tensorCoordinates}; const auto& patchTrimData = gridFactory.patchTrimData_.value(); - auto trimmer = Trimmer{}; + auto trimmer = Trimmer{}; for (auto& ele : elements(grid.leafGridView())) { ElementTrimData elementTrimData = trimmer.trimElement(ele, patchTrimData); - auto& vertexInfos = elementTrimData.vertices(); - auto& edgeInfos = elementTrimData.edges(); + auto& vertexInfos = elementTrimData.vertices(); + auto& edgeInfos = elementTrimData.edges(); } return t; diff --git a/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh b/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh index eb58cc37..3f55a39c 100644 --- a/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh +++ b/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh @@ -121,8 +121,8 @@ namespace Dune::IGANEW::DefaultTrim { // Getter [[nodiscard]] ElementTrimFlag flag() const { return flag_; } - [[nodiscard]] const std::vector& vertices() const {return vertices_;} - [[nodiscard]] const std::vector& edges() const {return edges_;} + [[nodiscard]] const std::vector& vertices() const { return vertices_; } + [[nodiscard]] const std::vector& edges() const { return edges_; } private: ElementTrimFlag flag_; diff --git a/dune/iga/trimmer/defaulttrimmer/patchtrimdata.hh b/dune/iga/trimmer/defaulttrimmer/patchtrimdata.hh index e2792684..8c843735 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchtrimdata.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchtrimdata.hh @@ -18,17 +18,15 @@ namespace Dune::IGANEW::DefaultTrim { std::vector curves_; }; - - class CurveManager { friend PatchTrimDataImpl; + public: using idx_t = u_int64_t; void addLoop(const BoundaryLoop& loop) { Clipper2Lib::PathD path; - for (idx_t i = loops_.empty() ? splitter_ : loops_.back().back().z + 1; - const auto& curve : loop.curves()) { + for (idx_t i = loops_.empty() ? splitter_ : loops_.back().back().z + 1; const auto& curve : loop.curves()) { if (curve.degree().front() == 1) { auto p1 = curve.corner(0); auto p2 = curve.corner(1); @@ -49,11 +47,8 @@ namespace Dune::IGANEW::DefaultTrim { [[nodiscard]] auto getIndices(const idx_t val) const -> std::pair { size_t loopIdx = 0; if (loops_.size() > 1) { - auto it = std::ranges::find_if(loopIndices_, [&](const idx_t t) { - return val > t; - }); - if (it == loopIndices_.end()) - DUNE_THROW(Dune::IOError, "Invalid z-Value"); + auto it = std::ranges::find_if(loopIndices_, [&](const idx_t t) { return val > t; }); + if (it == loopIndices_.end()) DUNE_THROW(Dune::IOError, "Invalid z-Value"); loopIdx = std::ranges::distance(loopIndices_.begin(), it); } // \todo multiplt loop e.g. - size of all loops before @@ -77,8 +72,7 @@ namespace Dune::IGANEW::DefaultTrim { const auto& loops() const { return loops_; } const auto& clipperLoops() const { - if (not finished_) - DUNE_THROW(Dune::GridError, "Call trimmer.setup() before quering for loops"); + if (not finished_) DUNE_THROW(Dune::GridError, "Call trimmer.setup() before quering for loops"); return manager_.loops_; } @@ -92,15 +86,12 @@ namespace Dune::IGANEW::DefaultTrim { auto getCurve(const std::pair& indices) const -> const TrimmingCurve& { return loops_[indices.first].curves()[indices.second]; } - auto getSplitter() const -> typename CurveManager::idx_t { - return manager_.splitter_; - } + auto getSplitter() const -> typename CurveManager::idx_t { return manager_.splitter_; } template void prepare(const ParameterType& parameters, const std::unique_ptr& parameterSpaceGrid) { manager_.splitter_ = parameters.splitter; - std::ranges::for_each(loops_, [&](const auto& loop) { manager_.addLoop(loop);}); - + std::ranges::for_each(loops_, [&](const auto& loop) { manager_.addLoop(loop); }); finished_ = true; } @@ -109,7 +100,6 @@ namespace Dune::IGANEW::DefaultTrim { bool finished_ = false; std::vector loops_; CurveManager manager_; - }; } // namespace Dune::IGANEW::DefaultTrim diff --git a/dune/iga/trimmer/defaulttrimmer/trimelement.hh b/dune/iga/trimmer/defaulttrimmer/trimelement.hh index 86e3c9b1..78027092 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimelement.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimelement.hh @@ -37,10 +37,9 @@ namespace Dune::IGANEW::DefaultTrim { auto getPt = [](auto&& vV) { return vV.pt; }; auto getHostIdx = [](const auto& vV) { return std::get(vV).hostIdx; }; auto getEdgeIdx = [](const auto& vV) { return std::get(vV).onEdgeIdx; }; - auto getTrimmingCurveIdx - = [&](auto& vV) -> std::pair { - return patchTrimData.getIndices(std::get(vV).trimmingCurveZ); - }; + auto getTrimmingCurveIdx = [&](auto& vV) -> std::pair { + return patchTrimData.getIndices(std::get(vV).trimmingCurveZ); + }; /// // Here the actual code is starting @@ -48,9 +47,9 @@ namespace Dune::IGANEW::DefaultTrim { // State std::vector> foundVertices; - bool isOnNewEdge = false; + bool isOnNewEdge = false; std::pair currentCurveIdx = {std::numeric_limits::infinity(), std::numeric_limits::infinity()}; - double currentT = std::numeric_limits::infinity(); + double currentT = std::numeric_limits::infinity(); for (const auto i : std::views::iota(0u, result.vertices_.size())) { auto vV1 = result.vertices_[i]; @@ -90,9 +89,9 @@ namespace Dune::IGANEW::DefaultTrim { currentCurveIdx = getTrimmingCurveIdx(vV1); FieldVector curvePoint; std::tie(currentT, curvePoint) - = Util::callFindIntersection(patchTrimData.getCurve(currentCurveIdx), getEdgeIdx(vV1), pt1, corners); + = Util::callFindIntersection(patchTrimData.getCurve(currentCurveIdx), getEdgeIdx(vV1), pt1, corners); std::cout << "Found: " << curvePoint << " From Clipping: " << pt1.x << " " << pt1.y << " t: " << currentT - << std::endl; + << std::endl; foundVertices.push_back(curvePoint); } assert(getTrimmingCurveIdx(vV2) == currentCurveIdx); @@ -109,7 +108,8 @@ namespace Dune::IGANEW::DefaultTrim { isOnNewEdge = true; currentT = tParam; } else { - auto elementTrimmingCurve = Util::createTrimmingCurveSlice(patchTrimData.getCurve(currentCurveIdx), currentT, tParam); + auto elementTrimmingCurve + = Util::createTrimmingCurveSlice(patchTrimData.getCurve(currentCurveIdx), currentT, tParam); elementTrimData.addEdgeNewNew(elementTrimmingCurve, curvePoint); isOnNewEdge = false; currentT = std::numeric_limits::infinity(); @@ -124,8 +124,8 @@ namespace Dune::IGANEW::DefaultTrim { FieldVector p; if (foundVertices.empty()) - std::tie(std::ignore, p) - = Util::callFindIntersection(patchTrimData.getCurve(getTrimmingCurveIdx(vV1)), getEdgeIdx(vV1), pt1, corners); + std::tie(std::ignore, p) = Util::callFindIntersection(patchTrimData.getCurve(getTrimmingCurveIdx(vV1)), + getEdgeIdx(vV1), pt1, corners); else p = foundVertices.back(); diff --git a/dune/iga/trimmer/defaulttrimmer/trimmer.hh b/dune/iga/trimmer/defaulttrimmer/trimmer.hh index 90044260..ce36f391 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmer.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmer.hh @@ -189,11 +189,11 @@ namespace Dune::IGANEW { class TrimmerImpl; template struct PatchGridFamily { - using ctype = ScalarType; - static constexpr int patchDim = dim; - static constexpr int worldDim = dimworld; - using Grid = PatchGrid; - using Trimmer = TrimmerImpl; + using ctype = ScalarType; + static constexpr int patchDim = dim; + static constexpr int worldDim = dimworld; + using Grid = PatchGrid; + using Trimmer = TrimmerImpl; using GlobalIdSet = PatchGridGlobalIdSet; @@ -498,16 +498,13 @@ namespace Dune::IGANEW { GridImp* grid_; void setup() { - if (trimData_.has_value()) - trimData_->prepare(parameters_, untrimmedParameterSpaceGrid_); + if (trimData_.has_value()) trimData_->prepare(parameters_, untrimmedParameterSpaceGrid_); } /** * @brief Change the parameters to the trimmer. * @param par The parameters. */ - void setParameters(const ParameterType& par) { - parameters_ = par; - } + void setParameters(const ParameterType& par) { parameters_ = par; } /** * @brief Get a const reference to the parameter space grid. diff --git a/dune/iga/trimmer/defaulttrimmer/trimmingutils/clipelementrectangle.hh b/dune/iga/trimmer/defaulttrimmer/trimmingutils/clipelementrectangle.hh index 22a32395..cc0eac91 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmingutils/clipelementrectangle.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmingutils/clipelementrectangle.hh @@ -17,7 +17,7 @@ namespace Dune::IGANEW::DefaultTrim::Util { -> std::tuple { using namespace Clipper2Lib; - auto eleGeo = element.geometry(); + auto eleGeo = element.geometry(); PathD eleRect; for (const auto i : std::views::iota(0u, 4u)) { @@ -66,12 +66,11 @@ namespace Dune::IGANEW::DefaultTrim::Util { return; } - const auto edgeIdx = giveEdgeIdx(e1bot.z, e1top.z); - const auto curveZ = e2bot.z; + const auto edgeIdx = giveEdgeIdx(e1bot.z, e1top.z); + const auto curveZ = e2bot.z; // Now check that we don't have a parallel intersection - if (checkParallel(patchTrimData.getCurve(curveZ), edgeIdx)) - return; + if (checkParallel(patchTrimData.getCurve(curveZ), edgeIdx)) return; result.addNewVertex(edgeIdx, pt, curveZ); }); @@ -97,15 +96,15 @@ namespace Dune::IGANEW::DefaultTrim::Util { auto pt = curve.corner(i); PointD ptClipper{pt[0], pt[1]}; - if (auto [isHost, idx] = isHostVertex(ptClipper, eleRect); isHost) - result.addOriginalVertex(idx); + if (auto [isHost, idx] = isHostVertex(ptClipper, eleRect); isHost) result.addOriginalVertex(idx); for (auto e = 0; e < edgeLookUp.size(); ++e) { if (const auto& edgeIdx = edgeLookUp[e]; - isPointOnLine(pt, eleGeo.corner(edgeIdx.front()), eleGeo.corner(edgeIdx.back())) + isPointOnLine(pt, eleGeo.corner(edgeIdx.front()), eleGeo.corner(edgeIdx.back())) && !checkParallel(curve, e)) { // \todo this needs to be done more generically - const size_t newIdx = i == 0 ? (cI + 1) * patchTrimData.getSplitter() : (cI + 1) * patchTrimData.getSplitter() + patchTrimData.getSplitter() - 1; + const size_t newIdx = i == 0 ? (cI + 1) * patchTrimData.getSplitter() + : (cI + 1) * patchTrimData.getSplitter() + patchTrimData.getSplitter() - 1; result.addNewVertex(e, ptClipper, newIdx); break; } diff --git a/dune/iga/trimmer/defaulttrimmer/trimmingutils/cliputils.hh b/dune/iga/trimmer/defaulttrimmer/trimmingutils/cliputils.hh index 21c3750b..92cf9838 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmingutils/cliputils.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmingutils/cliputils.hh @@ -137,7 +137,7 @@ namespace Dune::IGANEW::DefaultTrim::Util { std::ranges::rotate(vertices_, it); else std::cout << "Warning, no HostVertex" << std::endl; - //DUNE_THROW(Dune::NotImplemented, "Algorithm needs at least one HostVertex to work"); + // DUNE_THROW(Dune::NotImplemented, "Algorithm needs at least one HostVertex to work"); } void report() const { diff --git a/dune/iga/trimmer/defaulttrimmer/trimmingutils/trimutils.hh b/dune/iga/trimmer/defaulttrimmer/trimmingutils/trimutils.hh index cd7fd33c..3ec0a9af 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmingutils/trimutils.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmingutils/trimutils.hh @@ -37,11 +37,11 @@ namespace Dune::IGANEW::DefaultTrim::Util { return GeometryKernel::NURBSPatch(patchData); } - auto callFindIntersection(const auto& curvePatchGeo, const int edgeIdx, const auto& ip, - const auto& corners) -> std::pair> { + auto callFindIntersection(const auto& curvePatchGeo, const int edgeIdx, const auto& ip, const auto& corners) + -> std::pair> { // @todo gerneralize for more than one loop - auto pos = corners[edgeIdx]; - auto dir = edgeDirections[edgeIdx]; + auto pos = corners[edgeIdx]; + auto dir = edgeDirections[edgeIdx]; auto guessTParam = FieldVector{findGoodStartingPoint(curvePatchGeo, ip), 0.5}; diff --git a/dune/iga/trimmer/identitytrimmer/trimmer.hh b/dune/iga/trimmer/identitytrimmer/trimmer.hh index 09ce5004..3de366d8 100644 --- a/dune/iga/trimmer/identitytrimmer/trimmer.hh +++ b/dune/iga/trimmer/identitytrimmer/trimmer.hh @@ -266,7 +266,8 @@ namespace Dune::IGANEW { * @param patch NURBS patch data. * @param trimData Optional patch trim data. */ - TrimmerImpl(GridImp& grid, const std::optional& trimData, const ParameterType& par = {}) + TrimmerImpl(GridImp& grid, const std::optional& trimData, + const ParameterType& par = {}) : grid_{&grid}, leafIndexSet_(std::make_unique(*grid_)), globalIdSet_(std::make_unique(*grid_)),