Commit 4a87e2d0 authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

INT: splineEdge: allowing usage in extrudeMesh. See #1983.

parent 8be49d86
......@@ -50,7 +50,7 @@ It is likely incomplete...
- Norbert Weber
- Henry Weller
- Niklas Wikstrom
- Guanyang Xue
- Thorsten Zirwes
<!----------------------------------------------------------------------------->
......@@ -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<nSegments();segment++)
{
for (int i=0;i<5;i++)
{
sum+=wi[i]*derivative(segment,(xi[i]+1.0)/2.0)/2.0;
}
}
return sum;
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -80,6 +80,15 @@ class CatmullRomSpline
:
public polyLine
{
//- Derivative of spline
scalar derivative
(
const label segment,
const scalar mu
) const;
public:
// Constructors
......@@ -103,7 +112,6 @@ public:
point position(const label segment, const scalar lambda) const;
//- The length of the curve
// \note NotImplemented
scalar length() const;
};
......
......@@ -3,12 +3,20 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication extrudeMesh
# Extrude using arcs
USE_ARC=true runApplication -s arc extrudeMesh
# For output fields from checkMesh
mkdir -p 1
runApplication -s arc checkMesh -writeAllFields -time 1
runApplication checkMesh -writeAllFields
# Extrude using splines
USE_ARC=false runApplication -s spline extrudeMesh
# For output fields from checkMesh
mkdir -p 2
runApplication -s spline checkMesh -writeAllFields -time 2
paraFoam -touch -vtk
......
......@@ -42,7 +42,9 @@ polylineCoeffs
( 1.5 -1 1.183974596 )
);
edges 9
#if ${USE_ARC:-true}
//- Using arcs
edges
(
line 0 1
arc 1 2 ( 0 -0.087867966 0.962132034 )
......@@ -54,6 +56,22 @@ polylineCoeffs
arc 7 8 ( 0.976794919 -1 2.009807621 )
line 8 9
);
#else
//- Using spline (different shape):
edges
(
spline 0 9
(
( 0 0 0.05 )
( 0 0 0.5 )
( 0.5 0 0.5 )
( 0.5 0 0 )
( 1.5 0 0 )
( 1.5 -1 0 )
( 1.5 -1 1.183974596 )
)
);
#endif
toleranceCheck 1e-6;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment