Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
henrij22 committed Apr 9, 2024
1 parent 3219773 commit bf1edf9
Show file tree
Hide file tree
Showing 19 changed files with 180 additions and 60 deletions.
12 changes: 7 additions & 5 deletions dune/iga/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

# install headers install( FILES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga)

add_subdirectory(test)
# add_subdirectory(geometry)
add_subdirectory(oldStuff/io)
add_subdirectory(oldStuff/trim)
add_subdirectory(oldStuff/utils)
add_subdirectory(geometrykernel)
add_subdirectory(hierarchicpatch)
add_subdirectory(io)
add_subdirectory(splines)
add_subdirectory(trimmer)
add_subdirectory(utils)

add_subdirectory(test)
21 changes: 21 additions & 0 deletions dune/iga/geometrykernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

# install headers
set(HEADERS
algorithms.hh
basealgorithms.hh
closestpointprojection.hh
controlpoint.hh
findintersection.hh
geohelper.hh
makesurfaceofrevolution.hh
nurbspatchgeometry.hh
nurbspatchgeometrylocalview.hh
nurbspatchtransform.hh
slicecurve.hh
)

install(FILES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/geometrykernel
)
3 changes: 3 additions & 0 deletions dune/iga/geometrykernel/findintersection.hh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// SPDX-FileCopyrightText: 2023 The Ikarus Developers [email protected]
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once

#define DUNE_FMatrix_WITH_CHECKING

#include "dune/common/float_cmp.hh"
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>

Expand Down
15 changes: 2 additions & 13 deletions dune/iga/hierarchicpatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
# SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception

set(HEADERS
patchgridentity.hh
../trimmer/defaulttrimmer/patchgridentityseed.hh
../trimmer/defaulttrimmer/patchgridhierarchiciterator.hh
patchgridgeometry.hh
../trimmer/identitytrimmer/patchgridlocalgeometry.hh
../trimmer/defaulttrimmer/patchgridintersectioniterator.hh
patchgridintersections.hh
patchgridindexsets.hh
patchgridleafiterator.hh
../trimmer/identitytrimmer/patchgridleveliterator.hh
patchgridview.hh
../io/ibrareader.hh
set(HEADERS patchgridentity.hh patchgridgeometry.hh patchgridintersections.hh patchgridindexsets.hh
patchgridleafiterator.hh patchgridview.hh
)

install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/hierarchicpatch)
15 changes: 15 additions & 0 deletions dune/iga/io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

# install headers

set(HEADERS
griddrawer.hh
ibrageometry.hh
ibrajsonreader.hh
ibrareader.hh
)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/io
)
Empty file added dune/iga/io/griddrawer.hh
Empty file.
14 changes: 14 additions & 0 deletions dune/iga/splines/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

# install headers

set(HEADERS
bsplinealgorithms.hh
nurbsalgorithms.hh
nurbspatchdata.hh
)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/splines
)
36 changes: 21 additions & 15 deletions dune/iga/test/testibrareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@ auto testIbraReader() {
auto gridFactory = GridFactory();
gridFactory.insertTrimParameters(GridFactory::TrimParameterType{100});

const std::vector testCases{std::tuple<std::string, int, int>
{"auxiliaryfiles/element_trim_xb.ibra", 0, 3},
{"auxiliaryfiles/element_trim.ibra", 0, 3},
{"auxiliaryfiles/trim_2edges.ibra", 0, 3},
{"auxiliaryfiles/trim_multi.ibra", 0, 3},
{"auxiliaryfiles/surface-hole.ibra", 1, 3},
{"auxiliaryfiles/surface-hole-skew.ibra", 1, 3},
{"auxiliaryfiles/surface-hole-square.ibra", 1, 3}};
const std::vector testCases{
std::tuple<std::string, int, int>{ "auxiliaryfiles/element_trim_xb.ibra", 0, 3},
{ "auxiliaryfiles/element_trim.ibra", 0, 3},
{ "auxiliaryfiles/trim_2edges.ibra", 0, 3},
{ "auxiliaryfiles/trim_multi.ibra", 0, 3},
{ "auxiliaryfiles/surface-hole.ibra", 1, 3},
{ "auxiliaryfiles/surface-hole-skew.ibra", 1, 3},
{"auxiliaryfiles/surface-hole-square.ibra", 1, 3}
};

for (auto& [name, min, max] : testCases) {
for (int i = min; i <= max; i++) {
gridFactory.insertJson(name, true, {i, i});
gridFactory.createGrid();
}
for (int i = min; i <= max; i++)
for (int j = min; j <= max; j++) {
std::cout << "Testing now " << name << " (Refinement " << i << ", " << j << ")" << std::endl;
gridFactory.insertJson(name, true, {i, j});
try {
gridFactory.createGrid();
} catch (Dune::GridError& e) {
std::cout << "Failed" << std::endl;
}
}
}

return t;
Expand All @@ -62,8 +69,7 @@ auto testIbraReader3d() {
for (auto& [name, min, max] : testCases) {
for (int i = min; i <= max; i++) {
gridFactory.insertJson(name, true, {i, i});
// t.checkNoThrow([&]{auto grid = gridFactory.createGrid();});
auto grid = gridFactory.createGrid();
gridFactory.createGrid();
}
}

Expand All @@ -78,7 +84,7 @@ int main(int argc, char** argv) try {
Dune::TestSuite t("", Dune::TestSuite::ThrowPolicy::ThrowOnRequired);

t.subTest(testIbraReader());
// t.subTest(testIbraReader3d());
t.subTest(testIbraReader3d());

// auto success = t.report();

Expand Down
22 changes: 15 additions & 7 deletions dune/iga/test/trimtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ auto elementTrimDataObstacleCourse(const GridElement& ele, const Grid::Trimmer::
int nonHostEdges = totalEdges - hostEdgesCounter;
int nonHostVertices = totalVertices - hostVertexCounter;
t.check(nonHostEdges + 1 == nonHostVertices)
<< "Each non-host edge produces two non-host vertices." << "There are nonHostEdges " << nonHostEdges
<< " and nonHostVertices " << nonHostVertices;
<< "Each non-host edge produces two non-host vertices."
<< "There are nonHostEdges " << nonHostEdges << " and nonHostVertices " << nonHostVertices;

// windingNumber /= 2*std::numbers::pi_v<double>;
// t.check(Dune::FloatCmp::eq(windingNumber,1.0,1e-10) or Dune::FloatCmp::eq(windingNumber,1.0,1e-10))<<"The winding
Expand Down Expand Up @@ -362,16 +362,24 @@ auto checkTrim(std::string filename, const ExpectedValues& expectedValues, Execu

auto range = Dune::range(4);
for (auto refx : range) {
std::vector<int> yR(
range.begin(),
range.end()); // copy into vector sicne for_each does not work with iota_view and parallel execution
// copy into vector sicne for_each does not work with iota_view and parallel execution
std::vector<int> yR(range.begin(), range.end());

std::for_each(policy, yR.begin(), yR.end(), [&](auto refy) {
std::cout << "Thread: " << std::this_thread::get_id() << std::endl;
auto gridFactory = GridFactory();
auto brep = readJson<2>(filename);
std::cout << "Refinement level: (" << refx << ", " << refy << ")" << std::endl;
std::cout << "Grid: " << filename << " Refinement level: (" << refx << ", " << refy << ")" << std::endl;
gridFactory.insertJson(filename, true, {refx, refy});
auto igaGrid = gridFactory.createGrid();

std::unique_ptr<Grid> igaGrid{};
try {
igaGrid = gridFactory.createGrid();
} catch (Dune::GridError& e) {
t.load(std::memory_order_relaxed)->check(false) << "Grid Creation failed ...\n";
return;
}

auto patchTrimData = igaGrid->trimmer().patchTrimData();
const auto tensorCoordinates = GeometryKernel::NURBSPatch{gridFactory.patchData_}.uniqueKnotVector();
Dune::YaspGrid gridH{tensorCoordinates};
Expand Down
16 changes: 16 additions & 0 deletions dune/iga/trimmer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

add_subdirectory(defaulttrimmer)
add_subdirectory(identitytrimmer)


# install headers
set(HEADERS
concepts.hh
)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/trimmer
)

12 changes: 12 additions & 0 deletions dune/iga/trimmer/defaulttrimmer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

# install headers

set(HEADERS
createlevel.hh
)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/trimmer/defaulttrimmer
)
1 change: 1 addition & 0 deletions dune/iga/trimmer/defaulttrimmer/createlevel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "dune/iga/trimmer/defaulttrimmer/trimmer.hh"
#include <dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh>
namespace Dune::IGANEW::DefaultTrim {
// template <int dim, int dimworld, typename ScalarType>
Expand Down
12 changes: 6 additions & 6 deletions dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ struct ElementTrimDataImpl
}
bool checkInside(const Dune::FieldVector<double, 2>& local) const {
Clipper2Lib::PointD p(local[0], local[1]);
const auto result = Clipper2Lib::PointInPolygon<double>(p, path);
const auto result = Clipper2Lib::PointInPolygon<double>(p, path_);
return result == Clipper2Lib::PointInPolygonResult::IsInside or result == Clipper2Lib::PointInPolygonResult::IsOn;
}

double volume() const { return Clipper2Lib::Area(path); }
double volume() const { return Clipper2Lib::Area(path_); }

// Getter
[[nodiscard]] ElementTrimFlag flag() const { return flag_; }
Expand Down Expand Up @@ -204,7 +204,7 @@ private:
for (const auto v : Utilities::linspace(edge.geometry->domain()[0], 100)) {
auto fV = edge.geometry->global({v}) - lowerLeftCorner;
scaling.mv(fV, fV);
path.emplace_back(fV[0], fV[1]);
path_.emplace_back(fV[0], fV[1]);
}
} else {
auto cornerIdx = edgeLookUp[edge.idx];
Expand All @@ -214,16 +214,16 @@ private:
scaling.mv(firstVertex, firstVertex);
scaling.mv(secondVertex, secondVertex);

path.emplace_back(firstVertex[0], firstVertex[1]);
path.emplace_back(secondVertex[0], secondVertex[1]);
path_.emplace_back(firstVertex[0], firstVertex[1]);
path_.emplace_back(secondVertex[0], secondVertex[1]);
}
}
}
ElementTrimFlag flag_;
HostEntity hostEntity_;
std::vector<VertexInfo> vertices_{};
std::vector<EdgeInfo> edges_;
Clipper2Lib::PathD path;
Clipper2Lib::PathD path_;

int newVertexCounter_ = 4;
int newEdgeCounter_ = 4;
Expand Down
2 changes: 1 addition & 1 deletion dune/iga/trimmer/defaulttrimmer/trimmer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#include "trimmedentity.hh"
#include "trimmedlocalgeometry.hh"

#include "dune/iga/hierarchicpatch/patchgridfwd.hh"
#include <dune/geometry/referenceelements.hh>
#include <dune/grid/concepts.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/iga/hierarchicpatch/patchgridfwd.hh>
#include <dune/iga/hierarchicpatch/patchgridgeometry.hh>
#include <dune/iga/hierarchicpatch/patchgridview.hh>
#include <dune/iga/trimmer/identitytrimmer/patchgridlocalgeometry.hh>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ auto clipElementRectangle(const auto& element,
auto secondTrimmingCurveIndices = patchTrimData.getIndices(secondTrimmingCurvePoint.z);

auto intersectionIndices = patchTrimData.getIndices(intersectionPoint.z);
std::cout << "First Curve: " << firstTrimmingCurvePoint.z << " " << firstTrimmingCurveIndices << std::endl;
std::cout << "Second Curve: " << secondTrimmingCurvePoint.z << " " << secondTrimmingCurveIndices << std::endl;
std::cout << "Intersection: " << intersectionPoint.z << " " << intersectionIndices << std::endl;
// std::cout << "First Curve: " << firstTrimmingCurvePoint.z << " " << firstTrimmingCurveIndices << std::endl;
// std::cout << "Second Curve: " << secondTrimmingCurvePoint.z << " " << secondTrimmingCurveIndices << std::endl;
// std::cout << "Intersection: " << intersectionPoint.z << " " << intersectionIndices << std::endl;

assert(firstTrimmingCurveIndices.loop == secondTrimmingCurveIndices.loop &&
"The points of the trimming curves should be on the same loop");
Expand Down Expand Up @@ -151,7 +151,7 @@ auto clipElementRectangle(const auto& element,
result.finish(patchTrimData);

// While developing
result.report();
// result.report();

return std::make_tuple(ElementTrimFlag::trimmed, result);
}
Expand Down
8 changes: 8 additions & 0 deletions dune/iga/trimmer/defaulttrimmer/trimmingutils/cliputils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once

#include <array>
#include <clipper2/clipper.core.h>
#include <ranges>
#include <variant>

#include <dune/common/float_cmp.hh>
#include <dune/grid/common/exceptions.hh>

namespace Dune::IGANEW::DefaultTrim::Util {

inline int giveEdgeIdx(const std::size_t e1, const std::size_t e2) {
Expand Down
18 changes: 9 additions & 9 deletions dune/iga/trimmer/defaulttrimmer/trimmingutils/trimutils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once

#include <clipper2/clipper.core.h>
#include <ranges>

#include "dune/iga/geometrykernel/findintersection.hh"
#include "dune/iga/geometrykernel/nurbspatchgeometry.hh"
#include "dune/iga/trimmer/defaulttrimmer/trimmingutils/cliputils.hh"
#include <dune/common/float_cmp.hh>
#include <dune/iga/geometrykernel/geohelper.hh>

namespace Dune::IGANEW::DefaultTrim::Util {
template <typename ScalarType, int dim>
auto approxSamePoint(const Clipper2Lib::PointD& pt1, const FieldVector<ScalarType, dim>& pt2,
Expand Down Expand Up @@ -63,13 +72,4 @@ auto callFindIntersection(const auto& curvePatchGeo, int edgeIdx, const auto& ip
DUNE_THROW(Dune::GridError, "Couldn't find intersection Point");
};

// inline auto isNewVertex = [](const auto& vV) { return std::holds_alternative<ClippingResult::NewVertex>(vV); };
// inline auto isHostVertex = [](const auto& vV) { return std::holds_alternative<ClippingResult::HostVertex>(vV); };
// inline auto isInsideVertex = [](const auto& vV) { return std::holds_alternative<ClippingResult::InsideVertex>(vV);
// }; inline auto getPt = [](auto&& vV) { return vV.pt; }; inline auto getHostIdx = [](const auto& vV) { return
// std::get<ClippingResult::HostVertex>(vV).hostIdx; }; inline auto getEdgeIdx = [](const auto& vV) { return
// std::get<ClippingResult::NewVertex>(vV).onEdgeIdx; }; inline auto getCurveI = [](const auto& vV) {return
// std::get<ClippingResult::InsideVertex>(vV).curveIdxI; }; inline auto getCurveJ = [](const auto& vV) {return
// std::get<ClippingResult::InsideVertex>(vV).curveIdxJ; }; inline auto getLoopIdx = [](const auto& vV) {return
// std::get<ClippingResult::InsideVertex>(vV).loopIdx; };
} // namespace Dune::IGANEW::DefaultTrim::Util
12 changes: 12 additions & 0 deletions dune/iga/trimmer/identitytrimmer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

# install headers

set(HEADERS
trimmer.hh
)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/trimmer/identitytrimmer
)
13 changes: 13 additions & 0 deletions dune/iga/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2023 The dune-iga developers [email protected]
# SPDX-License-Identifier: LGPL-3.0-or-later

# install headers

set(HEADERS
mdnet.hh
typetraits.hh
)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/iga/utils
)

0 comments on commit bf1edf9

Please sign in to comment.