Exemplo n.º 1
0
void Foam::IOPosition<ParticleType>::readData
(
    Cloud<ParticleType>& c,
    bool checkClass
)
{
    Istream& is = readStream(checkClass ? typeName : "");

    token firstToken(is);

    if (firstToken.isLabel())
    {
        label s = firstToken.labelToken();

        // Read beginning of contents
        is.readBeginList("Cloud<ParticleType>");

        for (label i=0; i<s; i++)
        {
            // Do not read any fields, position only
            c.append(new ParticleType(c, is, false));
        }

        // Read end of contents
        is.readEndList("Cloud<ParticleType>");
    }
    else if (firstToken.isPunctuation())
    {
        if (firstToken.pToken() != token::BEGIN_LIST)
        {
            FatalIOErrorIn
            (
                "void IOPosition<ParticleType>::readData"
                "(Cloud<ParticleType>&, bool)",
                is
            )   << "incorrect first token, '(', found "
                << firstToken.info()
                << exit(FatalIOError);
        }

        token lastToken(is);
        while
        (
           !(
                lastToken.isPunctuation()
             && lastToken.pToken() == token::END_LIST
            )
        )
        {
            is.putBack(lastToken);
            // Do not read any fields, position only
            c.append(new ParticleType(c, is, false));
            is >> lastToken;
        }
    }
    else
    {
Exemplo n.º 2
0
void Foam::reconstructLagrangianPositions
(
    const polyMesh& mesh,
    const word& cloudName,
    const PtrList<fvMesh>& meshes,
    const PtrList<labelIOList>& faceProcAddressing,
    const PtrList<labelIOList>& cellProcAddressing
)
{
    Cloud<passiveParticle> lagrangianPositions
    (
        mesh,
        cloudName,
        IDLList<passiveParticle>()
    );

    forAll(meshes, i)
    {
        const labelList& cellMap = cellProcAddressing[i];

        Cloud<passiveParticle> lpi(meshes[i], cloudName, false);

        forAllIter(Cloud<passiveParticle>, lpi, iter)
        {
            const passiveParticle& ppi = iter();

            lagrangianPositions.append
            (
                new passiveParticle
                (
                    lagrangianPositions,
                    ppi.position(),
                    cellMap[ppi.cell()]
                )
            );
        }
    }

    IOPosition<passiveParticle>(lagrangianPositions).write();
}