mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: bezier: added bezier curves in blockMesh edges
This commit is contained in:
@ -3,6 +3,7 @@ curvedEdges/CatmullRomSpline.C
|
|||||||
curvedEdges/polyLine.C
|
curvedEdges/polyLine.C
|
||||||
|
|
||||||
curvedEdges/arcEdge.C
|
curvedEdges/arcEdge.C
|
||||||
|
curvedEdges/bezier.C
|
||||||
curvedEdges/curvedEdge.C
|
curvedEdges/curvedEdge.C
|
||||||
curvedEdges/lineEdge.C
|
curvedEdges/lineEdge.C
|
||||||
curvedEdges/polyLineEdge.C
|
curvedEdges/polyLineEdge.C
|
||||||
|
|||||||
97
src/mesh/blockMesh/curvedEdges/bezier.C
Normal file
97
src/mesh/blockMesh/curvedEdges/bezier.C
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "bezier.H"
|
||||||
|
#include "SubList.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(bezier, 0);
|
||||||
|
addToRunTimeSelectionTable(curvedEdge, bezier, Istream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::bezier::bezier
|
||||||
|
(
|
||||||
|
const pointField& ps,
|
||||||
|
const label start,
|
||||||
|
const label end,
|
||||||
|
const pointField& control
|
||||||
|
)
|
||||||
|
:
|
||||||
|
curvedEdge(ps, start, end),
|
||||||
|
control_(control)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::bezier::bezier(const pointField& ps, Istream& is)
|
||||||
|
:
|
||||||
|
curvedEdge(ps, is),
|
||||||
|
control_(appendEndPoints(ps, start_, end_, pointField(is)))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::bezier::~bezier()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::point Foam::bezier::position(const scalar lambda) const
|
||||||
|
{
|
||||||
|
pointField working(control_);
|
||||||
|
|
||||||
|
label nWorking(working.size());
|
||||||
|
|
||||||
|
forAll(working, workingI)
|
||||||
|
{
|
||||||
|
-- nWorking;
|
||||||
|
|
||||||
|
SubList<point>(working, nWorking).assign
|
||||||
|
(
|
||||||
|
(1 - lambda)*SubList<point>(working, nWorking)
|
||||||
|
+ lambda*SubList<point>(working, nWorking, 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return working[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::bezier::length() const
|
||||||
|
{
|
||||||
|
notImplemented("bezier::length() const");
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
121
src/mesh/blockMesh/curvedEdges/bezier.H
Normal file
121
src/mesh/blockMesh/curvedEdges/bezier.H
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::bezier
|
||||||
|
|
||||||
|
Description
|
||||||
|
Nth order bezier curve edge. Only interior control points should be
|
||||||
|
specified. The outer points are taken as start and end. Note that the
|
||||||
|
calculation of each point takes 0(N^2) time, where N is the number of
|
||||||
|
control points. This edge type shouldn't therefore be used for finely
|
||||||
|
discretised line data; polyLine or similar will be more appropriate for
|
||||||
|
such cases. Beziers are useful for simple curved shapes such as aerofoils,
|
||||||
|
or when you want an edge to match a specific direction at one, or both, or
|
||||||
|
its endpoints. In comparison with BSplines, the grading of bezier edges
|
||||||
|
should be smoother, and the code is much simpler. The algorithmic order is
|
||||||
|
worse, however, and the edge will not follow the control points as closely.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
bezier.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef bezier_H
|
||||||
|
#define bezier_H
|
||||||
|
|
||||||
|
#include "curvedEdge.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class bezier Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class bezier
|
||||||
|
:
|
||||||
|
public curvedEdge
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- Control points
|
||||||
|
pointField control_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
bezier(const bezier&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const bezier&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Static data members
|
||||||
|
TypeName("bezier");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
bezier
|
||||||
|
(
|
||||||
|
const pointField&,
|
||||||
|
const label start,
|
||||||
|
const label end,
|
||||||
|
const pointField& control
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
bezier(const pointField&, Istream&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~bezier();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the point position corresponding to the curve parameter
|
||||||
|
// 0 <= lambda <= 1
|
||||||
|
point position(const scalar lambda) const;
|
||||||
|
|
||||||
|
//- Return the length of the curve
|
||||||
|
scalar length() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user