Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
rath3t committed Jan 16, 2024
1 parent 1a27a5d commit 034da70
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 18 deletions.
3 changes: 2 additions & 1 deletion dune/iga/hierarchicpatch/patchgrid.hh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ namespace Dune::IGANEW {
*/
explicit PatchGrid(const NURBSPatchData<dim, dimworld, ctype>& patchData,
const std::optional<PatchTrimData>& patchTrimData = std::nullopt,
const typename Trimmer::ParameterType& par = {})
const typename GridFamily::TrimmerTraits::ParameterType
& par = {})
: patchGeometries_(1, GeometryKernel::NURBSPatch<dim, dimworld, ctype>(patchData)),
trimmer_(std::make_unique<Trimmer>(*this, patchTrimData, par)) {
patchGeometriesUnElevated = patchGeometries_;
Expand Down
4 changes: 2 additions & 2 deletions dune/iga/test/factorytest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ auto testFactoryWithPlateWithTriangularTrim2D() {
const double r = 1.0;
gridFactory.insertPatch(patchData);
gridFactory.insertTrimmingCurve(diagonalTrimmingCurve());
gridFactory.setupTrimmer({.dummy = 10, .trimPrecision = 1e-6});
gridFactory.insertTrimParameters({.dummy = 10, .trimPrecision = 1e-6});
auto grid = gridFactory.createGrid();
auto extractGeo = std::views::transform([](const auto& ent) { return ent.geometry(); });

Expand Down Expand Up @@ -146,7 +146,7 @@ auto testFactoryWithPlateWithTriangularTrim3D() {
const double r = 1.0;
gridFactory.insertPatch(patchData);
gridFactory.insertTrimmingCurve(diagonalTrimmingCurve());
gridFactory.setupTrimmer({.dummy = 10, .trimPrecision = 1e-6});
gridFactory.insertTrimParameters({.dummy = 10, .trimPrecision = 1e-6});
auto grid = gridFactory.createGrid();
auto extractGeo = std::views::transform([](const auto& ent) { return ent.geometry(); });

Expand Down
2 changes: 1 addition & 1 deletion dune/iga/test/testreferenceelement.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ auto checkSubEntities(const RE& re) {
}

template <class RE>
auto checkCheckInside(const RE& re, int minsamples = 10000, int maxsamples = 100000) {
auto checkCheckInside(const RE& re, int maxsamples = 100000) {
Dune::TestSuite t("checkCheckInside for reference element ");

// int insideCounter=0;
Expand Down
27 changes: 21 additions & 6 deletions dune/iga/test/trimtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ auto checkTrim(std::string filename, const ExpectedValues& expectedValues) {
using Trimmer = Grid::Trimmer;
using ElementTrimData = Trimmer::ElementTrimData;

auto range = Dune::range(3);
auto range = Dune::range(4);
for (auto refx : range) {
std::vector<int> yR(
range.begin(),
Expand All @@ -361,14 +361,16 @@ auto checkTrim(std::string filename, const ExpectedValues& expectedValues) {
auto brep = readJson<2>(filename);
std::cout << "Refinement level: (" << refx << ", " << refy << ")" << std::endl;
gridFactory.insertJson(filename, true, {refx, refy});
auto igaGrid = gridFactory.createGrid();
auto patchTrimData=igaGrid->trimmer().patchTrimData();
const auto tensorCoordinates = GeometryKernel::NURBSPatch{gridFactory.patchData_}.uniqueKnotVector();
Dune::YaspGrid gridH{tensorCoordinates};
Dune::SubGrid<2, decltype(gridH)> grid(gridH);
grid.createBegin();
grid.insertLeaf();
grid.createEnd();

const auto& patchTrimData = gridFactory.patchTrimData_.value();
// const auto& patchTrimData = gridFactory.patchTrimData_.value();
assert(patchTrimData.loops().size() == 1);
const auto& firstLoop = patchTrimData.loops()[0];
t.load(std::memory_order_relaxed)->check(firstLoop.curves().size() == expectedValues.firstLoopCurvesSize)
Expand Down Expand Up @@ -404,7 +406,7 @@ auto checkTrim(std::string filename, const ExpectedValues& expectedValues) {
<< expectedValues.notAffineCounter;
// std::cout << resTrimPatch.trimmingCurveTotalLength << std::endl;
// std::cout << resTrimPatch.trimmingCurveCurvedLength << std::endl;
// std::cout << resTrimPatch.straightLength << std::endl;
// std::cout << resTrimPatch.straightLength << std::endl;
t.load(std::memory_order_relaxed)
->check(
Dune::FloatCmp::eq(resTrimPatch.trimmingCurveTotalLength, expectedValues.trimmingCurveTotalLength))
Expand All @@ -423,7 +425,7 @@ auto checkTrim(std::string filename, const ExpectedValues& expectedValues) {

std::atomic<double> trimmedEdgeLengthsAccumulated{0};
std::for_each(
std::execution::par, gridView.template begin<0>(), gridView.template end<0>(), [&](const auto& ele) {
std::execution::par_unseq, gridView.template begin<0>(), gridView.template end<0>(), [&](const auto& ele) {
ElementTrimData elementTrimData = DefaultTrim::TrimmerImpl<2, 2, double>::trimElement(ele, patchTrimData);
auto [subTestEle, trimmedEdgeLength]
= elementTrimDataObstacleCourse(ele, elementTrimData, gridView, resTrimPatch);
Expand All @@ -442,15 +444,15 @@ auto checkTrim(std::string filename, const ExpectedValues& expectedValues) {
<< "trimmedEdgeLengthsAccumulated is " << trimmedEdgeLengthsAccumulated << " but should be "
<< resTrimPatch.trimmingCurveCurvedLength;

gridFactory.createGrid();

});
}

return *t.load(std::memory_order_relaxed);
}

#include <cfenv>
#include <tbb/parallel_for.h>

int main(int argc, char** argv) try {
feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT);
std::cout << std::thread::hardware_concurrency() << "\n";
Expand All @@ -469,6 +471,19 @@ int main(int argc, char** argv) try {
.trimmingCurveTotalLength = 4,
.firstLoopCurvesSize = 4,
.notAffineCounter = 0})));
t.subTest(
checkTrim("auxiliaryfiles/trim_2edges.ibra", ExpectedValues({.straightLength = 31.94725845850641,
.trimmingCurveCurvedLength = 6.323120188237797,
.trimmingCurveTotalLength = 38.27037864674421,
.firstLoopCurvesSize = 6,
.notAffineCounter = 2})));

t.subTest(
checkTrim("auxiliaryfiles/trim_multi.ibra", ExpectedValues({.straightLength = 27.06623257317474,
.trimmingCurveCurvedLength = 7.461084509983623,
.trimmingCurveTotalLength = 38.27037864674421,
.firstLoopCurvesSize = 5,
.notAffineCounter = 1})));
t.subTest(
checkTrim("auxiliaryfiles/element_trim_xb.ibra", ExpectedValues({.straightLength = 2.791977909806771,
.trimmingCurveCurvedLength = 1.6273832575204,
Expand Down
12 changes: 6 additions & 6 deletions dune/iga/trimmer/defaulttrimmer/trimelement.hh
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ namespace Dune::IGANEW::DefaultTrim {
if (isHostVertex(vV1) and isNewVertex(vV2)) {
currentCurveIdx = getTrimmingCurveIdx(vV2);
auto [tParam, curvePoint]
= Util::callFindIntersection(currentCurveIdx, getEdgeIdx(vV2), pt2, patchTrimData, corners);
// std::cout << "Found: " << curvePoint << " From Clipping: " << pt2.x << " " << pt2.y << " t: " << tParam
// << std::endl;
= Util::callFindIntersection(patchTrimData.getCurve(currentCurveIdx), getEdgeIdx(vV2), pt2, corners);
std::cout << "Found: " << curvePoint << " From Clipping: " << pt2.x << " " << pt2.y << " t: " << tParam
<< std::endl;

FieldVector<ScalarType, dim> p
= foundVertices.empty() ? FieldVector<ScalarType, dim>{pt1.x, pt1.y} : foundVertices.back();
Expand All @@ -105,9 +105,9 @@ namespace Dune::IGANEW::DefaultTrim {
assert(getTrimmingCurveIdx(vV2) == currentCurveIdx);

auto [tParam, curvePoint]
= Util::callFindIntersection(currentCurveIdx, getEdgeIdx(vV2), pt2, patchTrimData, corners);
// std::cout << "Found: " << curvePoint << " From Clipping: " << pt2.x << " " << pt2.y << " t: " << tParam
// << std::endl;
= Util::callFindIntersection(patchTrimData.getCurve(currentCurveIdx), getEdgeIdx(vV2), pt2, corners);
std::cout << "Found: " << curvePoint << " From Clipping: " << pt2.x << " " << pt2.y << " t: " << tParam
<< std::endl;

if (currentT > tParam) {
assert(getEdgeIdx(vV1) == getEdgeIdx(vV2));
Expand Down
4 changes: 3 additions & 1 deletion dune/iga/trimmer/defaulttrimmer/trimmer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ namespace Dune::IGANEW {
int dummy = 7; ///< Dummy variable.
double trimPrecision = 1e-10; ///< Precision for trimming.
};


// /**
// * @brief ElementTrimData struct representing trim data for an element.
Expand Down Expand Up @@ -224,6 +224,7 @@ namespace Dune::IGANEW {
static const bool hasHostEntity = true;

struct TrimmerTraits {
using ParameterType = Parameter; ///< Type for trimming parameters.
using ParameterSpaceGrid
= Dune::SubGrid<dim,
YaspGrid<dim, TensorProductCoordinates<ScalarType, dim>>>; ///< Type of the Parametric grid
Expand Down Expand Up @@ -536,6 +537,7 @@ namespace Dune::IGANEW {
// @todo Trim move the refine here from the grid
;
}
auto& patchTrimData() const{ return *trimData_; }

protected:
protected:
Expand Down
2 changes: 1 addition & 1 deletion dune/iga/trimmer/defaulttrimmer/trimmingutils/trimutils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Dune::IGANEW::DefaultTrim::Util {
return GeometryKernel::NURBSPatch(patchData);
}

auto callFindIntersection(const auto& curvePatchGeo, const int edgeIdx, const auto& ip, const auto& corners)
auto callFindIntersection(const auto& curvePatchGeo, int edgeIdx, const auto& ip, const auto& corners)
-> std::pair<double, FieldVector<double, 2>> {
// @todo gerneralize for more than one loop
auto pos = corners[edgeIdx];
Expand Down
4 changes: 4 additions & 0 deletions dune/iga/trimmer/identitytrimmer/trimmer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ namespace Dune::IGANEW {
static const bool hasHostEntity = true;

struct TrimmerTraits {
using ParameterType = Parameter; ///< Type for trimming parameters.

using PatchTrimData = PatchTrimDataImpl<dim, ScalarType>;
using ParameterSpaceGrid
= YaspGrid<dim, TensorProductCoordinates<ScalarType, dim>>; ///< Type of the Parametric grid
Expand Down Expand Up @@ -192,6 +194,8 @@ namespace Dune::IGANEW {
grid_, parameterSpaceGrid().levelGridView(ent.level()).ibegin(ent.impl().getHostEntity()));
}



//! Reference to one past the last neighbor
PatchGridLevelIntersectionIterator<const GridImp> ilevelend(const Entity<0>& ent) const {
return PatchGridLevelIntersectionIterator<const GridImp>(
Expand Down

0 comments on commit 034da70

Please sign in to comment.