void Foam::calcTypes::scalarMult::preCalc ( const argList& args, const Time& runTime, const fvMesh& mesh ) { baseFieldName_ = args.additionalArgs()[1]; if (args.optionFound("value")) { scalarMultValueStr_ = args.option("value"); } else { FatalErrorIn("calcTypes::scalarMult::preCalc") << "scalarMult requires -value option" << nl << exit(FatalError); } if (args.optionFound("resultName")) { resultName_ = args.option("resultName"); } }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); if (Uheader.headerOk()) { Info<< " Reading U" << endl; volVectorField U(Uheader, mesh); Info<< " Calculating vorticity" << endl; volVectorField vorticity ( IOobject ( "vorticity", runTime.timeName(), mesh, IOobject::NO_READ ), fvc::curl(U) ); volScalarField magVorticity ( IOobject ( "magVorticity", runTime.timeName(), mesh, IOobject::NO_READ ), mag(vorticity) ); Info<< "vorticity max/min : " << max(magVorticity).value() << " " << min(magVorticity).value() << endl; if (writeResults) { vorticity.write(); magVorticity.write(); } } else { Info<< " No U" << endl; } Info<< "\nEnd\n" << endl; }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); #include "getFields.H" Info<< "\nEnd\n" << endl; }
void Foam::calcTypes::interpolate::calc ( const argList& args, const Time& runTime, const fvMesh& mesh ) { #ifdef FOAM_DEV const word& fieldName = args.additionalArgs()[1]; #else const word fieldName = args[2]; #endif IOobject fieldHeader ( fieldName, runTime.timeName(), mesh, IOobject::MUST_READ ); // Check field exists if (fieldHeader.headerOk()) { bool processed = false; writeInterpolateField<scalar>(fieldHeader, mesh, processed); writeInterpolateField<vector>(fieldHeader, mesh, processed); writeInterpolateField<sphericalTensor>(fieldHeader, mesh, processed); writeInterpolateField<symmTensor>(fieldHeader, mesh, processed); writeInterpolateField<tensor>(fieldHeader, mesh, processed); if (!processed) { FatalError << "Unable to process " << fieldName << nl << "No call to interpolate for fields of type " << fieldHeader.headerClassName() << nl << nl << exit(FatalError); } } else { Info<< " No " << fieldName << endl; } }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); IOobject kheader ( "k", runTime.timeName(), mesh, IOobject::MUST_READ ); if (kheader.headerOk()) { Info<< " Reading k" << endl; volScalarField k(kheader, mesh); Info<< " Calculating uprime" << endl; volScalarField uprime ( IOobject ( "uprime", runTime.timeName(), mesh, IOobject::NO_READ ), sqrt((2.0/3.0)*k) ); Info<< "uprime max/min : " << max(uprime).value() << " " << min(uprime).value() << endl; if (writeResults) { uprime.write(); } } else { Info<< " No k" << endl; } Info<< "\nEnd\n" << endl; }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); if (Uheader.headerOk()) { Info<< " Reading U" << endl; volVectorField U(Uheader, mesh); Info<< " Calculating enstrophy" << endl; volScalarField enstrophy ( IOobject ( "enstrophy", runTime.timeName(), mesh, IOobject::NO_READ ), 0.5*magSqr(fvc::curl(U)) ); Info<< "enstrophy(U) max/min : " << max(enstrophy).value() << " " << min(enstrophy).value() << endl; if (writeResults) { enstrophy.write(); } } else { Info<< " No U" << endl; } Info<< "\nEnd\n" << endl; }
void Foam::calcTypes::domainIntegrate::calc ( const argList& args, const Time& runTime, const fvMesh& mesh ) { const word& fieldName = args.additionalArgs()[1]; IOobject fieldHeader ( fieldName, runTime.timeName(), mesh, IOobject::MUST_READ ); // Check field exists if (fieldHeader.headerOk()) { bool processed = false; calcDomainIntegrate<scalar>(fieldHeader, mesh, processed); calcDomainIntegrate<vector>(fieldHeader, mesh, processed); calcDomainIntegrate<sphericalTensor>(fieldHeader, mesh, processed); calcDomainIntegrate<symmTensor>(fieldHeader, mesh, processed); calcDomainIntegrate<tensor>(fieldHeader, mesh, processed); if (!processed) { FatalError << "Unable to process " << fieldName << nl << "No call to mag for fields of type " << fieldHeader.headerClassName() << nl << nl << exit(FatalError); } } else { Info<< " No " << fieldName << endl; } }
void Foam::calcTypes::div::calc ( const argList& args, const Time& runTime, const fvMesh& mesh ) { const word& fieldName = args.additionalArgs()[1]; IOobject fieldHeader ( fieldName, runTime.timeName(), mesh, IOobject::MUST_READ ); // Check field exists if (fieldHeader.headerOk()) { bool processed = false; writeDivField<surfaceScalarField>(fieldHeader, mesh, processed); writeDivField<volVectorField>(fieldHeader, mesh, processed); if (!processed) { FatalError << "Unable to process " << fieldName << nl << "No call to div for fields of type " << fieldHeader.headerClassName() << nl << nl << exit(FatalError); } } else { Info<< " No " << fieldName << endl; } }
Foam::wordList Foam::selectRegionNames(const argList& args, const Time& runTime) { const bool allRegions = args.optionFound("allRegions"); wordList regionNames; if (allRegions) { const regionProperties rp(runTime); forAllConstIter(HashTable<wordList>, rp, iter) { const wordList& regions = iter(); forAll(regions, i) { if (findIndex(regionNames, regions[i]) == -1) { regionNames.append(regions[i]); } } } } else {
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; } }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); if (Uheader.headerOk()) { Info<< " Reading U" << endl; volVectorField U(Uheader, mesh); Info<< " Calculating U^2" << endl; volVectorField U2 ( IOobject ( "U2", runTime.timeName(), mesh, IOobject::NO_READ ), mesh, dimensionedVector("U2",dimensionSet(0, 2, -2, 0, 0, 0, 0),vector::zero) ); Info<< " Calculating U^3" << endl; volVectorField U3 ( IOobject ( "U3", runTime.timeName(), mesh, IOobject::NO_READ ), mesh, dimensionedVector("U3",dimensionSet(0, 3, -3, 0, 0, 0, 0),vector::zero) ); /* only the internal */ //U2.internalField().replace(vector::Z, Ux.internalField()); /* include the boundary */ /* U2.replace(vector::X, U.component(vector::X)*U.component(vector::X)); U2.replace(vector::Y, U.component(vector::Y)*U.component(vector::Y)); U2.replace(vector::Z, U.component(vector::Z)*U.component(vector::Z)); */ U2.replace(vector::X, pow(U.component(vector::X), 2)); U2.replace(vector::Y, pow(U.component(vector::Y), 2)); U2.replace(vector::Z, pow(U.component(vector::Z), 2)); U3.replace(vector::X, pow(U.component(vector::X), 3)); U3.replace(vector::Y, pow(U.component(vector::Y), 3)); U3.replace(vector::Z, pow(U.component(vector::Z), 3)); /* Info<< "vorticity max/min : " << max(magVorticity).value() << " " << min(magVorticity).value() << endl; */ if (writeResults) { // vorticity.write(); // magVorticity.write(); U2.write(); U3.write(); } } else { Info<< " No U" << endl; } Info<< "\nEnd\n" << endl; }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); IOobject Theader ( "T", runTime.timeName(), mesh, IOobject::MUST_READ ); IOobject qheader ( "q", runTime.timeName(), mesh, IOobject::MUST_READ ); IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionedScalar Cpa ( transportProperties.lookup("Cpa") ); dimensionedScalar Cpv ( transportProperties.lookup("Cpv") ); dimensionedScalar lambda ( transportProperties.lookup("lambda") ); // Fluid density dimensionedScalar rho ( transportProperties.lookup("rho") ); dimensionedScalar TRef ( transportProperties.lookup("TRef") ); dimensionedScalar qRef ( transportProperties.lookup("qRef") ); if (qheader.headerOk() && Theader.headerOk()) { Info<< " Reading q" << endl; volScalarField q(qheader, mesh); Info<< " Reading T" << endl; volScalarField T(Theader, mesh); // specific enthalpy of dry air hda - ASHRAE 1.8 volScalarField hda("hda", rho*Cpa*T-rho*Cpa*TRef); // specific enthalpy of dry vapor volScalarField hdv("hdv", rho*q*(lambda + Cpv*T) - rho*qRef*(lambda + Cpv*TRef)); // specific enthalpy for moist air hmoist - ASHRAE 1.8 volScalarField hmoist("hmoist", hda + hdv); if (writeResults) { hda.write(); hdv.write(); hmoist.write(); } else { Info<< " Min hda : " << min(hda).value() << " [J/m3]" << "\n Max hda : "<< max(hda).value() << " [J/m3]" << endl; Info<< " Min hdv : " << min(hdv).value() << " [J/m3]" << "\n Max hdv : "<< max(hdv).value() << " [J/m3]" << endl; Info<< " Min hmoist : " << min(hmoist).value() << " [J/m3]" << "\n Max hmoist : "<< max(hmoist).value() << " [J/m3]" << endl; } // print results // // surfaceScalarField hdaBoundary = // fvc::interpolate(hda); // // const surfaceScalarField::GeometricBoundaryField& patchhda = // hdaBoundary.boundaryField(); // // const surfaceScalarField::GeometricBoundaryField& patchCondHeatFlux = // // condHeatFluxNormal.boundaryField(); // // const surfaceScalarField::GeometricBoundaryField& patchTurbHeatFlux = // // turbHeatFluxNormal.boundaryField(); // // const surfaceScalarField::GeometricBoundaryField& patchTotHeatFlux = // // totHeatFluxNormal.boundaryField(); // // Info<< "\nHeat at the boundaries " << endl; // forAll(patchhda, patchi) // { // if ( (!isA<emptyFvPatch>(mesh.boundary()[patchi])) && // (mesh.boundary()[patchi].size() > 0) ) // { // Info<< " " // << mesh.boundary()[patchi].name() // << "\n Total area [m2] : " // << gSum(mesh.magSf().boundaryField()[patchi]) // << "\n Integral Energy [J] : " // << gSum // ( // mesh.magSf().boundaryField()[patchi] // *patchhda[patchi] // ) // << nl << endl; // } // } // Info << endl; } else { Info<< " No q or No T" << endl; } Info<< "\nEnd\n" << endl; }
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 RASPropertiesHeader ( "RASProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ); IOobject LESPropertiesHeader ( "LESProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ); Info<< " Calculating Pe" << endl; if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) { if (RASPropertiesHeader.headerOk()) { IOdictionary RASProperties(RASPropertiesHeader); singlePhaseTransportModel laminarTransport(U, phi); autoPtr<incompressible::RASModel> RASModel ( incompressible::RASModel::New ( U, phi, laminarTransport ) ); PePtr.set ( new surfaceScalarField ( IOobject ( "Pe", runTime.timeName(), mesh, IOobject::NO_READ ), mag(phi) /( mesh.magSf() * mesh.surfaceInterpolation::deltaCoeffs() * fvc::interpolate(RASModel->nuEff()) ) ) ); } else if (LESPropertiesHeader.headerOk()) { IOdictionary LESProperties(LESPropertiesHeader); singlePhaseTransportModel laminarTransport(U, phi); autoPtr<incompressible::LESModel> sgsModel ( incompressible::LESModel::New(U, phi, laminarTransport) ); PePtr.set ( new surfaceScalarField ( IOobject ( "Pe", runTime.timeName(), mesh, IOobject::NO_READ ), mag(phi) /( mesh.magSf() * mesh.surfaceInterpolation::deltaCoeffs() * fvc::interpolate(sgsModel->nuEff()) ) ) ); } else { IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionedScalar nu(transportProperties.lookup("nu")); PePtr.set ( new surfaceScalarField ( IOobject ( "Pe", runTime.timeName(), mesh, IOobject::NO_READ ), mesh.surfaceInterpolation::deltaCoeffs() * (mag(phi)/mesh.magSf())*(runTime.deltaT()/nu) ) ); } } else if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) { if (RASPropertiesHeader.headerOk()) { IOdictionary RASProperties(RASPropertiesHeader); autoPtr<basicPsiThermo> thermo(basicPsiThermo::New(mesh)); volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh ), thermo->rho() ); autoPtr<compressible::RASModel> RASModel ( compressible::RASModel::New ( rho, U, phi, thermo() ) ); PePtr.set ( new surfaceScalarField ( IOobject ( "Pe", runTime.timeName(), mesh, IOobject::NO_READ ), mag(phi) /( mesh.magSf() * mesh.surfaceInterpolation::deltaCoeffs() * fvc::interpolate(RASModel->muEff()) ) ) ); } else if (LESPropertiesHeader.headerOk()) { IOdictionary LESProperties(LESPropertiesHeader); autoPtr<basicPsiThermo> thermo(basicPsiThermo::New(mesh)); volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh ), thermo->rho() ); autoPtr<compressible::LESModel> sgsModel ( compressible::LESModel::New(rho, U, phi, thermo()) ); PePtr.set ( new surfaceScalarField ( IOobject ( "Pe", runTime.timeName(), mesh, IOobject::NO_READ ), mag(phi) /( mesh.magSf() * mesh.surfaceInterpolation::deltaCoeffs() * fvc::interpolate(sgsModel->muEff()) ) ) ); } else { IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionedScalar mu(transportProperties.lookup("mu")); PePtr.set ( new surfaceScalarField ( IOobject ( "Pe", runTime.timeName(), mesh, IOobject::NO_READ ), mesh.surfaceInterpolation::deltaCoeffs() * (mag(phi)/(mesh.magSf()))*(runTime.deltaT()/mu) ) ); } } else { FatalErrorIn(args.executable()) << "Incorrect dimensions of phi: " << phi.dimensions() << abort(FatalError); } // can also check how many cells exceed a particular Pe limit /* { label count = 0; label PeLimit = 200; forAll(PePtr(), i) { if (PePtr()[i] > PeLimit) { count++; } } Info<< "Fraction > " << PeLimit << " = " << scalar(count)/Pe.size() << endl; } */ Info << "Pe max : " << max(PePtr()).value() << endl; if (writeResults) { PePtr().write(); } } else { Info<< " No phi" << endl; } Info<< "\nEnd\n" << endl; }
void Foam::calcTypes::fieldMap2d::preCalc ( const argList& args, const Time& runTime, const fvMesh& mesh ) { const word dictName("fieldMap2dDict"); IOdictionary dict ( IOobject ( dictName, runTime.system(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); if( !dict.readIfPresent<word>("patchName", patchName) ) { SeriousErrorIn("preCalc") << "There is no patchName parameter in fieldMap2dDict dictionary" << exit(FatalError); } if( !dict.readIfPresent<word>("geometry", geometry) ) { SeriousErrorIn("preCalc") << "There is no geometry parameter in fieldMap2dDict dictionary" << exit(FatalError); } point minPoint; if( !dict.readIfPresent<point>("minPoint", minPoint) ) { SeriousErrorIn("preCalc") << "There is no minPoint parameter in fieldMap2dDict dictionary" << exit(FatalError); } point maxPoint; if( !dict.readIfPresent<point>("maxPoint", maxPoint) ) { SeriousErrorIn("preCalc") << "There is no maxPoint parameter in fieldMap2dDict dictionary" << exit(FatalError); } int integrationDir; if( !dict.readIfPresent<int>("integrationDirection", integrationDir) ) { SeriousErrorIn("preCalc") << "There is no integrationDirection parameter " "in fieldMap2dDict dictionary" << exit(FatalError); } intDir = integrationDir; int flowDir; if( !dict.readIfPresent<int>("flowDirection", flowDir) ) { SeriousErrorIn("preCalc") << "There is no flowDirection parameter " "in fieldMap2dDict dictionary" << exit(FatalError); } majDir = flowDir; int expectedNumberOfIntersections; if ( !dict.readIfPresent<int> ( "expectedNumberOfIntersections", expectedNumberOfIntersections ) ) { SeriousErrorIn("preCalc") << "There is no expectedNumberOfIntersections parameter " "in fieldMap2dDict dictionary" << exit(FatalError); } expNI = expectedNumberOfIntersections; int numberOfIntegrationPoints; if ( !dict.readIfPresent<int> ( "numberOfIntegrationPoints", numberOfIntegrationPoints ) ) { SeriousErrorIn("preCalc") << "There is no numberOfIntegrationPoints parameter " "in fieldMap2dDict dictionary" << exit(FatalError); } #ifdef FOAM_DEV const word& processingType = args.additionalArgs()[1]; const word& Nword = args.additionalArgs()[2]; const word& Mword = args.additionalArgs()[3]; const word& Kword = args.additionalArgs()[4]; N_ = std::atoi( Nword.c_str() ); M_ = std::atoi( Mword.c_str() ); Info << "FOAM_DEV true: "<< FOAM_DEV <<nl; #else const word processingType = args[2]; N_ = std::atoi( args[3].c_str() ); M_ = std::atoi( args[4].c_str() ); Info << "FOAM_DEV false: " <<nl; #endif processingType_ = const_cast<word&>(processingType); latDir = 3 - (intDir + majDir); Info<<"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" <<nl <<"Post-processing parameters:"<<nl <<"patchName: "<< patchName<<nl <<"geometry: "<< geometry<<nl <<"minPoint: "<< minPoint<<nl <<"maxPoint: "<< maxPoint<<nl <<"major direction: "<< majDir<<nl <<"lateral direction: "<< latDir<<nl <<"integration direction: "<< intDir<<nl <<"number of intersections: "<<expNI<<nl <<"number of integration points: "<< numberOfIntegrationPoints <<endl; if ( processingType_!="ccAll" && geometry == "concentricCylinders" ) { SeriousErrorIn("preCalc") << "Concentric cylinders geometry should have proc type ccAll" << exit(FatalError); } N1_ = N_+1; M1_ = M_+1; K_ = numberOfIntegrationPoints; K1_ = numberOfIntegrationPoints+1; N1M1 = N1_*M1_; // need temporary arguments in order to add a 0 time directory /* argList argsTmp = args; argsTmp.setOption("time", "0"); Foam::Time timeTmp(Foam::Time::controlDictName, argsTmp); Foam::instantList timeDirs = Foam::timeSelector::select0(timeTmp, argsTmp); timeTmp.setTime(timeDirs[0], 0); Foam::fvMesh meshTmp ( Foam::IOobject ( Foam::fvMesh::defaultRegion, timeTmp.timeName(), timeTmp, Foam::IOobject::MUST_READ ) ); if( timeTmp.timeName()!="0" ) { SeriousErrorIn("fieldOperations::getInletAreaT0") <<"There is no 0 time directory. Check your decomposition as well!"<<nl <<"TimeTmp: "<< timeTmp.timeName()<<nl <<exit(FatalError); } */ //Info << "Calculating the max and min coordinates"<<nl; //const pointField &allPoints = meshTmp.points(); //minPosX = min( allPoints.component(vector::X) ); //minPosY = min( allPoints.component(vector::Y) ); //minPosZ = min( allPoints.component(vector::Z) ); if(geometry=="flat") { minPosMaj = minPoint.component(majDir); minPosLat = minPoint.component(latDir); minPosInt = minPoint.component(intDir); maxPosMaj = maxPoint.component(majDir); maxPosLat = maxPoint.component(latDir); maxPosInt = maxPoint.component(intDir); // z becomes x; x becomes y dx = (maxPosMaj - minPosMaj) / static_cast<scalar>(N_); dy = (maxPosLat - minPosLat) / static_cast<scalar>(M_); } else if(geometry=="concentricCylinders") { minPosMaj = minPoint.component(majDir); minPosLat = 0.0; minPosInt = 0.0; maxPosMaj = maxPoint.component(majDir); maxPosLat = constant::mathematical::twoPi; maxPosInt = maxPoint.component(intDir); // in case of concentric cylinders we go around the circle dx = (maxPosMaj - minPosMaj) / static_cast<scalar>(N_); dy = (maxPosLat - minPosLat) / static_cast<scalar>(M_); } else { FatalError<<"Unknown geometry"<<nl<<exit(FatalError); } // calculate the size of the current pattern being not bigger then 10^7 thisTimeSize = min(N1M1, maxNumProcPoints); curNum = 0; curEnd = thisTimeSize; totNumLoop = (N1M1-1) / maxNumProcPoints + 1; }
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()) { volScalarField Co ( IOobject ( "Co", runTime.timeName(), mesh, IOobject::NO_READ ), mesh, dimensionedScalar("0", dimless, 0), zeroGradientFvPatchScalarField::typeName ); Info<< " Reading phi" << endl; surfaceScalarField phi(phiHeader, mesh); if (phi.dimensions() == dimensionSet(1, 0, -1, 0, 0)) { Info<< " Calculating compressible Co" << endl; Info<< " Reading rho" << endl; volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::MUST_READ ), mesh ); Co.dimensionedInternalField() = (0.5*runTime.deltaT()) *fvc::surfaceSum(mag(phi))().dimensionedInternalField() /(rho*mesh.V()); Co.correctBoundaryConditions(); } else if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) { Info<< " Calculating incompressible Co" << endl; Co.dimensionedInternalField() = (0.5*runTime.deltaT()) *fvc::surfaceSum(mag(phi))().dimensionedInternalField() /mesh.V(); Co.correctBoundaryConditions(); } else { FatalErrorIn(args.executable()) << "Incorrect dimensions of phi: " << phi.dimensions() << abort(FatalError); } Info<< "Co max : " << max(Co).value() << endl; if (writeResults) { Co.write(); } } else { Info<< " No phi" << endl; } Info<< "\nEnd\n" << endl; }
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) { bool writeResults = !args.optionFound("noWrite"); IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); IOobject Theader ( "T", runTime.timeName(), mesh, IOobject::MUST_READ ); // Check U and T exists if (Uheader.headerOk() && Theader.headerOk()) { autoPtr<volScalarField> MachPtr; volVectorField U(Uheader, mesh); if (isFile(runTime.constantPath()/"thermophysicalProperties")) { // thermophysical Mach autoPtr<basicPsiThermo> thermo ( basicPsiThermo::New(mesh) ); volScalarField Cp = thermo->Cp(); volScalarField Cv = thermo->Cv(); MachPtr.set ( new volScalarField ( IOobject ( "Ma", runTime.timeName(), mesh ), mag(U)/(sqrt((Cp/Cv)*(Cp - Cv)*thermo->T())) ) ); } else { // thermodynamic Mach IOdictionary thermoProps ( IOobject ( "thermodynamicProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionedScalar R(thermoProps.lookup("R")); dimensionedScalar Cv(thermoProps.lookup("Cv")); volScalarField T(Theader, mesh); MachPtr.set ( new volScalarField ( IOobject ( "Ma", runTime.timeName(), mesh ), mag(U)/(sqrt(((Cv + R)/Cv)*R*T)) ) ); } Info<< "Mach max : " << max(MachPtr()).value() << endl; if (writeResults) { MachPtr().write(); } } else { Info<< " Missing U or T" << endl; } }
void calc ( const argList& args, const Time& runTime, const fvMesh& mesh, functionObjectList& fol ) { if (args.optionFound("noFlow")) { Info<< " Operating in no-flow mode; no models will be loaded." << " All vol, surface and point fields will be loaded." << endl; // Read objects in time directory IOobjectList objects(mesh, runTime.timeName()); // Read vol fields. PtrList<volScalarField> vsFlds; ReadFields(mesh, objects, vsFlds); PtrList<volVectorField> vvFlds; ReadFields(mesh, objects, vvFlds); PtrList<volSphericalTensorField> vstFlds; ReadFields(mesh, objects, vstFlds); PtrList<volSymmTensorField> vsymtFlds; ReadFields(mesh, objects, vsymtFlds); PtrList<volTensorField> vtFlds; ReadFields(mesh, objects, vtFlds); // Read surface fields. PtrList<surfaceScalarField> ssFlds; ReadFields(mesh, objects, ssFlds); PtrList<surfaceVectorField> svFlds; ReadFields(mesh, objects, svFlds); PtrList<surfaceSphericalTensorField> sstFlds; ReadFields(mesh, objects, sstFlds); PtrList<surfaceSymmTensorField> ssymtFlds; ReadFields(mesh, objects, ssymtFlds); PtrList<surfaceTensorField> stFlds; ReadFields(mesh, objects, stFlds); // Read point fields. const pointMesh& pMesh = pointMesh::New(mesh); PtrList<pointScalarField> psFlds; ReadFields(pMesh, objects, psFlds); PtrList<pointVectorField> pvFlds; ReadFields(pMesh, objects, pvFlds); PtrList<pointSphericalTensorField> pstFlds; ReadFields(pMesh, objects, pstFlds); PtrList<pointSymmTensorField> psymtFlds; ReadFields(pMesh, objects, psymtFlds); PtrList<pointTensorField> ptFlds; ReadFields(pMesh, objects, ptFlds); fol.execute(true); } else { Info<< " Reading phi" << endl; surfaceScalarField phi ( IOobject ( "phi", runTime.timeName(), mesh, IOobject::MUST_READ ), mesh ); Info<< " Reading U" << endl; volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ), mesh ); Info<< " Reading p" << endl; volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::MUST_READ ), mesh ); #include "createFvOptions.H" if (phi.dimensions() == dimVolume/dimTime) { IOobject RASPropertiesHeader ( "RASProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ); IOobject LESPropertiesHeader ( "LESProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ); if (RASPropertiesHeader.headerOk()) { IOdictionary RASProperties(RASPropertiesHeader); singlePhaseTransportModel laminarTransport(U, phi); autoPtr<incompressible::RASModel> RASModel ( incompressible::RASModel::New ( U, phi, laminarTransport ) ); fol.execute(true); } else if (LESPropertiesHeader.headerOk()) { IOdictionary LESProperties(LESPropertiesHeader); singlePhaseTransportModel laminarTransport(U, phi); autoPtr<incompressible::LESModel> sgsModel ( incompressible::LESModel::New(U, phi, laminarTransport) ); fol.execute(true); } else { IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); fol.execute(true); } } else if (phi.dimensions() == dimMass/dimTime) { autoPtr<fluidThermo> thermo(fluidThermo::New(mesh)); volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh ), thermo->rho() ); IOobject RASPropertiesHeader ( "RASProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ); IOobject LESPropertiesHeader ( "LESProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ); if (RASPropertiesHeader.headerOk()) { IOdictionary RASProperties(RASPropertiesHeader); autoPtr<compressible::RASModel> RASModel ( compressible::RASModel::New ( rho, U, phi, thermo() ) ); fol.execute(true); } else if (LESPropertiesHeader.headerOk()) { IOdictionary LESProperties(LESPropertiesHeader); autoPtr<compressible::LESModel> sgsModel ( compressible::LESModel::New(rho, U, phi, thermo()) ); fol.execute(true); } else { IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); fol.execute(true); } } else { FatalErrorIn(args.executable()) << "Incorrect dimensions of phi: " << phi.dimensions() << nl << exit(FatalError); } } }
void Foam::calcTypes::randomise::calc ( const argList& args, const Time& runTime, const fvMesh& mesh ) { const stringList& params = args.additionalArgs(); const scalar pertMag = readScalar(IStringStream(params[1])()); const word& fieldName = params[2]; Random rand(1234567); IOobject fieldHeader ( fieldName, runTime.timeName(), mesh, IOobject::MUST_READ ); // Check field exists if (fieldHeader.headerOk()) { bool processed = false; writeRandomField<vector> ( fieldHeader, pertMag, rand, mesh, processed ); writeRandomField<sphericalTensor> ( fieldHeader, pertMag, rand, mesh, processed ); writeRandomField<symmTensor> ( fieldHeader, pertMag, rand, mesh, processed ); writeRandomField<tensor> ( fieldHeader, pertMag, rand, mesh, processed ); if (!processed) { FatalError << "Unable to process " << fieldName << nl << "No call to randomise for fields of type " << fieldHeader.headerClassName() << nl << nl << exit(FatalError); } } else { Info<< " No " << fieldName << endl; } }