linearCommunication_.setSize(nProcs);

    // Master
    labelList belowIDs(nProcs - 1);
    forAll(belowIDs, i)
    {
        belowIDs[i] = i + 1;
    }

    linearCommunication_[0] = commsStruct
    (
        nProcs,
        0,
        -1,
        belowIDs,
        labelList(0)
    );

    // Slaves. Have no below processors, only communicate up to master
    for (label procID = 1; procID < nProcs; procID++)
    {
        linearCommunication_[procID] = commsStruct
        (
            nProcs,
            procID,
            0,
            labelList(0),
            labelList(0)
        );
    }
}
//- Calculate addressing for interpolative mapping
void topoCellMapper::calcAddressing() const
{
    if (directAddrPtr_ || interpolationAddrPtr_)
    {
        FatalErrorIn("void topoCellMapper::calcAddressing() const")
            << "Addressing already calculated."
            << abort(FatalError);
    }

    // Allocate for inserted cell labels
    label nInsertedCells = 0;

    insertedCellLabelsPtr_ = new labelList(mesh_.nCells(), -1);
    labelList& insertedCells = *insertedCellLabelsPtr_;

    if (direct())
    {
        // Direct addressing, no weights
        directAddrPtr_ = new labelList(mpm_.cellMap());
    }
    else
    {
        // Interpolative addressing
        interpolationAddrPtr_ = new labelListList(mesh_.nCells());
        labelListList& addr = *interpolationAddrPtr_;

        const List<objectMap>& cfc = mpm_.cellsFromCellsMap();

        forAll (cfc, cfcI)
        {
            // Get addressing
            const labelList& mo = cfc[cfcI].masterObjects();

            label cellI = cfc[cfcI].index();

            if (addr[cellI].size() > 0)
            {
                FatalErrorIn("void topoCellMapper::calcAddressing() const")
                    << "Master cell " << cellI
                    << " mapped from cells " << mo
                    << " is already destination for mapping."
                    << abort(FatalError);
            }

            // Set master objects
            addr[cellI] = mo;
        }

        // Do mapped cells. Note that this can already be set by cellsFromCells
        // so check if addressing size still zero.
        const labelList& cm = mpm_.cellMap();

        forAll (cm, cellI)
        {
            // Mapped from a single cell
            if (cm[cellI] > -1 && addr[cellI].empty())
            {
                addr[cellI] = labelList(1, cm[cellI]);
            }

            // Check for inserted cells without any addressing
            if (cm[cellI] < 0 && addr[cellI].empty())
            {
                insertedCells[nInsertedCells++] = cellI;
            }
        }
    }

    // Shorten inserted cells to actual size
    insertedCells.setSize(nInsertedCells);

    if (nInsertedCells)
    {
        FatalErrorIn("void topoCellMapper::calcAddressing() const")
            << " Found " << nInsertedCells << " which are"
            << " not mapped from any parent cells." << nl
            << " List: " << nl
            << insertedCells
            << abort(FatalError);
    }
}
示例#3
0
// Rework faceOnlySet samples.
// Take two consecutive samples
void Foam::midPointSet::genSamples()
{
    // Generate midpoints.

    List<point> midPoints(2*size());
    labelList midCells(2*size());
    labelList midSegments(2*size());
    scalarList midCurveDist(2*size());

    label midI = 0;

    label sampleI = 0;

    while(true && size()>0)
    {
        // calculate midpoint between sampleI and sampleI+1 (if in same segment)
        while
        (
            (sampleI < size() - 1)
         && (segments_[sampleI] == segments_[sampleI+1])
        )
        {
            midPoints[midI] =
                0.5*(operator[](sampleI) + operator[](sampleI+1));

            label cell1 = getCell(faces_[sampleI], midPoints[midI]);
            label cell2 = getCell(faces_[sampleI+1], midPoints[midI]);

            if (cell1 != cell2)
            {
                FatalErrorIn("midPointSet::genSamples()")
                    << "  sampleI:" << sampleI
                    << "  midI:" << midI
                    << "  sampleI:" << sampleI
                    << "  pts[sampleI]:" << operator[](sampleI)
                    << "  face[sampleI]:" << faces_[sampleI]
                    << "  pts[sampleI+1]:" << operator[](sampleI+1)
                    << "  face[sampleI+1]:" << faces_[sampleI+1]
                    << "  cell1:" << cell1
                    << "  cell2:" << cell2
                    << abort(FatalError);
            }

            midCells[midI] = cell1;
            midSegments[midI] = segments_[sampleI];
            midCurveDist[midI] = mag(midPoints[midI] - start());

            midI++;
            sampleI++;
        }

        if (sampleI == size() - 1)
        {
            break;
        }
        sampleI++;
    }

    midPoints.setSize(midI);
    midCells.setSize(midI);
    midSegments.setSize(midI);
    midCurveDist.setSize(midI);
    setSamples
    (
        midPoints,
        midCells,
        labelList(midCells.size(), -1),
        midSegments,
        midCurveDist
    );
}
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++;
            }
 // 2. Any new interfaces
 forAll(subPatchIDs, procI)
 {
     label nIntfcs = interPatchFaces[procI].size();
     subPatchIDs[procI].setSize(nIntfcs, labelList(1, patchi));
     subPatchStarts[procI].setSize(nIntfcs, labelList(1, label(0)));
 }
        );

        return;
    }

    // Set one handler per thread
    PtrList<meshHandler> hdl(nThreads);

    forAll(hdl, i)
    {
        hdl.set(i, new meshHandler(*this, threader()));
    }

    // Simple load-balancing scheme
    FixedList<label, 2> index(-1);
    FixedList<labelList, 2> tStarts(labelList(nThreads, 0));
    FixedList<labelList, 2> tSizes(labelList(nThreads, 0));

    index[0] = facesFromFaces_.size();
    index[1] = cellsFromCells_.size();

    if (debug > 2)
    {
        Info << " Mapping Faces: " << index[0] << endl;
        Info << " Mapping Cells: " << index[1] << endl;
    }

    forAll(index, indexI)
    {
        label j = 0, total = 0;
示例#7
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;
    }