ENH: add for geometric transformation properties for topoSet

- added solidBodyMotionFunctions to topoSet which allows things like
  moving cellSet selection for fvOptions etc.

COMP: relocate solidBodyMotionFunctions to meshTools

Co-authored-by: Kutalmis Bercin <>
This commit is contained in:
mattijs 2024-03-04 14:16:26 +00:00 committed by Mark Olesen
parent 4a0a63999e
commit a7d6f2720f
84 changed files with 276 additions and 185 deletions

View File

@ -109,19 +109,6 @@ motionSolvers/displacement/solidBody/solidBodyMotionSolver.C
motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver.C
motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.C
solidBodyMotionFunctions = motionSolvers/displacement/solidBody/solidBodyMotionFunctions
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunction.C
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunctionNew.C
$(solidBodyMotionFunctions)/SDA/SDA.C
$(solidBodyMotionFunctions)/tabulated6DoFMotion/tabulated6DoFMotion.C
$(solidBodyMotionFunctions)/linearMotion/linearMotion.C
$(solidBodyMotionFunctions)/drivenLinearMotion/drivenLinearMotion.C
$(solidBodyMotionFunctions)/rotatingMotion/rotatingMotion.C
$(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C
$(solidBodyMotionFunctions)/multiMotion/multiMotion.C
$(solidBodyMotionFunctions)/oscillatingLinearMotion/oscillatingLinearMotion.C
$(solidBodyMotionFunctions)/oscillatingRotatingMotion/oscillatingRotatingMotion.C
motionSolvers/displacement/solidBody/pointPatchFields/derived/solidBodyMotionDisplacement/solidBodyMotionDisplacementPointPatchVectorField.C
createShellMesh/createShellMesh.C

View File

@ -354,4 +354,18 @@ tetOverlapVolume/tetOverlapVolume.C
triangulatedPatch/triangulatedPatch.C
solidBodyMotion = solidBodyMotionFunctions
$(solidBodyMotion)/solidBodyMotionFunction/solidBodyMotionFunction.C
$(solidBodyMotion)/solidBodyMotionFunction/solidBodyMotionFunctionNew.C
$(solidBodyMotion)/SDA/SDA.C
$(solidBodyMotion)/tabulated6DoFMotion/tabulated6DoFMotion.C
$(solidBodyMotion)/linearMotion/linearMotion.C
$(solidBodyMotion)/drivenLinearMotion/drivenLinearMotion.C
$(solidBodyMotion)/rotatingMotion/rotatingMotion.C
$(solidBodyMotion)/axisRotationMotion/axisRotationMotion.C
$(solidBodyMotion)/multiMotion/multiMotion.C
$(solidBodyMotion)/oscillatingLinearMotion/oscillatingLinearMotion.C
$(solidBodyMotion)/oscillatingRotatingMotion/oscillatingRotatingMotion.C
LIB = $(FOAM_LIBBIN)/libmeshTools

View File

@ -1,7 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/surfMesh/lnInclude
LIB_LIBS = \
-lfileFormats \

View File

@ -39,12 +39,12 @@ Description
SourceFiles
solidBodyMotionFunction.C
dynamicFvMeshNew.C
solidBodyMotionFunctionNew.C
\*---------------------------------------------------------------------------*/
#ifndef solidBodyMotionFunction_H
#define solidBodyMotionFunction_H
#ifndef Foam_solidBodyMotionFunction_H
#define Foam_solidBodyMotionFunction_H
#include "Time.H"
#include "dictionary.H"
@ -101,7 +101,7 @@ public:
// Constructors
//- Construct from the SBMFCoeffs dictionary and Time
//- Construct from the coefficients dictionary and Time
solidBodyMotionFunction
(
const dictionary& SBMFCoeffs,
@ -114,10 +114,28 @@ public:
// Selectors
//- Select constructed from the SBMFCoeffs dictionary and Time
//- Construct and dispatch motionType with dictionary and Time.
// Returns nullptr if motionType is empty
static autoPtr<solidBodyMotionFunction> New
(
const dictionary& SBMFCoeffs,
const word& motionType,
const dictionary& dict,
const Time& runTime
);
//- Select "solidBodyMotionFunction" type from dictionary
//- and create with Time.
static autoPtr<solidBodyMotionFunction> New
(
const dictionary& dict,
const Time& runTime
);
//- Select "solidBodyMotionFunction" type (if present) from dictionary
//- and create with Time.
static autoPtr<solidBodyMotionFunction> NewIfPresent
(
const dictionary& dict,
const Time& runTime
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,15 +30,18 @@ License
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::solidBodyMotionFunction> Foam::solidBodyMotionFunction::New
Foam::autoPtr<Foam::solidBodyMotionFunction>
Foam::solidBodyMotionFunction::New
(
const word& motionType,
const dictionary& dict,
const Time& runTime
)
{
const word motionType(dict.get<word>("solidBodyMotionFunction"));
Info<< "Selecting solid-body motion function " << motionType << endl;
if (motionType.empty())
{
return nullptr;
}
auto* ctorPtr = dictionaryConstructorTable(motionType);
@ -53,8 +56,45 @@ Foam::autoPtr<Foam::solidBodyMotionFunction> Foam::solidBodyMotionFunction::New
) << exit(FatalIOError);
}
Info<< "Selecting solid-body motion function " << motionType << endl;
return autoPtr<solidBodyMotionFunction>(ctorPtr(dict, runTime));
}
Foam::autoPtr<Foam::solidBodyMotionFunction>
Foam::solidBodyMotionFunction::New
(
const dictionary& dict,
const Time& runTime
)
{
return New
(
dict.get<word>("solidBodyMotionFunction", keyType::LITERAL),
dict,
runTime
);
}
Foam::autoPtr<Foam::solidBodyMotionFunction>
Foam::solidBodyMotionFunction::NewIfPresent
(
const dictionary& dict,
const Time& runTime
)
{
word motionType;
dict.readIfPresent("solidBodyMotionFunction", motionType, keyType::LITERAL);
if (motionType.empty())
{
return nullptr;
}
return New(motionType, dict, runTime);
}
// ************************************************************************* //

View File

@ -90,10 +90,10 @@ Foam::boundaryToCell::boundaryToCell(const polyMesh& mesh)
Foam::boundaryToCell::boundaryToCell
(
const polyMesh& mesh,
const dictionary&
const dictionary& dict
)
:
topoSetCellSource(mesh)
topoSetCellSource(mesh, dict)
{}

View File

@ -92,7 +92,8 @@ static void readBoxDim(const dictionary& dict, treeBoundBox& bb)
void Foam::boxToCell::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.cellCentres();
const tmp<pointField> tctrs(this->transform(mesh_.cellCentres()));
const pointField& ctrs = tctrs();
forAll(ctrs, elemi)
{
@ -138,7 +139,7 @@ Foam::boxToCell::boxToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
bbs_()
{
// Accept 'boxes', 'box' or 'min/max'

View File

@ -70,7 +70,7 @@ Foam::cellToCell::cellToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
names_()
{
// Look for 'sets' or 'set'

View File

@ -69,7 +69,8 @@ void Foam::clipPlaneToCell::combine(topoSet& set, const bool add) const
{
// Cell centres above the plane
const pointField& ctrs = mesh_.cellCentres();
const tmp<pointField> tctrs(this->transform(mesh_.cellCentres()));
const pointField& ctrs = tctrs();
forAll(ctrs, elemi)
{
@ -102,12 +103,9 @@ Foam::clipPlaneToCell::clipPlaneToCell
const dictionary& dict
)
:
clipPlaneToCell
(
mesh,
dict.get<vector>("point"),
dict.get<vector>("normal")
)
topoSetCellSource(mesh, dict),
point_(dict.get<vector>("point")),
normal_(dict.get<vector>("normal"))
{}

View File

@ -68,7 +68,8 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderToCell::usage_
void Foam::cylinderToCell::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.cellCentres();
const tmp<pointField> tctrs(this->transform(mesh_.cellCentres()));
const pointField& ctrs = tctrs();
const vector axis = (point2_ - point1_);
const scalar magAxis2 = magSqr(axis);
@ -127,12 +128,12 @@ Foam::cylinderToCell::cylinderToCell
const dictionary& dict
)
:
cylinderToCell
topoSetCellSource(mesh, dict),
point1_(dict.getCompat<point>("point1", {{"p1", -2112}})),
point2_(dict.getCompat<point>("point2", {{"p2", -2112}})),
radius_(dict.getCompat<scalar>("radius", {{"outerRadius", -2112}})),
innerRadius_
(
mesh,
dict.getCompat<point>("point1", {{"p1", -2112}}),
dict.getCompat<point>("point2", {{"p2", -2112}}),
dict.getCompat<scalar>("radius", {{"outerRadius", -2112}}),
dict.getCheckOrDefault<scalar>("innerRadius", 0, scalarMinMax::ge(0))
)
{}

View File

@ -155,7 +155,7 @@ Foam::faceToCell::faceToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
names_(),
option_(faceActionNames_.get("option", dict))
{

View File

@ -214,7 +214,7 @@ Foam::faceZoneToCell::faceZoneToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
zoneMatcher_(),
option_(faceActionNames_.get("option", dict))
{

View File

@ -148,13 +148,10 @@ Foam::fieldToCell::fieldToCell
const dictionary& dict
)
:
fieldToCell
(
mesh,
dict.get<word>("field"),
dict.get<scalar>("min"),
dict.get<scalar>("max")
)
topoSetCellSource(mesh, dict),
fieldName_(dict.get<word>("field")),
min_(dict.get<scalar>("min")),
max_(dict.get<scalar>("max"))
{}

View File

@ -198,7 +198,8 @@ Foam::haloToCell::haloToCell
const dictionary& dict
)
:
haloToCell(mesh, dict.getOrDefault<label>("steps", 1))
topoSetCellSource(mesh, dict),
steps_(dict.getOrDefault<label>("steps", 1))
{}

View File

@ -94,7 +94,8 @@ Foam::labelToCell::labelToCell
const dictionary& dict
)
:
labelToCell(mesh, dict.get<labelList>("value"))
topoSetCellSource(mesh, dict),
labels_(dict.get<labelList>("value"))
{}

View File

@ -74,6 +74,7 @@ void Foam::nbrToCell::combine(topoSet& set, const bool add) const
}
const cellList& cells = mesh().cells();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
boolList isCoupled(mesh_.nBoundaryFaces(), false);
@ -136,7 +137,8 @@ Foam::nbrToCell::nbrToCell
const dictionary& dict
)
:
nbrToCell(mesh, dict.getCheck<label>("neighbours", labelMinMax::ge(1)))
topoSetCellSource(mesh, dict),
minNbrs_(dict.getCheck<label>("neighbours", labelMinMax::ge(1)))
{}

View File

@ -127,11 +127,8 @@ Foam::nearestToCell::nearestToCell
const dictionary& dict
)
:
nearestToCell
(
mesh,
dict.get<pointField>("points")
)
topoSetCellSource(mesh, dict),
points_(dict.get<pointField>("points"))
{}

View File

@ -125,7 +125,7 @@ Foam::patchToCell::patchToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
selectedPatches_()
{
// Look for 'patches' and 'patch', but accept 'name' as well

View File

@ -135,7 +135,7 @@ Foam::pointToCell::pointToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
names_(),
option_(pointActionNames_.get("option", dict))
{

View File

@ -403,7 +403,7 @@ Foam::regionToCell::regionToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
setName_(dict.getOrDefault<word>("set", "none")),
insidePoints_
(

View File

@ -96,7 +96,8 @@ void Foam::rotatedBoxToCell::combine(topoSet& set, const bool add) const
// Check whether cell centre is inside all faces of box.
const pointField& ctrs = mesh_.cellCentres();
const tmp<pointField> tctrs(this->transform(mesh_.cellCentres()));
const pointField& ctrs = tctrs();
forAll(ctrs, celli)
{
@ -146,14 +147,11 @@ Foam::rotatedBoxToCell::rotatedBoxToCell
const dictionary& dict
)
:
rotatedBoxToCell
(
mesh,
dict.get<point>("origin"),
dict.get<vector>("i"),
dict.get<vector>("j"),
dict.get<vector>("k")
)
topoSetCellSource(mesh, dict),
origin_(dict.get<point>("origin")),
i_(dict.get<vector>("i")),
j_(dict.get<vector>("j")),
k_(dict.get<vector>("k"))
{}

View File

@ -102,9 +102,13 @@ void Foam::searchableSurfaceToCell::combine(topoSet& set, const bool add) const
{
return;
}
const pointField& ctrs = mesh_.cellCentres();
const tmp<pointField> tctrs(this->transform(mesh_.cellCentres()));
const pointField& ctrs = tctrs();
const searchableSurface& s = *surf_;
// Cell centres within the enclosing volumes
List<volumeType> volTypes;
@ -130,7 +134,7 @@ Foam::searchableSurfaceToCell::searchableSurfaceToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
surf_
(
searchableSurface::New

View File

@ -116,7 +116,8 @@ Foam::shapeToCell::shapeToCell
const dictionary& dict
)
:
shapeToCell(mesh, dict.getCompat<word>("shape", {{"type", 1806}}))
topoSetCellSource(mesh, dict),
shape_(dict.getCompat<word>("shape", {{"type", 1806}}))
{}

View File

@ -68,7 +68,8 @@ Foam::topoSetSource::addToUsageTable Foam::sphereToCell::usage_
void Foam::sphereToCell::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.cellCentres();
const tmp<pointField> tctrs(this->transform(mesh_.cellCentres()));
const pointField& ctrs = tctrs();
const scalar orad2 = sqr(radius_);
const scalar irad2 = innerRadius_ > 0 ? sqr(innerRadius_) : -1;
@ -110,11 +111,11 @@ Foam::sphereToCell::sphereToCell
const dictionary& dict
)
:
sphereToCell
topoSetCellSource(mesh, dict),
origin_(dict.getCompat<vector>("origin", {{"centre", -1806}})),
radius_(dict.getCheck<scalar>("radius", scalarMinMax::ge(0))),
innerRadius_
(
mesh,
dict.getCompat<vector>("origin", {{"centre", -1806}}),
dict.getCheck<scalar>("radius", scalarMinMax::ge(0)),
dict.getCheckOrDefault<scalar>("innerRadius", 0, scalarMinMax::ge(0))
)
{}

View File

@ -434,7 +434,7 @@ Foam::surfaceToCell::surfaceToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
surfName_(dict.get<fileName>("file").expand()),
outsidePoints_(dict.get<pointField>("outsidePoints")),
includeCut_(dict.get<bool>("includeCut")),

View File

@ -301,13 +301,10 @@ Foam::targetVolumeToCell::targetVolumeToCell
const dictionary& dict
)
:
targetVolumeToCell
(
mesh,
dict.getCheck<scalar>("volume", scalarMinMax::ge(0)),
dict.get<vector>("normal"),
dict.getOrDefault<word>("set", "")
)
topoSetCellSource(mesh, dict),
vol_(dict.getCheck<scalar>("volume", scalarMinMax::ge(0))),
normal_(dict.get<vector>("normal")),
maskSetName_(dict.getOrDefault<word>("set", ""))
{}

View File

@ -181,7 +181,7 @@ Foam::zoneToCell::zoneToCell
const dictionary& dict
)
:
topoSetCellSource(mesh),
topoSetCellSource(mesh, dict),
zoneMatcher_()
{
// Look for 'zones' and 'zone', but accept 'name' as well

View File

@ -71,7 +71,7 @@ Foam::setToCellZone::setToCellZone
const dictionary& dict
)
:
topoSetCellZoneSource(mesh),
topoSetCellZoneSource(mesh, dict),
setName_(dict.get<word>("set"))
{}

View File

@ -91,10 +91,10 @@ Foam::boundaryToFace::boundaryToFace(const polyMesh& mesh)
Foam::boundaryToFace::boundaryToFace
(
const polyMesh& mesh,
const dictionary&
const dictionary& dict
)
:
topoSetFaceSource(mesh)
topoSetFaceSource(mesh, dict)
{}

View File

@ -92,7 +92,8 @@ static void readBoxDim(const dictionary& dict, treeBoundBox& bb)
void Foam::boxToFace::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.faceCentres();
const tmp<pointField> tctrs(this->transform(mesh_.faceCentres()));
const pointField& ctrs = tctrs();
forAll(ctrs, elemi)
{
@ -138,7 +139,7 @@ Foam::boxToFace::boxToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
bbs_()
{
// Accept 'boxes', 'box' or 'min/max'

View File

@ -233,7 +233,7 @@ Foam::cellToFace::cellToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
names_(),
option_(cellActionNames_.get("option", dict))
{

View File

@ -69,7 +69,8 @@ void Foam::clipPlaneToFace::combine(topoSet& set, const bool add) const
{
// Face centres above the plane
const pointField& ctrs = mesh_.faceCentres();
const tmp<pointField> tctrs(this->transform(mesh_.faceCentres()));
const pointField& ctrs = tctrs();
forAll(ctrs, elemi)
{
@ -102,12 +103,9 @@ Foam::clipPlaneToFace::clipPlaneToFace
const dictionary& dict
)
:
clipPlaneToFace
(
mesh,
dict.get<vector>("point"),
dict.get<vector>("normal")
)
topoSetFaceSource(mesh, dict),
point_(dict.get<vector>("point")),
normal_(dict.get<vector>("normal"))
{}

View File

@ -68,7 +68,8 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderToFace::usage_
void Foam::cylinderToFace::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.faceCentres();
const tmp<pointField> tctrs(this->transform(mesh_.faceCentres()));
const pointField& ctrs = tctrs();
const vector axis = (point2_ - point1_);
const scalar magAxis2 = magSqr(axis);
@ -127,12 +128,12 @@ Foam::cylinderToFace::cylinderToFace
const dictionary& dict
)
:
cylinderToFace
topoSetFaceSource(mesh, dict),
point1_(dict.getCompat<point>("point1", {{"p1", -2112}})),
point2_(dict.getCompat<point>("point2", {{"p2", -2112}})),
radius_(dict.getCompat<scalar>("radius", {{"outerRadius", -2112}})),
innerRadius_
(
mesh,
dict.getCompat<point>("point1", {{"p1", -2112}}),
dict.getCompat<point>("point2", {{"p2", -2112}}),
dict.getCompat<scalar>("radius", {{"outerRadius", -2112}}),
dict.getCheckOrDefault<scalar>("innerRadius", 0, scalarMinMax::ge(0))
)
{}

View File

@ -70,7 +70,7 @@ Foam::faceToFace::faceToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
names_()
{
// Look for 'sets' or 'set'

View File

@ -1095,7 +1095,7 @@ Foam::holeToFace::holeToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
zonePoints_(dict.get<List<pointField>>("points")),
blockedFaceNames_(),
blockedCellNames_(),

View File

@ -94,11 +94,8 @@ Foam::labelToFace::labelToFace
const dictionary& dict
)
:
labelToFace
(
mesh,
dict.get<labelList>("value")
)
topoSetFaceSource(mesh, dict),
labels_(dict.get<labelList>("value"))
{}

View File

@ -100,12 +100,9 @@ Foam::normalToFace::normalToFace
Foam::normalToFace::normalToFace(const polyMesh& mesh, const dictionary& dict)
:
normalToFace
(
mesh,
dict.get<vector>("normal"),
dict.get<scalar>("cos")
)
topoSetFaceSource(mesh, dict),
normal_(dict.get<vector>("normal")),
tol_(dict.get<scalar>("cos"))
{
setNormal();
}

View File

@ -121,7 +121,7 @@ Foam::patchToFace::patchToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
selectedPatches_()
{
// Look for 'patches' and 'patch', but accept 'name' as well

View File

@ -181,7 +181,7 @@ Foam::pointToFace::pointToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
names_(),
option_(pointActionNames_.get("option", dict))
{

View File

@ -227,7 +227,7 @@ Foam::regionToFace::regionToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
setName_(dict.get<word>("set")),
nearPoint_(dict.get<point>("nearPoint"))
{}

View File

@ -102,7 +102,9 @@ void Foam::searchableSurfaceToFace::combine(topoSet& set, const bool add) const
{
return;
}
const pointField& ctrs = mesh_.faceCentres();
const tmp<pointField> tctrs(this->transform(mesh_.faceCentres()));
const pointField& ctrs = tctrs();
const searchableSurface& s = *surf_;
// Face centres within the enclosing volumes
@ -130,7 +132,7 @@ Foam::searchableSurfaceToFace::searchableSurfaceToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
surf_
(
searchableSurface::New

View File

@ -67,7 +67,8 @@ Foam::topoSetSource::addToUsageTable Foam::sphereToFace::usage_
void Foam::sphereToFace::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.faceCentres();
const tmp<pointField> tctrs(this->transform(mesh_.faceCentres()));
const pointField& ctrs = tctrs();
const scalar orad2 = sqr(radius_);
const scalar irad2 = innerRadius_ > 0 ? sqr(innerRadius_) : -1;
@ -109,11 +110,11 @@ Foam::sphereToFace::sphereToFace
const dictionary& dict
)
:
sphereToFace
topoSetFaceSource(mesh, dict),
origin_(dict.getCompat<vector>("origin", {{"centre", -1806}})),
radius_(dict.getCheck<scalar>("radius", scalarMinMax::ge(0))),
innerRadius_
(
mesh,
dict.getCompat<vector>("origin", {{"centre", -1806}}),
dict.getCheck<scalar>("radius", scalarMinMax::ge(0)),
dict.getCheckOrDefault<scalar>("innerRadius", 0, scalarMinMax::ge(0))
)
{}

View File

@ -183,7 +183,7 @@ Foam::zoneToFace::zoneToFace
const dictionary& dict
)
:
topoSetFaceSource(mesh),
topoSetFaceSource(mesh, dict),
zoneMatcher_()
{
// Look for 'zones' and 'zone', but accept 'name' as well

View File

@ -160,7 +160,7 @@ Foam::cellToFaceZone::cellToFaceZone
const dictionary& dict
)
:
topoSetFaceZoneSource(mesh),
topoSetFaceZoneSource(mesh, dict),
names_(),
flip_(dict.getOrDefault("flip", false))
{

View File

@ -81,7 +81,7 @@ Foam::faceZoneToFaceZone::faceZoneToFaceZone
const dictionary& dict
)
:
topoSetFaceZoneSource(mesh),
topoSetFaceZoneSource(mesh, dict),
setName_(dict.get<word>("zone"))
{}

View File

@ -388,13 +388,10 @@ Foam::planeToFaceZone::planeToFaceZone
const dictionary& dict
)
:
planeToFaceZone
(
mesh,
dict.get<vector>("point"),
dict.get<vector>("normal"),
faceActionNames_.getOrDefault("option", dict, faceAction::ALL)
)
topoSetFaceZoneSource(mesh, dict),
point_(dict.get<vector>("point")),
normal_(dict.get<vector>("normal")),
option_(faceActionNames_.getOrDefault("option", dict, faceAction::ALL))
{}

View File

@ -109,7 +109,7 @@ Foam::searchableSurfaceToFaceZone::searchableSurfaceToFaceZone
const dictionary& dict
)
:
topoSetFaceZoneSource(mesh),
topoSetFaceZoneSource(mesh, dict),
surfacePtr_
(
searchableSurface::New

View File

@ -83,7 +83,7 @@ Foam::setAndNormalToFaceZone::setAndNormalToFaceZone
const dictionary& dict
)
:
topoSetFaceZoneSource(mesh),
topoSetFaceZoneSource(mesh, dict),
setName_(dict.get<word>("faceSet")),
normal_(dict.get<vector>("normal"))
{}

View File

@ -72,7 +72,7 @@ Foam::setToFaceZone::setToFaceZone
const dictionary& dict
)
:
topoSetFaceZoneSource(mesh),
topoSetFaceZoneSource(mesh, dict),
setName_(dict.get<word>("faceSet"))
{
if (dict.found("cellSet"))

View File

@ -77,7 +77,7 @@ Foam::setsToFaceZone::setsToFaceZone
const dictionary& dict
)
:
topoSetFaceZoneSource(mesh),
topoSetFaceZoneSource(mesh, dict),
faceSetName_(dict.get<word>("faceSet")),
cellSetName_(dict.get<word>("cellSet")),
flip_(dict.getOrDefault("flip", false))

View File

@ -92,7 +92,8 @@ static void readBoxDim(const dictionary& dict, treeBoundBox& bb)
void Foam::boxToPoint::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.points();
const tmp<pointField> tctrs(this->transform(mesh_.points()));
const pointField& ctrs = tctrs();
forAll(ctrs, elemi)
{
@ -138,7 +139,7 @@ Foam::boxToPoint::boxToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
bbs_()
{
// Accept 'boxes', 'box' or 'min/max'

View File

@ -109,7 +109,7 @@ Foam::cellToPoint::cellToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
names_(),
option_(cellActionNames_.get("option", dict))
{

View File

@ -69,7 +69,8 @@ void Foam::clipPlaneToPoint::combine(topoSet& set, const bool add) const
{
// Mesh points above plane
const pointField& ctrs = mesh_.points();
const tmp<pointField> tctrs(this->transform(mesh_.points()));
const pointField& ctrs = tctrs();
forAll(ctrs, elemi)
{
@ -102,12 +103,9 @@ Foam::clipPlaneToPoint::clipPlaneToPoint
const dictionary& dict
)
:
clipPlaneToPoint
(
mesh,
dict.get<vector>("point"),
dict.get<vector>("normal")
)
topoSetPointSource(mesh, dict),
point_(dict.get<vector>("point")),
normal_(dict.get<vector>("normal"))
{}

View File

@ -68,7 +68,8 @@ Foam::topoSetSource::addToUsageTable Foam::cylinderToPoint::usage_
void Foam::cylinderToPoint::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.points();
const tmp<pointField> tctrs(this->transform(mesh_.points()));
const pointField& ctrs = tctrs();
const vector axis = (point2_ - point1_);
const scalar magAxis2 = magSqr(axis);
@ -119,12 +120,12 @@ Foam::cylinderToPoint::cylinderToPoint
const dictionary& dict
)
:
cylinderToPoint
topoSetPointSource(mesh, dict),
point1_(dict.getCompat<point>("point1", {{"p1", -2112}})),
point2_(dict.getCompat<point>("point2", {{"p2", -2112}})),
radius_(dict.getCompat<scalar>("radius", {{"outerRadius", -2112}})),
innerRadius_
(
mesh,
dict.getCompat<point>("point1", {{"p1", -2112}}),
dict.getCompat<point>("point2", {{"p2", -2112}}),
dict.getCompat<scalar>("radius", {{"outerRadius", -2112}}),
dict.getCheckOrDefault<scalar>("innerRadius", 0, scalarMinMax::ge(0))
)
{}

View File

@ -103,7 +103,7 @@ Foam::faceToPoint::faceToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
names_(),
option_(faceActionNames_.get("option", dict))
{

View File

@ -94,7 +94,8 @@ Foam::labelToPoint::labelToPoint
const dictionary& dict
)
:
labelToPoint(mesh, dict.get<labelList>("value"))
topoSetPointSource(mesh, dict),
labels_(dict.get<labelList>("value"))
{}

View File

@ -146,7 +146,8 @@ Foam::nearestToPoint::nearestToPoint
const dictionary& dict
)
:
nearestToPoint(mesh, dict.get<pointField>("points"))
topoSetPointSource(mesh, dict),
points_(dict.get<pointField>("points"))
{}

View File

@ -70,7 +70,7 @@ Foam::pointToPoint::pointToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
names_()
{
// Look for 'sets' or 'set'

View File

@ -102,12 +102,15 @@ void Foam::searchableSurfaceToPoint::combine(topoSet& set, const bool add) const
{
return;
}
const tmp<pointField> tctrs(this->transform(mesh_.points()));
const pointField& ctrs = tctrs();
const searchableSurface& s = *surf_;
// Mesh points within the enclosing volumes
List<volumeType> volTypes;
s.getVolumeType(mesh_.points(), volTypes);
s.getVolumeType(ctrs, volTypes);
const label len = volTypes.size();
for (label id=0; id < len; ++id)
@ -129,7 +132,7 @@ Foam::searchableSurfaceToPoint::searchableSurfaceToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
surf_
(
searchableSurface::New

View File

@ -67,7 +67,8 @@ Foam::topoSetSource::addToUsageTable Foam::sphereToPoint::usage_
void Foam::sphereToPoint::combine(topoSet& set, const bool add) const
{
const pointField& ctrs = mesh_.points();
const tmp<pointField> tctrs(this->transform(mesh_.points()));
const pointField& ctrs = tctrs();
const scalar orad2 = sqr(radius_);
const scalar irad2 = innerRadius_ > 0 ? sqr(innerRadius_) : -1;
@ -109,11 +110,11 @@ Foam::sphereToPoint::sphereToPoint
const dictionary& dict
)
:
sphereToPoint
topoSetPointSource(mesh, dict),
origin_(dict.getCompat<vector>("origin", {{"centre", -1806}})),
radius_(dict.getCheck<scalar>("radius", scalarMinMax::ge(0))),
innerRadius_
(
mesh,
dict.getCompat<vector>("origin", {{"centre", -1806}}),
dict.getCheck<scalar>("radius", scalarMinMax::ge(0)),
dict.getCheckOrDefault<scalar>("innerRadius", 0, scalarMinMax::ge(0))
)
{}

View File

@ -153,7 +153,7 @@ Foam::surfaceToPoint::surfaceToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
surfName_(dict.get<fileName>("file").expand()),
surfType_(dict.getOrDefault<word>("fileType", word::null)),
scale_(dict.getOrDefault<scalar>("scale", -1)),

View File

@ -183,7 +183,7 @@ Foam::zoneToPoint::zoneToPoint
const dictionary& dict
)
:
topoSetPointSource(mesh),
topoSetPointSource(mesh, dict),
zoneMatcher_()
{
// Look for 'zones' and 'zone', but accept 'name' as well

View File

@ -71,7 +71,7 @@ Foam::setToPointZone::setToPointZone
const dictionary& dict
)
:
topoSetPointZoneSource(mesh),
topoSetPointZoneSource(mesh, dict),
setName_(dict.get<word>("set"))
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "polyMesh.H"
#include "bitSet.H"
#include "topoSet.H"
#include "transformField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -252,7 +253,8 @@ Foam::topoSetSource::topoSetSource
)
:
mesh_(mesh),
verbose_(verbose)
verbose_(verbose),
transformPtr_(nullptr)
{}
@ -262,10 +264,14 @@ Foam::topoSetSource::topoSetSource
const dictionary& dict
)
:
topoSetSource(mesh)
{
verbose(dict);
}
mesh_(mesh),
verbose_(dict.getOrDefault<bool>("verbose", true)),
transformPtr_
(
// Uses "solidBodyMotionFunction" if present
solidBodyMotionFunction::NewIfPresent(dict, mesh.time())
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -274,11 +280,28 @@ void Foam::topoSetSource::verbose(const dictionary& dict)
{
bool flag(verbose_);
if (dict.readIfPresent("verbose", flag))
if (dict.readIfPresent("verbose", flag, keyType::LITERAL))
{
verbose_ = flag;
}
}
Foam::tmp<Foam::pointField> Foam::topoSetSource::transform
(
const pointField& points
) const
{
if (transformPtr_)
{
return transformPoints(transformPtr_->transformation(), points);
}
else
{
// No transform - return reference to input points
return points;
}
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,7 +48,7 @@ SourceFiles
#include "autoPtr.H"
#include "Enum.H"
#include "HashTable.H"
#include "runTimeSelectionTables.H"
#include "solidBodyMotionFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -168,6 +168,9 @@ protected:
//- Output verbosity (default: true)
bool verbose_;
//- Optional transformation for geometric data
autoPtr<solidBodyMotionFunction> transformPtr_;
// Protected Member Functions
@ -386,6 +389,14 @@ public:
) const = 0;
//- True if coordinate transform is active.
bool hasTransform() const noexcept { return bool(transformPtr_); }
//- Coordinate transform (optionally) coordinates.
//- Returns reference to input data if no transform is active.
tmp<pointField> transform(const pointField& points) const;
// Housekeeping
//- Deprecated(2018-07) convert string to action