From 4a87e2d0b4ec2e6a13adf7370119cde407bbe8d9 Mon Sep 17 00:00:00 2001 From: Mattijs Janssens Date: Wed, 26 May 2021 12:22:24 +0000 Subject: [PATCH] INT: splineEdge: allowing usage in extrudeMesh. See #1983. --- CONTRIBUTORS.md | 2 +- .../blockEdges/splineEdge/CatmullRomSpline.C | 96 ++++++++++++++++--- .../blockEdges/splineEdge/CatmullRomSpline.H | 12 ++- tutorials/mesh/extrudeMesh/polyline/Allrun | 12 ++- .../polyline/system/extrudeMeshDict | 20 +++- 5 files changed, 125 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 30d191014a..c3ca4001ef 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -50,7 +50,7 @@ It is likely incomplete... - Norbert Weber - Henry Weller - Niklas Wikstrom +- Guanyang Xue - Thorsten Zirwes - diff --git a/src/mesh/blockMesh/blockEdges/splineEdge/CatmullRomSpline.C b/src/mesh/blockMesh/blockEdges/splineEdge/CatmullRomSpline.C index bfa0aaf27b..681b6c0316 100644 --- a/src/mesh/blockMesh/blockEdges/splineEdge/CatmullRomSpline.C +++ b/src/mesh/blockMesh/blockEdges/splineEdge/CatmullRomSpline.C @@ -27,6 +27,56 @@ License #include "CatmullRomSpline.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::scalar Foam::CatmullRomSpline::derivative +( + const label segment, + const scalar mu +) const +{ + const point& p0 = points()[segment]; + const point& p1 = points()[segment+1]; + + // determine the end points + point e0; + point e1; + + if (segment == 0) + { + // end: simple reflection + e0 = 2*p0 - p1; + } + else + { + e0 = points()[segment-1]; + } + + if (segment+1 == nSegments()) + { + // end: simple reflection + e1 = 2*p1 - p0; + } + else + { + e1 = points()[segment+2]; + } + const point derivativePoint + ( + 0.5 * + ( + (-e0 + p1) + + mu * + ( + 2 * (2*e0 - 5*p0 + 4*p1 - e1) + + mu * 3 * (-e0 + 3*p0 - 3*p1 + e1) + ) + ) + ); + return mag(derivativePoint); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::CatmullRomSpline::CatmullRomSpline @@ -114,27 +164,51 @@ Foam::point Foam::CatmullRomSpline::position } - return 0.5 * - ( - ( 2*p0 ) - + mu * + return + 0.5 * ( - ( -e0 + p1 ) + (2*p0) + mu * ( - ( 2*e0 - 5*p0 + 4*p1 - e1 ) + (-e0 + p1) + mu * - ( -e0 + 3*p0 - 3*p1 + e1 ) + ( + (2*e0 - 5*p0 + 4*p1 - e1) + + mu*(-e0 + 3*p0 - 3*p1 + e1) + ) ) - ) - ); + ); } Foam::scalar Foam::CatmullRomSpline::length() const { - NotImplemented; - return 1; + const solveScalar xi[5]= + { + -0.9061798459386639927976, + -0.5384693101056830910363, + 0, + 0.5384693101056830910363, + 0.9061798459386639927976 + }; + const solveScalar wi[5]= + { + 0.2369268850561890875143, + 0.4786286704993664680413, + 0.5688888888888888888889, + 0.4786286704993664680413, + 0.2369268850561890875143 + }; + scalar sum=0; + for (label segment=0;segment