Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce tolerance when creating cells via contourCoordinate in chordwise direction #1034

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
=========

Changes since last release
-------------
13/11/2024

- Fixes:
- In #1026, the tolerance for creating cells via contourCoordinate was reduced for cells in spanwise direction. That fixed a bug that caused cells to overlap potentially. The same reduction was missed in chordwise direction and is added now to avoid the cell overlap in chordwise direction, as well. (#1034)


Version 3.4.0
-------------
12/11/2024
Expand Down
4 changes: 2 additions & 2 deletions src/wing/CCPACSWingCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ void CCPACSWingCell::BuildSkinGeometry(GeometryCache& cache) const
*/
TrimSpanwise(cache, SpanWiseBorder::Inner, m_positioningInnerBorder, 1e-4);
TrimSpanwise(cache, SpanWiseBorder::Outer, m_positioningOuterBorder, 1e-4);
TrimChordwise(cache, ChordWiseBorder::LE, m_positioningLeadingEdge, 1e-2);
TrimChordwise(cache, ChordWiseBorder::TE, m_positioningTrailingEdge, 1e-2);
TrimChordwise(cache, ChordWiseBorder::LE, m_positioningLeadingEdge, 1e-4);
TrimChordwise(cache, ChordWiseBorder::TE, m_positioningTrailingEdge, 1e-4);

TopoDS_Builder builder;
TopoDS_Compound resultShape;
Expand Down
64 changes: 63 additions & 1 deletion tests/unittests/tiglWingCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST(WingCell, IsConvex)
ASSERT_TRUE(cell.IsConvex());
}

TEST(WingCell, IssueCellsNoOverlap)
TEST(WingCell, IssueCellsNoOverlapSpanwise)
{
std::string fileName = "TestData/IEA-22-280-RWT_DLR_loads_CPACS.xml";
std::string configName = "aircraft";
Expand Down Expand Up @@ -169,3 +169,65 @@ TEST(WingCell, IssueCellsNoOverlap)
ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3);
ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3);
}

TEST(WingCell, IssueCellsNoOverlapChordwise)
{
std::string fileName = "TestData/IEA-22-280-RWT_DLR_loads_CPACS.xml";
std::string configName = "aircraft";
std::string cell1Name = "span03_circ01";
std::string cell2Name = "span03_circ02";

ReturnCode tixiRet;
TiglReturnCode tiglRet;
Standard_Real first1, last1, first2, last2;
gp_Pnt pntCurve1, pntCurve2;

TiglCPACSConfigurationHandle tiglHandle = -1;
TixiDocumentHandle tixiHandle = -1;

tixiRet = tixiOpenDocument(fileName.c_str(), &tixiHandle);
ASSERT_TRUE(tixiRet == SUCCESS);

tiglRet = tiglOpenCPACSConfiguration(tixiHandle, configName.c_str(), &tiglHandle);
ASSERT_TRUE(tiglRet == TIGL_SUCCESS);

auto& uid_mgr = tigl::CCPACSConfigurationManager::GetInstance().GetConfiguration(tiglHandle).GetUIDManager();

auto& cell1 = uid_mgr.ResolveObject<tigl::CCPACSWingCell>(cell1Name.c_str());
TopoDS_Shape cellLoft1 = cell1.GetLoft()->Shape();

auto& cell2 = uid_mgr.ResolveObject<tigl::CCPACSWingCell>(cell2Name.c_str());
TopoDS_Shape cellLoft2 = cell2.GetLoft()->Shape();

// Take the first cell's edge adjacent to cell 2 and the second cell's edge adjacent to cell 1 (-> Should be shared edge)
// If these edges are identical, the cut of the cells is exactely defined by this edge
// Hence, the cells have no overlap
// In the following, the edges are compared by comparing three points at parameters 0, 0.5 and 1
// If the resulting points are pairwise the same (up to tolerance), the edges are the same and the cells do not overlap
TopTools_IndexedMapOfShape edges1, edges2;
TopExp::MapShapes (cellLoft1, TopAbs_EDGE, edges1);
TopExp::MapShapes (cellLoft2, TopAbs_EDGE, edges2);

TopoDS_Edge edge1 = TopoDS::Edge(edges1(1));
TopoDS_Edge edge2 = TopoDS::Edge(edges2(3));
Handle(Geom_BSplineCurve) curve1 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(edge1, first1, last1));
Handle(Geom_BSplineCurve) curve2 = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(edge2, first2, last2));

curve1->D0(0., pntCurve1);
curve2->D0(0., pntCurve2);
ASSERT_NEAR(pntCurve1.X(), pntCurve2.X(), 1e-3);
ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3);
ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3);

curve1->D0(0.5, pntCurve1);
curve2->D0(0.5, pntCurve2);
ASSERT_NEAR(pntCurve1.X(), pntCurve2.X(), 1e-3);
ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3);
ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3);

curve1->D0(1., pntCurve1);
curve2->D0(1., pntCurve2);
ASSERT_NEAR(pntCurve1.X(), pntCurve2.X(), 1e-3);
ASSERT_NEAR(pntCurve1.Y(), pntCurve2.Y(), 1e-3);
ASSERT_NEAR(pntCurve1.Z(), pntCurve2.Z(), 1e-3);
}
Loading