Exemplo n.º 1
0
Foam::monitorFunctionFromVorticity::monitorFunctionFromVorticity
(
    const IOdictionary& dict
)
:
    monitorFunctionFrom(dict),
    monBaseMin_(dict.lookup("monitorBaseMin")),
    monBaseMax_(dict.lookup("monitorBaseMax")),
    monitorMax_(readScalar(dict.lookup("monitorMax")))
{}
Exemplo n.º 2
0
void Foam::reducedUnits::setRefValues
(
    const IOdictionary& reducedUnitsDict
)
{
    refLength_ = readScalar(reducedUnitsDict.lookup("refLength"));

    refTime_ = readScalar(reducedUnitsDict.lookup("refTime"));

    refMass_  = readScalar(reducedUnitsDict.lookup("refMass"));

    calcRefValues();
}
int main(int argc, char *argv[])
{
    // Create global variable for the run
    #include "setRootCase.H"
    #include "createTime.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    IOdictionary nestingControlDict
    (
         IOobject
         (
              "nestingControlDict",
              runTime.system(),
              runTime,
              IOobject::MUST_READ,
              IOobject::NO_WRITE,
              true
         )
    );

    // load the master case
    word masterName(Foam::fvMesh::defaultRegion);
    Info << nl << "Load case: " << masterName << nl << endl;
    masterPimpleSolver masterSolver(masterName,runTime);

    // load the nested cases
    wordList allNestedCases(nestingControlDict.lookup("allNestedCases"));
    List< nestedBlendDsPimpleSolver* > allNestedSolvers(allNestedCases.size());
    forAll (allNestedCases,i)
    {
        word namei = allNestedCases[i];
        Info << nl << "Load case: " << namei << nl << endl;
        allNestedSolvers[i] = new nestedBlendDsPimpleSolver(namei,runTime,true);
    };
Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
(
    const polyMesh& mesh,
    const IOdictionary& dict
)
:
    displacementMotionSolver(mesh, dict, dict.lookup("solver")),
    fvMotionSolver(mesh),
    cellDisplacement_
    (
        IOobject
        (
            "cellDisplacement",
            mesh.time().timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        fvMesh_,
        dimensionedVector
        (
            "cellDisplacement",
            pointDisplacement().dimensions(),
            Zero
        ),
        cellMotionBoundaryTypes<vector>(pointDisplacement().boundaryField())
    ),
    diffusivityPtr_
    (
        motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
    )
{}
Exemplo n.º 5
0
Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New
(
    const fvMesh& mesh
)
{
    IOdictionary chemistryPropertiesDict
    (
        IOobject
        (
            "chemistryProperties",
            mesh.time().constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    const word solver(chemistryPropertiesDict.lookup("chemistrySolver"));

    wordList models = fvMeshConstructorTablePtr_->sortedToc();
    wordHashSet validModels;
    forAll(models, i)
    {
        label delim = models[i].find('<');
        validModels.insert(models[i](0, delim));
    }
Exemplo n.º 6
0
Foam::autoPtr<Foam::flameletModel> Foam::flameletModel::New
(
    volScalarField& rho,
    volVectorField& U,
    volScalarField& Su,
    volScalarField& Sigma,
    volScalarField& b,
    psiuReactionThermo& thermo,
    compressible::turbulenceModel& turbulence,
    IOdictionary& mdData
)
{
    const word flameletType(mdData.lookup("flameletModel"));

    Info<< "Selecting flamelet diffusion: " << flameletType << endl;

    dictionaryConstructorTable::iterator cstrIter =
        dictionaryConstructorTablePtr_->find(flameletType);

    if (cstrIter == dictionaryConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "flameletModel::New("
            "const IOdictionary& dict)"
        )   << "Unknown diffusion type "
            << flameletType << nl << nl
            << "Valid diffusion types are :" << endl
            << dictionaryConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<flameletModel>
      (cstrIter()(rho, U, Su, Sigma, b, thermo, turbulence, mdData));
}
Exemplo n.º 7
0
Foam::blockMesh::blockMesh(const IOdictionary& dict, const word& regionName)
:
    blockPointField_(dict.lookup("vertices")),
    scaleFactor_(1.0),
    topologyPtr_(createTopology(dict, regionName))
{
    calcMergeInfo();
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"

    IOdictionary meshDict
    (
        IOobject
        (
            "meshDict",
            runTime.system(),
            runTime,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    IOdictionary decomposeParDict
    (
        IOobject
        (
            "decomposeParDict",
            runTime.system(),
            runTime,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    const label nProcessors
    (
        readLabel(decomposeParDict.lookup("numberOfSubdomains"))
    );

    for(label procI=0;procI<nProcessors;++procI)
    {
        fileName file("processor");
        std::ostringstream ss;
        ss << procI;
        file += ss.str();
        Info << "Creating " << file << endl;

        // create a directory for processor data
        mkDir(runTime.path()/file);

        // generate constant directories
        mkDir(runTime.path()/"constant");

        // copy the contents of the const directory into processor*
        cp(runTime.path()/"constant", runTime.path()/file);

        // generate 0 directories
        mkDir(runTime.path()/file/"0");
    }

    Info << "End\n" << endl;
    return 0;
}
Exemplo n.º 9
0
Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
{
    // Enclose the creation of the dynamicMesh to ensure it is
    // deleted before the dynamicFvMesh is created otherwise the dictionary
    // is entered in the database twice
    IOdictionary dynamicMeshDict
    (
        IOobject
        (
            "dynamicMeshDict",
            io.time().constant(),
            io.db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );
    
    word dynamicFvMeshTypeName(dynamicMeshDict.lookup("dynamicFvMesh"));

    Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;

    dlLibraryTable::open
    (
        dynamicMeshDict,
        "dynamicFvMeshLibs",
        IOobjectConstructorTablePtr_
    );

    if (!IOobjectConstructorTablePtr_)
    {
        FatalErrorIn
        (
            "dynamicFvMesh::New(const IOobject&)"
        )   << "dynamicFvMesh table is empty"
            << exit(FatalError);
    }

    IOobjectConstructorTable::iterator cstrIter =
        IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);

    if (cstrIter == IOobjectConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "dynamicFvMesh::New(const IOobject&)"
        )   << "Unknown dynamicFvMesh type " << dynamicFvMeshTypeName
            << endl << endl
            << "Valid dynamicFvMesh types are :" << endl
            << IOobjectConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<dynamicFvMesh>(cstrIter()(io));
}
Exemplo n.º 10
0
Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New(const polyMesh& mesh)
{
    IOdictionary solverDict
    (
        IOobject
        (
            "dynamicMeshDict",
            mesh.time().constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    Istream& msData = solverDict.lookup("solver");

    word solverTypeName(msData);

    Info << "Selecting motion solver: " << solverTypeName << endl;

    dlLibraryTable::open
    (
        solverDict,
        "motionSolverLibs",
        dictionaryConstructorTablePtr_
    );

    if (!dictionaryConstructorTablePtr_)
    {
        FatalErrorIn
        (
            "motionSolver::New(const polyMesh& mesh)"
        )   << "solver table is empty"
            << exit(FatalError);
    }

    dictionaryConstructorTable::iterator cstrIter =
        dictionaryConstructorTablePtr_->find(solverTypeName);

    if (cstrIter == dictionaryConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "motionSolver::New(const polyMesh& mesh)"
        )   << "Unknown solver type " << solverTypeName
            << endl << endl
            << "Valid solver types are: " << endl
            << dictionaryConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<motionSolver>(cstrIter()(mesh, msData));
}
Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
{
    // Note: - do not register the dictionary since dynamicFvMeshes themselves
    // do this.
    // - defaultRegion (region0) gets loaded from constant, other ones
    //   get loaded from constant/<regionname>. Normally we'd use
    //   polyMesh::dbDir() but we haven't got a polyMesh yet ...
    IOdictionary dict
    (
        IOobject
        (
            "dynamicMeshDict",
            io.time().constant(),
            (io.name() == polyMesh::defaultRegion ? "" : io.name()),
            io.db(),
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE,
            false
        )
    );

    const word dynamicFvMeshTypeName(dict.lookup("dynamicFvMesh"));

    Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;

    const_cast<Time&>(io.time()).libs().open
    (
        dict,
        "dynamicFvMeshLibs",
        IOobjectConstructorTablePtr_
    );

    if (!IOobjectConstructorTablePtr_)
    {
        FatalErrorInFunction
            << "dynamicFvMesh table is empty"
            << exit(FatalError);
    }

    IOobjectConstructorTable::iterator cstrIter =
        IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);

    if (cstrIter == IOobjectConstructorTablePtr_->end())
    {
        FatalErrorInFunction
            << "Unknown dynamicFvMesh type "
            << dynamicFvMeshTypeName << nl << nl
            << "Valid dynamicFvMesh types are :" << endl
            << IOobjectConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<dynamicFvMesh>(cstrIter()(io));
}
Exemplo n.º 12
0
int main(int argc, char *argv[])
{
#   include "setRootCase.H"
#   include "createTime.H"
#   include "createMesh.H"

    // Reading faMeshDefinition dictionary
    IOdictionary faMeshDefinition
    (
        IOobject
        (
            "faMeshDefinition",
            runTime.constant(),
            "faMesh",
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    wordList polyMeshPatches
    (
        faMeshDefinition.lookup("polyMeshPatches")
    );

    dictionary bndDict = faMeshDefinition.subDict("boundary");

    wordList faPatchNames = bndDict.toc();

    List<faPatchData> faPatches(faPatchNames.size()+1);

    forAll (faPatchNames, patchI)
    {
        dictionary curPatchDict =
            bndDict.subDict(faPatchNames[patchI]);

        faPatches[patchI].name_ = faPatchNames[patchI];

        faPatches[patchI].type_ = 
            word(curPatchDict.lookup("type"));

        faPatches[patchI].ownPolyPatchID_ =
            mesh.boundaryMesh().findPatchID
            (
                word(curPatchDict.lookup("ownerPolyPatch"))
            );

        faPatches[patchI].ngbPolyPatchID_  =
            mesh.boundaryMesh().findPatchID
            (
                word(curPatchDict.lookup("neighbourPolyPatch"))
            );
    }
interfaceProperties::interfaceProperties
(
    const volScalarField& gamma,
    const volVectorField& U,
    const IOdictionary& dict
)
:
    transportPropertiesDict_(dict),
    cGamma_
    (
        readScalar
        (
            gamma.mesh().solutionDict().subDict("PISO").lookup("cGamma")
        )
    ),
    sigma_(dict.lookup("sigma")),

    deltaN_
    (
        "deltaN",
        1e-8/pow(average(gamma.mesh().V()), 1.0/3.0)
    ),

    gamma_(gamma),
    U_(U),

    nHatf_
    (
        IOobject
        (
            "nHatf",
            gamma_.time().timeName(),
            gamma_.mesh()
        ),
        gamma_.mesh(),
        dimensionedScalar("nHatf", dimArea, 0.0)
    ),

    K_
    (
        IOobject
        (
            "K",
            gamma_.time().timeName(),
            gamma_.mesh()
        ),
        gamma_.mesh(),
        dimensionedScalar("K", dimless/dimLength, 0.0)
    )
{
    calculateK();
}
Exemplo n.º 14
0
Foam::coalCloudList::coalCloudList
(
    const volScalarField& rho,
    const volVectorField& U,
    const dimensionedVector& g,
    const SLGThermo& slgThermo
)
:
    PtrList<coalCloud>(),
    mesh_(rho.mesh())
{
    IOdictionary props
    (
        IOobject
        (
            "coalCloudList",
            mesh_.time().constant(),
            mesh_,
            IOobject::MUST_READ
        )
    );

    const wordHashSet cloudNames(wordList(props.lookup("clouds")));

    setSize(cloudNames.size());

    label i = 0;
    forAllConstIter(wordHashSet, cloudNames, iter)
    {
        const word& name = iter.key();

        Info<< "creating cloud: " << name << endl;

        set
        (
            i++,
            new coalCloud
            (
                name,
                rho,
                U,
                g,
                slgThermo
            )
        );

        Info<< endl;
    }
}
Exemplo n.º 15
0
int main(int argc, char* argv[])
{

	// ------
	//  create PtrList from dictionary
	// ------
	
	#include "setRootCase.H"
	#include "createTime.H"
	#include "createMesh.H"

	IOdictionary dict
	(
		IOobject
		(
			"testDict",
			runTime.constant(),
			mesh,
			IOobject::MUST_READ,
			IOobject::NO_WRITE,
			true
		)
	);

	PtrList<myLib> ptl3
	(
		dict.lookup("group"),
		myLib::iNew()
	);

	Info << ptl3 << endl;

	Info << nl <<  "Display member name:" << endl;

	forAll(ptl3, i)
	{
		Info << ptl3[i].name() << endl;
	}

	Info << nl << "Display member ID:" << endl;

	forAll(ptl3, i)
	{
		Info << ptl3[i].ID() << endl;
	}

    return 0;
}
Foam::autoPtr<Foam::phaseChangeTwoPhaseMixture>
Foam::phaseChangeTwoPhaseMixture::New
(
    const volVectorField& U,
    const surfaceScalarField& phi,
    const word& alpha1Name
)
{
    IOdictionary transportPropertiesDict
    (
        IOobject
        (
            "transportProperties",
            U.time().constant(),
            U.db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    word phaseChangeTwoPhaseMixtureTypeName
    (
        transportPropertiesDict.lookup("phaseChangeTwoPhaseMixture")
    );

    Info<< "Selecting phaseChange model "
        << phaseChangeTwoPhaseMixtureTypeName << endl;

    componentsConstructorTable::iterator cstrIter =
        componentsConstructorTablePtr_
            ->find(phaseChangeTwoPhaseMixtureTypeName);

    if (cstrIter == componentsConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "phaseChangeTwoPhaseMixture::New"
        )   << "Unknown phaseChangeTwoPhaseMixture type "
            << phaseChangeTwoPhaseMixtureTypeName << endl << endl
            << "Valid  phaseChangeTwoPhaseMixtures are : " << endl
            << componentsConstructorTablePtr_->toc()
            << exit(FatalError);
    }

    return autoPtr<phaseChangeTwoPhaseMixture>(cstrIter()(U, phi, alpha1Name));
}
autoPtr<scalarTransportModel> scalarTransportModel::New
(
    const dictionary& dict, //Not used at the moment
    cfdemCloud& sm
)
{
    IOdictionary tempDict
    (
        IOobject
        (
            "scalarTransportProperties",
            sm.mesh().time().constant(),
            sm.mesh(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    word scalarTransportModelType
    (
        tempDict.lookup("scalarTransportModel")
    );

    Info<< "Selecting scalarTransportModel "
		 << scalarTransportModelType << endl;

    dictionaryConstructorTable::iterator cstrIter =
        dictionaryConstructorTablePtr_->find(scalarTransportModelType);

    if (cstrIter == dictionaryConstructorTablePtr_->end())
    {
        FatalError
            << "scalarTransportModel::New(const dictionary&, const spray&) : "
            << endl
            << "    unknown scalarTransportModelType type "
            << scalarTransportModelType
            << ", constructor not in hash table" << endl << endl
            << "    Valid scalarTransportModel types are :"
            << endl;
        Info<< dictionaryConstructorTablePtr_->toc()
            << abort(FatalError);
    }

    return autoPtr<scalarTransportModel>(cstrIter()(tempDict,sm));
}
Exemplo n.º 18
0
Foam::autoPtr<Foam::laminarFlameSpeed> Foam::laminarFlameSpeed::New
(
    const hhuCombustionThermo& ct
)
{
    IOdictionary laminarFlameSpeedDict
    (
        IOobject
        (
            "combustionProperties",
            ct.T().time().constant(),
            ct.T().db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    word laminarFlameSpeedType
    (
        laminarFlameSpeedDict.lookup("laminarFlameSpeedCorrelation")
    );

    Info<< "Selecting laminar flame speed correlation "
        << laminarFlameSpeedType << endl;

    dictionaryConstructorTable::iterator cstrIter =
        dictionaryConstructorTablePtr_->find(laminarFlameSpeedType);

    if (cstrIter == dictionaryConstructorTablePtr_->end())
    {
        FatalIOErrorIn
        (
            "laminarFlameSpeed::New(const hhuCombustionThermo&)",
            laminarFlameSpeedDict
        )   << "Unknown laminarFlameSpeed type "
            << laminarFlameSpeedType << endl << endl
            << "Valid laminarFlameSpeed types are :" << endl
            << dictionaryConstructorTablePtr_->sortedToc()
            << exit(FatalIOError);
    }

    return autoPtr<laminarFlameSpeed>(cstrIter()(laminarFlameSpeedDict, ct));
}
Exemplo n.º 19
0
tmp<volScalarField> laminarFlux::DEff() const
{
    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime_.constant(),
            mesh_,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        )
    );

    dimensionedScalar D
    (
        transportProperties.lookup("D")
    );

   // Info<<"Reading diffusivity "<< D << endl;

    //return tmp<volScalarField>(new volScalarField("DEff", D.value()));

    return tmp<volScalarField>
    (
        new volScalarField
        (
            IOobject
            (
                "DEff",
                runTime_.timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh_,
            dimensionedScalar("DEff", dimensionSet(0,2,-1,0,0,0,0), D.value())
        )
    );

}
Exemplo n.º 20
0
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    
    Info << "\nReading environmentalProperties" << endl;

    IOdictionary envProperties
    (
        IOobject
        (
            "environmentalProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ
        )
    );

    dimensionedVector g(envProperties.lookup("g"));
    dimensionedVector ghat = g/mag(g);

    Info << "Reading in sponge layer coefficients\n" << endl;
    const scalar zB(readScalar(envProperties.lookup("spongeBase")));
    const scalar zt(readScalar(envProperties.lookup("spongeTop")));
    const scalar muBar(readScalar(envProperties.lookup("spongeMean")));
    const scalar xSpongeCentre
    (
        envProperties.lookupOrDefault<scalar>("xSpongeCentre", scalar(0))
    );
    const scalar xSpongeEnd
    (
        envProperties.lookupOrDefault<scalar>("xSpongeEnd", scalar(0))
    );
    const scalar xSpongeLength = mag(xSpongeCentre - xSpongeEnd);
    const scalar x2SpongeCentre
    (
        envProperties.lookupOrDefault<scalar>("x2SpongeCentre", scalar(0))
    );
    const scalar x2SpongeEnd
    (
        envProperties.lookupOrDefault<scalar>("x2SpongeEnd", scalar(0))
    );
    const scalar x2SpongeLength = mag(x2SpongeCentre - x2SpongeEnd);
        
    Info<< "Creating muSponge\n" << endl;
    surfaceScalarField muSponge
    (
        IOobject("muSponge", runTime.constant(), mesh),
        mesh,
        dimensionedScalar("muSponge", dimless, scalar(0))
    );

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    // Loop over all faces and set muSponge
    forAll(muSponge, faceI)
    {
        // First check if face has a vertical normal
        if(mag(mesh.Sf()[faceI] ^ ghat.value()) < mesh.magSf()[faceI]*1e-6)
        {
            // height of face centre
            const scalar z = -(mesh.Cf()[faceI] & ghat.value());
            // x distance to x sponge centre
            const scalar xDist = mag(mesh.Cf()[faceI].x() - xSpongeCentre);
            const scalar x2Dist = mag(mesh.Cf()[faceI].x() - x2SpongeCentre);
            
            // set the sponge value if the height is above sponge base
            if (z > zB)
            {
                muSponge[faceI] = muBar*sqr(Foam::sin(0.5*pi*(z-zB)/(zt-zB)));
            }
            else if (z > zt)
            {
                FatalErrorIn("createSpongeLayer") << "face " << faceI
                    << " has height " << z
                    << " but the sponge is defined to lie between " << zB
                    << " and " << zt << exit(FatalError);
            }
            
            // set the sponge value if x is between xMin and xMax
            if (xDist <= xSpongeLength)
            {
                muSponge[faceI] += muBar
                    *sqr(Foam::sin(0.5*pi*(xSpongeLength-xDist)/xSpongeLength));
            } else if (x2Dist <= x2SpongeLength)
            {
                muSponge[faceI] += muBar
                    *sqr(Foam::sin(0.5*pi*(x2SpongeLength-x2Dist)/x2SpongeLength));
            }
        }
    }   

    muSponge.write();

    Info<< "End\n" << endl;

    return 0;
}
Foam::autoPtr<Foam::solidChemistryModel> Foam::solidChemistryModel::New
(
    const fvMesh& mesh
)
{
    IOdictionary chemistryPropertiesDict
    (
        IOobject
        (
            "chemistryProperties",
            mesh.time().constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    const word userModel(chemistryPropertiesDict.lookup("solidChemistryModel"));

    const word ODEModelName(chemistryPropertiesDict.lookup("chemistrySolver"));
    const word gasThermoName(chemistryPropertiesDict.lookup("gasThermoModel"));

    // construct chemistry model type name by inserting first template argument
    const label tempOpen = userModel.find('<');
    const label tempClose = userModel.find('>');

    const word className = userModel(0, tempOpen);
    const word thermoTypeName =
        userModel(tempOpen + 1, tempClose - tempOpen - 1);

    const word modelType =
        ODEModelName + '<' + className
      + '<' + typeName + ',' + thermoTypeName + ',' + gasThermoName + ">>";


    if (debug)
    {
        Info<< "Selecting solidChemistryModel " << modelType << endl;
    }
    else
    {
        Info<< "Selecting solidChemistryModel " << userModel + gasThermoName
            << endl;
    }

    fvMeshConstructorTable::iterator cstrIter =
        fvMeshConstructorTablePtr_->find(modelType);

    if (cstrIter == fvMeshConstructorTablePtr_->end())
    {
        if (debug)
        {
            FatalErrorIn("solidChemistryModel::New(const mesh&)")
                << "Unknown solidChemistryModel type "
                << modelType << nl << nl
                << "Valid solidChemistryModel types are:" << nl
                << fvMeshConstructorTablePtr_->sortedToc() << nl
                << exit(FatalError);
        }
        else
        {
            wordList models = fvMeshConstructorTablePtr_->sortedToc();
            forAll(models, i)
            {
                models[i] = models[i].replace(typeName + ',', "");
            }

            FatalErrorIn("solidChemistryModel::New(const mesh&)")
                << "Unknown solidChemistryModel type "
                << userModel << nl << nl
                << "Valid solidChemistryModel types are:" << nl
                << models << nl
                << exit(FatalError);
        }
    }
Exemplo n.º 22
0
Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
{
    wordList libNames(1);
    libNames[0]=word("mesquiteMotionSolver");

    forAll(libNames,i) {
        const word libName("lib"+libNames[i]+".so");

        bool ok=dlLibraryTable::open(libName);
        if(!ok) {
            WarningIn("dynamicFvMesh::New(const IOobject& io)")
                << "Loading of dynamic mesh library " << libName
                    << " unsuccesful. Some dynamic mesh  methods may not be "
                    << " available"
                    << endl;
        }
    }

    // Enclose the creation of the dynamicMesh to ensure it is
    // deleted before the dynamicFvMesh is created otherwise the dictionary
    // is entered in the database twice
    IOdictionary dynamicMeshDict
    (
        IOobject
        (
            "dynamicMeshDict",
            io.time().constant(),
            (io.name() == dynamicFvMesh::defaultRegion ? "" : io.name() ),
            io.db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );

    word dynamicFvMeshTypeName(dynamicMeshDict.lookup("dynamicFvMesh"));

    Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;

    dlLibraryTable::open
    (
        dynamicMeshDict,
        "dynamicFvMeshLibs",
        IOobjectConstructorTablePtr_
    );

    if (!IOobjectConstructorTablePtr_)
    {
        FatalErrorIn
        (
            "dynamicFvMesh::New(const IOobject&)"
        )   << "dynamicFvMesh table is empty"
            << exit(FatalError);
    }

    IOobjectConstructorTable::iterator cstrIter =
        IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);

    if (cstrIter == IOobjectConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "dynamicFvMesh::New(const IOobject&)"
        )   << "Unknown dynamicFvMesh type " << dynamicFvMeshTypeName
            << endl << endl
            << "Valid dynamicFvMesh types are :" << endl
            << IOobjectConstructorTablePtr_->toc()
            << exit(FatalError);
    }

    return autoPtr<dynamicFvMesh>(cstrIter()(io));
}
int main(int argc, char *argv[])
{
    timeSelector::addOptions();

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

    instantList timeDirs = timeSelector::select0(runTime, args);

#   include "createMesh.H"

    Info<< "\nEstimating error in scalar transport equation\n"
        << "Reading transportProperties\n" << endl;

    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );


    Info<< "Reading diffusivity DT\n" << endl;

    dimensionedScalar DT
    (
        transportProperties.lookup("DT")
    );


    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

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

        mesh.readUpdate();

        IOobject THeader
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );

        IOobject Uheader
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );

        if (THeader.headerOk() && Uheader.headerOk())
        {
            Info << "Reading T" << endl;
            volScalarField T(THeader, mesh);

            Info << "Reading U" << endl;
            volVectorField U(Uheader, mesh);

#           include "createPhi.H"

            errorEstimate<scalar> ee
            (
                resError::div(phi, T)
              - resError::laplacian(DT, T)
            );

            ee.residual()().write();
            volScalarField e = ee.error();
            e.write();
            mag(e)().write();
        }
        else
        {
            Info<< "    No T or U" << endl;
        }

        Info<< endl;
    }
int main(int argc, char *argv[])
{
    argList::validOptions.insert("overwrite", "");
#   include "setRootCase.H"
#   include "createTime.H"
    runTime.functionObjects().off();
#   include "createMesh.H"

    Info<< "Read mesh in = "
        << runTime.cpuTimeIncrement() << " s" << endl;

    const bool overwrite = args.optionFound("overwrite");


    // Check patches and faceZones are synchronised
    mesh.boundaryMesh().checkParallelSync(true);
    meshRefinement::checkCoupledFaceZones(mesh);


    // Read decomposePar dictionary
    IOdictionary decomposeDict
    (
        IOobject
        (
            "decomposeParDict",
            runTime.system(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    // Read meshing dictionary
    IOdictionary meshDict
    (
       IOobject
       (
            "snappyHexMeshDict",
            runTime.system(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
       )
    );

    // all surface geometry
    const dictionary& geometryDict = meshDict.subDict("geometry");

    // refinement parameters
    const dictionary& refineDict = meshDict.subDict("castellatedMeshControls");

    // mesh motion and mesh quality parameters
    const dictionary& motionDict = meshDict.subDict("meshQualityControls");

    // snap-to-surface parameters
    const dictionary& snapDict = meshDict.subDict("snapControls");

    // layer addition parameters
    const dictionary& layerDict = meshDict.subDict("addLayersControls");


    const scalar mergeDist = getMergeDistance
    (
        mesh,
        readScalar(meshDict.lookup("mergeTolerance"))
    );



    // Debug
    // ~~~~~

    const label debug(readLabel(meshDict.lookup("debug")));
    if (debug > 0)
    {
        meshRefinement::debug = debug;
        autoRefineDriver::debug = debug;
        autoSnapDriver::debug = debug;
        autoLayerDriver::debug = debug;
    }


    // Read geometry
    // ~~~~~~~~~~~~~

    searchableSurfaces allGeometry
    (
        IOobject
        (
            "abc",                      // dummy name
            mesh.time().constant(),     // instance
            //mesh.time().findInstance("triSurface", word::null),// instance
            "triSurface",               // local
            mesh.time(),                // registry
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        geometryDict
    );


    // Read refinement surfaces
    // ~~~~~~~~~~~~~~~~~~~~~~~~

    Info<< "Reading refinement surfaces." << endl;
    refinementSurfaces surfaces
    (
        allGeometry,
        refineDict.subDict("refinementSurfaces")
    );
    Info<< "Read refinement surfaces in = "
        << mesh.time().cpuTimeIncrement() << " s" << nl << endl;


    // Read refinement shells
    // ~~~~~~~~~~~~~~~~~~~~~~

    Info<< "Reading refinement shells." << endl;
    shellSurfaces shells
    (
        allGeometry,
        refineDict.subDict("refinementRegions")
    );
    Info<< "Read refinement shells in = "
        << mesh.time().cpuTimeIncrement() << " s" << nl << endl;


    Info<< "Setting refinement level of surface to be consistent"
        << " with shells." << endl;
    surfaces.setMinLevelFields(shells);
    Info<< "Checked shell refinement in = "
        << mesh.time().cpuTimeIncrement() << " s" << nl << endl;


    // Refinement engine
    // ~~~~~~~~~~~~~~~~~

    Info<< nl
        << "Determining initial surface intersections" << nl
        << "-----------------------------------------" << nl
        << endl;

    // Main refinement engine
    meshRefinement meshRefiner
    (
        mesh,
        mergeDist,          // tolerance used in sorting coordinates
        overwrite,          // overwrite mesh files?
        surfaces,           // for surface intersection refinement
        shells              // for volume (inside/outside) refinement
    );
    Info<< "Calculated surface intersections in = "
        << mesh.time().cpuTimeIncrement() << " s" << nl << endl;

    // Some stats
    meshRefiner.printMeshInfo(debug, "Initial mesh");

    meshRefiner.write
    (
        debug&meshRefinement::OBJINTERSECTIONS,
        mesh.time().path()/meshRefiner.timeName()
    );


    // Add all the surface regions as patches
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    labelList globalToPatch;
    {
        Info<< nl
            << "Adding patches for surface regions" << nl
            << "----------------------------------" << nl
            << endl;

        // From global region number to mesh patch.
        globalToPatch.setSize(surfaces.nRegions(), -1);

        Info<< "Patch\tRegion" << nl
            << "-----\t------"
            << endl;

        const labelList& surfaceGeometry = surfaces.surfaces();
        forAll(surfaceGeometry, surfI)
        {
            label geomI = surfaceGeometry[surfI];

            const wordList& regNames = allGeometry.regionNames()[geomI];

            Info<< surfaces.names()[surfI] << ':' << nl << nl;

            forAll(regNames, i)
            {
                label patchI = meshRefiner.addMeshedPatch
                (
                    regNames[i],
                    wallPolyPatch::typeName
                );

                Info<< patchI << '\t' << regNames[i] << nl;

                globalToPatch[surfaces.globalRegion(surfI, i)] = patchI;
            }

            Info<< nl;
        }
int main(int argc, char *argv[])
{
#   include "addRegionOption.H"

#   include "addLoadFunctionPlugins.H"

    argList::validOptions.insert("overwrite", "");
    argList::validOptions.insert("expression","expression to write");
    argList::validOptions.insert("dictExt","Extension to the dictionary");
    argList::validOptions.insert("relative", "");
    argList::validOptions.insert("allowFunctionObjects","");

#   include "setRootCase.H"

    printSwakVersion();

#   include "createTime.H"

    Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);

#   include "createNamedMesh.H"

#   include "loadFunctionPlugins.H"

    if(!args.options().found("allowFunctionObjects")) {
        runTime.functionObjects().off();
    } else {
        runTime.functionObjects().start();
    }

    const word oldInstance = mesh.pointsInstance();

    bool overwrite    = args.optionFound("overwrite");
    bool relative     = false;

    pointField newPoints;

    if (!overwrite)
    {
        runTime++;
    }

    if(args.optionFound("expression")) {
        if(args.optionFound("dictExt")) {
            FatalErrorIn(args.executable())
                << "Can't specify 'dictExt' and 'expression' at the same time"
                    << endl
                    << exit(FatalError);

        }
        relative=args.optionFound("relative");
        exprString expression(
            args.options()["expression"],
            dictionary::null
        );
        FieldValueExpressionDriver driver(
            runTime.timeName(),
            runTime,
            mesh
        );
        // no clearVariables needed here
        driver.parse(expression);
        if(!driver.resultIsTyp<pointVectorField>()) {
            FatalErrorIn(args.executable())
                << "Expression " << expression
                    << " does not evaluate to a pointVectorField but a "
                    << driver.typ()
                    << endl
                    << exit(FatalError);
        }
        newPoints=driver.getResult<pointVectorField>().internalField();
    } else {
        Info << "Dictionary mode" << nl << endl;
        if(args.optionFound("relative")) {
            FatalErrorIn(args.executable())
                << "Option 'relative' not allowed in dictionary-mode"
                    << endl
                    << exit(FatalError);
        }
        word dictName("funkyWarpMeshDict");
        if(args.optionFound("dictExt")) {
            dictName+="."+word(args.options()["dictExt"]);
        }
        IOdictionary warpDict
            (
                IOobject
                (
                    dictName,
                    runTime.system(),
                    mesh,
                    IOobject::MUST_READ,
                    IOobject::NO_WRITE
                )
            );
        const word mode(warpDict.lookup("mode"));
        if(mode=="set") {
            relative=readBool(warpDict.lookup("relative"));
            exprString expression(
                warpDict.lookup("expression"),
                warpDict
            );
            FieldValueExpressionDriver driver(
                runTime.timeName(),
                runTime,
                mesh
            );
            driver.readVariablesAndTables(warpDict);
            driver.clearVariables();

            driver.parse(expression);
            if(!driver.resultIsTyp<pointVectorField>()) {
                FatalErrorIn(args.executable())
                    << "Expression " << expression
                        << " does not evaluate to a pointVectorField but a "
                        << driver.typ()
                        << endl
                        << exit(FatalError);
            }
            newPoints=driver.getResult<pointVectorField>().internalField();
        } else if (mode=="move") {
            notImplemented(args.executable()+" mode: move");
        } else {
            FatalErrorIn(args.executable())
                << "Possible values for 'mode' are 'set' or 'move'"
                    << endl
                    << exit(FatalError);
        }
    }

    if(relative) {
        newPoints += mesh.points();
    }

    mesh.movePoints(newPoints);

    // Write mesh
    if (overwrite)
    {
        mesh.setInstance(oldInstance);
    }
    Info << nl << "Writing polyMesh to time " << runTime.timeName() << endl;

    IOstream::defaultPrecision(15);

    // Bypass runTime write (since only writes at outputTime)
    if
    (
       !runTime.objectRegistry::writeObject
        (
            runTime.writeFormat(),
            IOstream::currentVersion,
            runTime.writeCompression()
#ifdef FOAM_REGIOOBJECT_WRITEOBJECT_WITH_VALID
            ,true
#endif
        )
    )
    {
        FatalErrorIn(args.executable())
            << "Failed writing polyMesh."
            << exit(FatalError);
    }

    // Write points goes here

    // Write fields
    runTime.write();

    Info << "End\n" << endl;

    Info << nl << "Now run 'checkMesh' before you do anything else"
        << nl << endl;

    return 0;
}
Exemplo n.º 26
0
int main(int argc, char *argv[])
{
#   include "setRootCase.H"

#   include "createTime.H"
#   include "createMesh.H"

    Info << "perturbU: generalised velocity perturbation implementation for "
         << "the initialisation of ducted well-resolved LES flows." << endl;
    
    // Xdir -> Ubar - streamwise
    // Ydir -> wallReflection vectors
    // Zdir -> cross product Xdir^Ydir
    
    // Ubar and Retau should be set in transportProperties
    // The choice of Retau is not critical as long as it is 
    // approximately the right order of magnitude
    
    // A laminar background velocity profile is assumed
    // with maximum U at h = max(wall distance)
    // A laminar initial profile is essential since wall normal motion
    // of a mean turbulent profile without resolved turbulence will
    // diffuse the perturbations, preventing transition in some cases
    
    
    wallDist yw(mesh);
    const scalar h = max(yw.internalField());
    
    // local yDir
    wallDistReflection reflexVec(mesh);
    
    const volVectorField yDir = reflexVec.n();


    IOobject Uheader
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );
    Info << "Reading U" << endl;
    volVectorField U(Uheader, mesh);

    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    dimensionedScalar nu
    (
        transportProperties.lookup("nu")
    );
    dimensionedVector Ubar
    (
        transportProperties.lookup("Ubar")
    );
    dimensionedScalar Retau
    (
        transportProperties.lookup("Retau")
    );
    scalar sigma
    (
        transportProperties.lookupOrDefault<scalar>("sigma", 0.00055)
    );
    Info << " sigma = " << sigma << endl;
    scalar duplusC
    (
        transportProperties.lookupOrDefault<scalar>("duplusC", 0.25)
    );
    Info << " duplusC = " << duplusC << endl;
    scalar epsilonC
    (
        transportProperties.lookupOrDefault<scalar>("epsilonC", 0.05)
    );
    Info << " epsilonC = " << epsilonC << endl;
    scalar deviationC
    (
        transportProperties.lookupOrDefault<scalar>("deviationC", 0.2)
    );
    Info << " deviationC = " << deviationC << endl;
    
    vector xDir = Ubar.value() / mag(Ubar.value());


    Info << "Re(tau) = " << Retau << endl;
    const scalar utau = Retau.value() * nu.value() / h;
    Info << " u(tau) = " << utau << endl;

    // wall normal circulation
    const scalar duplus = Ubar.value().x() * duplusC / utau;
    // spanwise wavenumber: spacing z+ = 200
    const scalar betaPlus = 2.0 * 3.14 *(1.0 / 200.0);
    // streamwise wave number: spacing x+ = 500
    const scalar alphaPlus = 2.0 * 3.14 * (1.0 / 500.0);
    const scalar epsilon = Ubar.value().x() * epsilonC;

    const vectorField& centres(mesh.C());

    Random perturbation(1234567);

    forAll(centres, celli)
    {
        // add a small random component to enhance symmetry breaking
        scalar deviation = 1.0 + deviationC * perturbation.GaussNormal();
        const vector& cCentre = centres[celli];

        vector zDir = xDir^yDir[celli];
        zDir /= mag(zDir);

        scalar zplus = (cCentre & zDir) * Retau.value() / h;
        scalar yplus = yw[celli] * Retau.value() / h;
        scalar xplus = (cCentre & xDir) * Retau.value() / h;

        // ML: it seems that this profile (or coefficient before Ubar)
        //     is correct for rectangular shape, for body of
        //     revolution it is (should be?) different
        // laminar parabolic profile
        U[celli] = 3.0 * Ubar.value() * (yw[celli] / h - 0.5 * sqr(yw[celli] / h));

        // streak streamwise velocity
        U[celli] +=
            xDir * (utau * duplus / 2.0) * (yplus / 40.0)
            * Foam::exp(-sigma * Foam::sqr(yplus) + 0.5)
            * Foam::cos(betaPlus * zplus) * deviation;

        // streak spanwise perturbation
        U[celli] +=
            zDir * epsilon
          * Foam::sin(alphaPlus * xplus)
          * yplus
          * Foam::exp(-sigma * Foam::sqr(yplus))
          * deviation;

    }
// Same check as snapMesh
void checkSnapMesh
(
    const Time& runTime,
    const polyMesh& mesh,
    labelHashSet& wrongFaces
)
{
    IOdictionary snapDict
    (
        IOobject
        (
            "snapMeshDict",
            runTime.system(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    // Max nonorthogonality allowed
    scalar maxNonOrtho(readScalar(snapDict.lookup("maxNonOrtho")));
    primitiveMesh::nonOrthThreshold_ = maxNonOrtho;

    // Max concaveness allowed.
    scalar maxConcave(readScalar(snapDict.lookup("maxConcave")));
    primitiveMesh::faceAngleThreshold_ = maxConcave;

    // Min volume allowed (factor of minimum cellVolume)
    scalar relMinVol(readScalar(snapDict.lookup("minVol")));
    const scalar minCellVol = min(mesh.cellVolumes());
    const scalar minPyrVol = relMinVol*minCellVol;

    // Min area
    scalar minArea(readScalar(snapDict.lookup("minArea")));

    if (maxNonOrtho < 180.0 - SMALL)
    {
        Pout<< "Checking non orthogonality" << endl;

        label nOldSize = wrongFaces.size();
        mesh.checkFaceOrthogonality(false, &wrongFaces);

        Pout<< "Detected " << wrongFaces.size() - nOldSize
            << " faces with non-orthogonality > " << maxNonOrtho << " degrees"
            << endl;
    }

    if (minPyrVol > -GREAT)
    {
        Pout<< "Checking face pyramids" << endl;

        label nOldSize = wrongFaces.size();
        mesh.checkFacePyramids(false, minPyrVol, &wrongFaces);
        Pout<< "Detected additional " << wrongFaces.size() - nOldSize
            << " faces with illegal face pyramids" << endl;
    }

    if (maxConcave < 180.0 - SMALL)
    {
        Pout<< "Checking face angles" << endl;

        label nOldSize = wrongFaces.size();
        mesh.checkFaceAngles(false, &wrongFaces);

        Pout<< "Detected additional " << wrongFaces.size() - nOldSize
            << " faces with concavity > " << maxConcave << " degrees"
            << endl;
    }

    if (minArea > -SMALL)
    {
        Pout<< "Checking face areas" << endl;

        label nOldSize = wrongFaces.size();

        const scalarField magFaceAreas = mag(mesh.faceAreas());

        forAll(magFaceAreas, faceI)
        {
            if (magFaceAreas[faceI] < minArea)
            {
                wrongFaces.insert(faceI);
            }
        }

        Pout<< "Detected additional " << wrongFaces.size() - nOldSize
            << " faces with area < " << minArea << " m^2" << endl;
    }
Exemplo n.º 28
0
void Foam::scalarTransportPOD::calcDerivativeCoeffs() const
{
    if (derivativeMatrixPtr_)
    {
        FatalErrorIn
        (
            "void scalarTransportPOD::calcDerivativeCoeffs() const"
        )   << "Derivative matrix already calculated"
            << abort(FatalError);
    }

    // Calculate coefficients for differential equation
    // Get times list
    Time& runTime = const_cast<Time&>(this->mesh().time());

    // Remember time index to restore it
    label origTimeIndex = runTime.timeIndex();

    // Read diffusivity

    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            this->mesh(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    Info<< "Reading diffusivity D\n" << endl;

    dimensionedScalar DT
    (
        transportProperties.lookup("DT")
    );

    // Find velocity field

    word Uname(this->dict().lookup("velocity"));

    instantList Times = runTime.times();

    volVectorField* Uptr = NULL;

    forAll (Times, i)
    {
        runTime.setTime(Times[i], i);

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

        IOobject Uheader
        (
            Uname,
            runTime.timeName(),
            this->mesh(),
            IOobject::MUST_READ
        );

        if (Uheader.headerOk())
        {
            Info<< "    Reading " << Uname << endl;

            Uptr = new volVectorField(Uheader, this->mesh());
            break;
        }
        else
        {
            Info<< "    No " << Uname << endl;
        }
    }
Exemplo n.º 29
0
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    bool writeResults = !args.optionFound("noWrite");

    IOobject phiHeader
    (
        "phi",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (phiHeader.headerOk())
    {
        autoPtr<surfaceScalarField> PePtr;

        Info<< "    Reading phi" << endl;
        surfaceScalarField phi(phiHeader, mesh);

        volVectorField U
        (
            IOobject
            (
                "U",
                runTime.timeName(),
                mesh,
                IOobject::MUST_READ
            ),
            mesh
        );

        IOobject turbulencePropertiesHeader
        (
            "turbulenceProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE
        );

        Info<< "    Calculating Pe" << endl;

        if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
        {
            if (turbulencePropertiesHeader.headerOk())
            {
                singlePhaseTransportModel laminarTransport(U, phi);

                autoPtr<incompressible::turbulenceModel> turbulenceModel
                (
                    incompressible::turbulenceModel::New
                    (
                        U,
                        phi,
                        laminarTransport
                    )
                );

                PePtr.set
                (
                    new surfaceScalarField
                    (
                        IOobject
                        (
                            "Pef",
                            runTime.timeName(),
                            mesh
                        ),
                        mag(phi)
                       /(
                            mesh.magSf()
                          * mesh.surfaceInterpolation::deltaCoeffs()
                          * fvc::interpolate(turbulenceModel->nuEff())
                        )
                    )
                );
            }
            else
            {
                IOdictionary transportProperties
                (
                    IOobject
                    (
                        "transportProperties",
                        runTime.constant(),
                        mesh,
                        IOobject::MUST_READ_IF_MODIFIED,
                        IOobject::NO_WRITE
                    )
                );

                dimensionedScalar nu(transportProperties.lookup("nu"));

                PePtr.set
                (
                    new surfaceScalarField
                    (
                        IOobject
                        (
                            "Pef",
                            runTime.timeName(),
                            mesh
                        ),
                        mag(phi)
                       /(
                            mesh.magSf()
                          * mesh.surfaceInterpolation::deltaCoeffs()
                          * nu
                        )
                    )
                );
            }
        }
        else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0))
        {
            if (turbulencePropertiesHeader.headerOk())
            {
                autoPtr<fluidThermo> thermo(fluidThermo::New(mesh));

                volScalarField rho
                (
                    IOobject
                    (
                        "rho",
                        runTime.timeName(),
                        mesh
                    ),
                    thermo->rho()
                );

                autoPtr<compressible::turbulenceModel> turbulenceModel
                (
                    compressible::turbulenceModel::New
                    (
                        rho,
                        U,
                        phi,
                        thermo()
                    )
                );

                PePtr.set
                (
                    new surfaceScalarField
                    (
                        IOobject
                        (
                            "Pef",
                            runTime.timeName(),
                            mesh
                        ),
                        mag(phi)
                       /(
                            mesh.magSf()
                          * mesh.surfaceInterpolation::deltaCoeffs()
                          * fvc::interpolate(turbulenceModel->muEff())
                        )
                    )
                );
            }
            else
            {
                IOdictionary transportProperties
                (
                    IOobject
                    (
                        "transportProperties",
                        runTime.constant(),
                        mesh,
                        IOobject::MUST_READ_IF_MODIFIED,
                        IOobject::NO_WRITE
                    )
                );

                dimensionedScalar mu(transportProperties.lookup("mu"));

                PePtr.set
                (
                    new surfaceScalarField
                    (
                        IOobject
                        (
                            "Pef",
                            runTime.timeName(),
                            mesh
                        ),
                        mag(phi)
                       /(
                            mesh.magSf()
                          * mesh.surfaceInterpolation::deltaCoeffs()
                          * mu
                        )
                    )
                );
            }
        }
        else
        {
            FatalErrorInFunction
                << "Incorrect dimensions of phi: " << phi.dimensions()
                    << abort(FatalError);
        }

        Info<< "    Pe max : " << max(PePtr()).value() << endl;

        if (writeResults)
        {
            Info<< "    Writing surfaceScalarField : "
                << PePtr().name() << endl;
            PePtr().write();

            volScalarField Pe
            (
                IOobject
                (
                    "Pe",
                    runTime.timeName(),
                    mesh
                ),
                fvc::average(PePtr())
            );

            Info<< "    Writing volScalarField : "
                << Pe.name() << endl;
            Pe.write();
        }
    }
    else
    {
        Info<< "    No phi" << endl;
    }
}
Exemplo n.º 30
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);
           }


        }

    }