Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
OpenFOAM-plus
Commits
64a991d0
Commit
64a991d0
authored
Jun 20, 2019
by
mattijs
Browse files
ENH: patchSetSet: new sampledSet. Fixes
#1346
.
parent
d07a0f93
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/sampling/Make/files
View file @
64a991d0
...
...
@@ -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
...
...
src/sampling/sampledSet/patchEdge/patchEdgeSet.C
0 → 100644
View file @
64a991d0
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
();
}
// ************************************************************************* //
src/sampling/sampledSet/patchEdge/patchEdgeSet.H
0 → 100644
View file @
64a991d0
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment