Skip to content
Snippets Groups Projects
InteractionLists.C 33.7 KiB
Newer Older
  • Learn to ignore specific revisions
  •         const labelPair& wfiat = wallFaceIndexAndTransformToDistribute_[rWVI];
    
    
            label wallFaceIndex = globalTransforms_.index(wfiat);
    
    
            const vectorTensorTransform& transform = globalTransforms_.transform
    
            (
                globalTransforms_.transformIndex(wfiat)
            );
    
    
            label patchI = mesh_.boundaryMesh().patchID()
            [
                wallFaceIndex - mesh_.nInternalFaces()
            ];
    
            label patchFaceI =
                wallFaceIndex
              - mesh_.boundaryMesh()[patchI].start();
    
            // Need to transform velocity when tensor transforms are
            // supported
            referredWallData_[rWVI] = U.boundaryField()[patchI][patchFaceI];
    
            if (transform.hasR())
            {
                referredWallData_[rWVI] =
                    transform.R().T() & referredWallData_[rWVI];
            }
    
    template<class ParticleType>
    void Foam::InteractionLists<ParticleType>::writeReferredWallFaces() const
    {
    
        if (referredWallFaces_.empty())
        {
            return;
        }
    
        fileName objDir = mesh_.time().timePath()/cloud::prefix;
    
        fileName objFileName = "referredWallFaces.obj";
    
        OFstream str(objDir/objFileName);
    
        Info<< "    Writing "
            << mesh_.time().timeName()/cloud::prefix/objFileName
            << endl;
    
        label offset = 1;
    
        forAll(referredWallFaces_, rWFI)
    
            const referredWallFace& rwf = referredWallFaces_[rWFI];
    
            forAll(rwf, fPtI)
    
                meshTools::writeOBJ(str, rwf.points()[rwf[fPtI]]);
    
            forAll(rwf, fPtI)
    
                str<< ' ' << fPtI + offset;
            }
    
            offset += rwf.size();
    
    // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
    
    
    template<class ParticleType>
    Foam::InteractionLists<ParticleType>::InteractionLists(const polyMesh& mesh)
    :
        mesh_(mesh),
        cloud_(mesh_, "NULL_Cloud", IDLList<ParticleType>()),
        writeCloud_(false),
        cellMapPtr_(),
        wallFaceMapPtr_(),
        globalTransforms_(mesh_),
        maxDistance_(0.0),
        dil_(),
        dwfil_(),
        ril_(),
        rilInverse_(),
        cellIndexAndTransformToDistribute_(),
        wallFaceIndexAndTransformToDistribute_(),
        referredWallFaces_(),
        UName_("unknown_UName"),
        referredWallData_(),
        referredParticles_()
    {}
    
    
    
    template<class ParticleType>
    Foam::InteractionLists<ParticleType>::InteractionLists
    (
        const polyMesh& mesh,
        scalar maxDistance,
        Switch writeCloud,
        const word& UName
    )
    :
        mesh_(mesh),
        cloud_(mesh_, "referredParticleCloud", IDLList<ParticleType>()),
        writeCloud_(writeCloud),
        cellMapPtr_(),
        wallFaceMapPtr_(),
        globalTransforms_(mesh_),
        maxDistance_(maxDistance),
        dil_(),
        dwfil_(),
        ril_(),
        rilInverse_(),
        cellIndexAndTransformToDistribute_(),
        wallFaceIndexAndTransformToDistribute_(),
        referredWallFaces_(),
        UName_(UName),
        referredWallData_(),
        referredParticles_()
    {
        buildInteractionLists();
    }
    
    
    // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
    
    
    template<class ParticleType>
    
    Foam::InteractionLists<ParticleType>::~InteractionLists()
    {}
    
    
    // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
    
    template<class ParticleType>
    
    void Foam::InteractionLists<ParticleType>::sendReferredData
    
        const List<DynamicList<ParticleType*> >& cellOccupancy,
        PstreamBuffers& pBufs
    
        if (mesh_.changing())
        {
            WarningIn
            (
                "void Foam::InteractionLists<ParticleType>::sendReferredData"
                "("
                    "const List<DynamicList<ParticleType*> >& cellOccupancy,"
                    "PstreamBuffers& pBufs"
                ")"
            )
                << "Mesh changing, rebuilding InteractionLists form scratch."
                << endl;
    
            buildInteractionLists();
        }
    
    
        prepareParticlesToRefer(cellOccupancy);
    
        for (label domain = 0; domain < Pstream::nProcs(); domain++)
    
            const labelList& subMap = cellMap().subMap()[domain];
    
                UOPstream toDomain(domain, pBufs);
    
                UIndirectList<IDLList<ParticleType> > subMappedParticles
                (
                    referredParticles_,
                    subMap
                );
    
                forAll(subMappedParticles, i)
                {
                    toDomain << subMappedParticles[i];
                }
    
        // Using the mapDistribute to start sending and receiving the
        // buffer but not block, i.e. it is calling
        //     pBufs.finishedSends(false);
        wallFaceMap().send(pBufs, referredWallData_);
    
    template<class ParticleType>
    
    void Foam::InteractionLists<ParticleType>::receiveReferredData
    
        referredParticles_.setSize(cellMap().constructSize());
    
    
        for (label domain = 0; domain < Pstream::nProcs(); domain++)
    
            const labelList& constructMap = cellMap().constructMap()[domain];
    
            if (constructMap.size())
    
                UIPstream str(domain, pBufs);
    
                forAll(constructMap, i)
    
                    referredParticles_[constructMap[i]] = IDLList<ParticleType>
                    (
                        str,
                        typename ParticleType::iNew(cloud_)
                    );
    
        fillReferredParticleCloud();
    
    
        wallFaceMap().receive(pBufs, referredWallData_);
    
    }
    
    
    // ************************************************************************* //