Foam::polyBoundaryMesh::polyBoundaryMesh ( const IOobject& io, const polyMesh& mesh ) : polyPatchList(), regIOobject(io), mesh_(mesh) { if ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED ) { if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) { WarningInFunction << "Specified IOobject::MUST_READ_IF_MODIFIED but class" << " does not support automatic rereading." << endl; } polyPatchList& patches = *this; // Read polyPatchList Istream& is = readStream(typeName); PtrList<entry> patchEntries(is); patches.setSize(patchEntries.size()); forAll(patches, patchi) { patches.set ( patchi, polyPatch::New ( patchEntries[patchi].keyword(), patchEntries[patchi].dict(), patchi, *this ) ); } // Check state of IOstream is.check ( "polyBoundaryMesh::polyBoundaryMesh" "(const IOobject&, const polyMesh&)" ); close(); }
void Foam::polyTopoChanger::readModifiers() { if ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) { WarningIn("polyTopoChanger::readModifiers()") << "Specified IOobject::MUST_READ_IF_MODIFIED but class" << " does not support automatic rereading." << endl; } PtrList<polyMeshModifier>& modifiers = *this; // Read modifiers Istream& is = readStream(typeName); PtrList<entry> patchEntries(is); modifiers.setSize(patchEntries.size()); forAll(modifiers, modifierI) { modifiers.set ( modifierI, polyMeshModifier::New ( patchEntries[modifierI].keyword(), patchEntries[modifierI].dict(), modifierI, *this ) ); } // Check state of IOstream is.check ( "polyTopoChanger::polyTopoChanger" "(const IOobject&, const polyMesh&)" ); close(); }
Foam::polyBoundaryMesh::polyBoundaryMesh ( const IOobject& io, const polyMesh& mesh ) : polyPatchList(), regIOobject(io), mesh_(mesh), neighbourEdgesPtr_(NULL) { if (readOpt() == IOobject::MUST_READ) { polyPatchList& patches = *this; // Read polyPatchList Istream& is = readStream(typeName); PtrList<entry> patchEntries(is); patches.setSize(patchEntries.size()); forAll(patches, patchI) { patches.set ( patchI, polyPatch::New ( patchEntries[patchI].keyword(), patchEntries[patchI].dict(), patchI, *this ) ); }
bool Foam::regIOobject::checkIn() { if (!registered_) { // multiple checkin of same object is disallowed - this would mess up // any mapping registered_ = db().checkIn(*this); if ( registered_ && readOpt() == MUST_READ_IF_MODIFIED && time().runTimeModifiable() ) { if (watchIndex_ != -1) { FatalErrorInFunction << "Object " << objectPath() << " already watched with index " << watchIndex_ << abort(FatalError); } fileName f = filePath(); if (!f.size()) { // We don't have this file but would like to re-read it. // Possibly if master-only reading mode. f = objectPath(); } watchIndex_ = time().addWatch(f); } // check-in on defaultRegion is allowed to fail, since subsetted meshes // are created with the same name as their originating mesh if (!registered_ && debug && name() != polyMesh::defaultRegion) { if (debug == 2) { // for ease of finding where attempted duplicate check-in // originated FatalErrorInFunction << "failed to register object " << objectPath() << " the name already exists in the objectRegistry" << endl << "Contents:" << db().sortedToc() << abort(FatalError); } else { WarningInFunction << "failed to register object " << objectPath() << " the name already exists in the objectRegistry" << endl; } } } return registered_; }
topoSet::topoSet(const IOobject& obj, const word& wantedType) : regIOobject(obj) { if ( readOpt() == IOobject::MUST_READ || ( readOpt() == IOobject::READ_IF_PRESENT && headerOk() ) ) { if (readStream(wantedType).good()) { readStream(wantedType) >> static_cast<labelHashSet&>(*this); close(); } }
Foam::Istream& Foam::regIOobject::readStream() { if (IFstream::debug) { Info<< "regIOobject::readStream() : " << "reading object " << name() << " from file " << objectPath() << endl; } if (readOpt() == NO_READ) { FatalErrorIn("regIOobject::readStream()") << "NO_READ specified for read-constructor of object " << name() << " of class " << headerClassName() << abort(FatalError); } // Construct object stream and read header if not already constructed if (!isPtr_) { if (!(isPtr_ = objectStream())) { FatalIOError ( "regIOobject::readStream()", __FILE__, __LINE__, objectPath(), 0 ) << "cannot open file" << exit(FatalIOError); } else if (!readHeader(*isPtr_)) { FatalIOErrorIn("regIOobject::readStream()", *isPtr_) << "problem while reading header for object " << name() << exit(FatalIOError); } } if (!lastModified_) { lastModified_ = lastModified(filePath()); } return *isPtr_; }
Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f) { label index = -1; if (readOpt() == MUST_READ_IF_MODIFIED) { index = findIndex(files_, f); if (index == -1) { index = files_.size(); files_.append(f); } } return index; }
void Foam::unwatchedIOdictionary::addWatch() { if (readOpt() == MUST_READ_IF_MODIFIED) { fileName f = filePath(); if (!f.size()) { // We don't have this file but would like to re-read it. // Possibly if master-only reading mode. f = objectPath(); } if (findIndex(files_, f) != -1) { FatalErrorIn("regIOobject::addWatch()") << "Object " << objectPath() << " of type " << type() << " already watched" << abort(FatalError); } // If master-only reading only the master will have all dependencies // so scatter these to slaves bool masterOnly = global() && ( regIOobject::fileModificationChecking == timeStampMaster || regIOobject::fileModificationChecking == inotifyMaster ); if (masterOnly && Pstream::parRun()) { Pstream::scatter(files_); } addWatch(f); } }
Foam::surfZoneIOList::surfZoneIOList ( const IOobject& io ) : surfZoneList(), regIOobject(io) { Foam::string functionName = "surfZoneIOList::surfZoneIOList" "(const IOobject& io)"; if ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED ) { surfZoneList& zones = *this; Istream& is = readStream(typeName); PtrList<entry> dictEntries(is); zones.setSize(dictEntries.size()); label faceI = 0; forAll(zones, zoneI) { const dictionary& dict = dictEntries[zoneI].dict(); label zoneSize = readLabel(dict.lookup("nFaces")); label startFaceI = readLabel(dict.lookup("startFace")); zones[zoneI] = surfZone ( dictEntries[zoneI].keyword(), zoneSize, startFaceI, zoneI ); word geoType; if (dict.readIfPresent("geometricType", geoType)) { zones[zoneI].geometricType() = geoType; } if (startFaceI != faceI) { FatalErrorIn(functionName) << "surfZones are not ordered. Start of zone " << zoneI << " does not correspond to sum of preceding zones." << nl << "while reading " << io.objectPath() << endl << exit(FatalError); } faceI += zoneSize; } // Check state of IOstream is.check(functionName.c_str()); close(); }
// Construct from IOObject Foam::surfacePatchIOList::surfacePatchIOList ( const IOobject& io ) : surfacePatchList(), regIOobject(io) { Foam::string functionName = "surfacePatchIOList::surfacePatchIOList" "(const IOobject& io)"; if ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED ) { if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) { WarningInFunction << "Specified IOobject::MUST_READ_IF_MODIFIED but class" << " does not support automatic rereading." << endl; } surfacePatchList& patches = *this; // read polyPatchList Istream& is = readStream(typeName); PtrList<entry> patchEntries(is); patches.setSize(patchEntries.size()); label facei = 0; forAll(patches, patchi) { const dictionary& dict = patchEntries[patchi].dict(); label patchSize = readLabel(dict.lookup("nFaces")); label startFacei = readLabel(dict.lookup("startFace")); patches[patchi] = surfacePatch ( word(dict.lookup("geometricType")), patchEntries[patchi].keyword(), patchSize, startFacei, patchi ); if (startFacei != facei) { FatalErrorInFunction << "Patches are not ordered. Start of patch " << patchi << " does not correspond to sum of preceding patches." << endl << "while reading " << io.objectPath() << exit(FatalError); } facei += patchSize; } // Check state of IOstream is.check(functionName.c_str()); close(); } }
Foam::fvSchemes::fvSchemes(const objectRegistry& obr) : IOdictionary ( IOobject ( "fvSchemes", obr.time().system(), obr, ( obr.readOpt() == IOobject::MUST_READ || obr.readOpt() == IOobject::READ_IF_PRESENT ? IOobject::MUST_READ_IF_MODIFIED : obr.readOpt() ), IOobject::NO_WRITE ) ), ddtSchemes_ ( ITstream ( objectPath() + ".ddtSchemes", tokenList() )() ), defaultDdtScheme_ ( ddtSchemes_.name() + ".default", tokenList() ), d2dt2Schemes_ ( ITstream ( objectPath() + ".d2dt2Schemes", tokenList() )() ), defaultD2dt2Scheme_ ( d2dt2Schemes_.name() + ".default", tokenList() ), interpolationSchemes_ ( ITstream ( objectPath() + ".interpolationSchemes", tokenList() )() ), defaultInterpolationScheme_ ( interpolationSchemes_.name() + ".default", tokenList() ), divSchemes_ ( ITstream ( objectPath() + ".divSchemes", tokenList() )() ), defaultDivScheme_ ( divSchemes_.name() + ".default", tokenList() ), gradSchemes_ ( ITstream ( objectPath() + ".gradSchemes", tokenList() )() ), defaultGradScheme_ ( gradSchemes_.name() + ".default", tokenList() ), snGradSchemes_ ( ITstream ( objectPath() + ".snGradSchemes", tokenList() )() ), defaultSnGradScheme_ ( snGradSchemes_.name() + ".default", tokenList() ), laplacianSchemes_ ( ITstream ( objectPath() + ".laplacianSchemes", tokenList() )() ), defaultLaplacianScheme_ ( laplacianSchemes_.name() + ".default", tokenList() ), fluxRequired_ ( ITstream ( objectPath() + ".fluxRequired", tokenList() )() ), defaultFluxRequired_(false), steady_(false) { if ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { read(schemesDict()); } }
Foam::fvSchemes::fvSchemes(const objectRegistry& obr) : IOdictionary ( IOobject ( "fvSchemes", obr.time().system(), obr, ( obr.readOpt() == IOobject::MUST_READ ? IOobject::MUST_READ_IF_MODIFIED : obr.readOpt() ), IOobject::NO_WRITE ) ), ddtSchemes_ ( ITstream ( objectPath() + "::ddtSchemes", tokenList() )() ), defaultDdtScheme_ ( ddtSchemes_.name() + "::default", tokenList() ), d2dt2Schemes_ ( ITstream ( objectPath() + "::d2dt2Schemes", tokenList() )() ), defaultD2dt2Scheme_ ( d2dt2Schemes_.name() + "::default", tokenList() ), interpolationSchemes_ ( ITstream ( objectPath() + "::interpolationSchemes", tokenList() )() ), defaultInterpolationScheme_ ( interpolationSchemes_.name() + "::default", tokenList() ), divSchemes_ ( ITstream ( objectPath() + "::divSchemes", tokenList() )() ), defaultDivScheme_ ( divSchemes_.name() + "::default", tokenList() ), gradSchemes_ ( ITstream ( objectPath() + "::gradSchemes", tokenList() )() ), defaultGradScheme_ ( gradSchemes_.name() + "::default", tokenList() ), snGradSchemes_ ( ITstream ( objectPath() + "::snGradSchemes", tokenList() )() ), defaultSnGradScheme_ ( snGradSchemes_.name() + "::default", tokenList() ), laplacianSchemes_ ( ITstream ( objectPath() + "::laplacianSchemes", tokenList() )() ), defaultLaplacianScheme_ ( laplacianSchemes_.name() + "::default", tokenList() ), fluxRequired_ ( ITstream ( objectPath() + "::fluxRequired", tokenList() )() ), defaultFluxRequired_(false) { // persistent settings across reads is incorrect clear(); if ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED ) { read(schemesDict()); } }
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io) : regIOobject(io), edgeMesh(pointField(0), edgeList(0)), concaveStart_(0), mixedStart_(0), nonFeatureStart_(0), internalStart_(0), flatStart_(0), openStart_(0), multipleStart_(0), normals_(0), edgeDirections_(0), edgeNormals_(0), featurePointNormals_(0), featurePointEdges_(0), regionEdges_(0), pointTree_(), edgeTree_(), edgeTreesByType_() { if ( io.readOpt() == IOobject::MUST_READ || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) { WarningIn ( "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh" "(const IOobject&)" ) << "Specified IOobject::MUST_READ_IF_MODIFIED but class" << " does not support automatic rereading." << endl; } Istream& is = readStream(typeName); is >> *this >> concaveStart_ >> mixedStart_ >> nonFeatureStart_ >> internalStart_ >> flatStart_ >> openStart_ >> multipleStart_ >> normals_ >> edgeNormals_ >> featurePointNormals_ >> featurePointEdges_ >> regionEdges_; close(); { // Calculate edgeDirections const edgeList& eds(edges()); const pointField& pts(points()); edgeDirections_.setSize(eds.size()); forAll(eds, eI) { edgeDirections_[eI] = eds[eI].vec(pts); } edgeDirections_ /= mag(edgeDirections_); } }