label addFaceZone(const polyMesh& mesh, const word& name) { label zoneID = mesh.faceZones().findZoneID(name); if (zoneID != -1) { Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name() << " at index " << zoneID << endl; } else { faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh).faceZones(); zoneID = faceZones.size(); Info<< "Adding faceZone " << name << " at index " << zoneID << endl; faceZones.setSize(zoneID+1); faceZones.set ( zoneID, new faceZone ( name, labelList(0), boolList(), zoneID, faceZones ) ); } return zoneID; }
void Foam::simpleEngineTopoFvMesh::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston and valve motion if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 ) { Info<< "void Foam::simpleEngineTopoFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; if (topoChanger_.size() == 0) { FatalErrorIn ( "void simpleEngineTopoFvMesh::addZonesAndModifiers()" ) << "Mesh modifiers not read properly" << abort(FatalError); } return; } Info<< "Time = " << engineTime_.theta() << endl << "Adding zones to the engine mesh" << endl; List<pointZone*> pz(nValves()); List<faceZone*> fz(6*nValves() + 1); List<cellZone*> cz(0); label nPointZones = 0; label nFaceZones = 0; for (label valveI = 0; valveI < nValves(); valveI++) { // If both sides of the interface exist, add sliding interface // for a valve if ( valves_[valveI].curtainInCylinderPatchID().active() && valves_[valveI].curtainInPortPatchID().active() ) { Info<< "Adding sliding interface zones for curtain of valve " << valveI + 1 << endl; pz[nPointZones] = new pointZone ( "cutPointsV" + Foam::name(valveI + 1), labelList(0), nPointZones, pointZones() ); nPointZones++; const polyPatch& cylCurtain = boundaryMesh() [valves_[valveI].curtainInCylinderPatchID().index()]; labelList cylCurtainLabels(cylCurtain.size(), cylCurtain.start()); forAll (cylCurtainLabels, i) { cylCurtainLabels[i] += i; } fz[nFaceZones] = new faceZone ( "curtainCylZoneV" + Foam::name(valveI + 1), cylCurtainLabels, boolList(cylCurtainLabels.size(), false), nFaceZones, faceZones() ); nFaceZones++; const polyPatch& portCurtain = boundaryMesh() [valves_[valveI].curtainInPortPatchID().index()]; labelList portCurtainLabels ( portCurtain.size(), portCurtain.start() ); forAll (portCurtainLabels, i) { portCurtainLabels[i] += i; } fz[nFaceZones] = new faceZone ( "curtainPortZoneV" + Foam::name(valveI + 1), portCurtainLabels, boolList(portCurtainLabels.size(), false), nFaceZones, faceZones() ); nFaceZones++; // Add empty zone for cut faces fz[nFaceZones] = new faceZone ( "cutFaceZoneV" + Foam::name(valveI + 1), labelList(0), boolList(0, false), nFaceZones, faceZones() ); nFaceZones++; // Create a detach zone if ( valves_[valveI].detachInCylinderPatchID().active() && valves_[valveI].detachInPortPatchID().active() && valves_[valveI].detachFaces().size() > 0 ) { Info<< "Adding detach boundary for valve " << valveI + 1 << endl; const vectorField& areas = Sf().internalField(); const labelList& df = valves_[valveI].detachFaces(); boolList flip(df.size(), false); const vector& pistonAxis = piston().cs().axis(); forAll (df, dfI) { if (isInternalFace(df[dfI])) { if ((areas[df[dfI]] & pistonAxis) > 0) { flip[dfI] = true; } } else { FatalErrorIn ( "void simpleEngineTopoFvMesh::" "addZonesAndModifiers()" ) << "found boundary face in valve detach definition" << " for valve " << valveI + 1 << ". This is not allowed. Detach faces: " << df << " nInternalFaces: " << nInternalFaces() << abort(FatalError); } } // Add detach face zone fz[nFaceZones] = new faceZone ( "detachFaceZoneV" + Foam::name(valveI + 1), df, flip, nFaceZones, faceZones() ); nFaceZones++; } }
const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const polyPatch& innerSlider = boundaryMesh()[boundaryMesh().findPatchID(innerSliderName)]; labelList isf(innerSlider.size()); forAll (isf, i) { isf[i] = innerSlider.start() + i; } fz[0] = new faceZone ( "insideSliderZone", isf, boolList(innerSlider.size(), false), 0, faceZones() ); // Outer slider const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const polyPatch& outerSlider = boundaryMesh()[boundaryMesh().findPatchID(outerSliderName)]; labelList osf(outerSlider.size()); forAll (osf, i) { osf[i] = outerSlider.start() + i; }
// Do face zones for slider // Moving slider labelList isf(movingSlider.size()); forAll (isf, i) { isf[i] = movingSlider.start() + i; } fz[0] = new faceZone ( movingSliderName + "Zone", isf, boolList(movingSlider.size(), false), 0, faceZones() ); // Static slider labelList osf(staticSlider.size()); forAll (osf, i) { osf[i] = staticSlider.start() + i; } fz[1] = new faceZone ( staticSliderName + "Zone",
// Read mesh if available. Otherwise create empty mesh with same non-proc // patches as proc0 mesh. Requires all processors to have all patches // (and in same order). autoPtr<fvMesh> createMesh ( const Time& runTime, const word& regionName, const fileName& instDir, const bool haveMesh ) { //Pout<< "Create mesh for time = " // << runTime.timeName() << nl << endl; IOobject io ( regionName, instDir, runTime, IOobject::MUST_READ ); if (!haveMesh) { // Create dummy mesh. Only used on procs that don't have mesh. IOobject noReadIO(io); noReadIO.readOpt() = IOobject::NO_READ; fvMesh dummyMesh ( noReadIO, xferCopy(pointField()), xferCopy(faceList()), xferCopy(labelList()), xferCopy(labelList()), false ); // Add some dummy zones so upon reading it does not read them // from the undecomposed case. Should be done as extra argument to // regIOobject::readStream? List<pointZone*> pz ( 1, new pointZone ( "dummyPointZone", labelList(0), 0, dummyMesh.pointZones() ) ); List<faceZone*> fz ( 1, new faceZone ( "dummyFaceZone", labelList(0), boolList(0), 0, dummyMesh.faceZones() ) ); List<cellZone*> cz ( 1, new cellZone ( "dummyCellZone", labelList(0), 0, dummyMesh.cellZones() ) ); dummyMesh.addZones(pz, fz, cz); //Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() // << endl; dummyMesh.write(); } //Pout<< "Reading mesh from " << io.objectPath() << endl; autoPtr<fvMesh> meshPtr(new fvMesh(io)); fvMesh& mesh = meshPtr(); // Sync patches // ~~~~~~~~~~~~ if (Pstream::master()) { // Send patches for ( int slave=Pstream::firstSlave(); slave<=Pstream::lastSlave(); slave++ ) { OPstream toSlave(Pstream::scheduled, slave); toSlave << mesh.boundaryMesh(); } } else { // Receive patches IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); PtrList<entry> patchEntries(fromMaster); if (haveMesh) { // Check master names against mine const polyBoundaryMesh& patches = mesh.boundaryMesh(); forAll(patchEntries, patchI) { const entry& e = patchEntries[patchI]; const word type(e.dict().lookup("type")); const word& name = e.keyword(); if (type == processorPolyPatch::typeName) { break; } if (patchI >= patches.size()) { FatalErrorIn ( "createMesh(const Time&, const fileName&, const bool)" ) << "Non-processor patches not synchronised." << endl << "Processor " << Pstream::myProcNo() << " has only " << patches.size() << " patches, master has " << patchI << exit(FatalError); } if ( type != patches[patchI].type() || name != patches[patchI].name() ) { FatalErrorIn ( "createMesh(const Time&, const fileName&, const bool)" ) << "Non-processor patches not synchronised." << endl << "Master patch " << patchI << " name:" << type << " type:" << type << endl << "Processor " << Pstream::myProcNo() << " patch " << patchI << " has name:" << patches[patchI].name() << " type:" << patches[patchI].type() << exit(FatalError); } } } else { // Add patch List<polyPatch*> patches(patchEntries.size()); label nPatches = 0; forAll(patchEntries, patchI) { const entry& e = patchEntries[patchI]; const word type(e.dict().lookup("type")); const word& name = e.keyword(); if (type == processorPolyPatch::typeName) { break; } //Pout<< "Adding patch:" << nPatches // << " name:" << name << " type:" << type << endl; dictionary patchDict(e.dict()); patchDict.remove("nFaces"); patchDict.add("nFaces", 0); patchDict.remove("startFace"); patchDict.add("startFace", 0); patches[patchI] = polyPatch::New ( name, patchDict, nPatches++, mesh.boundaryMesh() ).ptr(); } patches.setSize(nPatches); mesh.addFvPatches(patches, false); // no parallel comms //// Write empty mesh now we have correct patches //meshPtr().write(); } }
// Inner slider const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); const polyPatch& innerSlider = boundaryMesh()[innerSliderName]; labelList isf(innerSlider.size()); forAll(isf, i) { isf[i] = innerSlider.start() + i; } fz[0] = new faceZone ( "insideSliderZone", isf, boolList(innerSlider.size(), false), 0, faceZones() ); // Outer slider const word outerSliderName(motionDict_.subDict("slider").lookup("outside")); const polyPatch& outerSlider = boundaryMesh()[outerSliderName]; labelList osf(outerSlider.size()); forAll(osf, i) { osf[i] = outerSlider.start() + i; }
void Foam::sixDofTopoMotion::addZonesAndModifiers() { // Add zones and modifiers for motion action if (useTopoSliding_) { if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 ) { Info<< "void sixDofTopoMotion::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; if (topoChanger_.size() == 0) { FatalErrorIn ( "void sixDofTopoMotion::addZonesAndModifiers()" ) << "Mesh modifiers not read properly" << abort(FatalError); } return; } Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; // Add zones List<pointZone*> pz(3*bodies_.size()); List<faceZone*> fz(3*bodies_.size()); List<cellZone*> cz(0); label npz = 0; label nfz = 0; label nSliders = 0; forAll (bodies_, bodyI) { const floatingBody& curBody = bodies_[bodyI]; if ( curBody.hullSlider().active() && curBody.fixedSlider().active() ) { nSliders++; // Add an empty zone for cut points pz[npz] = new pointZone ( curBody.name() + "CutPointZone", labelList(0), npz, pointZones() ); npz++; // Do face zones for slider // Inner slider const polyPatch& innerSlider = boundaryMesh()[curBody.hullSlider().index()]; labelList isf(innerSlider.size()); forAll (isf, i) { isf[i] = innerSlider.start() + i; } fz[nfz] = new faceZone ( curBody.name() + "InsideSliderZone", isf, boolList(innerSlider.size(), false), nfz, faceZones() ); nfz++; // Outer slider const polyPatch& outerSlider = boundaryMesh()[curBody.fixedSlider().index()]; labelList osf(outerSlider.size()); forAll (osf, i) { osf[i] = outerSlider.start() + i; } fz[nfz] = new faceZone ( curBody.name() + "OutsideSliderZone", osf, boolList(outerSlider.size(), false), nfz, faceZones() ); nfz++; // Add empty zone for cut faces fz[nfz] = new faceZone ( curBody.name() + "CutFaceZone", labelList(0), boolList(0, false), nfz, faceZones() ); nfz++; }