mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: foamyHexMesh: add rayShooting initial points method
This commit is contained in:
@ -64,6 +64,7 @@ initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C
|
||||
initialPointsMethod/faceCentredCubic/faceCentredCubic.C
|
||||
initialPointsMethod/pointFile/pointFile.C
|
||||
initialPointsMethod/autoDensity/autoDensity.C
|
||||
initialPointsMethod/rayShooting/rayShooting.C
|
||||
|
||||
relaxationModel/relaxationModel/relaxationModel.C
|
||||
relaxationModel/adaptiveLinear/adaptiveLinear.C
|
||||
|
||||
@ -1249,7 +1249,7 @@ void Foam::conformalVoronoiMesh::move()
|
||||
if
|
||||
(
|
||||
(
|
||||
(vA->internalPoint() && vB->internalPoint())
|
||||
(vA->internalPoint() || vB->internalPoint())
|
||||
&& (!vA->referred() || !vB->referred())
|
||||
// ||
|
||||
// (
|
||||
|
||||
@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ 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 "rayShooting.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "triSurfaceMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(rayShooting, 0);
|
||||
addToRunTimeSelectionTable(initialPointsMethod, rayShooting, dictionary);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
rayShooting::rayShooting
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const Time& runTime,
|
||||
Random& rndGen,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const cellShapeControl& cellShapeControls,
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
)
|
||||
:
|
||||
initialPointsMethod
|
||||
(
|
||||
typeName,
|
||||
initialPointsDict,
|
||||
runTime,
|
||||
rndGen,
|
||||
geometryToConformTo,
|
||||
cellShapeControls,
|
||||
decomposition
|
||||
),
|
||||
maxRayLength_(readScalar(detailsDict().lookup("maxRayLength"))),
|
||||
randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")),
|
||||
randomPerturbationCoeff_
|
||||
(
|
||||
readScalar(detailsDict().lookup("randomPerturbationCoeff"))
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
List<Vb::Point> rayShooting::initialPoints() const
|
||||
{
|
||||
// Loop over surface faces
|
||||
const searchableSurfaces& surfaces = geometryToConformTo().geometry();
|
||||
const labelList& surfacesToConformTo = geometryToConformTo().surfaces();
|
||||
|
||||
// Initialise points list
|
||||
label initialPointsSize = 0;
|
||||
forAll(surfaces, surfI)
|
||||
{
|
||||
initialPointsSize += surfaces[surfI].size();
|
||||
}
|
||||
|
||||
DynamicList<Vb::Point> initialPoints(initialPointsSize);
|
||||
|
||||
forAll(surfacesToConformTo, surfI)
|
||||
{
|
||||
const searchableSurface& s = surfaces[surfacesToConformTo[surfI]];
|
||||
|
||||
tmp<pointField> faceCentresTmp(s.coordinates());
|
||||
const pointField& faceCentres = faceCentresTmp();
|
||||
|
||||
Info<< " Shoot rays from " << s.name() << nl
|
||||
<< " nRays = " << faceCentres.size() << endl;
|
||||
|
||||
|
||||
forAll(faceCentres, fcI)
|
||||
{
|
||||
const Foam::point& fC = faceCentres[fcI];
|
||||
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
&& !decomposition().positionOnThisProcessor(fC)
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const scalar pert =
|
||||
randomPerturbationCoeff_
|
||||
*cellShapeControls().cellSize(fC);
|
||||
|
||||
pointIndexHit surfHitStart;
|
||||
label hitSurfaceStart;
|
||||
|
||||
// Face centres should be on the surface so search distance can be
|
||||
// small
|
||||
geometryToConformTo().findSurfaceNearest
|
||||
(
|
||||
fC,
|
||||
sqr(SMALL),
|
||||
surfHitStart,
|
||||
hitSurfaceStart
|
||||
);
|
||||
|
||||
vectorField normStart(1, vector::min);
|
||||
geometryToConformTo().getNormal
|
||||
(
|
||||
hitSurfaceStart,
|
||||
List<pointIndexHit>(1, surfHitStart),
|
||||
normStart
|
||||
);
|
||||
|
||||
pointIndexHit surfHitEnd;
|
||||
label hitSurfaceEnd;
|
||||
|
||||
geometryToConformTo().findSurfaceNearestIntersection
|
||||
(
|
||||
fC - normStart[0]*SMALL,
|
||||
fC - normStart[0]*maxRayLength_,
|
||||
surfHitEnd,
|
||||
hitSurfaceEnd
|
||||
);
|
||||
|
||||
vectorField normEnd(1, vector::min);
|
||||
geometryToConformTo().getNormal
|
||||
(
|
||||
hitSurfaceEnd,
|
||||
List<pointIndexHit>(1, surfHitEnd),
|
||||
normEnd
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
surfHitEnd.hit()
|
||||
&& ((normStart[0] & normEnd[0]) < 0)
|
||||
)
|
||||
{
|
||||
line<point, point> l(fC, surfHitEnd.hitPoint());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Clip the line in parallel
|
||||
pointIndexHit procIntersection =
|
||||
decomposition().findLine
|
||||
(
|
||||
l.start() + l.vec()*SMALL,
|
||||
l.end() - l.vec()*maxRayLength_
|
||||
);
|
||||
|
||||
if (procIntersection.hit())
|
||||
{
|
||||
l =
|
||||
line<point, point>
|
||||
(
|
||||
l.start(),
|
||||
procIntersection.hitPoint()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Foam::point midPoint(l.centre());
|
||||
|
||||
const scalar minDistFromSurfaceSqr =
|
||||
minimumSurfaceDistanceCoeffSqr_
|
||||
*sqr(cellShapeControls().cellSize(midPoint));
|
||||
|
||||
if
|
||||
(
|
||||
magSqr(midPoint - l.start()) > minDistFromSurfaceSqr
|
||||
&& magSqr(midPoint - l.end()) > minDistFromSurfaceSqr
|
||||
)
|
||||
{
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
midPoint.x() += pert*(rndGen().scalar01() - 0.5);
|
||||
midPoint.y() += pert*(rndGen().scalar01() - 0.5);
|
||||
midPoint.z() += pert*(rndGen().scalar01() - 0.5);
|
||||
}
|
||||
|
||||
initialPoints.append(toPoint(midPoint));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return initialPoints.shrink();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ 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::rayShooting
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
rayShooting.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rayShooting_H
|
||||
#define rayShooting_H
|
||||
|
||||
#include "initialPointsMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class rayShooting Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class rayShooting
|
||||
:
|
||||
public initialPointsMethod
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
const scalar maxRayLength_;
|
||||
|
||||
//- Should the initial positions be randomised
|
||||
Switch randomiseInitialGrid_;
|
||||
|
||||
//- Randomise the initial positions by fraction of the initialCellSize_
|
||||
scalar randomPerturbationCoeff_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("rayShooting");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
rayShooting
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const Time& runTime,
|
||||
Random& rndGen,
|
||||
const conformationSurfaces& geometryToConformTo,
|
||||
const cellShapeControl& cellShapeControls,
|
||||
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~rayShooting()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the initial points for the conformalVoronoiMesh
|
||||
virtual List<Vb::Point> initialPoints() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user