Hot-fix: moving cone topo

This commit is contained in:
Hrvoje Jasak 2011-08-24 23:37:36 +01:00
parent e6e0e33518
commit 05a22e5307
7 changed files with 531 additions and 665 deletions

View file

@ -3,7 +3,7 @@ topoChangerFvMesh/topoChangerFvMesh.C
linearValveFvMesh/linearValveFvMesh.C
attachDetachFvMesh/attachDetachFvMesh.C
linearValveLayersFvMesh/linearValveLayersFvMesh.C
movingConeTopoFvMesh/movingConeTopoFvMesh.C
movingBodyTopoFvMesh/movingBodyTopoFvMesh.C
mixerFvMesh/mixerFvMesh.C
multiMixerFvMesh/mixerRotor.C
multiMixerFvMesh/multiMixerFvMesh.C

View file

@ -3,6 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/meshMotion/solidBodyMotion/lnInclude \
-I$(LIB_SRC)/dynamicMesh/meshMotion/tetDecompositionMotionSolver/lnInclude \
-I$(LIB_SRC)/tetDecompositionFiniteElement/lnInclude \
$(WM_DECOMP_INC)
@ -12,4 +13,5 @@ LIB_LIBS = \
-ldynamicFvMesh \
-ldynamicMesh \
-lmeshTools \
-lsolidBodyMotion \
$(WM_DECOMP_LIBS)

View file

@ -46,50 +46,35 @@ namespace Foam
void Foam::mixerFvMesh::addZonesAndModifiers()
{
// Add zones and modifiers for motion action
if
(
pointZones().size() > 0
|| faceZones().size() > 0
|| cellZones().size() > 0
)
if (cellZones().size() > 0)
{
Info<< "void mixerFvMesh::addZonesAndModifiers() : "
<< "Zones and modifiers already present. Skipping."
<< endl;
// Check definition of the modifier
if
(
pointZones().size() > 0
|| faceZones().size() > 0
)
{
if (topoChanger_.size() == 0)
{
FatalErrorIn
(
"void mixerFvMesh::addZonesAndModifiers()"
) << "Mesh modifiers not read properly"
) << "Mesh modifiers not read properly. "
<< "pointZones = " << pointZones().size()
<< " faceZones = " << faceZones().size()
<< abort(FatalError);
}
}
return;
}
Info<< "Time = " << time().timeName() << endl
<< "Adding zones and modifiers to the mesh" << endl;
// Add zones
List<pointZone*> pz(1);
// Add an empty zone for cut points
pz[0] = new pointZone
(
"cutPointZone",
labelList(0),
0,
pointZones()
);
// Do face zones for slider
List<faceZone*> fz(3);
// Find patches and check sizes
// Moving slider
const word movingSliderName(dict_.subDict("slider").lookup("moving"));
@ -114,7 +99,39 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
}
const polyPatch& movingSlider = boundaryMesh()[movingSliderIndex];
const polyPatch& staticSlider = boundaryMesh()[staticSliderIndex];
List<pointZone*> pz;
List<faceZone*> fz;
bool addSlider = false;
if (movingSlider.size() > 0 && staticSlider.size() > 0)
{
addSlider = true;
pz.setSize(1);
fz.setSize(3);
Info<< "Time = " << time().timeName() << endl
<< "Adding zones and modifiers to the mesh" << endl;
// Add zones
// Add an empty zone for cut points
pz[0] = new pointZone
(
"cutPointZone",
labelList(0),
0,
pointZones()
);
// Do face zones for slider
// Moving slider
labelList isf(movingSlider.size());
forAll (isf, i)
@ -132,8 +149,6 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
);
// Static slider
const polyPatch& staticSlider = boundaryMesh()[staticSliderIndex];
labelList osf(staticSlider.size());
forAll (osf, i)
@ -159,6 +174,9 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
2,
faceZones()
);
}
// Add cell zone even if slider does not exist
List<cellZone*> cz(1);
@ -194,9 +212,12 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
Info << "Adding point, face and cell zones" << endl;
addZones(pz, fz, cz);
if (addSlider)
{
// Add a topology modifier
Info << "Adding topology modifiers" << endl;
topoChanger_.setSize(1);
topoChanger_.set
(
0,
@ -216,6 +237,7 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
intersection::VISIBLE // Projection algorithm
)
);
}
// Write mesh and modifiers
topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
@ -226,7 +248,16 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
bool Foam::mixerFvMesh::attached() const
{
return refCast<const slidingInterface>(topoChanger_[0]).attached();
bool result = false;
if (topoChanger_.size() > 0)
{
result = refCast<const slidingInterface>(topoChanger_[0]).attached();
}
reduce(result, orOp<bool>());
return result;
}
@ -272,10 +303,12 @@ void Foam::mixerFvMesh::calcMovingMask() const
}
}
if (topoChanger_.size() > 0)
{
// Topo changer present. Use zones for motion
const word movingSliderZoneName
(
word(dict_.subDict("slider").lookup("moving"))
+ "Zone"
word(dict_.subDict("slider").lookup("moving")) + "Zone"
);
const labelList& movingSliderAddr =
@ -293,8 +326,7 @@ void Foam::mixerFvMesh::calcMovingMask() const
const word staticSliderZoneName
(
word(dict_.subDict("slider").lookup("static"))
+ "Zone"
word(dict_.subDict("slider").lookup("static")) + "Zone"
);
const labelList& staticSliderAddr =
@ -309,6 +341,7 @@ void Foam::mixerFvMesh::calcMovingMask() const
movingPointsMask[curFace[pointI]] = 0;
}
}
}
}
@ -415,23 +448,44 @@ bool Foam::mixerFvMesh::update()
autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();
if (topoChangeMap->morphing())
bool localMorphing = topoChangeMap->morphing();
bool globalMorphing = localMorphing;
reduce(globalMorphing, orOp<bool>());
if (globalMorphing)
{
Info << "Attaching rotors" << endl;
deleteDemandDrivenData(movingPointsMaskPtr_);
// Move the sliding interface points to correct position
if (localMorphing)
{
pointField mappedOldPointsNew(allPoints().size());
mappedOldPointsNew.map(oldPointsNew, topoChangeMap->pointMap());
movePoints(mappedOldPointsNew);
resetMotion();
setV0();
// Move the sliding interface points to correct position
movePoints(topoChangeMap->preMotionPoints());
}
else
{
pointField newPoints = allPoints();
movePoints(oldPointsNew);
resetMotion();
setV0();
// Move the sliding interface points to correct position
movePoints(newPoints);
}
}
return topoChangeMap->morphing();
}

View file

@ -0,0 +1,306 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "movingBodyTopoFvMesh.H"
#include "Time.H"
#include "mapPolyMesh.H"
#include "layerAdditionRemoval.H"
#include "volMesh.H"
#include "transformField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(movingBodyTopoFvMesh, 0);
addToRunTimeSelectionTable
(
topoChangerFvMesh,
movingBodyTopoFvMesh,
IOobject
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::scalarField>
Foam::movingBodyTopoFvMesh::calcMotionMask() const
{
Info<< "Updating vertex markup" << endl;
tmp<scalarField> tvertexMarkup(new scalarField(allPoints().size(), 0));
scalarField& vertexMarkup = tvertexMarkup();
cellZoneID movingCellsID(movingCellsName_, cellZones());
// In order to do a correct update on a mask on processor boundaries,
// Detection of moving cells should use patchNeighbourField for
// processor (not coupled!) boundaries. This is done by expanding
// a moving cell set into a field and making sure that processor patch
// points move in sync. Not done at the moment, probably best to do
// using parallel update of pointFields. HJ, 19/Feb/2011
// If moving cells are found, perform mark-up
if (movingCellsID.active())
{
// Get cell-point addressing
const labelListList& cp = cellPoints();
// Get labels of all moving cells
const labelList& movingCells = cellZones()[movingCellsID.index()];
forAll (movingCells, cellI)
{
const labelList& curCp = cp[movingCells[cellI]];
forAll (curCp, pointI)
{
vertexMarkup[curCp[pointI]] = 1;
}
}
}
faceZoneID frontFacesID(frontFacesName_, faceZones());
if (frontFacesID.active())
{
const faceZone& frontFaces = faceZones()[frontFacesID.index()];
const labelList& mp = frontFaces().meshPoints();
forAll (mp, mpI)
{
vertexMarkup[mp[mpI]] = 1;
}
}
faceZoneID backFacesID(backFacesName_, faceZones());
if (backFacesID.active())
{
const faceZone& backFaces = faceZones()[backFacesID.index()];
const labelList& mp = backFaces().meshPoints();
forAll (mp, mpI)
{
vertexMarkup[mp[mpI]] = 1;
}
}
return tvertexMarkup;
}
void Foam::movingBodyTopoFvMesh::addZonesAndModifiers()
{
// Add zones and modifiers for motion action
if (topoChanger_.size() > 0)
{
Info<< "void movingBodyTopoFvMesh::addZonesAndModifiers() : "
<< "Zones and modifiers already present. Skipping."
<< endl;
return;
}
// Add layer addition/removal interfaces
topoChanger_.setSize(2);
label nMods = 0;
faceZoneID frontFacesID(frontFacesName_, faceZones());
faceZoneID backFacesID(backFacesName_, faceZones());
if (frontFacesID.active())
{
const faceZone& frontFaces = faceZones()[frontFacesID.index()];
if (!frontFaces.empty())
{
topoChanger_.set
(
nMods,
new layerAdditionRemoval
(
frontFacesName_ + "Layer",
nMods,
topoChanger_,
frontFacesName_,
readScalar
(
dict_.subDict("front").lookup("minThickness")
),
readScalar
(
dict_.subDict("front").lookup("maxThickness")
)
)
);
nMods++;
}
}
if (backFacesID.active())
{
const faceZone& backFaces = faceZones()[backFacesID.index()];
if (!backFaces.empty())
{
topoChanger_.set
(
nMods,
new layerAdditionRemoval
(
backFacesName_ + "Layer",
nMods,
topoChanger_,
backFacesName_,
readScalar
(
dict_.subDict("back").lookup("minThickness")
),
readScalar
(
dict_.subDict("back").lookup("maxThickness")
)
)
);
nMods++;
}
}
topoChanger_.setSize(nMods);
reduce(nMods, sumOp<label>());
Info << "Adding " << nMods << " mesh modifiers" << endl;
// Write mesh and modifiers
topoChanger_.write();
// No need to write the mesh - only modifiers are added.
// HJ, 18/Feb/2011
// write();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::movingBodyTopoFvMesh::movingBodyTopoFvMesh(const IOobject& io)
:
topoChangerFvMesh(io),
dict_
(
IOdictionary
(
IOobject
(
"dynamicMeshDict",
time().constant(),
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
).subDict(typeName + "Coeffs")
),
movingCellsName_(dict_.lookup("movingCells")),
frontFacesName_(dict_.lookup("frontFaces")),
backFacesName_(dict_.lookup("backFaces")),
SBMFPtr_(solidBodyMotionFunction::New(dict_, time())),
motionMask_()
{
addZonesAndModifiers();
motionMask_ = calcMotionMask();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::movingBodyTopoFvMesh::~movingBodyTopoFvMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::movingBodyTopoFvMesh::update()
{
// Store points to recreate mesh motion
pointField oldPointsNew = allPoints();
pointField newPoints = allPoints();
autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();
bool localMeshChanged = topoChangeMap->morphing();
bool globalMeshChanged = localMeshChanged;
reduce(globalMeshChanged, orOp<bool>());
if (globalMeshChanged)
{
Pout<< "Topology change. Calculating motion point mask" << endl;
motionMask_ = calcMotionMask();
}
if (localMeshChanged)
{
// // Map old points onto the new mesh
// pointField mappedOldPointsNew(allPoints().size());
// mappedOldPointsNew.map(oldPointsNew, topoChangeMap->pointMap());
// movePoints(mappedOldPointsNew);
// resetMotion();
// setV0();
// Get new points from preMotion
newPoints = topoChangeMap().preMotionPoints();
}
// else
// {
// // No change, use old points
// movePoints(oldPointsNew);
// resetMotion();
// setV0();
// }
// Calculate new points using a velocity transformation
newPoints += motionMask_*
transform(SBMFPtr_().velocity(), newPoints)*time().deltaT().value();
Info << "Executing mesh motion" << endl;
movePoints(newPoints);
return localMeshChanged;
}
// ************************************************************************* //

View file

@ -23,22 +23,30 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::movingConeTopoFvMesh
Foam::movingBodyTopoFvMesh
Description
Sample topoChangerFvMesh that moves an object in x direction
and introduces/removes layers.
Sample topoChangerFvMesh that moves a cell zone in a given direction,
introducing/removing layers around it.
Cells in the movingCells zone shall be moved given the prescribed velocity
and will be bounded in "front" and "back" by other cell zones.
Layer addition/removal interfaces are inserted at boundaries between the
moving zone and front and back, pointing outside of the moving cell zone
Author and rewrite
Hrvoje Jasak, Wikki Ltd.
SourceFiles
movingConeTopoFvMesh.C
movingBodyTopoFvMesh.C
\*---------------------------------------------------------------------------*/
#ifndef movingConeTopoFvMesh_H
#define movingConeTopoFvMesh_H
#ifndef movingBodyTopoFvMesh_H
#define movingBodyTopoFvMesh_H
#include "topoChangerFvMesh.H"
#include "motionSolver.H"
#include "solidBodyMotionFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,35 +54,29 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class movingConeTopoFvMesh Declaration
Class movingBodyTopoFvMesh Declaration
\*---------------------------------------------------------------------------*/
class movingConeTopoFvMesh
class movingBodyTopoFvMesh
:
public topoChangerFvMesh
{
// Private data
//- Motion dictionary
dictionary motionDict_;
//- Dynamic mesh dictionary
dictionary dict_;
//- Motion velocity amplitude
vector motionVelAmplitude_;
//- Moving cell zone name
word movingCellsName_;
//- Motion velocity period
scalar motionVelPeriod_;
//- Front face zone name
word frontFacesName_;
//- Motion velocity period
vector curMotionVel_;
//- Back face zone name
word backFacesName_;
//- Left edge
scalar leftEdge_;
//- Current left obstacle position
scalar curLeft_;
//- Current right obstacle position
scalar curRight_;
//- Motion control function
autoPtr<solidBodyMotionFunction> SBMFPtr_;
//- Vertex motion mask
scalarField motionMask_;
@ -83,39 +85,34 @@ class movingConeTopoFvMesh
// Private Member Functions
//- Disallow default bitwise copy construct
movingConeTopoFvMesh(const movingConeTopoFvMesh&);
movingBodyTopoFvMesh(const movingBodyTopoFvMesh&);
//- Disallow default bitwise assignment
void operator=(const movingConeTopoFvMesh&);
void operator=(const movingBodyTopoFvMesh&);
//- Add mixer zones and modifiers
void addZonesAndModifiers();
//- Markup motion vertices
tmp<scalarField> vertexMarkup
(
const pointField& p,
const scalar& curLeft,
const scalar& curRight
) const;
//- Mark motion vertices
tmp<scalarField> calcMotionMask() const;
public:
//- Runtime type information
TypeName("movingConeTopoFvMesh");
TypeName("movingBodyTopoFvMesh");
// Constructors
//- Construct from database
explicit movingConeTopoFvMesh(const IOobject& io);
explicit movingBodyTopoFvMesh(const IOobject& io);
// Destructor
virtual ~movingConeTopoFvMesh();
virtual ~movingBodyTopoFvMesh();
// Member Functions

View file

@ -1,429 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "movingConeTopoFvMesh.H"
#include "Time.H"
#include "mapPolyMesh.H"
#include "layerAdditionRemoval.H"
#include "addToRunTimeSelectionTable.H"
#include "volMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(movingConeTopoFvMesh, 0);
addToRunTimeSelectionTable
(
topoChangerFvMesh,
movingConeTopoFvMesh,
IOobject
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::movingConeTopoFvMesh::vertexMarkup
(
const pointField& p,
const scalar& curLeft,
const scalar& curRight
) const
{
Info<< "Updating vertex markup. curLeft: "
<< curLeft << " curRight: " << curRight << endl;
tmp<scalarField> tvertexMarkup(new scalarField(p.size()));
scalarField& vertexMarkup = tvertexMarkup();
forAll (p, pI)
{
if (p[pI].x() < curLeft - 1e-10)
{
vertexMarkup[pI] = -1;
}
else if (p[pI].x() > curRight + 1e-10)
{
vertexMarkup[pI] = 1;
}
else
{
vertexMarkup[pI] = 0;
}
}
return tvertexMarkup;
}
void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
{
// Add zones and modifiers for motion action
if
(
pointZones().size() > 0
|| faceZones().size() > 0
|| cellZones().size() > 0
)
{
Info<< "void movingConeTopoFvMesh::addZonesAndModifiers() : "
<< "Zones and modifiers already present. Skipping."
<< endl;
if (topoChanger_.size() == 0)
{
FatalErrorIn
(
"void movingConeTopoFvMesh::addZonesAndModifiers()"
) << "Mesh modifiers not read properly"
<< abort(FatalError);
}
return;
}
Info<< "Time = " << time().timeName() << endl
<< "Adding zones and modifiers to the mesh" << endl;
const vectorField& fc = faceCentres();
const vectorField& fa = faceAreas();
labelList zone1(fc.size());
boolList flipZone1(fc.size(), false);
label nZoneFaces1 = 0;
labelList zone2(fc.size());
boolList flipZone2(fc.size(), false);
label nZoneFaces2 = 0;
forAll (fc, faceI)
{
if
(
fc[faceI].x() > -0.003501
&& fc[faceI].x() < -0.003499
)
{
if ((fa[faceI] & vector(1, 0, 0)) < 0)
{
flipZone1[nZoneFaces1] = true;
}
zone1[nZoneFaces1] = faceI;
Info<< "face " << faceI << " for zone 1. Flip: "
<< flipZone1[nZoneFaces1] << endl;
nZoneFaces1++;
}
else if
(
fc[faceI].x() > -0.00701
&& fc[faceI].x() < -0.00699
)
{
zone2[nZoneFaces2] = faceI;
if ((fa[faceI] & vector(1, 0, 0)) > 0)
{
flipZone2[nZoneFaces2] = true;
}
Info << "face " << faceI << " for zone 2. Flip: "
<< flipZone2[nZoneFaces2] << endl;
nZoneFaces2++;
}
}
zone1.setSize(nZoneFaces1);
flipZone1.setSize(nZoneFaces1);
zone2.setSize(nZoneFaces2);
flipZone2.setSize(nZoneFaces2);
Info << "zone: " << zone1 << endl;
Info << "zone: " << zone2 << endl;
List<pointZone*> pz(0);
List<faceZone*> fz(2);
List<cellZone*> cz(0);
label nFz = 0;
fz[nFz] =
new faceZone
(
"rightExtrusionFaces",
zone1,
flipZone1,
nFz,
faceZones()
);
nFz++;
fz[nFz] =
new faceZone
(
"leftExtrusionFaces",
zone2,
flipZone2,
nFz,
faceZones()
);
nFz++;
fz.setSize(nFz);
Info << "Adding mesh zones." << endl;
addZones(pz, fz, cz);
// Add layer addition/removal interfaces
topoChanger_.setSize(2);
label nMods = 0;
topoChanger_.set
(
0,
new layerAdditionRemoval
(
"right",
nMods,
topoChanger_,
"rightExtrusionFaces",
readScalar
(
motionDict_.subDict("right").lookup("minThickness")
),
readScalar
(
motionDict_.subDict("right").lookup("maxThickness")
)
)
);
nMods++;
topoChanger_.set
(
1,
new layerAdditionRemoval
(
"left",
nMods,
topoChanger_,
"leftExtrusionFaces",
readScalar
(
motionDict_.subDict("left").lookup("minThickness")
),
readScalar
(
motionDict_.subDict("left").lookup("maxThickness")
)
)
);
nMods++;
Info << "Adding " << nMods << " mesh modifiers" << endl;
// Write mesh and modifiers
topoChanger_.write();
write();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::movingConeTopoFvMesh::movingConeTopoFvMesh(const IOobject& io)
:
topoChangerFvMesh(io),
motionDict_
(
IOdictionary
(
IOobject
(
"dynamicMeshDict",
time().constant(),
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
).subDict(typeName + "Coeffs")
),
motionVelAmplitude_(motionDict_.lookup("motionVelAmplitude")),
motionVelPeriod_(readScalar(motionDict_.lookup("motionVelPeriod"))),
curMotionVel_
(
motionVelAmplitude_*
Foam::sin(time().value()*M_PI/motionVelPeriod_)
),
leftEdge_(readScalar(motionDict_.lookup("leftEdge"))),
curLeft_(readScalar(motionDict_.lookup("leftObstacleEdge"))),
curRight_(readScalar(motionDict_.lookup("rightObstacleEdge"))),
motionMask_
(
vertexMarkup
(
points(),
curLeft_,
curRight_
)
)
{
addZonesAndModifiers();
curLeft_ = average
(
faceZones()
[
faceZones().findZoneID("leftExtrusionFaces")
]().localPoints()
).x();
curRight_ = average
(
faceZones()
[
faceZones().findZoneID("rightExtrusionFaces")
]().localPoints()
).x();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::movingConeTopoFvMesh::~movingConeTopoFvMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::movingConeTopoFvMesh::update()
{
autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();
// Calculate the new point positions depending on whether the
// topological change has happened or not
pointField newPoints;
vector curMotionVel_ =
motionVelAmplitude_*
Foam::sin(time().value()*M_PI/motionVelPeriod_);
bool meshChanged = topoChangeMap->morphing();
if (meshChanged)
{
Info << "Topology change. Calculating motion points" << endl;
if (topoChangeMap().hasMotionPoints())
{
motionMask_ =
vertexMarkup
(
topoChangeMap().preMotionPoints(),
curLeft_,
curRight_
);
}
else
{
motionMask_ =
vertexMarkup
(
points(),
curLeft_,
curRight_
);
}
// Create new points by moving old points but using the
// pre-motion points at the motion selector for the moving
// region
newPoints =
points()
+ (
pos(0.5 - mag(motionMask_)) // cells above the body
// + pos(motionMask_ - 0.5)* // cells in front of the body
// (
// points().component(vector::X)/curRight
// )
// + pos(-motionMask_ - 0.5)* // cells behind the body
// (
// (
// points().component(vector::X)
// - leftEdge
// )/
// (curLeft_ - leftEdge_)
// )
)*curMotionVel_*time().deltaT().value();
// Correct mesh motion for correct volume continuity
movePoints(topoChangeMap().preMotionPoints());
resetMotion();
setV0();
}
else
{
Info << "No topology change" << endl;
// Set the mesh motion
newPoints =
points()
+ (
pos(0.5 - mag(motionMask_)) // cells above the body
// + pos(motionMask_ - 0.5)* // cells in front of the body
// (
// points().component(vector::X)/curRight
// )
// + pos(-motionMask_ - 0.5)* // cells behind the body
// (
// (
// points().component(vector::X)
// - leftEdge
// )/
// (curLeft_ - leftEdge_)
// )
)*curMotionVel_*time().deltaT().value();
}
curLeft_ += curMotionVel_.x()*time().deltaT().value();
curRight_ += curMotionVel_.x()*time().deltaT().value();
// The mesh now contains the cells with zero volume
Info << "Executing mesh motion" << endl;
movePoints(newPoints);
// The mesh now has got non-zero volume cells
return meshChanged;
}
// ************************************************************************* //

View file

@ -28,7 +28,6 @@ License
#include "regionSplit.H"
#include "polyTopoChanger.H"
#include "slidingInterface.H"
#include "ggiPolyPatch.H"
#include "Time.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -222,17 +221,8 @@ void Foam::mixerRotor::calcMovingMask() const
const cellList& c = mesh_.cells();
const faceList& f = mesh_.allFaces();
label movingCellZoneID =
mesh_.cellZones().findZoneID("movingCellsZone" + name_);
if (movingCellZoneID < 0)
{
FatalErrorIn("void mixerRotor::calcMovingMask() const")
<< "Cannot find moving cell zone ID"
<< abort(FatalError);
}
const labelList& cellAddr = mesh_.cellZones()[movingCellZoneID];
const labelList& cellAddr = mesh_.cellZones()
[mesh_.cellZones().findZoneID("movingCellsZone" + name_)];
forAll (cellAddr, cellI)
{
@ -251,35 +241,8 @@ void Foam::mixerRotor::calcMovingMask() const
}
// Attempt to enforce motion on sliders if zones exist
// Master side
label msI = -1;
if (useTopoSliding_)
{
// For topological changes, find the zone
msI = mesh_.faceZones().findZoneID(movingSliderName_ + "Zone" + name_);
}
else
{
// For GGI, take face zone from ggi interpolator
label movingSliderIndex =
mesh_.boundaryMesh().findPatchID(movingSliderName_);
if (movingSliderIndex > -1)
{
if (isA<ggiPolyPatch>(mesh_.boundaryMesh()[movingSliderIndex]))
{
const ggiPolyPatch& movingSliderGgi =
refCast<const ggiPolyPatch>
(
mesh_.boundaryMesh()[movingSliderIndex]
);
msI = mesh_.faceZones().findZoneID(movingSliderGgi.zoneName());
}
}
}
const label msI =
mesh_.faceZones().findZoneID(movingSliderName_ + "Zone" + name_);
if (msI > -1)
{
@ -296,35 +259,8 @@ void Foam::mixerRotor::calcMovingMask() const
}
}
// Slave side
label ssI = -1;
if (useTopoSliding_)
{
// For topological changes, find the zone
ssI = mesh_.faceZones().findZoneID(staticSliderName_ + "Zone" + name_);
}
else
{
// For GGI, take face zone from ggi interpolator
label staticSliderIndex =
mesh_.boundaryMesh().findPatchID(staticSliderName_);
if (staticSliderIndex > -1)
{
if (isA<ggiPolyPatch>(mesh_.boundaryMesh()[staticSliderIndex]))
{
const ggiPolyPatch& staticSliderGgi =
refCast<const ggiPolyPatch>
(
mesh_.boundaryMesh()[staticSliderIndex]
);
ssI = mesh_.faceZones().findZoneID(staticSliderGgi.zoneName());
}
}
}
const label ssI =
mesh_.faceZones().findZoneID(staticSliderName_ + "Zone" + name_);
if (ssI > -1)
{