Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    Foam::argList::addBoolOption
    (
        "checkGeometry",
        "check all surface geometry for quality"
    );

    Foam::argList::addBoolOption
    (
        "conformationOnly",
        "conform to the initial points without any point motion"
    );

    #include "setRootCase.H"
    #include "createTime.H"

    runTime.functionObjects().off();

    const bool checkGeometry = args.optionFound("checkGeometry");
    const bool conformationOnly = args.optionFound("conformationOnly");

    IOdictionary foamyHexMeshDict
    (
        IOobject
        (
            args.executable() + "Dict",
            runTime.system(),
            runTime,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );


    if (checkGeometry)
    {
        const searchableSurfaces allGeometry
        (
            IOobject
            (
                "cvSearchableSurfaces",
                runTime.constant(),
                "triSurface",
                runTime,
                IOobject::MUST_READ,
                IOobject::NO_WRITE
            ),
            foamyHexMeshDict.subDict("geometry"),
            foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
        );

        // Write some stats
        allGeometry.writeStats(List<wordList>(0), Info);
        // Check topology
        allGeometry.checkTopology(true);
        // Check geometry
        allGeometry.checkGeometry
        (
            100.0,      // max size ratio
            1e-9,       // intersection tolerance
            autoPtr<writer<scalar>>(new vtkSetWriter<scalar>()),
            0.01,       // min triangle quality
            true
        );

        return 0;
    }


    conformalVoronoiMesh::debug = true;

    Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;

    conformalVoronoiMesh mesh(runTime, foamyHexMeshDict);


    if (conformationOnly)
    {
        mesh.initialiseForConformation();

        runTime++;

        mesh.writeMesh(runTime.timeName());
    }
    else
    {
        mesh.initialiseForMotion();

        while (runTime.run())
        {
            runTime++;

            Info<< nl << "Time = " << runTime.timeName() << endl;

            mesh.move();

            Info<< nl
                << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
                << "  ClockTime = " << runTime.elapsedClockTime() << " s"
                << nl << endl;
        }
    }


    Info<< nl << "End" << nl << endl;

    return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
    argList::noParallel();
    timeSelector::addOptions();

#   include "setRootCase.H"
#   include "createTime.H"

    // Get times list
    instantList timeDirs = timeSelector::select0(runTime, args);

#   include "createMesh.H"
#   include "readTransportProperties.H"

    const word& gFormat = runTime.graphFormat();

    // Setup channel indexing for averaging over channel down to a line

    IOdictionary channelDict
    (
        IOobject
        (
            "postChannelExtDict",
            mesh.time().constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );
    channelIndex channelIndexing(mesh, channelDict);

    List<Triple<word> > fields(channelDict.lookup("fieldsAndIdentifiers"));

    bool backwardsCompatibility(channelDict.lookupOrDefault("backwardsCompatibility", true));

    // For each time step read all fields
    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);
        Info << "Processing fields for time " << runTime.timeName() << endl;
        Info << endl;

        fileName path(runTime.rootPath()/runTime.caseName()/"graphs"/runTime.timeName());
        mkDir(path);

        forAll(fields, I)
        {
           const word& fieldName = fields[I].first();
           const word& identifierName = fields[I].second();
           const word& moment = fields[I].third();

           IOobject fieldHeader
           (
               fieldName,
               runTime.timeName(),
               mesh,
               IOobject::MUST_READ
           );

           if (!fieldHeader.headerOk())
           {
               Info << endl;
               Info<< "No " << fieldName <<" field" << endl;
               Info << endl;
               continue;
           }

           Info << endl;
           Info << fieldName << endl;

           if(fieldHeader.headerClassName() == volScalarField::typeName)
           {
               Info << endl;
               Info << "    Reading field" << endl;
              
               volScalarField field(fieldHeader, mesh);

               Info << "    Collapsing field"  << endl;
               Info << endl;
               processField(field, channelIndexing, identifierName, path, gFormat, moment);
           }

           if(fieldHeader.headerClassName() == volVectorField::typeName)
           {
               Info << endl;
               Info << "    Reading field" << endl;
               
               volVectorField field(fieldHeader, mesh);
               
               Info << "    Collapsing field"  << endl;
               Info << endl;
               
               
               if((fieldHeader.name() == "U" || fieldHeader.name() == "UMean") && backwardsCompatibility)
               {
                   processField(field.component(vector::X)(), channelIndexing, identifierName, path, gFormat, "mean");
               }
               else
               {
                   processField(field.component(vector::X)(), channelIndexing, identifierName+"_x", path, gFormat, moment);
                   processField(field.component(vector::Y)(), channelIndexing, identifierName+"_y", path, gFormat, moment);
                   processField(field.component(vector::Z)(), channelIndexing, identifierName+"_z", path, gFormat, moment);
                    
               }
           }

           if(fieldHeader.headerClassName() == volSymmTensorField::typeName)
           {
               Info << endl;
               Info << "    Reading field" << endl;

               volSymmTensorField field(fieldHeader, mesh);

               Info << "    Collapsing field"  << endl;
               Info << endl;
               
               if((fieldHeader.name() == "UPrime2Mean") && backwardsCompatibility)
               {
                   processField(field.component(symmTensor::XX)(), channelIndexing, "u", path, gFormat, "rms");
                   processField(field.component(symmTensor::YY)(), channelIndexing, "v", path, gFormat, "rms");
                   processField(field.component(symmTensor::ZZ)(), channelIndexing, "w", path, gFormat, "rms");
                   processField(field.component(symmTensor::XY)(), channelIndexing, "uv", path, gFormat, "mean", true);
               }
               else
               {
                   processField(field.component(symmTensor::XX)(), channelIndexing, identifierName+"_xx", path, gFormat, moment);
                   processField(field.component(symmTensor::XY)(), channelIndexing, identifierName+"_xy", path, gFormat, moment, true);
                   processField(field.component(symmTensor::XZ)(), channelIndexing, identifierName+"_xz", path, gFormat, moment, true);
                   processField(field.component(symmTensor::YY)(), channelIndexing, identifierName+"_yy", path, gFormat, moment);
                   processField(field.component(symmTensor::YZ)(), channelIndexing, identifierName+"_yz", path, gFormat, moment, true);
                   processField(field.component(symmTensor::ZZ)(), channelIndexing, identifierName+"_zz", path, gFormat, moment);
               }
           }

           if(fieldHeader.headerClassName() == volTensorField::typeName)
           {
               Info << endl;
               Info << "    Reading field" << endl;

               volTensorField field(fieldHeader, mesh);

               Info << "    Collapsing field"  << endl;
               Info << endl;

               processField(field.component(tensor::XX)(), channelIndexing, identifierName+"_xx", path, gFormat, moment);
               processField(field.component(tensor::XY)(), channelIndexing, identifierName+"_xy", path, gFormat, moment, true);
               processField(field.component(tensor::XZ)(), channelIndexing, identifierName+"_xz", path, gFormat, moment, true);
               processField(field.component(tensor::YX)(), channelIndexing, identifierName+"_yx", path, gFormat, moment, true);
               processField(field.component(tensor::YY)(), channelIndexing, identifierName+"_yy", path, gFormat, moment);
               processField(field.component(tensor::YZ)(), channelIndexing, identifierName+"_yz", path, gFormat, moment, true);
               processField(field.component(tensor::XZ)(), channelIndexing, identifierName+"_xz", path, gFormat, moment, true);
               processField(field.component(tensor::YZ)(), channelIndexing, identifierName+"_yz", path, gFormat, moment, true);
               processField(field.component(tensor::ZZ)(), channelIndexing, identifierName+"_zz", path, gFormat, moment);
           }


        }

    }