diff --git a/kratos/geometries/brep_surface.h b/kratos/geometries/brep_surface.h index 17e40f7b509..ede13791653 100644 --- a/kratos/geometries/brep_surface.h +++ b/kratos/geometries/brep_surface.h @@ -58,6 +58,7 @@ class BrepSurface typedef Geometry BaseType; typedef Geometry GeometryType; typedef typename GeometryType::Pointer GeometryPointer; + using GeometrySurrogateArrayType = DenseVector; typedef GeometryData::IntegrationMethod IntegrationMethod; @@ -163,6 +164,8 @@ class BrepSurface mInnerLoopArray = rOther.mInnerLoopArray; mEmbeddedEdgesArray = rOther.mEmbeddedEdgesArray; mIsTrimmed = rOther.mIsTrimmed; + mpSurrogateInnerLoopGeometries = rOther.mpSurrogateInnerLoopGeometries; + mpSurrogateOuterLoopGeometries = rOther.mpSurrogateOuterLoopGeometries; return *this; } @@ -176,6 +179,8 @@ class BrepSurface mInnerLoopArray = rOther.mInnerLoopArray; mEmbeddedEdgesArray = rOther.mEmbeddedEdgesArray; mIsTrimmed = rOther.mIsTrimmed; + mpSurrogateInnerLoopGeometries = rOther.mpSurrogateInnerLoopGeometries; + mpSurrogateOuterLoopGeometries = rOther.mpSurrogateOuterLoopGeometries; return *this; } @@ -550,6 +555,42 @@ class BrepSurface return GeometryData::KratosGeometryType::Kratos_Brep_Surface; } + /** + * @brief Set the Surrogate Outer Loop Geometries object + * @param pSurrogateOuterLoopArray + */ + void SetSurrogateOuterLoopGeometries(GeometrySurrogateArrayType &rSurrogateOuterLoopArray) + { + mpSurrogateOuterLoopGeometries = &rSurrogateOuterLoopArray; + } + + /** + * @brief Set the Surrogate Inner Loop Geometries object + * @param pSurrogateInnerLoopArray + */ + void SetSurrogateInnerLoopGeometries(GeometrySurrogateArrayType &rSurrogateInnerLoopArray) + { + mpSurrogateInnerLoopGeometries = &rSurrogateInnerLoopArray; + } + + /** + * @brief Get the Surrogate Inner Loop Geometries object + * @return GeometrySurrogateArrayType + */ + GeometrySurrogateArrayType& GetSurrogateInnerLoopGeometries() + { + return *mpSurrogateInnerLoopGeometries; + } + + /** + * @brief Get the Surrogate Outer Loop Geometries object + * @return GeometrySurrogateArrayType + */ + GeometrySurrogateArrayType& GetSurrogateOuterLoopGeometries() + { + return *mpSurrogateOuterLoopGeometries; + } + ///@} ///@name Information ///@{ @@ -595,6 +636,10 @@ class BrepSurface BrepCurveOnSurfaceArrayType mEmbeddedEdgesArray; + GeometrySurrogateArrayType* mpSurrogateInnerLoopGeometries; + GeometrySurrogateArrayType* mpSurrogateOuterLoopGeometries; + + /** IsTrimmed is used to optimize processes as * e.g. creation of integration domain. */ @@ -614,6 +659,8 @@ class BrepSurface rSerializer.save("InnerLoopArray", mInnerLoopArray); rSerializer.save("EmbeddedEdgesArray", mEmbeddedEdgesArray); rSerializer.save("IsTrimmed", mIsTrimmed); + rSerializer.save("SurrogateInnerLoopGeometries", mpSurrogateInnerLoopGeometries); + rSerializer.save("SurrogateOuterLoopGeometries", mpSurrogateOuterLoopGeometries); } void load( Serializer& rSerializer ) override @@ -624,6 +671,8 @@ class BrepSurface rSerializer.load("InnerLoopArray", mInnerLoopArray); rSerializer.load("EmbeddedEdgesArray", mEmbeddedEdgesArray); rSerializer.load("IsTrimmed", mIsTrimmed); + rSerializer.save("SurrogateInnerLoopGeometries", mpSurrogateInnerLoopGeometries); + rSerializer.save("SurrogateOuterLoopGeometries", mpSurrogateOuterLoopGeometries); } BrepSurface() diff --git a/kratos/tests/cpp_tests/geometries/test_brep_surface.cpp b/kratos/tests/cpp_tests/geometries/test_brep_surface.cpp index 4eb56d9ff59..5ddd316f168 100644 --- a/kratos/tests/cpp_tests/geometries/test_brep_surface.cpp +++ b/kratos/tests/cpp_tests/geometries/test_brep_surface.cpp @@ -195,5 +195,62 @@ namespace Testing { //auto results = p_brep_curve_on_surface.GlobalDerivatives(coords, 3); //KRATOS_WATCH(results[0]) } + + KRATOS_TEST_CASE_IN_SUITE(NurbsBrepSurfaceSurrogate, KratosCoreGeometriesFastSuite) + { + auto p_surface = GenerateReferenceNodeSurfaceHalfCirclePointer(); + + using BrepSurfaceType = BrepSurface, true, PointerVector>; + using BrepCurveOnSurfaceLoopArrayType = typename BrepSurfaceType::BrepCurveOnSurfaceLoopArrayType; + + using GeometrySurrogateArrayType = typename BrepSurfaceType::GeometrySurrogateArrayType; + + + BrepCurveOnSurfaceLoopArrayType outer_loops, inner_loops; + + Model model; + ModelPart& rSurrogateModelPartOuter = model.CreateModelPart("surrogate_model_part_outer"); + rSurrogateModelPartOuter.CreateNewProperties(0); + rSurrogateModelPartOuter.CreateNewNode(1, 0.0, 0.0, 0.0); + rSurrogateModelPartOuter.CreateNewNode(2, 2.0, 0.0, 0.0); + rSurrogateModelPartOuter.CreateNewNode(3, 2.0, 2.0, 0.0); + rSurrogateModelPartOuter.CreateNewNode(4, 0.0, 2.0, 0.0); + + Properties::Pointer p_prop = rSurrogateModelPartOuter.pGetProperties(0); + rSurrogateModelPartOuter.CreateNewCondition("LineCondition2D2N", 1, {{1, 2}}, p_prop); + rSurrogateModelPartOuter.CreateNewCondition("LineCondition2D2N", 2, {{2, 3}}, p_prop); + rSurrogateModelPartOuter.CreateNewCondition("LineCondition2D2N", 3, {{3, 4}}, p_prop); + rSurrogateModelPartOuter.CreateNewCondition("LineCondition2D2N", 4, {{4, 1}}, p_prop); + + GeometrySurrogateArrayType surrogate_outer_loop_geometries(rSurrogateModelPartOuter.NumberOfConditions()); + GeometrySurrogateArrayType surrogate_inner_loop_geometries(rSurrogateModelPartOuter.NumberOfConditions()); + + int count = 0; + for (auto i_cond : rSurrogateModelPartOuter.Conditions()) + { + surrogate_outer_loop_geometries[count] = i_cond.pGetGeometry(); + count++; + } + + count = 0; + for (auto i_cond : rSurrogateModelPartOuter.Conditions()) + { + surrogate_inner_loop_geometries[count] = i_cond.pGetGeometry(); + count++; + } + + auto p_brep_surface = + Kratos::make_shared( + p_surface, + outer_loops, + inner_loops); + + p_brep_surface->SetSurrogateInnerLoopGeometries(surrogate_inner_loop_geometries); + p_brep_surface->SetSurrogateOuterLoopGeometries(surrogate_outer_loop_geometries); + + KRATOS_EXPECT_EQ(p_brep_surface->GetSurrogateInnerLoopGeometries().size(), 4); + KRATOS_EXPECT_EQ(p_brep_surface->GetSurrogateOuterLoopGeometries().size(), 4); + + } } // namespace Testing. } // namespace Kratos.