// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::danckwertsFvPatchScalarField::updateCoeffs() { if(debug) { Info<<"danckwerts::updateCoeffs: updated: "<<updated()<<endl; } if (updated()) return; vectorField n = (-1)*this->patch().nf(); scalarField iF = this->patchInternalField(); vectorField del = (-1)*this->patch().delta(); vectorField boundaryU = this->patch().template lookupPatchField<volVectorField, vector>("U"); scalarField AA; if(this->db().find("D") != this->db().end()){ if( this->db().find("D")()->type() == "volScalarField" ){ const scalarField& patchD = this->patch().template lookupPatchField<volScalarField, scalar>("D"); AA = (boundaryU & n) * (del & n) / patchD; } else if( this->db().find("D")()->type() == "surfaceScalarField" ){ const scalarField& patchD = this->patch().template lookupPatchField<surfaceScalarField, scalar>("D"); AA = (boundaryU & n) * (del & n) / patchD; } else if( this->db().find("D")()->type() == "volSphericalTensorField" ){ const sphericalTensorField& patchD = this->patch().template lookupPatchField<volSphericalTensorField, sphericalTensor>("D"); AA = (boundaryU & n) * (del & n) / (n & patchD & n); } else if( this->db().find("D")()->type() == "volSymmTensorField" ){ const symmTensorField& patchD = this->patch().template lookupPatchField<volSymmTensorField, symmTensor>("D"); AA = (boundaryU & n) * (del & n) / (n & patchD & n); } else if( this->db().find("D")()->type() == "volTensorField" ){ const tensorField& patchD = this->patch().template lookupPatchField<volTensorField, tensor>("D"); AA = (boundaryU & n) * (del & n) / (n & patchD & n); } else{ SeriousErrorIn("danckwertsFvPatchScalarField::updateCoeffs()") <<"D type is not implemented. D type is "<< this->db().find("D")()->type() <<exit(FatalError); } } else{ const IOdictionary& iod = this->db().lookupObject<IOdictionary>("transportProperties"); scalar patchD = (new dimensionedScalar(iod.lookup("D")))->value(); AA = (boundaryU & n) * (del & n) / patchD; } this->refValue() = pTraits<scalar>::one; this->refGrad() = pTraits<scalar>::zero; this->valueFraction() = AA / (AA+1.0); mixedFvPatchScalarField::updateCoeffs(); }
// Print state of istream. void Foam::state(istream& from, const string& s) { state_value isState = state_value(from.rdstate()); switch (isState) { case _good: // Do not anything 'unusual'. break; case _eof: Info << "Input stream: premature end of stream", s << endl; Info<< "If all else well, possibly a quote mark missing" << endl; break; case _fail: SeriousErrorIn("state(istream& from, const string& s)") << "Input stream failure (bad format?)", s << endl; Info<< "If all else well, possibly a quote mark missing" << endl; break; case (_fail + _eof) : SeriousErrorIn("state(istream& from, const string& s)") << "Input stream failure and end of stream", s << endl; Info<< "If all else well, possibly a quote mark missing" << endl; break; case _bad: SeriousErrorIn("state(istream& from, const string& s)") << "Serious input stream failure", s << endl; break; default: SeriousErrorIn("state(istream& from, const string& s)") << "Input stream failure of unknown type", s << endl; SeriousErrorIn("state(istream& from, const string& s)") << "Stream state value = ", isState << endl; break; } return; }
void Foam::state(ostream& to, const string& s) { state_value osState = state_value(to.rdstate()); switch (osState) { case _good: // Do not anything 'unusual'. break; case _eof: Info << "Output stream: premature end of stream", s << endl; break; case _fail: SeriousErrorIn("state(ostream& to, const string& s)") << "Output stream failure (bad format?)", s << endl; break; case (_fail + _eof) : SeriousErrorIn("state(ostream& to, const string& s)") << "Output stream failure and end of stream", s << endl; break; case _bad: SeriousErrorIn("state(ostream& to, const string& s)") << "Serious output stream failure", s << endl; break; default: SeriousErrorIn("state(ostream& to, const string& s)") << "Output stream failure of unknown type", s << endl << "Stream state value = ", osState << endl; break; } return; }
void Foam::cyclicFaPatch::calcTransforms() { if (size() > 0) { pointField half0Ctrs(size()/2); pointField half1Ctrs(size()/2); for (label i=0; i<size()/2; i++) { half0Ctrs[i] = this->edgeCentres()[i]; half1Ctrs[i] = this->edgeCentres()[i+size()/2]; } vectorField half0Normals(size()/2); vectorField half1Normals(size()/2); vectorField eN = edgeNormals()*magEdgeLengths(); scalar maxMatchError = 0; label errorEdge = -1; for (label edgei = 0; edgei < size()/2; edgei++) { half0Normals[edgei] = eN[edgei]; label nbrEdgei = edgei + size()/2; half1Normals[edgei] = eN[nbrEdgei]; scalar magLe = mag(half0Normals[edgei]); scalar nbrMagLe = mag(half1Normals[edgei]); scalar avLe = (magLe + nbrMagLe)/2.0; if (magLe < ROOTVSMALL && nbrMagLe < ROOTVSMALL) { // Undetermined normal. Use dummy normal to force separation // check. (note use of sqrt(VSMALL) since that is how mag // scales) half0Normals[edgei] = point(1, 0, 0); half1Normals[edgei] = half0Normals[edgei]; } else if ( mag(magLe - nbrMagLe)/avLe > matchTol_ ) { // Error in area matching. Find largest error maxMatchError = Foam::max(maxMatchError, mag(magLe - nbrMagLe)/avLe); errorEdge = edgei; } else { half0Normals[edgei] /= magLe; half1Normals[edgei] /= nbrMagLe; } } // Check for error in edge matching if (maxMatchError > matchTol_) { label nbrEdgei = errorEdge + size()/2; scalar magLe = mag(half0Normals[errorEdge]); scalar nbrMagLe = mag(half1Normals[errorEdge]); scalar avLe = (magLe + nbrMagLe)/2.0; FatalErrorIn ( "cyclicFaPatch::calcTransforms()" ) << "edge " << errorEdge << " area does not match neighbour " << nbrEdgei << " by " << 100*mag(magLe - nbrMagLe)/avLe << "% -- possible edge ordering problem." << endl << "patch:" << name() << " my area:" << magLe << " neighbour area:" << nbrMagLe << " matching tolerance:" << matchTol_ << endl << "Mesh edge:" << start() + errorEdge << endl << "Neighbour edge:" << start() + nbrEdgei << endl << "Other errors also exist, only the largest is reported. " << "Please rerun with cyclic debug flag set" << " for more information." << exit(FatalError); } // Calculate transformation tensors calcTransformTensors ( half0Ctrs, half1Ctrs, half0Normals, half1Normals ); // Check transformation tensors if (!parallel()) { if (forwardT().size() > 1 || reverseT().size() > 1) { SeriousErrorIn ( "void cyclicFaPatch::calcTransforms()" ) << "Transformation tensor is not constant for the cyclic " << "patch. Please reconsider your setup and definition of " << "cyclic boundaries." << endl; } } } }
bool Foam::regIOobject::writeObject ( IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp ) const { if (!good()) { SeriousErrorIn("regIOobject::write()") << "bad object " << name() << endl; return false; } if (instance().empty()) { SeriousErrorIn("regIOobject::write()") << "instance undefined for object " << name() << endl; return false; } if ( instance() != time().timeName() && instance() != time().system() && instance() != time().caseSystem() && instance() != time().constant() && instance() != time().caseConstant() ) { const_cast<regIOobject&>(*this).instance() = time().timeName(); } mkDir(path()); if (OFstream::debug) { Info<< "regIOobject::write() : " << "writing file " << objectPath(); } bool osGood = false; { // Try opening an OFstream for object OFstream os(objectPath(), fmt, ver, cmp); // If any of these fail, return (leave error handling to Ostream class) if (!os.good()) { return false; } if (!writeHeader(os)) { return false; } // Write the data to the Ostream if (!writeData(os)) { return false; } writeEndDivider(os); osGood = os.good(); } if (OFstream::debug) { Info<< " .... written" << endl; } // Only update the lastModified_ time if this object is re-readable, // i.e. lastModified_ is already set if (lastModified_) { lastModified_ = lastModified(objectPath()); } return osGood; }
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; }