Professional Documents
Culture Documents
On linearValveLayersFvMesh
On linearValveLayersFvMesh
namespace Foam
{
defineTypeNameAndDebug(linearValveLayersFvMesh, 0);
addToRunTimeSelectionTable
(
topoChangerFvMesh,
linearValveLayersFvMesh,
IOobject
);
}
void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
{
// Inner slider
const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
// Outer slider
const word outerSliderName
(
motionDict_.subDict("slider").lookup("outside")
);
if
(
insideZoneID > -1
|| outsideZoneID > -1
)
{
// Zones found. Check topo changer
if (topoChanger_.empty())
{
FatalErrorIn
(
"void linearValveLayersFvMesh::addZonesAndModifiers()"
) << "Mesh modifiers not read properly"
<< abort(FatalError);
}
initialised = true;
}
if (initialised)
{
InfoIn("void linearValveLayersFvMesh::addZonesAndModifiers()")
<< "Zones and modifiers already present. Skipping."
<< endl;
return;
}
// Add zones
label nPz = 0;
label nFz = 0;
label nCz = 0;
List<pointZone*> pz(pointZones().size() + 1);
List<faceZone*> fz(faceZones().size() + 4);
List<cellZone*> cz(cellZones().size());
// Inner slider
const polyPatch& innerSlider =
boundaryMesh()[boundaryMesh().findPatchID(innerSliderName)];
// Outer slider
const polyPatch& outerSlider =
boundaryMesh()[boundaryMesh().findPatchID(outerSliderName)];
labelList isf(innerSlider.size());
forAll (isf, i)
{
isf[i] = innerSlider.start() + i;
}
labelList osf(outerSlider.size());
forAll (osf, i)
{
osf[i] = outerSlider.start() + i;
}
// Add face zone for layer addition. This is present on all processors
const word layerPatchName
(
motionDict_.subDict("layer").lookup("patch")
);
labelList lpf(layerPatch.size());
forAll (lpf, i)
{
lpf[i] = layerPatch.start() + i;
}
void Foam::linearValveLayersFvMesh::makeLayersLive()
{
const polyTopoChanger& topoChanges = topoChanger_;
// Enable layering
forAll (topoChanges, modI)
{
if (isA<layerAdditionRemoval>(topoChanges[modI]))
{
topoChanges[modI].enable();
}
else if (isA<slidingInterface>(topoChanges[modI]))
{
topoChanges[modI].disable();
}
else
{
FatalErrorIn("void linearValveLayersFvMesh::makeLayersLive()")
<< "Don't know what to do with mesh modifier "
<< modI << " of type " << topoChanges[modI].type()
<< abort(FatalError);
}
}
}
void Foam::linearValveLayersFvMesh::makeSlidersLive()
{
const polyTopoChanger& topoChanges = topoChanger_;
return result;
}
Foam::tmp<Foam::pointField>
Foam::linearValveLayersFvMesh::newLayerPoints() const
{
tmp<pointField> tnewLayerPoints
(
new pointField(allPoints())
);
pointField& np = tnewLayerPoints();
return tnewLayerPoints;
}
// * * * * * * * * * * * *
* * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::linearValveLayersFvMesh::~linearValveLayersFvMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::linearValveLayersFvMesh::update()
{
// Detaching the interface
if (attached())
{
Info<< "Decoupling sliding interfaces" << endl;
makeSlidersLive();
if (localMorphing1)
{
Info << "Topology change; executing pre-motion after "
<< "sliding detach" << endl;
movePoints(topoChangeMap1->preMotionPoints());
}
else
{
pointField newPoints = allPoints();
// Dummy motion
movePoints(newPoints);
}
reduce(globalMorphing1, orOp<bool>());
if (globalMorphing1)
{
Info<< "Topology change; executing pre-motion after "
<< "dynamic layering" << endl;
if (localMorphing1)
{
Info << "Topology change; executing pre-motion" << endl;
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(topoChangeMap2->preMotionPoints());
newPoints = topoChangeMap2->preMotionPoints();
}
else
{
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(newPoints);
}
setV0();
resetMotion();
}
reduce(globalMorphing3, orOp<bool>());
if (globalMorphing3)
{
Info<< "Topology change; executing pre-motion after "
<< "sliding attach" << endl;
// Grab points
newPoints = allPoints();
if (localMorphing3)
{
// If there is layering, pick up correct points
if (topoChangeMap3->hasMotionPoints())
{
newPoints = topoChangeMap3->preMotionPoints();
}
pointField mappedOldPointsNew(newPoints.size());
mappedOldPointsNew.map
(
oldPointsNew,
topoChangeMap3->pointMap()
);
resetMotion();
setV0();
resetMotion();
setV0();
return true;
}
// ************************************************************************* //
polyTopoChange
Instead of recording changes and executing them all in one go (as did v1.3 polyTopoChange) this
class actually holds the current points/faces/cells and does the change immediately. It can be asked
to compress out all unused points/faces/cells and renumber everything to be consistent.
Note:
2. adding a face using non-existing cells causes all intermediate cells to be added. So always
first add cells/points and then faces. (or set strict checking)
3. strict checking:
7. coupled patches: the reorderCoupledFaces routine (borrowed from the couplePatches utility)
reorders coupled patch faces and uses the cyclicPolyPatch,processorPolyPatch functionality.
Source files
• polyTopoChange.H
• polyTopoChange.C
• polyTopoChangeI.H
• polyTopoChangeTemplates.C
Definition at line 97 of file polyTopoChange.H.