mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: patchSetSet: new sampledSet. Fixes #1346.
This commit is contained in:
@ -11,6 +11,7 @@ sampledSet/face/faceOnlySet.C
|
||||
sampledSet/midPoint/midPointSet.C
|
||||
sampledSet/midPointAndFace/midPointAndFaceSet.C
|
||||
sampledSet/patchSeed/patchSeedSet.C
|
||||
sampledSet/patchEdge/patchEdgeSet.C
|
||||
sampledSet/sampledSet/sampledSet.C
|
||||
sampledSet/sampledSets/sampledSets.C
|
||||
sampledSet/sampledSets/sampledSetsGrouping.C
|
||||
|
||||
185
src/sampling/sampledSet/patchEdge/patchEdgeSet.C
Normal file
185
src/sampling/sampledSet/patchEdge/patchEdgeSet.C
Normal file
@ -0,0 +1,185 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2019 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 "patchEdgeSet.H"
|
||||
#include "polyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "searchableSurface.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(patchEdgeSet, 0);
|
||||
addToRunTimeSelectionTable(sampledSet, patchEdgeSet, word);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::patchEdgeSet::genSamples()
|
||||
{
|
||||
// Storage for sample points
|
||||
DynamicList<point> samplingPts;
|
||||
DynamicList<label> samplingCells;
|
||||
DynamicList<label> samplingFaces;
|
||||
DynamicList<label> samplingSegments;
|
||||
DynamicList<scalar> samplingCurveDist;
|
||||
|
||||
const labelList patchIDs(patchSet_.sortedToc());
|
||||
|
||||
for (const label patchi : patchIDs)
|
||||
{
|
||||
const polyPatch& pp = mesh().boundaryMesh()[patchi];
|
||||
const edgeList& edges = pp.edges();
|
||||
const labelList& mp = pp.meshPoints();
|
||||
const pointField& pts = pp.points();
|
||||
|
||||
pointField start(edges.size());
|
||||
pointField end(edges.size());
|
||||
forAll(edges, edgei)
|
||||
{
|
||||
const edge& e = edges[edgei];
|
||||
start[edgei] = pts[mp[e[0]]];
|
||||
end[edgei] = pts[mp[e[1]]];
|
||||
}
|
||||
|
||||
|
||||
List<List<pointIndexHit>> hits;
|
||||
surfPtr_->findLineAll(start, end, hits);
|
||||
|
||||
forAll(hits, edgei)
|
||||
{
|
||||
const List<pointIndexHit>& eHits = hits[edgei];
|
||||
|
||||
if (eHits.size())
|
||||
{
|
||||
const label meshFacei = pp.start()+pp.edgeFaces()[edgei][0];
|
||||
const label celli = mesh().faceOwner()[meshFacei];
|
||||
for (const auto& hit : eHits)
|
||||
{
|
||||
const point& pt = hit.hitPoint();
|
||||
samplingPts.append(pt);
|
||||
samplingCells.append(celli);
|
||||
samplingFaces.append(meshFacei);
|
||||
samplingSegments.append(0);
|
||||
samplingCurveDist.append(mag(pt-origin_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////- Alternative hardcoded to use plane
|
||||
//forAll(edges, edgei)
|
||||
//{
|
||||
// const edge& e = edges[edgei];
|
||||
// const point& p0 = pts[mp[e[0]]];
|
||||
// const point& p1 = pts[mp[e[1]]];
|
||||
// const vector dir(p1-p0);
|
||||
// const scalar s = pl_.normalIntersect(p0, dir);
|
||||
//
|
||||
// if (s >= 0.0 && s < 1.0)
|
||||
// {
|
||||
// const point pt(p0+s*dir);
|
||||
//
|
||||
// // Calculate distance on curve
|
||||
// //const scalar dist = (pt-start_)&curve;
|
||||
// //if (dist >= 0 && dist < magCurve)
|
||||
// const scalar dist = mag(pt-pl_.origin());
|
||||
//
|
||||
// // Take any face using this edge
|
||||
// const label meshFacei = pp.start()+pp.edgeFaces()[edgei][0];
|
||||
//
|
||||
// samplingPts.append(pt);
|
||||
// samplingCells.append(mesh().faceOwner()[meshFacei]);
|
||||
// samplingFaces.append(meshFacei);
|
||||
// samplingSegments.append(0);
|
||||
// samplingCurveDist.append(dist);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
samplingPts.shrink();
|
||||
samplingCells.shrink();
|
||||
samplingFaces.shrink();
|
||||
samplingSegments.shrink();
|
||||
samplingCurveDist.shrink();
|
||||
|
||||
setSamples
|
||||
(
|
||||
samplingPts,
|
||||
samplingCells,
|
||||
samplingFaces,
|
||||
samplingSegments,
|
||||
samplingCurveDist
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
write(Info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::patchEdgeSet::patchEdgeSet
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
sampledSet(name, mesh, searchEngine, dict),
|
||||
surfPtr_
|
||||
(
|
||||
searchableSurface::New
|
||||
(
|
||||
dict.get<word>("surfaceType"),
|
||||
IOobject
|
||||
(
|
||||
dict.lookupOrDefault("surfaceName", name),
|
||||
mesh.time().constant(), // directory
|
||||
"triSurface", // instance
|
||||
mesh.time(), // registry
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dict
|
||||
)
|
||||
),
|
||||
origin_(dict.get<point>("origin")),
|
||||
//end_(dict.get<point>("end")),
|
||||
//pl_(dict),
|
||||
patchSet_
|
||||
(
|
||||
mesh.boundaryMesh().patchSet(dict.get<wordRes>("patches"))
|
||||
)
|
||||
{
|
||||
genSamples();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
185
src/sampling/sampledSet/patchEdge/patchEdgeSet.H
Normal file
185
src/sampling/sampledSet/patchEdge/patchEdgeSet.H
Normal file
@ -0,0 +1,185 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2019 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::patchEdgeSet
|
||||
|
||||
Description
|
||||
Like Foam::uniformSet but samples patch edges
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
sets
|
||||
{
|
||||
type sets;
|
||||
libs ("libsampling.so");
|
||||
writeControl timeStep;
|
||||
writeInterval 1;
|
||||
|
||||
fields (p U);
|
||||
interpolationScheme cellPoint;
|
||||
setFormat vtk;
|
||||
|
||||
sets
|
||||
(
|
||||
// Intersections of patches with plane
|
||||
patchEdge
|
||||
{
|
||||
type patchEdge;
|
||||
axis x;
|
||||
|
||||
patches (movingWall);
|
||||
|
||||
// Surface type
|
||||
surfaceType searchablePlane;
|
||||
// Additional info for surface
|
||||
planeType pointAndNormal;
|
||||
pointAndNormalDict
|
||||
{
|
||||
point (1.5 1.5 1.5);
|
||||
normal (0.1 0 1);
|
||||
}
|
||||
|
||||
// Sort point according to distance to origin
|
||||
origin (0 1 0);
|
||||
}
|
||||
|
||||
// Intersections of patches with stl
|
||||
sphere.stl
|
||||
{
|
||||
type patchEdge;
|
||||
axis x;
|
||||
|
||||
patches (movingWall);
|
||||
|
||||
surfaceType triSurfaceMesh;
|
||||
// Sort point according to distance to origin
|
||||
origin (0 1 0);
|
||||
}
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
type | patchEdge | yes |
|
||||
axis | x, y, z, xyz, distance | yes |
|
||||
patches | List of patch names or regexs | yes |
|
||||
surfaceType | Definition of the surface | yes |
|
||||
origin | reference location | yes |
|
||||
\endtable
|
||||
|
||||
Note
|
||||
The ordering of the points is according to the distance to the specified
|
||||
origin.
|
||||
|
||||
SourceFiles
|
||||
patchEdgeSet.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef patchEdgeSet_H
|
||||
#define patchEdgeSet_H
|
||||
|
||||
#include "sampledSet.H"
|
||||
#include "DynamicList.H"
|
||||
#include "HashSet.H"
|
||||
#include "plane.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class searchableSurface;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class patchEdgeSet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class patchEdgeSet
|
||||
:
|
||||
public sampledSet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- The surface
|
||||
const autoPtr<searchableSurface> surfPtr_;
|
||||
|
||||
//- Reference point
|
||||
const point origin_;
|
||||
|
||||
//- Patches to sample
|
||||
const labelHashSet patchSet_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Samples all points in sampleCoords.
|
||||
void calcSamples
|
||||
(
|
||||
DynamicList<point>& samplingPts,
|
||||
DynamicList<label>& samplingCells,
|
||||
DynamicList<label>& samplingFaces,
|
||||
DynamicList<label>& samplingSegments,
|
||||
DynamicList<scalar>& samplingCurveDist
|
||||
) const;
|
||||
|
||||
//- Uses calcSamples to obtain samples. Copies them into *this.
|
||||
void genSamples();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("patchEdge");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
patchEdgeSet
|
||||
(
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const meshSearch& searchEngine,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~patchEdgeSet() = default;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user