mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: solidBodMotionFvMesh - add support for specifying cells by cellSet
This commit is contained in:
@ -28,6 +28,7 @@ License
|
|||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "transformField.H"
|
#include "transformField.H"
|
||||||
#include "cellZoneMesh.H"
|
#include "cellZoneMesh.H"
|
||||||
|
#include "cellSet.H"
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
#include "syncTools.H"
|
#include "syncTools.H"
|
||||||
|
|
||||||
@ -74,8 +75,8 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
zoneID_(-1),
|
pointIDs_(),
|
||||||
pointIDs_()
|
UName_(dynamicMeshCoeffs_.lookupOrDefault<word>("UName", "U"))
|
||||||
{
|
{
|
||||||
if (undisplacedPoints_.size() != nPoints())
|
if (undisplacedPoints_.size() != nPoints())
|
||||||
{
|
{
|
||||||
@ -92,14 +93,31 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
|
|||||||
word cellZoneName =
|
word cellZoneName =
|
||||||
dynamicMeshCoeffs_.lookupOrDefault<word>("cellZone", "none");
|
dynamicMeshCoeffs_.lookupOrDefault<word>("cellZone", "none");
|
||||||
|
|
||||||
|
word cellSetName =
|
||||||
|
dynamicMeshCoeffs_.lookupOrDefault<word>("cellSet", "none");
|
||||||
|
|
||||||
|
if ((cellZoneName != "none") && (cellSetName != "none"))
|
||||||
|
{
|
||||||
|
FatalIOErrorIn
|
||||||
|
(
|
||||||
|
"solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject&)",
|
||||||
|
dynamicMeshCoeffs_
|
||||||
|
)
|
||||||
|
<< "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")
|
if (cellZoneName != "none")
|
||||||
{
|
{
|
||||||
Info<< "Applying solid body motion to cellZone " << cellZoneName
|
Info<< "Applying solid body motion to cellZone " << cellZoneName
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
zoneID_ = cellZones().findZoneID(cellZoneName);
|
label zoneID = cellZones().findZoneID(cellZoneName);
|
||||||
|
|
||||||
if (zoneID_ == -1)
|
if (zoneID == -1)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -111,16 +129,28 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cellZone& cz = cellZones()[zoneID_];
|
cellIDs = cellZones()[zoneID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cellSetName != "none")
|
||||||
|
{
|
||||||
|
Info<< "Applying solid body motion to cellSet " << cellSetName
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
cellSet set(*this, cellSetName);
|
||||||
|
|
||||||
|
cellIDs = set.toc();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cellIDs.size())
|
||||||
|
{
|
||||||
// collect point IDs of points in cell zone
|
// collect point IDs of points in cell zone
|
||||||
|
|
||||||
boolList movePts(nPoints(), false);
|
boolList movePts(nPoints(), false);
|
||||||
|
|
||||||
forAll(cz, i)
|
forAll(cellIDs, i)
|
||||||
{
|
{
|
||||||
label cellI = cz[i];
|
label cellI = cellIDs[i];
|
||||||
const cell& c = cells()[cellI];
|
const cell& c = cells()[cellI];
|
||||||
forAll(c, j)
|
forAll(c, j)
|
||||||
{
|
{
|
||||||
@ -165,7 +195,7 @@ bool Foam::solidBodyMotionFvMesh::update()
|
|||||||
{
|
{
|
||||||
static bool hasWarned = false;
|
static bool hasWarned = false;
|
||||||
|
|
||||||
if (zoneID_ != -1)
|
if (pointIDs_.size())
|
||||||
{
|
{
|
||||||
pointField transformedPts(undisplacedPoints_);
|
pointField transformedPts(undisplacedPoints_);
|
||||||
|
|
||||||
@ -191,18 +221,20 @@ bool Foam::solidBodyMotionFvMesh::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (foundObject<volVectorField>("U"))
|
if (foundObject<volVectorField>(UName_))
|
||||||
{
|
{
|
||||||
const_cast<volVectorField&>(lookupObject<volVectorField>("U"))
|
const volVectorField& U = lookupObject<volVectorField>(UName_);
|
||||||
.correctBoundaryConditions();
|
|
||||||
|
const_cast<volVectorField&>(U).correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
else if (!hasWarned)
|
else if (!hasWarned)
|
||||||
{
|
{
|
||||||
hasWarned = true;
|
hasWarned = true;
|
||||||
|
|
||||||
WarningIn("solidBodyMotionFvMesh::update()")
|
WarningIn("solidBodyMotionFvMesh::update()")
|
||||||
<< "Did not find volVectorField U."
|
<< "Did not find volVectorField " << UName_
|
||||||
<< " Not updating U boundary conditions." << endl;
|
<< " Not updating " << UName_ << "boundary conditions."
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -65,12 +65,12 @@ class solidBodyMotionFvMesh
|
|||||||
//- The reference points which are transformed
|
//- The reference points which are transformed
|
||||||
pointIOField undisplacedPoints_;
|
pointIOField undisplacedPoints_;
|
||||||
|
|
||||||
//- Specified cellZone or -1 for whole-body
|
|
||||||
label zoneID_;
|
|
||||||
|
|
||||||
//- Points to move when cell zone is supplied
|
//- Points to move when cell zone is supplied
|
||||||
labelList pointIDs_;
|
labelList pointIDs_;
|
||||||
|
|
||||||
|
//- Name of velocity field
|
||||||
|
word UName_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user