Skip to content
Snippets Groups Projects
Commit 7ee82c56 authored by andy's avatar andy Committed by Andrew Heather
Browse files

ENH: solidBodMotionFvMesh - add support for specifying cells by cellSet

parent 17a85930
Branches
Tags
No related merge requests found
......@@ -28,6 +28,7 @@ License
#include "volFields.H"
#include "transformField.H"
#include "cellZoneMesh.H"
#include "cellSet.H"
#include "boolList.H"
#include "syncTools.H"
......@@ -74,8 +75,8 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
false
)
),
zoneID_(-1),
pointIDs_()
pointIDs_(),
UName_(dynamicMeshCoeffs_.lookupOrDefault<word>("UName", "U"))
{
if (undisplacedPoints_.size() != nPoints())
{
......@@ -92,14 +93,31 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
word cellZoneName =
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")
{
Info<< "Applying solid body motion to cellZone " << cellZoneName
<< endl;
zoneID_ = cellZones().findZoneID(cellZoneName);
label zoneID = cellZones().findZoneID(cellZoneName);
if (zoneID_ == -1)
if (zoneID == -1)
{
FatalErrorIn
(
......@@ -111,16 +129,28 @@ Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
<< 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
boolList movePts(nPoints(), false);
forAll(cz, i)
forAll(cellIDs, i)
{
label cellI = cz[i];
label cellI = cellIDs[i];
const cell& c = cells()[cellI];
forAll(c, j)
{
......@@ -165,7 +195,7 @@ bool Foam::solidBodyMotionFvMesh::update()
{
static bool hasWarned = false;
if (zoneID_ != -1)
if (pointIDs_.size())
{
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"))
.correctBoundaryConditions();
const volVectorField& U = lookupObject<volVectorField>(UName_);
const_cast<volVectorField&>(U).correctBoundaryConditions();
}
else if (!hasWarned)
{
hasWarned = true;
WarningIn("solidBodyMotionFvMesh::update()")
<< "Did not find volVectorField U."
<< " Not updating U boundary conditions." << endl;
<< "Did not find volVectorField " << UName_
<< " Not updating " << UName_ << "boundary conditions."
<< endl;
}
return true;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -65,12 +65,12 @@ class solidBodyMotionFvMesh
//- The reference points which are transformed
pointIOField undisplacedPoints_;
//- Specified cellZone or -1 for whole-body
label zoneID_;
//- Points to move when cell zone is supplied
labelList pointIDs_;
//- Name of velocity field
word UName_;
// Private Member Functions
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment