void Foam::engineValveSliding::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston motion

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
     || topoChanger_.size() > 0
    ) 
    {
        Info<< "Time = " << engTime().theta() << endl;
        Info<< "void Foam::verticalValvesGambit::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;
        
        setVirtualPositions();
//        checkAndCalculate();

        Info << "Point zones found = " << pointZones().size() << endl;
        Info << "Face zones found = " << faceZones().size() << endl;
        Info << "Cell zones found = " << cellZones().size() << endl;
        
        return;

    }

    Info << "checkAndCalculate()" << endl;

    Info<< "Time = " << engTime().theta() << endl
        << "Adding zones to the engine mesh" << endl;

/*
    Point zones
    1) Piston points
    1) Cut point zone for liner in head

    nValves*
    1) cutPointsV            
    2) valveTopPoints
    3) valveBottomPoints
*/
    
    DynamicList<pointZone*> pz;
 
/*
    Face zones
    1) Piston layer faces

    nValves*
    1) valveTopLayerFaces
    2) valveBottomLayerFaces
    3) valveCurtainPort
    4) valveCurtainCyl
    5) cutFaceV
*/
    DynamicList<faceZone*> fz;

/*
    cell zones
    1) moving cells inside piston

    nValves*
    1) moving cells in the top of the valve
    2) moving cells in the bottom of the valve
*/

    DynamicList<cellZone*> cz;

    label nPointZones = 0;
    label nFaceZones = 0;
    label nCellZones = 0;

/* 
    Adding the following faces zones:
    1:  pistonLayerFaces
    nV: pistonLayerFacesV
    
    Adding the following cell zones:
    1:  movingCellsPiston
    nV:  movingCellsPistonV
    
    Adding the following point zones:
    1: pistonPoints
    nV: valvePistonPointsV

*/

#   include "addPistonFacesPointZonesEngineValveSliding.H"

/*
    Adding the following face zones:
    
    nV: curtainCylZoneV
    nV: curtainPortZoneV
    nV: cutFaceZoneV
    nV: poppetZoneV
    nV: bottomZoneV
    
    Adding the following point zones:

    nV: cutPointsV
    
*/

#   include "addValvesFacesPointZonesEngineValveSliding.H"

/*
    
    Adding the following point zones:
    
    nV: valveTopPointsV
    nV: valveBottomPointsV

    Adding the following cell zones:

    nV: movingCellsTopV
    nV: movingCellsBotV

*/

#   include "addOutputCellsEngineValveSliding.H"

    Info<< "Adding " << nPointZones << " point, "
        << nFaceZones << " face zones and "
        << nCellZones << " cell zones" << endl;

    pz.setSize(nPointZones);
    Info << "setSize pz" << endl;
    fz.setSize(nFaceZones);
    Info << "setSize fz" << endl;
    cz.setSize(nCellZones);
    Info << "setSize cz" << endl;

    addZones(pz, fz, cz);

#   include "addMeshModifiersEngineValveSliding.H"

    // Calculating the virtual positions of piston and valves

    setVirtualPositions();

    Info << " Write mesh " << endl;
    // Write mesh and modifiers
    topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
    write();

    Info << " Mesh written " << endl;

//    Info << "virtualPistonPosition = " << virtualPistonPosition() << endl;
//    Info << "piston position = " << pistonPosition() << endl;

}
void Foam::layerARGambit::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston motion

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
    )
    {
        Info<< "void layerARGambit::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void layerARGambit::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        setVirtualPistonPosition();
        checkAndCalculate();

        return;
    }

    checkAndCalculate();
    

    Info<< "Time = " << engTime().theta() << endl
        << "Adding zones to the engine mesh" << endl;

    //fz = 1: faces where layer are added/removed
    //pz = 2: points below the virtual piston faces and head points

    List<pointZone*> pz(2);
    List<faceZone*> fz(1);
    List<cellZone*> cz(0);

    label nPointZones = 0;
    label nFaceZones = 0;

    // Add the piston zone
    if (piston().patchID().active() && offSet() > SMALL)
    {

        // Piston position
        
        label pistonPatchID = piston().patchID().index();
        
        scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z();
        
        scalar zPistV = zPist + offSet();

        labelList zone1(faceCentres().size());
        boolList flipZone1(faceCentres().size(), false);
        label nZoneFaces1 = 0;

        bool foundAtLeastOne = false;
        scalar zHigher = GREAT;
        scalar zLower = GREAT;
        scalar dh = GREAT;
        scalar dl = GREAT;

        forAll (faceCentres(), faceI)
        {
            scalar zc = faceCentres()[faceI].z();
            vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]);
            scalar dd = n & vector(0,0,1);

            if (mag(dd) > 0.1)
            {
                if (zPistV - zc > 0 && zPistV - zc < dl)
                {
                    zLower = zc;
                    dl = zPistV - zc;
                }
            
                if (zc - zPistV > 0 && zc - zPistV < dh)
                {
                    zHigher = zc;
                    dh = zc - zHigher;
                }
            
                if
                (
                    zc > zPistV - delta()
                    && zc < zPistV + delta()
                )
                {
                    foundAtLeastOne = true;
                    if ((faceAreas()[faceI] & vector(0,0,1)) < 0)
                    {
                        flipZone1[nZoneFaces1] = true;
                    }
                
                    zone1[nZoneFaces1] = faceI;
                    nZoneFaces1++;
                }
            }
        }
void Foam::simpleEngineTopoFvMesh::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston and valve motion

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
    )
    {
        Info<< "void Foam::simpleEngineTopoFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void simpleEngineTopoFvMesh::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << abort(FatalError);
        }

        return;
    }

    Info<< "Time = " << engineTime_.theta() << endl
        << "Adding zones to the engine mesh" << endl;

    List<pointZone*> pz(nValves());
    List<faceZone*> fz(6*nValves() + 1);
    List<cellZone*> cz(0);

    label nPointZones = 0;
    label nFaceZones = 0;

    for (label valveI = 0; valveI < nValves(); valveI++)
    {
        // If both sides of the interface exist, add sliding interface
        // for a valve
        if
        (
            valves_[valveI].curtainInCylinderPatchID().active()
         && valves_[valveI].curtainInPortPatchID().active()
        )
        {
            Info<< "Adding sliding interface zones for curtain of valve "
                << valveI + 1 << endl;

            pz[nPointZones] =
                new pointZone
                (
                    "cutPointsV" + Foam::name(valveI + 1),
                    labelList(0),
                    nPointZones,
                    pointZones()
                );
            nPointZones++;

            const polyPatch& cylCurtain =
                boundaryMesh()
                    [valves_[valveI].curtainInCylinderPatchID().index()];

            labelList cylCurtainLabels(cylCurtain.size(), cylCurtain.start());

            forAll (cylCurtainLabels, i)
            {
                cylCurtainLabels[i] += i;
            }

            fz[nFaceZones] =
                new faceZone
                (
                    "curtainCylZoneV" + Foam::name(valveI + 1),
                    cylCurtainLabels,
                    boolList(cylCurtainLabels.size(), false),
                    nFaceZones,
                    faceZones()
                );
            nFaceZones++;

            const polyPatch& portCurtain =
                boundaryMesh()
                    [valves_[valveI].curtainInPortPatchID().index()];

            labelList portCurtainLabels
            (
                portCurtain.size(),
                portCurtain.start()
            );

            forAll (portCurtainLabels, i)
            {
                portCurtainLabels[i] += i;
            }

            fz[nFaceZones] =
                new faceZone
                (
                    "curtainPortZoneV" + Foam::name(valveI + 1),
                    portCurtainLabels,
                    boolList(portCurtainLabels.size(), false),
                    nFaceZones,
                    faceZones()
                );
            nFaceZones++;

            // Add empty zone for cut faces
            fz[nFaceZones] =
                new faceZone
                (
                    "cutFaceZoneV" + Foam::name(valveI + 1),
                    labelList(0),
                    boolList(0, false),
                    nFaceZones,
                    faceZones()
                );
            nFaceZones++;

            // Create a detach zone
            if
            (
                valves_[valveI].detachInCylinderPatchID().active()
             && valves_[valveI].detachInPortPatchID().active()
             && valves_[valveI].detachFaces().size() > 0
            )
            {
                Info<< "Adding detach boundary for valve "
                    << valveI + 1 << endl;

                const vectorField& areas = Sf().internalField();

                const labelList& df = valves_[valveI].detachFaces();

                boolList flip(df.size(), false);

                const vector& pistonAxis = piston().cs().axis();

                forAll (df, dfI)
                {
                    if (isInternalFace(df[dfI]))
                    {
                        if ((areas[df[dfI]] & pistonAxis) > 0)
                        {
                            flip[dfI] = true;
                        }
                    }
                    else
                    {
                        FatalErrorIn
                        (
                            "void simpleEngineTopoFvMesh::"
                            "addZonesAndModifiers()"
                        )   << "found boundary face in valve detach definition"
                            << " for valve " << valveI + 1
                            << ".  This is not allowed.  Detach faces: "
                            << df << " nInternalFaces: " << nInternalFaces()
                            << abort(FatalError);
                    }
                }

                // Add detach face zone
                fz[nFaceZones] =
                    new faceZone
                    (
                        "detachFaceZoneV" + Foam::name(valveI + 1),
                        df,
                        flip,
                        nFaceZones,
                        faceZones()
                    );
                nFaceZones++;
            }
        }
Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
:
    dynamicFvMesh(io),
    dynamicMeshCoeffs_
    (
        IOdictionary
        (
            IOobject
            (
                "dynamicMeshDict",
                io.time().constant(),
                *this,
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).subDict(typeName + "Coeffs")
    ),
    SBMFPtr_(solidBodyMotionFunction::New(dynamicMeshCoeffs_, io.time())),
    undisplacedPoints_
    (
        IOobject
        (
            "points",
            io.time().constant(),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    ),
    zoneID_(-1),
    pointIDs_()
{
    if (undisplacedPoints_.size() != nPoints())
    {
        FatalIOErrorIn
        (
            "solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject&)",
            dynamicMeshCoeffs_
        )   << "Read " << undisplacedPoints_.size()
            << " undisplaced points from " << undisplacedPoints_.objectPath()
            << " but the current mesh has " << nPoints()
            << exit(FatalError);
    }

    word cellZoneName =
        dynamicMeshCoeffs_.lookupOrDefault<word>("cellZone", "none");

    if (cellZoneName != "none")
    {
        zoneID_ = cellZones().findZoneID(cellZoneName);
        Info<< "Applying solid body motion to cellZone " << cellZoneName
            << endl;

        const cellZone& cz = cellZones()[zoneID_];


        // collect point IDs of points in cell zone

        boolList movePts(nPoints(), false);

        forAll(cz, i)
        {
            label cellI = cz[i];
            const cell& c = cells()[cellI];
            forAll(c, j)
            {
                const face& f = faces()[c[j]];
                forAll(f, k)
                {
                    label pointI = f[k];
                    movePts[pointI] = true;
                }
            }
Пример #5
0
void Foam::simpleTwoStroke::calcMovingMasks() const
{
    if (debug)
    {
        Info<< "void movingSquaresTM::calcMovingMasks() const : "
            << "Calculating point and cell masks"
            << endl;
    }

    if (movingPointsMaskPtr_)
    {
        FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
            << "point mask already calculated"
            << abort(FatalError);
    }

    // Set the point mask
    movingPointsMaskPtr_ = new scalarField(allPoints().size(), 0);
    scalarField& movingPointsMask = *movingPointsMaskPtr_;

    const cellList& c = cells();
    const faceList& f = allFaces();

    const labelList& cellAddr =
        cellZones()[cellZones().findZoneID("movingCells")];

    forAll (cellAddr, cellI)
    {
        const cell& curCell = c[cellAddr[cellI]];

        forAll (curCell, faceI)
        {
            // Mark all the points as moving
            const face& curFace = f[curCell[faceI]];

            forAll (curFace, pointI)
            {
                movingPointsMask[curFace[pointI]] = 1;
            }
        }
    }

    
    if(foundScavPorts())
    {

        const word innerScavZoneName
        (
            scavInCylPatchName_  + "Zone"
        );

        const labelList& innerScavAddr =
            faceZones()[faceZones().findZoneID(innerScavZoneName)];

        forAll (innerScavAddr, faceI)
        {
            const face& curFace = f[innerScavAddr[faceI]];

            forAll (curFace, pointI)
            {
                movingPointsMask[curFace[pointI]] = 1;
            }
        }

        const word outerScavZoneName
        (
            scavInPortPatchName_ + "Zone"
        );

        const labelList& outerScavAddr =
            faceZones()[faceZones().findZoneID(outerScavZoneName)];

        forAll (outerScavAddr, faceI)
        {
            const face& curFace = f[outerScavAddr[faceI]];

            forAll (curFace, pointI)
            {
                movingPointsMask[curFace[pointI]] = 0;
            }
        }
    
    }
           
}
 // Copy existing cell zones
 forAll (cellZones(), zoneI)
 {
     cz[nCz] = cellZones()[zoneI].clone(cellZones()).ptr();
     nCz++;
 }
void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
{
    // Inner slider
    const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));

    // Outer slider
    const word outerSliderName
    (
        motionDict_.subDict("slider").lookup("outside")
    );

    bool initialised = false;

    // Check if zones and modifiers for motion action are present
    label insideZoneID = faceZones().findZoneID(innerSliderName + "Zone");
    label outsideZoneID = faceZones().findZoneID(outerSliderName + "Zone");

    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;
    }

    // Check if slider has been initialised on any of the processors
    reduce(initialised, orOp<bool>());

    if (initialised)
    {
        InfoIn("void linearValveLayersFvMesh::addZonesAndModifiers()")
            << "Zones and modifiers already present.  Skipping."
            << endl;

        return;
    }

    // Add zones and modifiers for motion action
    Info<< "Time = " << time().timeName() << endl
        << "Adding zones and modifiers to the mesh" << endl;

    // 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());

    // Add a topology modifier
    topoChanger_.setSize(2);
    label nTc = 0;

    // Copy existing point zones
    forAll (pointZones(), zoneI)
    {
        pz[nPz] = pointZones()[zoneI].clone(pointZones()).ptr();
        nPz++;
    }  
bool Foam::simpleTwoStroke::update()
{
    // Detaching the interface
    if (attached())
    {
        Info << "Decoupling sliding interfaces" << endl;
        makeSlidersLive();
        topoChanger_.changeMesh();

        Info << "sliding interfaces successfully decoupled!!!" << endl;
    }
    else
    {
        Info << "Sliding interfaces decoupled" << endl;
    }

    Info << "Executing layer action" << endl;

    // Piston Layering

    makeLayersLive();

    // Find piston mesh modifier
    const label pistonLayerID =
        topoChanger_.findModifierID("pistonLayer");

    if (pistonLayerID < 0)
    {
        FatalErrorIn("void engineFvMesh::moveAndMorph()")
            << "Piston modifier not found."
            << abort(FatalError);
    }

    scalar minLayerThickness = piston().minLayer();
    scalar deltaZ = engTime().pistonDisplacement().value();
    virtualPistonPosition() += deltaZ;

    Info << "virtualPistonPosition = " << virtualPistonPosition()
    << ", deckHeight = " << deckHeight()
    << ", pistonPosition = " << pistonPosition() << endl;

    if (realDeformation())
    {
        // Dectivate piston layer
        Info << "Mesh deformation mode" << endl;
        topoChanger_[pistonLayerID].disable();
    }
    else
    {
        // Activate piston layer
        Info << "Piston layering mode" << endl;
        topoChanger_[pistonLayerID].enable();
    }


    // Changing topology by hand
    autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh();

    // Work array for new points position.
    pointField newPoints = points();

    if (topoChangeMap->morphing())
    {

        if (topoChangeMap->hasMotionPoints())
        {
            Info << "Topology change; executing pre-motion" << endl;
            movePoints(topoChangeMap->preMotionPoints());
            newPoints = topoChangeMap->preMotionPoints();
        }
        setV0();
        resetMotion();
    }

    // Reset the position of layered interfaces

    boolList scaleDisp(nPoints(), true);
    label nScaled = nPoints();

    List<bool> pistonPoint(newPoints.size(), false);
    List<bool> headPoint(newPoints.size(), false);

//    label pistonPtsIndex = pointZones().findZoneID("pistonPoints");
//    const labelList& pistonPoints = pointZones()[pistonPtsIndex];

    labelList pistonPoints;

    {
        label movingCellsIndex = cellZones().findZoneID("movingCells");

        if (movingCellsIndex < 0)
        {
            FatalErrorIn("bool twoStrokeEngine::update()")
                << "Cannot find cell zone movingCells"
                << abort(FatalError);
        }


        const labelList& pistonCells = cellZones()[movingCellsIndex];

        const labelListList& cp = cellPoints();

        boolList count(newPoints.size(), false);

        forAll (pistonCells, cellI)
        {
            const labelList& curCellPoints = cp[pistonCells[cellI]];

            forAll (curCellPoints, i)
            {
                count[curCellPoints[i]] = true;
            }
        }

        // Count the points
        label nCounted = 0;
        forAll (count, pointI)
        {
            if (count[pointI] == true)
            {
                nCounted++;
            }
        }

        pistonPoints.setSize(nCounted);

        // Collect the points
        nCounted = 0;
        forAll (count, pointI)
        {
            if (count[pointI] == true)
            {
                pistonPoints[nCounted] = pointI;
                nCounted++;
            }
        }

    }

    label headPtsIndex = pointZones().findZoneID("headPoints");
    const labelList& headPoints = pointZones()[headPtsIndex];

    const scalarField& movingPointsM = movingPointsMask();

    forAll(pistonPoints, i)
    {
        label pointI = pistonPoints[i];
        pistonPoint[pointI] = true;
        point& p = newPoints[pointI];

        if (p.z() < pistonPosition() - 1.0e-6)
        {
            scaleDisp[pointI] = false;
            nScaled--;
        }
    }
Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
:
    dynamicFvMesh(io),
    dynamicMeshCoeffs_
    (
        IOdictionary
        (
            IOobject
            (
                "dynamicMeshDict",
                io.time().constant(),
                *this,
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).subDict(typeName + "Coeffs")
    ),
    SBMFPtr_(solidBodyMotionFunction::New(dynamicMeshCoeffs_, io.time())),
    undisplacedPoints_
    (
        IOobject
        (
            "points",
            io.time().constant(),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    ),
    pointIDs_(),
    moveAllCells_(false),
    UName_(dynamicMeshCoeffs_.lookupOrDefault<word>("UName", "U"))
{
    if (undisplacedPoints_.size() != nPoints())
    {
        FatalIOErrorIn
        (
            "solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject&)",
            dynamicMeshCoeffs_
        )   << "Read " << undisplacedPoints_.size()
            << " undisplaced points from " << undisplacedPoints_.objectPath()
            << " but the current mesh has " << nPoints()
            << exit(FatalIOError);
    }

    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;

        label zoneID = cellZones().findZoneID(cellZoneName);

        if (zoneID == -1)
        {
            FatalErrorIn
            (
                "solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject&)"
            )
                << "Unable to find cellZone " << cellZoneName
                << ".  Valid celLZones are:"
                << cellZones().names()
                << exit(FatalError);
        }

        cellIDs = cellZones()[zoneID];
    }

    if (cellSetName != "none")
    {
        Info<< "Applying solid body motion to cellSet " << cellSetName
            << endl;

        cellSet set(*this, cellSetName);

        cellIDs = set.toc();
    }

    label nCells = returnReduce(cellIDs.size(), sumOp<label>());
    moveAllCells_ = nCells == 0;

    if (moveAllCells_)
    {
        Info<< "Applying solid body motion to entire mesh" << endl;
    }
    else
    {
        // collect point IDs of points in cell zone

        boolList movePts(nPoints(), false);

        forAll(cellIDs, i)
        {
            label cellI = cellIDs[i];
            const cell& c = cells()[cellI];
            forAll(c, j)
            {
                const face& f = faces()[c[j]];
                forAll(f, k)
                {
                    label pointI = f[k];
                    movePts[pointI] = true;
                }
            }
        }
void Foam::sixDofTopoMotion::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if (useTopoSliding_)
    {
        if
        (
            pointZones().size() > 0
         || faceZones().size() > 0
         || cellZones().size() > 0
        )
        {
            Info<< "void sixDofTopoMotion::addZonesAndModifiers() : "
                << "Zones and modifiers already present.  Skipping."
                << endl;

            if (topoChanger_.size() == 0)
            {
                FatalErrorIn
                (
                    "void sixDofTopoMotion::addZonesAndModifiers()"
                )   << "Mesh modifiers not read properly"
                    << abort(FatalError);
            }

            return;
        }

        Info<< "Time = " << time().timeName() << endl
            << "Adding zones and modifiers to the mesh" << endl;

        // Add zones
        List<pointZone*> pz(3*bodies_.size());
        List<faceZone*> fz(3*bodies_.size());
        List<cellZone*> cz(0);

        label npz = 0;
        label nfz = 0;
        label nSliders = 0;

        forAll (bodies_, bodyI)
        {
            const floatingBody& curBody = bodies_[bodyI];

            if
            (
                curBody.hullSlider().active()
             && curBody.fixedSlider().active()
            )
            {
                nSliders++;

                // Add an empty zone for cut points
                pz[npz] = new pointZone
                (
                    curBody.name() + "CutPointZone",
                    labelList(0),
                    npz,
                    pointZones()
                );
                npz++;

                // Do face zones for slider

                // Inner slider
                const polyPatch& innerSlider =
                    boundaryMesh()[curBody.hullSlider().index()];

                labelList isf(innerSlider.size());

                forAll (isf, i)
                {
                    isf[i] = innerSlider.start() + i;
                }

                fz[nfz] = new faceZone
                (
                    curBody.name() + "InsideSliderZone",
                    isf,
                    boolList(innerSlider.size(), false),
                    nfz,
                    faceZones()
                );
                nfz++;

                // Outer slider
                const polyPatch& outerSlider =
                    boundaryMesh()[curBody.fixedSlider().index()];

                labelList osf(outerSlider.size());

                forAll (osf, i)
                {
                    osf[i] = outerSlider.start() + i;
                }

                fz[nfz] = new faceZone
                (
                    curBody.name() + "OutsideSliderZone",
                    osf,
                    boolList(outerSlider.size(), false),
                    nfz,
                    faceZones()
                );
                nfz++;

                // Add empty zone for cut faces
                fz[nfz] = new faceZone
                (
                    curBody.name() + "CutFaceZone",
                    labelList(0),
                    boolList(0, false),
                    nfz,
                    faceZones()
                );
                nfz++;
            }
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;
}
Foam::multiSolidBodyMotionFvMesh::multiSolidBodyMotionFvMesh(const IOobject& io)
:
    dynamicFvMesh(io),
    dynamicMeshCoeffs_
    (
        IOdictionary
        (
            IOobject
            (
                "dynamicMeshDict",
                io.time().constant(),
                *this,
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).subDict(typeName + "Coeffs")
    ),
    undisplacedPoints_
    (
        IOobject
        (
            "points",
            io.time().constant(),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    )
{
    if (undisplacedPoints_.size() != nPoints())
    {
        FatalIOErrorInFunction
        (
            dynamicMeshCoeffs_
        )   << "Read " << undisplacedPoints_.size()
            << " undisplaced points from " << undisplacedPoints_.objectPath()
            << " but the current mesh has " << nPoints()
            << exit(FatalIOError);
    }


    zoneIDs_.setSize(dynamicMeshCoeffs_.size());
    SBMFs_.setSize(dynamicMeshCoeffs_.size());
    pointIDs_.setSize(dynamicMeshCoeffs_.size());
    label zoneI = 0;

    forAllConstIter(dictionary, dynamicMeshCoeffs_, iter)
    {
        if (iter().isDict())
        {
            zoneIDs_[zoneI] = cellZones().findZoneID(iter().keyword());

            if (zoneIDs_[zoneI] == -1)
            {
                FatalIOErrorInFunction
                (
                    dynamicMeshCoeffs_
                )   << "Cannot find cellZone named " << iter().keyword()
                    << ". Valid zones are " << cellZones().names()
                    << exit(FatalIOError);
            }

            const dictionary& subDict = iter().dict();

            SBMFs_.set
            (
                zoneI,
                solidBodyMotionFunction::New(subDict, io.time())
            );

            // Collect points of cell zone.
            const cellZone& cz = cellZones()[zoneIDs_[zoneI]];

            boolList movePts(nPoints(), false);

            forAll(cz, i)
            {
                label celli = cz[i];
                const cell& c = cells()[celli];
                forAll(c, j)
                {
                    const face& f = faces()[c[j]];
                    forAll(f, k)
                    {
                        label pointi = f[k];
                        movePts[pointi] = true;
                    }
                }
            }
void Foam::pistonSliding::addZonesAndModifiers()
{
    // Add the zones and mesh modifiers to operate piston motion

    if
    (
        pointZones().size() > 0
     || faceZones().size() > 0
     || cellZones().size() > 0
     || topoChanger_.size() > 0
    )
    {
        Info<< "Time = " << engTime().theta() << endl;
        Info<< "void Foam::verticalValvesGambit::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        setVirtualPositions();
//        checkAndCalculate();

        Info << "Point zones found = " << pointZones().size() << endl;
        Info << "Face zones found = " << faceZones().size() << endl;
        Info << "Cell zones found = " << cellZones().size() << endl;

        return;

    }

    if
    (
        engTime().engineDict().found("zOffsetGambit")
     && engTime().engineDict().found("zDisplGambit")
    )
    {
        Info << "Assembling the cylinder mesh" << endl;

        scalar zOffset
        (
            readScalar(engTime().engineDict().lookup("zOffsetGambit"))
        );

        scalar zDispl
        (
            readScalar(engTime().engineDict().lookup("zDisplGambit"))
        );

        pointField pDispl = points();

        forAll(points(), pointI)
        {
            const point p = points()[pointI];

            if(p.z() >= zOffset)
            {
                pDispl[pointI].z() -= zDispl;
            }
        }

        movePoints(pDispl);
        write();
        resetMotion();

        Info << "Cylinder mesh assembled" << endl;
    }
Пример #14
0
void Foam::mixerFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if
    (
        pointZones().size() > 0
        || faceZones().size() > 0
        || cellZones().size() > 0
    )
    {
        Info<< "void mixerFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        if (topoChanger_.size() == 0)
        {
            FatalErrorIn
            (
                "void mixerFvMesh::addZonesAndModifiers()"
            )   << "Mesh modifiers not read properly"
                << 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);

    // Moving slider
    const word movingSliderName(dict_.subDict("slider").lookup("moving"));
    label movingSliderIndex = boundaryMesh().findPatchID(movingSliderName);

    if (movingSliderIndex < 0)
    {
        FatalErrorIn("void mixerFvMesh::addZonesAndModifiers() const")
                << "Moving slider patch not found in boundary"
                << abort(FatalError);
    }

    const word staticSliderName(dict_.subDict("slider").lookup("static"));
    label staticSliderIndex = boundaryMesh().findPatchID(staticSliderName);

    if (staticSliderIndex < 0)
    {
        FatalErrorIn("void mixerFvMesh::addZonesAndModifiers() const")
                << "Static slider patch not found in boundary"
                << abort(FatalError);

    }

    const polyPatch& movingSlider = boundaryMesh()[movingSliderIndex];

    labelList isf(movingSlider.size());

    forAll (isf, i)
    {
        isf[i] = movingSlider.start() + i;
    }
Пример #15
0
        if (rs[cellI] == originRegion)
        {
            movingCells[nMovingCells] = cellI;
            nMovingCells++;
        }
    }

    movingCells.setSize(nMovingCells);
    Info << "Number of cells in the moving region: " << nMovingCells << endl;

    cz[0] = new cellZone
    (
        "movingCells",
        movingCells,
        0,
        cellZones()
    );

    Info << "Adding point, face and cell zones" << endl;
    addZones(pz, fz, cz);

    // Add a topology modifier
    Info << "Adding topology modifiers" << endl;
    topoChanger_.setSize(1);
    topoChanger_.set
    (
        0,
        new slidingInterface
        (
            "mixerSlider",
            0,
Пример #16
0
void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
{
    // Add zones and modifiers for motion action

    if
    (
        pointZones().size()
     || faceZones().size()
     || cellZones().size()
     || topoChanger_.size()
    )
    {
        Info<< "void movingConeTopoFvMesh::addZonesAndModifiers() : "
            << "Zones and modifiers already present.  Skipping."
            << endl;

        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

    List<polyMeshModifier*> tm(2);
    label nMods = 0;

    tm[nMods] =
        new layerAdditionRemoval
        (
            "right",
            nMods,
            topoChanger_,
            "rightExtrusionFaces",
            readScalar
            (
                motionDict_.subDict("right").lookup("minThickness")
            ),
            readScalar
            (
                motionDict_.subDict("right").lookup("maxThickness")
            )
        );
    nMods++;

    tm[nMods] = new layerAdditionRemoval
    (
        "left",
        nMods,
        topoChanger_,
        "leftExtrusionFaces",
        readScalar
        (
            motionDict_.subDict("left").lookup("minThickness")
        ),
        readScalar
        (
            motionDict_.subDict("left").lookup("maxThickness")
        )
    );
    nMods++;
    tm.setSize(nMods);

    Info<< "Adding " << nMods << " mesh modifiers" << endl;
    topoChanger_.addTopologyModifiers(tm);

    write();
}