mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support multi-zone motion (#2484)
- select motion for the entire mesh, or restrict to a subset of points based on a specified cellSet or cellZone(s). Can now combine cellSet and cellZone specifications (uses an 'or' combination). - move consistent use of keyType and wordRe to allow regex selection, possibly using zone groups STYLE: remove duplicate code in solidBodyMotionSolver
This commit is contained in:
@ -30,7 +30,6 @@ License
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "motionSolver.H"
|
||||
#include "volFields.H"
|
||||
#include "zoneMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -89,9 +89,8 @@ bool Foam::dynamicMultiMotionSolverFvMesh::init(const bool doInit)
|
||||
);
|
||||
const dictionary& dynamicMeshCoeffs = dynDict.subDict(typeName + "Coeffs");
|
||||
|
||||
zoneIDs_.setSize(dynamicMeshCoeffs.size());
|
||||
motionPtr_.setSize(dynamicMeshCoeffs.size());
|
||||
pointIDs_.setSize(dynamicMeshCoeffs.size());
|
||||
motionPtr_.resize(dynamicMeshCoeffs.size());
|
||||
pointIDs_.resize(dynamicMeshCoeffs.size());
|
||||
|
||||
label zonei = 0;
|
||||
|
||||
@ -103,20 +102,25 @@ bool Foam::dynamicMultiMotionSolverFvMesh::init(const bool doInit)
|
||||
{
|
||||
const dictionary& subDict = dEntry.dict();
|
||||
|
||||
const word zoneName(subDict.get<word>("cellZone"));
|
||||
wordRe cellZoneName;
|
||||
subDict.readEntry("cellZone", cellZoneName);
|
||||
|
||||
zoneIDs_[zonei] = cellZones().findZoneID(zoneName);
|
||||
// Also handles groups, multiple zones (as wordRe match) ...
|
||||
labelList zoneIDs = cellZones().indices(cellZoneName);
|
||||
|
||||
if (zoneIDs_[zonei] == -1)
|
||||
if (zoneIDs.empty())
|
||||
{
|
||||
FatalIOErrorInFunction(dynamicMeshCoeffs)
|
||||
<< "Cannot find cellZone named " << zoneName
|
||||
<< ". Valid zones are " << cellZones().names()
|
||||
<< "No matching cellZones: " << cellZoneName << nl
|
||||
<< " Valid zones : "
|
||||
<< flatOutput(cellZones().names()) << nl
|
||||
<< " Valid groups: "
|
||||
<< flatOutput(cellZones().groupNames())
|
||||
<< nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
IOobject io(dynDict);
|
||||
io.readOpt(IOobject::NO_READ);
|
||||
IOobject io(dynDict, IOobject::NO_READ, IOobject::NO_WRITE);
|
||||
|
||||
motionPtr_.set
|
||||
(
|
||||
@ -129,16 +133,19 @@ bool Foam::dynamicMultiMotionSolverFvMesh::init(const bool doInit)
|
||||
);
|
||||
|
||||
|
||||
// Collect points of cell zone.
|
||||
// Markup points associated with cell zone(s)
|
||||
|
||||
movePts.reset();
|
||||
movePts.resize(nPoints());
|
||||
|
||||
for (const label celli : cellZones()[zoneIDs_[zonei]])
|
||||
for (const label zoneID : zoneIDs)
|
||||
{
|
||||
for (const label facei : cells()[celli])
|
||||
for (const label celli : cellZones()[zoneID])
|
||||
{
|
||||
movePts.set(faces()[facei]); // set multiple points
|
||||
for (const label facei : cells()[celli])
|
||||
{
|
||||
movePts.set(faces()[facei]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,14 +159,14 @@ bool Foam::dynamicMultiMotionSolverFvMesh::init(const bool doInit)
|
||||
Info<< "Applying motionSolver " << motionPtr_[zonei].type()
|
||||
<< " to "
|
||||
<< returnReduce(pointIDs_[zonei].size(), sumOp<label>())
|
||||
<< " points of cellZone " << zoneName << endl;
|
||||
<< " points of cellZone " << cellZoneName << endl;
|
||||
|
||||
++zonei;
|
||||
}
|
||||
}
|
||||
zoneIDs_.setSize(zonei);
|
||||
motionPtr_.setSize(zonei);
|
||||
pointIDs_.setSize(zonei);
|
||||
|
||||
motionPtr_.resize(zonei);
|
||||
pointIDs_.resize(zonei);
|
||||
|
||||
// Assume changed ...
|
||||
return true;
|
||||
@ -174,10 +181,11 @@ bool Foam::dynamicMultiMotionSolverFvMesh::update()
|
||||
|
||||
forAll(motionPtr_, zonei)
|
||||
{
|
||||
tmp<pointField> tnewPoints(motionPtr_[zonei].newPoints());
|
||||
const pointField& newPoints = tnewPoints();
|
||||
const labelList& zonePoints = pointIDs_[zonei];
|
||||
|
||||
for (const label pointi : pointIDs_[zonei])
|
||||
const pointField newPoints(motionPtr_[zonei].newPoints());
|
||||
|
||||
for (const label pointi : zonePoints)
|
||||
{
|
||||
transformedPts[pointi] = newPoints[pointi];
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dynamicMultiMotionSolverFvMesh_H
|
||||
#define dynamicMultiMotionSolverFvMesh_H
|
||||
#ifndef Foam_dynamicMultiMotionSolverFvMesh_H
|
||||
#define Foam_dynamicMultiMotionSolverFvMesh_H
|
||||
|
||||
#include "dynamicFvMesh.H"
|
||||
#include "motionSolver.H"
|
||||
@ -54,15 +54,12 @@ class dynamicMultiMotionSolverFvMesh
|
||||
:
|
||||
public dynamicFvMesh
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- The motion control function
|
||||
PtrList<motionSolver> motionPtr_;
|
||||
|
||||
//- Specified cellZones
|
||||
labelList zoneIDs_;
|
||||
|
||||
//- Points to move per cellZone
|
||||
//- Points to move, per motion solver
|
||||
labelListList pointIDs_;
|
||||
|
||||
|
||||
@ -95,7 +92,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
~dynamicMultiMotionSolverFvMesh() = default;
|
||||
virtual ~dynamicMultiMotionSolverFvMesh() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -37,8 +37,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef displacementMotionSolver_H
|
||||
#define displacementMotionSolver_H
|
||||
#ifndef Foam_displacementMotionSolver_H
|
||||
#define Foam_displacementMotionSolver_H
|
||||
|
||||
#include "points0MotionSolver.H"
|
||||
|
||||
@ -57,15 +57,13 @@ class displacementMotionSolver
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Point motion field
|
||||
mutable pointVectorField pointDisplacement_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
// Protected Member Functions
|
||||
|
||||
//- No copy construct
|
||||
displacementMotionSolver(const displacementMotionSolver&) = delete;
|
||||
@ -139,13 +137,13 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return reference to the point motion displacement field
|
||||
pointVectorField& pointDisplacement()
|
||||
pointVectorField& pointDisplacement() noexcept
|
||||
{
|
||||
return pointDisplacement_;
|
||||
}
|
||||
|
||||
//- Return const reference to the point motion displacement field
|
||||
const pointVectorField& pointDisplacement() const
|
||||
const pointVectorField& pointDisplacement() const noexcept
|
||||
{
|
||||
return pointDisplacement_;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,9 +28,10 @@ License
|
||||
|
||||
#include "zoneMotion.H"
|
||||
#include "syncTools.H"
|
||||
#include "cellZoneMesh.H"
|
||||
#include "bitSet.H"
|
||||
#include "cellSet.H"
|
||||
#include "boolList.H"
|
||||
#include "cellZoneMesh.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,104 +42,102 @@ Foam::zoneMotion::zoneMotion
|
||||
)
|
||||
:
|
||||
pointIDs_(),
|
||||
moveAllCells_(false)
|
||||
moveAllCells_(true)
|
||||
{
|
||||
word cellZoneName =
|
||||
dict.getOrDefault<word>("cellZone", "none");
|
||||
// Specified cellSet?
|
||||
word cellSetName;
|
||||
|
||||
word cellSetName =
|
||||
dict.getOrDefault<word>("cellSet", "none");
|
||||
|
||||
if ((cellZoneName != "none") && (cellSetName != "none"))
|
||||
if
|
||||
(
|
||||
dict.readIfPresent("cellSet", cellSetName)
|
||||
&& cellSetName == "none" // Compat: ignore 'none' placeholder
|
||||
)
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Either cellZone OR cellSet can be supplied, but not both. "
|
||||
<< "If neither is supplied, all cells will be included"
|
||||
<< exit(FatalIOError);
|
||||
cellSetName.clear();
|
||||
}
|
||||
|
||||
labelList cellIDs;
|
||||
if (cellZoneName != "none")
|
||||
if (!cellSetName.empty())
|
||||
{
|
||||
Info<< "Applying solid body motion to cellZone " << cellZoneName
|
||||
<< endl;
|
||||
Info<< "Applying motion to cellSet: " << cellSetName << endl;
|
||||
|
||||
label zoneID = mesh.cellZones().findZoneID(cellZoneName);
|
||||
cellIDs = cellSet(mesh, cellSetName).toc();
|
||||
}
|
||||
|
||||
if (zoneID == -1)
|
||||
|
||||
// Specified cellZone(s) ?
|
||||
wordRe cellZoneName;
|
||||
|
||||
if
|
||||
(
|
||||
dict.readIfPresent("cellZone", cellZoneName)
|
||||
&& cellZoneName == "none" // Compat: ignore 'none' placeholder
|
||||
)
|
||||
{
|
||||
cellZoneName.clear();
|
||||
}
|
||||
|
||||
labelList zoneIDs;
|
||||
if (!cellZoneName.empty())
|
||||
{
|
||||
Info<< "Applying motion to cellZone: " << cellZoneName << endl;
|
||||
|
||||
// Also handles groups, multiple zones (as wordRe match) ...
|
||||
zoneIDs = mesh.cellZones().indices(cellZoneName);
|
||||
|
||||
if (zoneIDs.empty())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find cellZone " << cellZoneName
|
||||
<< ". Valid cellZones are:"
|
||||
<< mesh.cellZones().names()
|
||||
<< exit(FatalError);
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "No matching cellZones: " << cellZoneName << nl
|
||||
<< " Valid zones : "
|
||||
<< flatOutput(mesh.cellZones().names()) << nl
|
||||
<< " Valid groups: "
|
||||
<< flatOutput(mesh.cellZones().groupNames())
|
||||
<< nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
cellIDs = mesh.cellZones()[zoneID];
|
||||
}
|
||||
|
||||
if (cellSetName != "none")
|
||||
if (!cellSetName.empty() || !cellZoneName.empty())
|
||||
{
|
||||
Info<< "Applying solid body motion to cellSet " << cellSetName
|
||||
<< endl;
|
||||
bitSet movePts(mesh.nPoints());
|
||||
|
||||
cellSet set(mesh, cellSetName);
|
||||
|
||||
cellIDs = set.toc();
|
||||
}
|
||||
|
||||
label nCells = returnReduce(cellIDs.size(), sumOp<label>());
|
||||
moveAllCells_ = (nCells == 0);
|
||||
|
||||
if (moveAllCells_)
|
||||
{
|
||||
Info<< "Applying solid body motion to entire mesh" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolList movePts(mesh.nPoints(), false);
|
||||
|
||||
for (label celli : cellIDs)
|
||||
// Markup points associated with cell zone(s)
|
||||
for (const label zoneID : zoneIDs)
|
||||
{
|
||||
const cell& c = mesh.cells()[celli];
|
||||
for (label cellFacei : c)
|
||||
for (const label celli : mesh.cellZones()[zoneID])
|
||||
{
|
||||
const face& f = mesh.faces()[cellFacei];
|
||||
for (label pointi : f)
|
||||
for (const label facei : mesh.cells()[celli])
|
||||
{
|
||||
movePts[pointi] = true;
|
||||
movePts.set(mesh.faces()[facei]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncTools::syncPointList(mesh, movePts, orEqOp<bool>(), false);
|
||||
|
||||
DynamicList<label> ptIDs(mesh.nPoints());
|
||||
forAll(movePts, i)
|
||||
// Markup points associated with cellSet
|
||||
for (const label celli : cellIDs)
|
||||
{
|
||||
if (movePts[i])
|
||||
for (const label facei : mesh.cells()[celli])
|
||||
{
|
||||
ptIDs.append(i);
|
||||
movePts.set(mesh.faces()[facei]);
|
||||
}
|
||||
}
|
||||
|
||||
pointIDs_.transfer(ptIDs);
|
||||
syncTools::syncPointList(mesh, movePts, orEqOp<unsigned int>(), 0u);
|
||||
|
||||
pointIDs_ = movePts.sortedToc();
|
||||
}
|
||||
|
||||
|
||||
// No cell points selected (as set or zones) => move all points
|
||||
|
||||
moveAllCells_ = returnReduce(pointIDs_.empty(), andOp<bool>());
|
||||
|
||||
if (moveAllCells_)
|
||||
{
|
||||
Info<< "Applying motion to entire mesh" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Members * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::labelList& Foam::zoneMotion::pointIDs() const
|
||||
{
|
||||
return pointIDs_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::zoneMotion::moveAllCells() const
|
||||
{
|
||||
return moveAllCells_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,19 +27,33 @@ Class
|
||||
Foam::zoneMotion
|
||||
|
||||
Description
|
||||
Intermediate class for handling "zonified" motion.
|
||||
Can select motion for the entire mesh, or restrict to a subset
|
||||
of points based on a specified cellSet or cellZone(s).
|
||||
|
||||
Usage
|
||||
\verbatim
|
||||
{
|
||||
cellSet <name>;
|
||||
|
||||
// and/or
|
||||
cellZone <name or regex>;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The cellZone can be specified as a wordRe and will select by name
|
||||
or group. The special name "none" is treated as ignored.
|
||||
|
||||
SourceFiles
|
||||
zoneMotion.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef zoneMotion_H
|
||||
#define zoneMotion_H
|
||||
#ifndef Foam_zoneMotion_H
|
||||
#define Foam_zoneMotion_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "dictionary.H"
|
||||
#include "wordRes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -47,6 +61,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -57,43 +72,38 @@ class zoneMotion
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Points to move when cell zone is supplied
|
||||
//- Points to move when cell zones or sets are supplied
|
||||
labelList pointIDs_;
|
||||
|
||||
//- Flag to indicate whether all cells should move
|
||||
bool moveAllCells_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
zoneMotion(const zoneMotion&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const zoneMotion&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return pointsID
|
||||
const labelList& pointIDs() const;
|
||||
|
||||
//- Return flag
|
||||
bool moveAllCells() const;
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
zoneMotion
|
||||
(
|
||||
const dictionary&,
|
||||
const polyMesh&
|
||||
);
|
||||
zoneMotion(const dictionary& dict, const polyMesh& mesh);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~zoneMotion() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The point ids (for cell set/zone subset)
|
||||
const labelList& pointIDs() const noexcept
|
||||
{
|
||||
return pointIDs_;
|
||||
}
|
||||
|
||||
//- Move all cells?
|
||||
bool moveAllCells() const noexcept
|
||||
{
|
||||
return moveAllCells_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef points0MotionSolver_H
|
||||
#define points0MotionSolver_H
|
||||
#ifndef Foam_points0MotionSolver_H
|
||||
#define Foam_points0MotionSolver_H
|
||||
|
||||
#include "motionSolver.H"
|
||||
#include "pointFields.H"
|
||||
@ -49,6 +49,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -62,15 +63,13 @@ class points0MotionSolver
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Data
|
||||
|
||||
//- Starting points
|
||||
pointIOField points0_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
// Protected Member Functions
|
||||
|
||||
//- No copy construct
|
||||
points0MotionSolver(const points0MotionSolver&) = delete;
|
||||
@ -114,14 +113,14 @@ public:
|
||||
//- Return IO object for points0
|
||||
static IOobject points0IO(const polyMesh& mesh);
|
||||
|
||||
//- Return reference to the reference field
|
||||
pointField& points0()
|
||||
//- Return reference to the reference ('0') pointField
|
||||
pointField& points0() noexcept
|
||||
{
|
||||
return points0_;
|
||||
}
|
||||
|
||||
//- Return reference to the reference field
|
||||
const pointField& points0() const
|
||||
//- Return reference to the reference ('0') pointField
|
||||
const pointField& points0() const noexcept
|
||||
{
|
||||
return points0_;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,7 +30,7 @@ License
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "transformField.H"
|
||||
#include "cellZoneMesh.H"
|
||||
#include "boolList.H"
|
||||
#include "bitSet.H"
|
||||
#include "syncTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -57,26 +57,33 @@ Foam::multiSolidBodyMotionSolver::multiSolidBodyMotionSolver
|
||||
:
|
||||
points0MotionSolver(mesh, dict, typeName)
|
||||
{
|
||||
zoneIDs_.setSize(coeffDict().size());
|
||||
SBMFs_.setSize(coeffDict().size());
|
||||
pointIDs_.setSize(coeffDict().size());
|
||||
SBMFs_.resize(coeffDict().size());
|
||||
pointIDs_.resize(coeffDict().size());
|
||||
|
||||
label zonei = 0;
|
||||
|
||||
bitSet movePts;
|
||||
|
||||
for (const entry& dEntry : coeffDict())
|
||||
{
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
const word& zoneName = dEntry.keyword();
|
||||
const keyType& cellZoneName = dEntry.keyword();
|
||||
|
||||
const dictionary& subDict = dEntry.dict();
|
||||
|
||||
zoneIDs_[zonei] = mesh.cellZones().findZoneID(zoneName);
|
||||
// Also handles groups, multiple zones (as wordRe match) ...
|
||||
labelList zoneIDs = mesh.cellZones().indices(cellZoneName);
|
||||
|
||||
if (zoneIDs_[zonei] == -1)
|
||||
if (zoneIDs.empty())
|
||||
{
|
||||
FatalIOErrorInFunction(coeffDict())
|
||||
<< "Cannot find cellZone named " << zoneName
|
||||
<< ". Valid zones are "
|
||||
<< flatOutput(mesh.cellZones().names())
|
||||
<< "No matching cellZones: " << cellZoneName << nl
|
||||
<< " Valid zones : "
|
||||
<< flatOutput(mesh.cellZones().names()) << nl
|
||||
<< " Valid groups: "
|
||||
<< flatOutput(mesh.cellZones().groupNames())
|
||||
<< nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
@ -86,50 +93,41 @@ Foam::multiSolidBodyMotionSolver::multiSolidBodyMotionSolver
|
||||
solidBodyMotionFunction::New(subDict, mesh.time())
|
||||
);
|
||||
|
||||
// Collect points of cell zone.
|
||||
const cellZone& cz = mesh.cellZones()[zoneIDs_[zonei]];
|
||||
|
||||
boolList movePts(mesh.nPoints(), false);
|
||||
// Markup points associated with cell zone(s)
|
||||
|
||||
forAll(cz, i)
|
||||
movePts.reset();
|
||||
movePts.resize(mesh.nPoints());
|
||||
|
||||
for (const label zoneID : zoneIDs)
|
||||
{
|
||||
label celli = cz[i];
|
||||
const cell& c = mesh.cells()[celli];
|
||||
forAll(c, j)
|
||||
for (const label celli : mesh.cellZones()[zoneID])
|
||||
{
|
||||
const face& f = mesh.faces()[c[j]];
|
||||
forAll(f, k)
|
||||
for (const label facei : mesh.cells()[celli])
|
||||
{
|
||||
label pointi = f[k];
|
||||
movePts[pointi] = true;
|
||||
movePts.set(mesh.faces()[facei]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncTools::syncPointList(mesh, movePts, orEqOp<bool>(), false);
|
||||
syncTools::syncPointList
|
||||
(
|
||||
mesh, movePts, orEqOp<unsigned int>(), 0u
|
||||
);
|
||||
|
||||
DynamicList<label> ptIDs(mesh.nPoints());
|
||||
forAll(movePts, i)
|
||||
{
|
||||
if (movePts[i])
|
||||
{
|
||||
ptIDs.append(i);
|
||||
}
|
||||
}
|
||||
|
||||
pointIDs_[zonei].transfer(ptIDs);
|
||||
pointIDs_[zonei] = movePts.sortedToc();
|
||||
|
||||
Info<< "Applying solid body motion " << SBMFs_[zonei].type()
|
||||
<< " to "
|
||||
<< returnReduce(pointIDs_[zonei].size(), sumOp<label>())
|
||||
<< " points of cellZone " << zoneName << endl;
|
||||
<< " points of cellZone " << cellZoneName << endl;
|
||||
|
||||
zonei++;
|
||||
++zonei;
|
||||
}
|
||||
}
|
||||
zoneIDs_.setSize(zonei);
|
||||
SBMFs_.setSize(zonei);
|
||||
pointIDs_.setSize(zonei);
|
||||
|
||||
SBMFs_.resize(zonei);
|
||||
pointIDs_.resize(zonei);
|
||||
}
|
||||
|
||||
|
||||
@ -137,16 +135,16 @@ Foam::multiSolidBodyMotionSolver::multiSolidBodyMotionSolver
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::multiSolidBodyMotionSolver::curPoints() const
|
||||
{
|
||||
tmp<pointField> ttransformedPts(new pointField(mesh().points()));
|
||||
pointField& transformedPts = ttransformedPts.ref();
|
||||
auto ttransformedPts = tmp<pointField>::New(mesh().points());
|
||||
auto& transformedPts = ttransformedPts.ref();
|
||||
|
||||
forAll(zoneIDs_, i)
|
||||
forAll(SBMFs_, zonei)
|
||||
{
|
||||
const labelList& zonePoints = pointIDs_[i];
|
||||
const labelList& zonePoints = pointIDs_[zonei];
|
||||
|
||||
UIndirectList<point>(transformedPts, zonePoints) = transformPoints
|
||||
(
|
||||
SBMFs_[i].transformation(),
|
||||
SBMFs_[zonei].transformation(),
|
||||
pointField(points0_, zonePoints)
|
||||
);
|
||||
}
|
||||
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef multiSolidBodyMotionSolver_H
|
||||
#define multiSolidBodyMotionSolver_H
|
||||
#ifndef Foam_multiSolidBodyMotionSolver_H
|
||||
#define Foam_multiSolidBodyMotionSolver_H
|
||||
|
||||
#include "points0MotionSolver.H"
|
||||
#include "solidBodyMotionFunction.H"
|
||||
@ -54,14 +54,11 @@ class multiSolidBodyMotionSolver
|
||||
:
|
||||
public points0MotionSolver
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- The motion control function
|
||||
PtrList<solidBodyMotionFunction> SBMFs_;
|
||||
|
||||
//- Specified cellZones
|
||||
labelList zoneIDs_;
|
||||
|
||||
//- Points to move per cellZone
|
||||
labelListList pointIDs_;
|
||||
|
||||
@ -86,8 +83,8 @@ public:
|
||||
//- Construct from mesh and dictionary
|
||||
multiSolidBodyMotionSolver
|
||||
(
|
||||
const polyMesh&,
|
||||
const IOdictionary&
|
||||
const polyMesh& mesh,
|
||||
const IOdictionary& dict
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -29,10 +29,6 @@ License
|
||||
#include "solidBodyMotionSolver.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "transformField.H"
|
||||
#include "cellZoneMesh.H"
|
||||
#include "cellSet.H"
|
||||
#include "boolList.H"
|
||||
#include "syncTools.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -57,101 +53,15 @@ Foam::solidBodyMotionSolver::solidBodyMotionSolver
|
||||
)
|
||||
:
|
||||
points0MotionSolver(mesh, dict, typeName),
|
||||
SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
|
||||
pointIDs_(),
|
||||
moveAllCells_(false)
|
||||
{
|
||||
word cellZoneName =
|
||||
coeffDict().getOrDefault<word>("cellZone", "none");
|
||||
|
||||
word cellSetName =
|
||||
coeffDict().getOrDefault<word>("cellSet", "none");
|
||||
|
||||
if ((cellZoneName != "none") && (cellSetName != "none"))
|
||||
{
|
||||
FatalIOErrorInFunction(coeffDict())
|
||||
<< "Either cellZone OR cellSet can be supplied, but not both. "
|
||||
<< "If neither is supplied, all cells will be included"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
labelList cellIDs;
|
||||
if (cellZoneName != "none")
|
||||
{
|
||||
Info<< "Applying solid body motion to cellZone " << cellZoneName
|
||||
<< endl;
|
||||
|
||||
label zoneID = mesh.cellZones().findZoneID(cellZoneName);
|
||||
|
||||
if (zoneID == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find cellZone " << cellZoneName
|
||||
<< ". Valid cellZones are:"
|
||||
<< mesh.cellZones().names()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
cellIDs = mesh.cellZones()[zoneID];
|
||||
}
|
||||
|
||||
if (cellSetName != "none")
|
||||
{
|
||||
Info<< "Applying solid body motion to cellSet " << cellSetName
|
||||
<< endl;
|
||||
|
||||
cellSet set(mesh, cellSetName);
|
||||
|
||||
cellIDs = set.toc();
|
||||
}
|
||||
|
||||
label nCells = returnReduce(cellIDs.size(), sumOp<label>());
|
||||
moveAllCells_ = nCells == 0;
|
||||
|
||||
if (moveAllCells_)
|
||||
{
|
||||
Info<< "Applying solid body motion to entire mesh" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// collect point IDs of points in cell zone
|
||||
|
||||
boolList movePts(mesh.nPoints(), false);
|
||||
|
||||
for (label celli : cellIDs)
|
||||
{
|
||||
const cell& c = mesh.cells()[celli];
|
||||
for (label cellFacei : c)
|
||||
{
|
||||
const face& f = mesh.faces()[cellFacei];
|
||||
for (label pointi : f)
|
||||
{
|
||||
movePts[pointi] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncTools::syncPointList(mesh, movePts, orEqOp<bool>(), false);
|
||||
|
||||
DynamicList<label> ptIDs(mesh.nPoints());
|
||||
forAll(movePts, i)
|
||||
{
|
||||
if (movePts[i])
|
||||
{
|
||||
ptIDs.append(i);
|
||||
}
|
||||
}
|
||||
|
||||
pointIDs_.transfer(ptIDs);
|
||||
}
|
||||
}
|
||||
SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time()))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::solidBodyMotionSolver::curPoints() const
|
||||
{
|
||||
if (moveAllCells_)
|
||||
if (moveAllCells())
|
||||
{
|
||||
return transformPoints(SBMFPtr_().transformation(), points0_);
|
||||
}
|
||||
@ -160,10 +70,10 @@ Foam::tmp<Foam::pointField> Foam::solidBodyMotionSolver::curPoints() const
|
||||
auto ttransformedPts = tmp<pointField>::New(mesh().points());
|
||||
pointField& transformedPts = ttransformedPts.ref();
|
||||
|
||||
UIndirectList<point>(transformedPts, pointIDs_) = transformPoints
|
||||
UIndirectList<point>(transformedPts, pointIDs()) = transformPoints
|
||||
(
|
||||
SBMFPtr_().transformation(),
|
||||
pointField(points0_, pointIDs_)
|
||||
pointField(points0_, pointIDs())
|
||||
);
|
||||
|
||||
return ttransformedPts;
|
||||
|
||||
@ -35,8 +35,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef solidBodyMotionSolver_H
|
||||
#define solidBodyMotionSolver_H
|
||||
#ifndef Foam_solidBodyMotionSolver_H
|
||||
#define Foam_solidBodyMotionSolver_H
|
||||
|
||||
#include "points0MotionSolver.H"
|
||||
#include "solidBodyMotionFunction.H"
|
||||
@ -54,17 +54,11 @@ class solidBodyMotionSolver
|
||||
:
|
||||
public points0MotionSolver
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- The motion control function
|
||||
autoPtr<solidBodyMotionFunction> SBMFPtr_;
|
||||
|
||||
//- Points to move when cell zone is supplied
|
||||
labelList pointIDs_;
|
||||
|
||||
//- Flag to indicate whether all cells should move
|
||||
bool moveAllCells_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -86,8 +80,8 @@ public:
|
||||
//- Construct from mesh and dictionary
|
||||
solidBodyMotionSolver
|
||||
(
|
||||
const polyMesh&,
|
||||
const IOdictionary&
|
||||
const polyMesh& mesh,
|
||||
const IOdictionary& dict
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user