Engine updates: parallelisation of topo changes

This commit is contained in:
Hrvoje Jasak 2011-05-27 20:38:01 +01:00
parent dbdb3f2d65
commit 6208a5ccd1
12 changed files with 436 additions and 341 deletions

View file

@ -9,7 +9,6 @@
forAll(valves_, valveI) forAll(valves_, valveI)
{ {
vector valveVel = vector valveVel =
valves_[valveI].curVelocity()*valves_[valveI].cs().axis(); valves_[valveI].curVelocity()*valves_[valveI].cs().axis();
@ -18,7 +17,6 @@
valveVel = vector::zero; valveVel = vector::zero;
} }
{ {
// label movingPtsIndex = pZones.findZoneID("movingPointsV"+Foam::name(valveI + 1)); // label movingPtsIndex = pZones.findZoneID("movingPointsV"+Foam::name(valveI + 1));
@ -79,11 +77,9 @@
constraintSize++; constraintSize++;
} }
} }
{ {
// label staticPtsIndex = pZones.findZoneID("staticPointsV"+Foam::name(valveI + 1)); // label staticPtsIndex = pZones.findZoneID("staticPointsV"+Foam::name(valveI + 1));
// const labelList& staticPointsV = pZones[staticPtsIndex]; // const labelList& staticPointsV = pZones[staticPtsIndex];
/* /*
@ -203,7 +199,6 @@
} }
} }
forAll(movingPointsP, mpI) forAll(movingPointsP, mpI)
{ {
constrainedPoints.append(movingPointsP[mpI]); constrainedPoints.append(movingPointsP[mpI]);
@ -213,6 +208,4 @@
} }
} }

View file

@ -301,8 +301,6 @@ void Foam::simpleTwoStroke::addZonesAndModifiers()
nFaceZones++; nFaceZones++;
Info << "cut p" << endl;
pz[nPointZones] = new pointZone pz[nPointZones] = new pointZone
( (
"cutPointZone", "cutPointZone",

View file

@ -0,0 +1,60 @@
if (piston().patchID().active())
{
// Add faces for piston layering
// Note: because of operation of layer addition/removal
// (reduce function in layer addition/removal thickness)
// the layering modifier needs to be present on all processors
// even if the patch size is zero
// HJ, 7/Mar/2011
faceSet pistonFaceSet(*this, piston().pistonFaceSetName());
boolList flipPistonFaces(pistonFaceSet.toc().size(), false);
label nSet = pistonFaceSet.toc().size();
label nFlip = 0;
forAll (flipPistonFaces, facei)
{
scalar scalProd =
(faceAreas()[pistonFaceSet.toc()[facei]] & vector(0, 0, 1));
if (scalProd < 0)
{
flipPistonFaces[facei] = true;
nFlip++;
}
}
Info << "nSet = " << nSet << endl;
Info << "nFlip = " << nFlip << endl;
fz[nFaceZones] =
(
new faceZone
(
"pistonLayerFaces",
pistonFaceSet.toc(),
flipPistonFaces,
nFaceZones,
faceZones()
)
);
nFaceZones++;
cellSet movingPistonCells(*this, piston().pistonCellSetName());
Info<< "Adding piston cell set" << endl;
cz[nCellZones] =
(
new cellZone
(
"pistonCells",
movingPistonCells.toc(),
nCellZones,
cellZones()
)
);
nCellZones++;
}

View file

@ -62,13 +62,12 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
return; return;
} }
Info << "checkAndCalculate()" << endl;
checkAndCalculate(); checkAndCalculate();
Info<< "Time = " << engTime().theta() << endl Info<< "Time = " << engTime().theta() << endl
<< "Adding zones to the engine mesh" << endl; << "Adding zones to the engine mesh" << endl;
// Zones to add
// fz = 4: virtual piston, outSidePort, insidePort, cutFaceZone // fz = 4: virtual piston, outSidePort, insidePort, cutFaceZone
// pz = 2: piston points, cutPointZone // pz = 2: piston points, cutPointZone
// cz = 1: moving mask // cz = 1: moving mask
@ -76,11 +75,11 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
label nPorts = scavInCylPatches_.size(); label nPorts = scavInCylPatches_.size();
DynamicList<pointZone*> pz(2 + nPorts); List<pointZone*> pz(nPorts + 2);
DynamicList<faceZone*> fz(3*nPorts + 1); List<faceZone*> fz(3*nPorts + 1);
// Added piston cells and head cells // Added piston cells and head cells
DynamicList<cellZone*> cz(3); List<cellZone*> cz(3);
label nPointZones = 0; label nPointZones = 0;
label nFaceZones = 0; label nFaceZones = 0;
@ -88,24 +87,11 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
Info << "Adding piston layer faces" << endl; Info << "Adding piston layer faces" << endl;
# include "addPistonLayerHrv.H" # include "addPistonLayer.H"
// adding head points (does not move) // Add head points that do not move
{ {
// pointSet headPointSet(*this, headPointsSetName_);
// pz[nPointZones] =
// new pointZone
// (
// "headPoints",
// headPointSet.toc(),
// nPointZones,
// pointZones()
// );
// nPointZones++;
cellSet headCellSet(*this, headCellsSetName_); cellSet headCellSet(*this, headCellsSetName_);
cz[nCellZones] = cz[nCellZones] =
@ -133,6 +119,19 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
boundaryMesh().findPatchID(scavInCylPatches_[patchi]) boundaryMesh().findPatchID(scavInCylPatches_[patchi])
]; ];
// Outer slider
const polyPatch& outerScav =
boundaryMesh()
[
boundaryMesh().findPatchID(scavInPortPatches_[patchi])
];
Pout<< "A: " << innerScav.size() << " " << outerScav.size()
<< endl;
// Add zone if both patches has got faces
if (!innerScav.empty() && !outerScav.empty())
{
// Inner
labelList isf(innerScav.size()); labelList isf(innerScav.size());
forAll (isf, i) forAll (isf, i)
@ -142,7 +141,8 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
fz[nFaceZones] = new faceZone fz[nFaceZones] = new faceZone
( (
scavInCylPatches_[patchi] + "Zone" + Foam::name(patchi + 1), scavInCylPatches_[patchi] + "Zone"
+ Foam::name(patchi + 1),
isf, isf,
boolList(innerScav.size(), false), boolList(innerScav.size(), false),
nFaceZones, nFaceZones,
@ -151,14 +151,7 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
nFaceZones++; nFaceZones++;
// Outer slider // Outer
const polyPatch& outerScav =
boundaryMesh()
[
boundaryMesh().findPatchID(scavInPortPatches_[patchi])
];
labelList osf(outerScav.size()); labelList osf(outerScav.size());
forAll (osf, i) forAll (osf, i)
@ -168,7 +161,8 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
fz[nFaceZones] = new faceZone fz[nFaceZones] = new faceZone
( (
scavInPortPatches_[patchi] + "Zone" + Foam::name(patchi + 1), scavInPortPatches_[patchi] + "Zone"
+ Foam::name(patchi + 1),
osf, osf,
boolList(outerScav.size(), false), boolList(outerScav.size(), false),
nFaceZones, nFaceZones,
@ -177,6 +171,7 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
nFaceZones++; nFaceZones++;
// Cut faces
fz[nFaceZones] = new faceZone fz[nFaceZones] = new faceZone
( (
"cutFaceZone" + Foam::name(patchi + 1), "cutFaceZone" + Foam::name(patchi + 1),
@ -188,8 +183,7 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
nFaceZones++; nFaceZones++;
Info << "cut p" << endl; // Cut points
pz[nPointZones] = new pointZone pz[nPointZones] = new pointZone
( (
"cutPointZone" + Foam::name(patchi + 1), "cutPointZone" + Foam::name(patchi + 1),
@ -201,8 +195,9 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
nPointZones++; nPointZones++;
} }
} }
}
Info << "moving cells" << endl; Info << "Adding moving cells zone" << endl;
{ {
cellSet movingCells(*this, movingCellSetName_); cellSet movingCells(*this, movingCellSetName_);
@ -218,9 +213,7 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
nCellZones++; nCellZones++;
} }
Info << "moving cells added" << endl; Pout<< "Adding " << nPointZones << " point, "
Info<< "Adding " << nPointZones << " point, "
<< nFaceZones << " face zones and " << nCellZones << nFaceZones << " face zones and " << nCellZones
<< " cell zones" << endl; << " cell zones" << endl;
@ -229,7 +222,7 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
cz.setSize(nCellZones); cz.setSize(nCellZones);
addZones(pz, fz, cz); addZones(pz, fz, cz);
List<polyMeshModifier*> tm(1 + nPorts); List<polyMeshModifier*> tm(nPorts + 1);
label nMods = 0; label nMods = 0;
// Add piston layer addition // Add piston layer addition
@ -240,6 +233,28 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
{ {
forAll (scavInPortPatches_, i) forAll (scavInPortPatches_, i)
{ {
// Check if patches are present on local processor
const label sipID =
boundaryMesh().findPatchID(scavInPortPatches_[i]);
const label sicID =
boundaryMesh().findPatchID(scavInCylPatches_[i]);
if (sipID > -1 && sicID > -1)
{
if
(
boundaryMesh()[sipID].size() > 0
&& boundaryMesh()[sicID].size() > 0
)
{
Pout<< "Adding slider for pair " << scavInPortPatches_[i]
<< " and " << scavInCylPatches_[i]
<< " with sizes "
<< boundaryMesh()[sipID].size() << " "
<< boundaryMesh()[sicID].size() << endl;
// Patches present. Add modifier
topoChanger_.setSize(topoChanger_.size() + 1); topoChanger_.setSize(topoChanger_.size() + 1);
topoChanger_.set topoChanger_.set
@ -265,6 +280,8 @@ void Foam::twoStrokeEngine::addZonesAndModifiers()
nMods++; nMods++;
} }
} }
}
}
Info << "Adding " << nMods << " topology modifiers" << endl; Info << "Adding " << nMods << " topology modifiers" << endl;

View file

@ -152,13 +152,13 @@ void Foam::twoStrokeEngine::setBoundaryVelocity(volVectorField& U)
// On the piston movingWallVelocity is used. // On the piston movingWallVelocity is used.
// There is no need to update the piston velocity // There is no need to update the piston velocity
// U.boundaryField()[piston().patchID().index()] = pistonVel;
forAll (scavInPortPatches_, patchi) forAll (scavInPortPatches_, patchi)
{ {
U.boundaryField() const label curPatchID =
[boundaryMesh().findPatchID(scavInPortPatches_[patchi])] == boundaryMesh().findPatchID(scavInPortPatches_[patchi]);
pistonVel;
U.boundaryField()[curPatchID] == pistonVel;
} }
} }

View file

@ -61,8 +61,12 @@ void Foam::twoStrokeEngine::calcMovingMasks() const
const cellList& c = cells(); const cellList& c = cells();
const faceList& f = allFaces(); const faceList& f = allFaces();
const labelList& cellAddr = const label movingCellsID = cellZones().findZoneID("movingCells");
cellZones()[cellZones().findZoneID("movingCells")];
// If moving cell zone is found, mark the vertices
if (movingCellsID > -1)
{
const labelList& cellAddr = cellZones()[movingCellsID];
forAll (cellAddr, cellI) forAll (cellAddr, cellI)
{ {
@ -80,6 +84,7 @@ void Foam::twoStrokeEngine::calcMovingMasks() const
} }
} }
} }
}
// Return moving points mask. Moving points marked with 1 // Return moving points mask. Moving points marked with 1

View file

@ -46,7 +46,6 @@ void Foam::twoStrokeEngine::checkAndCalculate()
forAll (boundary(), i) forAll (boundary(), i)
{ {
Info << boundary()[i].name() << endl;
if (boundary()[i].name() == "piston") if (boundary()[i].name() == "piston")
{ {
pistonIndex = i; pistonIndex = i;
@ -111,34 +110,31 @@ void Foam::twoStrokeEngine::checkAndCalculate()
} }
} }
void Foam::twoStrokeEngine::setVirtualPistonPosition() void Foam::twoStrokeEngine::setVirtualPistonPosition()
{ {
label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces"); label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces");
bool foundPistonFace = (pistonFaceIndex != -1); if(pistonFaceIndex == -1)
Info << "piston face index = " << pistonFaceIndex << endl;
if(!foundPistonFace)
{ {
FatalErrorIn("Foam::twoStrokeEngine::setVirtualPistonPosition()") FatalErrorIn("Foam::twoStrokeEngine::setVirtualPistonPosition()")
<< " : cannot find the pistonLayerFaces" << "Cannot find the pistonLayerFaces"
<< exit(FatalError); << abort(FatalError);
} }
const labelList& pistonFaces = faceZones()[pistonFaceIndex]; const labelList& pistonPoints =
forAll(pistonFaces, i) faceZones()[pistonFaceIndex]().meshPoints();
{
const face& f = faces()[pistonFaces[i]];
// should loop over facepoints... const pointField& p = points();
forAll(f, j)
forAll (pistonPoints, i)
{ {
virtualPistonPosition() = virtualPistonPosition() =
Foam::max(virtualPistonPosition(), points()[f[j]].z()); Foam::max(virtualPistonPosition_, p[pistonPoints[i]].z());
}
} }
reduce(virtualPistonPosition(), maxOp<scalar>()); reduce(virtualPistonPosition(), maxOp<scalar>());
} }
// ************************************************************************* //

View file

@ -41,11 +41,11 @@ void Foam::twoStrokeEngine::makeLayersLive()
// Enable layering // Enable layering
forAll (morphs, modI) forAll (morphs, modI)
{ {
if (typeid(morphs[modI]) == typeid(layerAdditionRemoval)) if (isA<layerAdditionRemoval>(morphs[modI]))
{ {
morphs[modI].enable(); morphs[modI].enable();
} }
else if (typeid(morphs[modI]) == typeid(slidingInterface)) else if (isA<slidingInterface>(morphs[modI]))
{ {
morphs[modI].disable(); morphs[modI].disable();
} }
@ -59,6 +59,7 @@ void Foam::twoStrokeEngine::makeLayersLive()
} }
} }
void Foam::twoStrokeEngine::makeSlidersLive() void Foam::twoStrokeEngine::makeSlidersLive()
{ {
const polyTopoChanger& morphs = topoChanger_; const polyTopoChanger& morphs = topoChanger_;
@ -66,11 +67,11 @@ void Foam::twoStrokeEngine::makeSlidersLive()
// Enable sliding interface // Enable sliding interface
forAll (morphs, modI) forAll (morphs, modI)
{ {
if (typeid(morphs[modI]) == typeid(layerAdditionRemoval)) if (isA<layerAdditionRemoval>(morphs[modI]))
{ {
morphs[modI].disable(); morphs[modI].disable();
} }
else if (typeid(morphs[modI]) == typeid(slidingInterface)) else if (isA<slidingInterface>(morphs[modI]))
{ {
morphs[modI].enable(); morphs[modI].enable();
} }
@ -93,10 +94,9 @@ bool Foam::twoStrokeEngine::attached() const
forAll (morphs, modI) forAll (morphs, modI)
{ {
if (typeid(morphs[modI]) == typeid(slidingInterface)) if (isA<slidingInterface>(morphs[modI]))
{ {
result = result = result
result
|| refCast<const slidingInterface>(morphs[modI]).attached(); || refCast<const slidingInterface>(morphs[modI]).attached();
} }
} }
@ -104,7 +104,7 @@ bool Foam::twoStrokeEngine::attached() const
// Check thal all sliders are in sync (debug only) // Check thal all sliders are in sync (debug only)
forAll (morphs, modI) forAll (morphs, modI)
{ {
if (typeid(morphs[modI]) == typeid(slidingInterface)) if (isA<slidingInterface>(morphs[modI]))
{ {
if if
( (
@ -120,6 +120,9 @@ bool Foam::twoStrokeEngine::attached() const
} }
} }
// Sync across processors
reduce(result, orOp<bool>());
return result; return result;
} }
@ -133,13 +136,25 @@ bool Foam::twoStrokeEngine::update()
makeSlidersLive(); makeSlidersLive();
// Changing topology by hand // Changing topology by hand
autoPtr<mapPolyMesh> topoChangeMap5 = topoChanger_.changeMesh(); autoPtr<mapPolyMesh> topoChangeMap1 = topoChanger_.changeMesh();
if (topoChangeMap5->hasMotionPoints() && topoChangeMap5->morphing()) bool localMorphing1 = topoChangeMap1->morphing();
// Note: Since we are detaching, global morphing is always true
// HJ, 7/Mar/2011
if (localMorphing1)
{ {
Info << "Topology change; executing pre-motion after " Info << "Topology change; executing pre-motion after "
<< "sliding detach" << endl; << "sliding detach" << endl;
movePoints(topoChangeMap5->preMotionPoints()); movePoints(topoChangeMap1->preMotionPoints());
}
else
{
pointField newPoints = allPoints();
// Dummy motion
movePoints(newPoints);
} }
Info << "sliding interfaces successfully decoupled!!!" << endl; Info << "sliding interfaces successfully decoupled!!!" << endl;
@ -154,25 +169,14 @@ bool Foam::twoStrokeEngine::update()
// Piston Layering // Piston Layering
makeLayersLive(); makeLayersLive();
// Changing topology by hand
// Find piston mesh modifier if present on processor
// /* Tommaso, 23/5/2008
// Find piston mesh modifier
const label pistonLayerID = const label pistonLayerID =
topoChanger_.findModifierID("pistonLayer"); topoChanger_.findModifierID("pistonLayer");
if (pistonLayerID < 0)
{
FatalErrorIn("void engineFvMesh::moveAndMorph()")
<< "Piston modifier not found."
<< abort(FatalError);
}
scalar minLayerThickness = piston().minLayer(); scalar minLayerThickness = piston().minLayer();
scalar deltaZ = engTime().pistonDisplacement().value(); scalar deltaZ = engTime().pistonDisplacement().value();
virtualPistonPosition() += deltaZ; virtualPistonPosition_ += deltaZ;
Info << "virtualPistonPosition = " << virtualPistonPosition() Info << "virtualPistonPosition = " << virtualPistonPosition()
<< ", deckHeight = " << deckHeight() << ", deckHeight = " << deckHeight()
@ -181,32 +185,45 @@ bool Foam::twoStrokeEngine::update()
if (realDeformation()) if (realDeformation())
{ {
// Dectivate piston layer // Dectivate piston layer
if (pistonLayerID > -1)
{
Info << "Mesh deformation mode" << endl; Info << "Mesh deformation mode" << endl;
topoChanger_[pistonLayerID].disable(); topoChanger_[pistonLayerID].disable();
} }
}
else else
{ {
// Activate piston layer // Activate piston layer
if (pistonLayerID > -1)
{
Info << "Piston layering mode" << endl; Info << "Piston layering mode" << endl;
topoChanger_[pistonLayerID].enable(); topoChanger_[pistonLayerID].enable();
} }
}
// Changing topology by hand // Changing topology by hand
autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(); autoPtr<mapPolyMesh> topoChangeMap2 = topoChanger_.changeMesh();
bool localMorphing2 = topoChangeMap2->morphing();
bool globalMorphing2 = localMorphing2;
// Work array for new points position. // Work array for new points position.
pointField newPoints = allPoints(); pointField newPoints = allPoints();
const pointField& refPoints = allPoints();
if (topoChangeMap->morphing()) if (globalMorphing2)
{
if (topoChangeMap->hasMotionPoints())
{ {
Info<< "Topology change; executing pre-motion after " Info<< "Topology change; executing pre-motion after "
<< "dynamic layering" << endl; << "dynamic layering" << endl;
movePoints(topoChangeMap->preMotionPoints());
newPoints = topoChangeMap->preMotionPoints(); if (localMorphing2)
{
movePoints(topoChangeMap2->preMotionPoints());
newPoints = topoChangeMap2->preMotionPoints();
}
else
{
movePoints(newPoints);
} }
setV0(); setV0();
@ -225,33 +242,18 @@ bool Foam::twoStrokeEngine::update()
labelList pistonPoints; labelList pistonPoints;
labelList headPoints; labelList headPoints;
{ {
label pistonCellIndex = cellZones().findZoneID("pistonCells"); // Get cell-point addressing
if (pistonCellIndex < 0)
{
FatalErrorIn("bool twoStrokeEngine::update()")
<< "Cannot find cell zone pistonCells"
<< abort(FatalError);
}
const labelList& pistonCells = cellZones()[pistonCellIndex];
label headCellIndex = cellZones().findZoneID("headCells");
if (headCellIndex < 0)
{
FatalErrorIn("bool twoStrokeEngine::update()")
<< "Cannot find cell zone headCells"
<< abort(FatalError);
}
const labelList& headCells = cellZones()[headCellIndex];
const labelListList& cp = cellPoints(); const labelListList& cp = cellPoints();
boolList count(newPoints.size(), false); boolList count(newPoints.size(), false);
// Piston points
label pistonCellID = cellZones().findZoneID("pistonCells");
if (pistonCellID > -1)
{
const labelList& pistonCells = cellZones()[pistonCellID];
forAll (pistonCells, cellI) forAll (pistonCells, cellI)
{ {
const labelList& curCellPoints = cp[pistonCells[cellI]]; const labelList& curCellPoints = cp[pistonCells[cellI]];
@ -284,13 +286,20 @@ bool Foam::twoStrokeEngine::update()
nCounted++; nCounted++;
} }
} }
}
// Repeat for head points // Repeat for head points
count = false; count = false;
const label headCellID = cellZones().findZoneID("headCells");
if (headCellID > -1)
{
const labelList& headCells = cellZones()[headCellID];
forAll (headCells, cellI) forAll (headCells, cellI)
{ {
const labelList& curCellPoints = cp[pistonCells[cellI]]; const labelList& curCellPoints = cp[headCells[cellI]];
forAll (curCellPoints, i) forAll (curCellPoints, i)
{ {
@ -299,7 +308,7 @@ bool Foam::twoStrokeEngine::update()
} }
// Count the points // Count the points
nCounted = 0; label nCounted = 0;
forAll (count, pointI) forAll (count, pointI)
{ {
if (count[pointI] == true) if (count[pointI] == true)
@ -321,16 +330,11 @@ bool Foam::twoStrokeEngine::update()
} }
} }
} }
}
label nScaled = nPoints(); label nScaled = nPoints();
// label pistonPtsIndex = pointZones().findZoneID("pistonPoints");
// const labelList& pistonPoints = pointZones()[pistonPtsIndex];
// label headPtsIndex = pointZones().findZoneID("headPoints");
// const labelList& headPoints = pointZones()[headPtsIndex];
const scalarField& movingPointsM = movingPointsMask(); const scalarField& movingPointsM = movingPointsMask();
forAll(pistonPoints, i) forAll(pistonPoints, i)
@ -377,6 +381,7 @@ bool Foam::twoStrokeEngine::update()
{ {
// Always move piston // Always move piston
scalar pistonTopZ = -GREAT; scalar pistonTopZ = -GREAT;
forAll(pistonPoints, i) forAll(pistonPoints, i)
{ {
point& p = newPoints[pistonPoints[i]]; point& p = newPoints[pistonPoints[i]];
@ -406,15 +411,11 @@ bool Foam::twoStrokeEngine::update()
} }
} }
movePoints(newPoints); movePoints(newPoints);
deleteDemandDrivenData(movingPointsMaskPtr_); deleteDemandDrivenData(movingPointsMaskPtr_);
pistonPosition() += deltaZ; pistonPosition() += deltaZ;
//*/ //Tommaso, 23/5/2008
{ {
// Grab old points to correct the motion // Grab old points to correct the motion
pointField oldPointsNew = oldAllPoints(); pointField oldPointsNew = oldAllPoints();
@ -424,42 +425,49 @@ bool Foam::twoStrokeEngine::update()
makeSlidersLive(); makeSlidersLive();
// Changing topology by hand // Changing topology by hand
autoPtr<mapPolyMesh> topoChangeMap4 = topoChanger_.changeMesh(); autoPtr<mapPolyMesh> topoChangeMap3 = topoChanger_.changeMesh();
if (topoChangeMap4->morphing()) bool localMorphing3 = topoChangeMap3->morphing();
{ bool globalMorphing3 = localMorphing3;
if (topoChangeMap4->hasMotionPoints())
reduce(globalMorphing3, orOp<bool>());
if (globalMorphing3)
{ {
Info<< "Topology change; executing pre-motion after " Info<< "Topology change; executing pre-motion after "
<< "sliding attach" << endl; << "sliding attach" << endl;
// Info<< "topoChangeMap4->preMotionPoints().size() = " // Grab points
// << topoChangeMap4->preMotionPoints().size() << nl newPoints = allPoints();
// << "allPoints.size() = " << allPoints().size() << nl
// << "points.size() = " << points().size() << endl;
movePoints(topoChangeMap4->preMotionPoints()); if (localMorphing3)
newPoints = points(); {
// If there is layering, pick up correct points
if (topoChangeMap3->hasMotionPoints())
{
newPoints = topoChangeMap3->preMotionPoints();
} }
{ // Prepare old points for the move
pointField mappedOldPointsNew(allPoints().size()); pointField mappedOldPointsNew(allPoints().size());
mappedOldPointsNew.map mappedOldPointsNew.map
( (
oldPointsNew, topoChangeMap4->pointMap() oldPointsNew, topoChangeMap3->pointMap()
); );
forAll(scavInPortPatches_, patchi) forAll(scavInPortPatches_, patchi)
{ {
const labelList& cutPointsAddressing = // Find cut point zone ID
pointZones() const label cutPointZoneID = pointZones().findZoneID
[
pointZones().findZoneID
( (
"cutPointZone" + Foam::name(patchi + 1) "cutPointZone" + Foam::name(patchi + 1)
) );
];
if (cutPointZoneID > -1)
{
const labelList& cutPointsAddressing =
pointZones()[cutPointZoneID];
forAll(cutPointsAddressing, i) forAll(cutPointsAddressing, i)
{ {
@ -475,22 +483,40 @@ bool Foam::twoStrokeEngine::update()
> virtualPistonPosition() > virtualPistonPosition()
) )
{ {
mappedOldPointsNew[cutPointsAddressing[i]].z() = mappedOldPointsNew
[cutPointsAddressing[i]].z() =
newPoints[cutPointsAddressing[i]].z(); newPoints[cutPointsAddressing[i]].z();
} }
else else
{ {
mappedOldPointsNew[cutPointsAddressing[i]].z() = mappedOldPointsNew
newPoints[cutPointsAddressing[i]].z() - deltaZ; [cutPointsAddressing[i]].z() =
newPoints[cutPointsAddressing[i]].z()
- deltaZ;
}
} }
} }
} }
pointField newPoints = allPoints();
// Move mesh into correct old configuration
movePoints(mappedOldPointsNew); movePoints(mappedOldPointsNew);
resetMotion(); resetMotion();
setV0(); setV0();
// Set new point motion
movePoints(newPoints);
}
else
{
// No local topological change. Execute double motion for
// sync with topological changes
movePoints(oldPointsNew);
resetMotion();
setV0();
// Set new point motion
movePoints(newPoints); movePoints(newPoints);
} }
} }

View file

@ -1,8 +1,8 @@
// Add piston layer addition/removal // Add piston layer addition/removal
if (piston().patchID().active()) if (piston().patchID().active())
{ {
Info<< "Adding a layer addition/removal mesh modifier to the piston"
Info << "Adding a layer addition/removal mesh modifier to the piston" << endl; << endl;
topoChanger_.setSize(nMods + 1); topoChanger_.setSize(nMods + 1);
@ -20,6 +20,6 @@
) )
); );
nMods++; nMods++;
Info << "pistonLayer" << endl;
Info << nMods << endl; Info << "pistonLayer modifier number " << nMods << endl;
} }

View file

@ -7,7 +7,8 @@
( (
engineTopoChangerMesh::defaultRegion, engineTopoChangerMesh::defaultRegion,
runTime.timeName(), runTime.timeName(),
runTime runTime,
IOobject::MUST_READ
) )
) )
); );

View file

@ -43,7 +43,7 @@ namespace Foam
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
topoChangerFvMesh, engineTopoChangerMesh,
simpleEngineTopoFvMesh, simpleEngineTopoFvMesh,
IOobject IOobject
); );
@ -458,8 +458,7 @@ Foam::simpleEngineTopoFvMesh::simpleEngineTopoFvMesh
const IOobject& io const IOobject& io
) )
: :
topoChangerFvMesh(io), engineTopoChangerMesh(io),
engineTime_(refCast<const engineTime>(time())),
valves_(*this, engineTime_.engineDict().lookup("valves")), valves_(*this, engineTime_.engineDict().lookup("valves")),
piston_(*this, engineTime_.engineDict().subDict("piston")), piston_(*this, engineTime_.engineDict().subDict("piston")),
msPtr_(motionSolver::New(*this)), msPtr_(motionSolver::New(*this)),

View file

@ -27,8 +27,7 @@ License
#ifndef simpleEngineTopoFvMesh_H #ifndef simpleEngineTopoFvMesh_H
#define simpleEngineTopoFvMesh_H #define simpleEngineTopoFvMesh_H
#include "topoChangerFvMesh.H" #include "engineTopoChangerMesh.H"
#include "engineTime.H"
#include "valveBank.H" #include "valveBank.H"
#include "simpleEnginePiston.H" #include "simpleEnginePiston.H"
#include "motionSolver.H" #include "motionSolver.H"
@ -44,13 +43,10 @@ namespace Foam
class simpleEngineTopoFvMesh class simpleEngineTopoFvMesh
: :
public topoChangerFvMesh public engineTopoChangerMesh
{ {
// Private data // Private data
//- Engine database
const engineTime& engineTime_;
//- Engine valves //- Engine valves
valveBank valves_; valveBank valves_;
@ -76,6 +72,9 @@ class simpleEngineTopoFvMesh
void operator=(const simpleEngineTopoFvMesh&); void operator=(const simpleEngineTopoFvMesh&);
//- Add valve and piston zones and modifiers
void addZonesAndModifiers();
//- Make layering modifiers live //- Make layering modifiers live
void makeLayersLive(); void makeLayersLive();
@ -140,11 +139,12 @@ public:
&& engineTime_.thetaRevolution() < deformSwitch_; && engineTime_.thetaRevolution() < deformSwitch_;
} }
//- Add valve and piston zones and modifiers
void addZonesAndModifiers();
//- Update the mesh for both mesh motion and topology change //- Update the mesh for both mesh motion and topology change
virtual bool update(); virtual bool update();
//- Set boundary velocities
virtual void setBoundaryVelocity(volVectorField& U)
{}
}; };