Skip to content

Commit

Permalink
detailed comments on sbm cases
Browse files Browse the repository at this point in the history
  • Loading branch information
NickNick9 committed Dec 18, 2024
1 parent 0fdd6c0 commit 5d2cc11
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
7 changes: 7 additions & 0 deletions kratos/geometries/brep_curve_on_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Kratos
* @class BrepCurveOnSurface
* @ingroup KratosCore
* @brief The BrepCurveOnSurface acts as topology for curves on surfaces.
* @tparam TShiftedBoundary Boolean flag indicating whether is defined with shifted boundary conditions.
*/
template<class TContainerPointType, bool TShiftedBoundary, class TContainerPointEmbeddedType = TContainerPointType >
class BrepCurveOnSurface
Expand Down Expand Up @@ -324,6 +325,10 @@ class BrepCurveOnSurface
*/
void SpansLocalSpace(std::vector<double>& rSpans, IndexType DirectionIndex = 0) const override
{
/* When the `TShiftedBoundary` template parameter is true, the spans are computed using
* the shifted boundary method by invoking `SpansLocalSpaceSBM`.
* Otherwise, the spans are computed using the standard method by invoking `SpansLocalSpace`
*/
if constexpr (TShiftedBoundary) {
mpCurveOnSurface->SpansLocalSpaceSBM(rSpans,
mCurveNurbsInterval.GetT0(), mCurveNurbsInterval.GetT1());
Expand Down Expand Up @@ -565,6 +570,8 @@ class BrepCurveOnSurface
const IntegrationPointsArrayType& rIntegrationPoints,
IntegrationInfo& rIntegrationInfo) override
{
// If `TShiftedBoundary` is true, the method `CreateQuadraturePointGeometriesSBM` is called.
// Otherwise, the method `CreateQuadraturePointGeometries` is used for standard processing.
if constexpr (TShiftedBoundary) {
mpCurveOnSurface->CreateQuadraturePointGeometriesSBM(
rResultGeometries, NumberOfShapeFunctionDerivatives, rIntegrationPoints, rIntegrationInfo);
Expand Down
12 changes: 12 additions & 0 deletions kratos/geometries/brep_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace Kratos
* @ingroup KratosCore
* @brief The BrepSurface acts as topology for faces. Those
* can be enclosed by a certain set of brep face curves.
* @tparam TShiftedBoundary Boolean flag indicating whether is
* defined with shifted boundary conditions.
*/
template<class TContainerPointType, bool TShiftedBoundary, class TContainerPointEmbeddedType = TContainerPointType>
class BrepSurface
Expand Down Expand Up @@ -428,6 +430,16 @@ class BrepSurface
///@{

/* Creates integration points on the nurbs surface of this geometry.
* Accounting for whether the surface is trimmed or untrimmed, and whether shifted
* boundary conditions are used
*
* - **Untrimmed Surface**: -> Non-cutting case
* - If `TShiftedBoundary` is true, the method prepares for the shifted boundary method (SBM)
* - Otherwise, it directly uses `CreateIntegrationPoints` from the underlying NURBS surface.
* - **Trimmed Surface**: -> Cutting case
* - It calls `BrepTrimmingUtilities::CreateBrepSurfaceTrimmingIntegrationPoints`
* to generate integration points that conform to the trimming curve.
*
* @param return integration points.
*/
void CreateIntegrationPoints(
Expand Down
35 changes: 28 additions & 7 deletions kratos/geometries/nurbs_curve_on_surface_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,20 @@ class NurbsCurveOnSurfaceGeometry : public Geometry<typename TSurfaceContainerPo
}

/**
* @brief
* SBM case: compute only knot spans intersections
* @brief Computes the knot span intersections for the shifted boundary method (SBM) case.
* This function calculates the intersections between a NURBS curve segment and the knot spans
* of a surface in the local parameter space, specifically for SBM-based geometries. The computed
* intersections are returned in the `rSpans` vector.
*
* * @details
* The function operates as follows:
* - Computes the physical coordinates of the start (`Start`) and end (`End`) points of the curve segment.
* - Determines the segment's orientation (horizontal or vertical) based on the difference in coordinates.
* - For each direction (U or V):
* - Calculates the relevant knot interval.
* - Iterates over the surface spans in the corresponding direction, identifying intersections within the interval.
* - Maps the intersection values back to the curve's parameter space and stores them in `rSpans`.
*
* @param rSpans
* @param Start
* @param End
Expand Down Expand Up @@ -343,7 +355,7 @@ class NurbsCurveOnSurfaceGeometry : public Geometry<typename TSurfaceContainerPo
const double tolerance_orientation = 1e-10;
const double tolerance_intersection = 1e-15;

// Scale factor between volume coordinate and surface one
// Scale factor between surface coordinate and curve one
double physical_length_segment = norm_2(physical_coord_1-physical_coord_2);
double parameter_length_segment = norm_2(local_coord_1-local_coord_2);
double scale_factor = parameter_length_segment/physical_length_segment;
Expand All @@ -359,7 +371,7 @@ class NurbsCurveOnSurfaceGeometry : public Geometry<typename TSurfaceContainerPo

knot_interval[0] -= tolerance_intersection;
knot_interval[1] += tolerance_intersection;
// Compare with volume_spans_u
// Compare with surface_spans_u
for (IndexType i = 0; i < surface_spans_u.size(); i++) {
double curr_knot_value = surface_spans_u[i];
if (curr_knot_value < knot_interval[0]) {continue;}
Expand All @@ -372,14 +384,14 @@ class NurbsCurveOnSurfaceGeometry : public Geometry<typename TSurfaceContainerPo
}

} else if (std::abs(physical_coord_1[1]-physical_coord_2[1]) > tolerance_orientation) {
// vertical case
// vertical case
knot_interval[0] = physical_coord_1[1];
knot_interval[1] = physical_coord_2[1];
std::sort(knot_interval.begin(), knot_interval.end());

knot_interval[0] -= tolerance_intersection;
knot_interval[1] += tolerance_intersection;
// Compare with volume_spans_v
// Compare with surface_spans_v
for (IndexType i = 0; i < surface_spans_v.size(); i++) {
double curr_knot_value = surface_spans_v[i];
if (curr_knot_value < knot_interval[0]) {continue;}
Expand Down Expand Up @@ -649,6 +661,15 @@ class NurbsCurveOnSurfaceGeometry : public Geometry<typename TSurfaceContainerPo
* @brief This method creates a list of quadrature point geometries
* from a list of integration points in the SBM case.
*
* * @details
* 1. Checks whether the BRep is internal (aligned with specific knot spans) or external.
* - Internal boundaries are associated with a fixed span (knot span edge) in the U and V directions.
* - External boundaries are associated with body-fitted cases.
* 2. Iterates over each integration point:
* - Computes global space derivatives for the NURBS curve at the integration point.
* - Gathers nonzero control points and associated shape function values.
* 3. Creates a geometry shape function container and assigns it to the result geometries array.
*
* @param rResultGeometries list of quadrature point geometries.
* @param rIntegrationPoints list of integration points.
* @param NumberOfShapeFunctionDerivatives the number provided
Expand Down Expand Up @@ -753,7 +774,7 @@ class NurbsCurveOnSurfaceGeometry : public Geometry<typename TSurfaceContainerPo
global_space_derivatives[0][1]);
}
else {
// Trimming case or external brep
// SBM case on external brep
shape_function_container.ComputeBSplineShapeFunctionValues(
mpNurbsSurface->KnotsU(), mpNurbsSurface->KnotsV(),
global_space_derivatives[0][0], global_space_derivatives[0][1]);
Expand Down

0 comments on commit 5d2cc11

Please sign in to comment.