Skip to content

Commit

Permalink
add additional hull tests in c++ and python
Browse files Browse the repository at this point in the history
  • Loading branch information
MarAlder committed Mar 19, 2024
1 parent e0c4709 commit 0eca07e
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 45 deletions.
27 changes: 21 additions & 6 deletions bindings/python_internal/configuration.i
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@
#include "CCPACSDuctAssembly.h"
#include "CCPACSDuct.h"
#include "generated/CPACSFuselageFuelTanks.h"
#include "generated/CPACSGenericFuelTanks.h"
#include "CCPACSGenericFuelTanks.h"
#include "CCPACSGenericFuelTank.h"
#include "CCPACSHulls.h"
#include "CCPACSHull.h"


%}

%feature("autodoc", "3");
Expand Down Expand Up @@ -328,14 +333,22 @@ namespace tigl
%include "CPACSRotorHubHinge_type.h"

// --------------- Fuselage tanks -----------------//
// ToDo: Check which classes need to be assigned to boost_optional
%boost_optional(tigl::generated::CPACSGenericFuelTanks)
%boost_optional(tigl::CCPACSGenericFuelTanks)
%boost_optional(tigl::generated::CPACSFuselageFuelTanks)

%include "generated/CPACSGenericFuelTanks.h"
namespace tigl {
class CCPACSFuselageSegments;

This comment has been minimized.

Copy link
@MarAlder

MarAlder Mar 20, 2024

Author Owner

relates to DLR-SC#986 | maybe needs to be relocated.

}
%include "CTiglFuselageConnection.h"
%include "CCPACSFuselageSegment.h"
%include "CCPACSFuselageSegments.h"
%include "CCPACSGenericFuelTanks.h"
%include "CCPACSGenericFuelTank.h"
%include "CCPACSHulls.h"
%include "CCPACSHull.h"
%include "generated/CPACSFuselageFuelTanks.h"

// -------------------- Wing Structure -------------------//
// -------------------- Wing Structure -------------------//

namespace tigl {
class CCPACSWingCSStructure;
Expand Down Expand Up @@ -545,7 +558,9 @@ class CCPACSWingRibsPositioning;
tigl::CCPACSEnginePylon,
tigl::CCPACSTrailingEdgeDevice,
tigl::CCPACSDuct,
tigl::CCPACSDuctAssembly
tigl::CCPACSDuctAssembly,
tigl::CCPACSGenericFuelTank,
tigl::CCPACSHull
);

namespace tigl
Expand Down
67 changes: 67 additions & 0 deletions src/fuelTanks/CCPACSHull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#include "CCPACSGenericFuelTank.h"
#include "CCPACSGenericFuelTanks.h"

#include "GProp_GProps.hxx"
#include "BRepGProp.hxx"
#include "TopTools_IndexedMapOfShape.hxx"
#include "TopExp.hxx"


namespace tigl {

Expand Down Expand Up @@ -58,6 +63,68 @@ TiglGeometricComponentIntent CCPACSHull::GetComponentIntent() const
return TIGL_INTENT_PHYSICAL;
}

int CCPACSHull::GetSectionCount() const
{
return m_sections.GetSectionCount();
}

int CCPACSHull::GetSegmentCount() const
{
return m_segments.GetSegmentCount();
}

CCPACSFuselageSegment& CCPACSHull::GetSegment(const int index)
{
return m_segments.GetSegment(index);
}

const CCPACSFuselageSegment& CCPACSHull::GetSegment(const int index) const
{
return m_segments.GetSegment(index);
}

CCPACSFuselageSegment& CCPACSHull::GetSegment(std::string uid)
{
return m_segments.GetSegment(uid);
}

double CCPACSHull::GetVolume()
{
const TopoDS_Shape fusedSegments = GetLoft()->Shape();

GProp_GProps hull;
BRepGProp::VolumeProperties(fusedSegments, hull);
double myVolume = hull.Mass();
return myVolume;
}

double CCPACSHull::GetSurfaceArea()
{
const PNamedShape& fusedSegments = GetLoft();

// loop over all faces that are not symmetry, front or rear
double myArea = 0.;

TopTools_IndexedMapOfShape shapeMap;
TopExp::MapShapes(fusedSegments->Shape(), TopAbs_FACE, shapeMap);
for (int i = 1; i <= shapeMap.Extent(); ++i) {
if (GetUID() == fusedSegments->GetFaceTraits(i-1).Name()) {
const TopoDS_Face& f = TopoDS::Face(shapeMap(i));
GProp_GProps System;
BRepGProp::SurfaceProperties(f, System);
myArea += System.Mass();
}
}

// Calculate surface area
return myArea;
}

double CCPACSHull::GetCircumference(const int segmentIndex, const double eta)
{
return static_cast<CCPACSFuselageSegment&>(GetSegment(segmentIndex)).GetCircumference(eta);
}

PNamedShape CCPACSHull::BuildLoft() const
{
TiglContinuity cont = m_segments.GetSegment(1).GetContinuity();
Expand Down
15 changes: 15 additions & 0 deletions src/fuelTanks/CCPACSHull.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ class CCPACSHull : public generated::CPACSHull, public CTiglRelativelyPositioned
TIGL_EXPORT TiglGeometricComponentType GetComponentType() const override;
TIGL_EXPORT TiglGeometricComponentIntent GetComponentIntent() const override;

TIGL_EXPORT int GetSectionCount() const;

TIGL_EXPORT int GetSegmentCount() const;

TIGL_EXPORT CCPACSFuselageSegment& GetSegment(const int index);
TIGL_EXPORT const CCPACSFuselageSegment& GetSegment(const int index) const;
TIGL_EXPORT CCPACSFuselageSegment& GetSegment(std::string uid);

TIGL_EXPORT double GetVolume();

TIGL_EXPORT double GetSurfaceArea();

TIGL_EXPORT double GetCircumference(int segmentIndex, double eta);


protected:
PNamedShape BuildLoft() const override;

Expand Down
22 changes: 0 additions & 22 deletions tests/unittests/fuelTanks-tests.py

This file was deleted.

38 changes: 21 additions & 17 deletions tests/unittests/test_fuelTanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,35 @@
from tixi3.tixi3wrapper import *
from tigl3 import configuration


class FuselageTank(unittest.TestCase):

def setUp(self):
self.tixi = Tixi3()
self.tigl = Tigl3()
self.assertIsNone(self.tixi.open('TestData/simpletest.cpacs.xml'))
self.assertIsNone(self.tigl.open(self.tixi, ''))
self.assertIsNone(self.tixi.open("TestData/simpletest-fuelTanks.cpacs.xml"))
self.assertIsNone(self.tigl.open(self.tixi, ""))

mgr = configuration.CCPACSConfigurationManager_get_instance()
uid_mgr = mgr.get_configuration(self.tigl._handle.value).get_uidmanager()
fuselage = uid_mgr.get_geometric_component('SimpleFuselage')
fuelTanks = fuselage.get_fuel_tanks()
# help(fuselage)
print(fuelTanks)



self.fuelTank = uid_mgr.get_geometric_component("genericTank1")
self.hull = uid_mgr.get_geometric_component("outerHull")

def tearDown(self):
self.tigl.close()
self.tixi.close()

def test_tiglGetVersion(self):
print('TIGL-Version: ' + self.tigl.version)

def test_true(self):
self.assertTrue(True)

if __name__ == '__main__':
unittest.main()
def test_fuelTank(self):
print("Intend: " + self.tigl.version)

def test_hull(self):
self.assertEqual(self.hull.get_section_count(), 3)
self.assertEqual(self.hull.get_segment_count(), 2)
self.assertEqual(self.hull.get_volume(), 0.41085764204179498)
self.assertEqual(self.hull.get_surface_area(), 2.7879599486116566)
self.assertEqual(self.hull.get_circumference(1, 0.5), 1.8586415856382374)


if __name__ == "__main__":
unittest.main()
10 changes: 10 additions & 0 deletions tests/unittests/tiglTanks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class FuselageTank : public ::testing::Test

// hulls
const std::vector<std::unique_ptr<tigl::CCPACSHull>> &hulls = fuelTank->GetHulls_choice1()->GetHulls();
tigl::CCPACSHull *hull = &uidMgr.ResolveObject<tigl::CCPACSHull>("outerHull");
};

TixiDocumentHandle FuselageTank::tixiHandle = 0;
Expand All @@ -105,4 +106,13 @@ TEST_F(FuselageTank, testLoft)
{
const std::unique_ptr<tigl::CCPACSHull> &hull = hulls.at(0);
const PNamedShape &loft = hull->GetLoft();
}

TEST_F(FuselageTank, hull)
{
EXPECT_EQ(hull->GetSectionCount(), 3);
EXPECT_EQ(hull->GetSegmentCount(), 2);
EXPECT_EQ(hull->GetVolume(),0.41085764204179498);
EXPECT_EQ(hull->GetSurfaceArea(), 2.7879599486116566);
EXPECT_EQ(hull->GetCircumference(1, 0.5), 1.8586415856382374);
}

0 comments on commit 0eca07e

Please sign in to comment.