void Foam::verticalValves::setVirtualPositions() { { virtualPistonPosition() = -GREAT; label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces"); bool foundPistonFace = (pistonFaceIndex != -1); if(!foundPistonFace) { FatalErrorIn("Foam::verticalValves::setVirtualPistonPosition()") << " : cannot find the pistonLayerFaces" << exit(FatalError); } const labelList& pistonFaces = faceZones()[pistonFaceIndex]; forAll(pistonFaces, i) { const face& f = faces()[pistonFaces[i]]; // should loop over facepoints... forAll(f, j) { virtualPistonPosition() = max(virtualPistonPosition(), points()[f[j]].z()); } } reduce(virtualPistonPosition(), maxOp<scalar>()); }
void Foam::mixerGgiFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if (cellZones().size() > 0) { Info<< "void mixerGgiFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; return; } Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; // Add zones List<pointZone*> pz(0); List<faceZone*> fz(0); List<cellZone*> cz(1); // Copy the face zones associated with the GGI interfaces if (faceZones().size() > 0) { // Copy face zones Info << "Copying existing face zones" << endl; fz.setSize(faceZones().size()); forAll (faceZones(), i) { fz[i] = faceZones()[i].clone(faceZones()).ptr(); }
forAll(valves_, valveI) { if(valves_[valveI].poppetPatchID().active()) { valveTopPosition_[valveI] = -GREAT; label valveFaceIndex = faceZones().findZoneID("poppetZoneV" + Foam::name(valveI + 1)); bool foundValveFace = (valveFaceIndex != -1); if(!foundValveFace) { FatalErrorIn("Foam::verticalValves::setVirtualPositions()") << " : cannot find the poppetValveFaces" << exit(FatalError); } const labelList& valvePoppetFaces = faceZones()[valveFaceIndex]; forAll(valvePoppetFaces, i) { const face& f = faces()[valvePoppetFaces[i]]; // should loop over facepoints... forAll(f, j) { valveTopPosition_[valveI] = max(valveTopPosition_[valveI], points()[f[j]].z()); } }
// Construct from components Foam::movingConeTopoFvMesh::movingConeTopoFvMesh(const IOobject& io) : topoChangerFvMesh(io), motionDict_ ( IOdictionary ( IOobject ( "dynamicMeshDict", time().constant(), *this, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, false ) ).subDict(typeName + "Coeffs") ), motionVelAmplitude_(motionDict_.lookup("motionVelAmplitude")), motionVelPeriod_(readScalar(motionDict_.lookup("motionVelPeriod"))), curMotionVel_ ( motionVelAmplitude_* Foam::sin(time().value()*M_PI/motionVelPeriod_) ), leftEdge_(readScalar(motionDict_.lookup("leftEdge"))), curLeft_(readScalar(motionDict_.lookup("leftObstacleEdge"))), curRight_(readScalar(motionDict_.lookup("rightObstacleEdge"))) { Pout<< "Initial time:" << time().value() << " Initial curMotionVel_:" << curMotionVel_ << endl; addZonesAndModifiers(); curLeft_ = average ( faceZones() [ faceZones().findZoneID("leftExtrusionFaces") ]().localPoints() ).x() - SMALL; curRight_ = average ( faceZones() [ faceZones().findZoneID("rightExtrusionFaces") ]().localPoints() ).x() + SMALL; motionMask_ = vertexMarkup ( points(), curLeft_, curRight_ ); }
void Foam::linearValveLayersFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 ) { Info<< "void linearValveLayersFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; if (topoChanger_.size() == 0) { FatalErrorIn ( "void linearValveLayersFvMesh::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(1); List<faceZone*> fz(4); List<cellZone*> cz(0); // Add an empty zone for cut points pz[0] = new pointZone ( "cutPointZone", labelList(0), 0, pointZones() ); // Do face zones for slider // Inner slider 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; }
void Foam::twoStrokeEngine::setVirtualPistonPosition() { label pistonFaceIndex = faceZones().findZoneID("pistonLayerFaces"); if(pistonFaceIndex == -1) { FatalErrorIn("Foam::twoStrokeEngine::setVirtualPistonPosition()") << "Cannot find the pistonLayerFaces" << abort(FatalError); } const labelList& pistonPoints = faceZones()[pistonFaceIndex]().meshPoints(); const pointField& p = points(); forAll (pistonPoints, i) { virtualPistonPosition() = Foam::max(virtualPistonPosition_, p[pistonPoints[i]].z()); }
void Foam::linearValveFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if ( pointZones().size() || faceZones().size() || cellZones().size() || topoChanger_.size() ) { Info<< "void linearValveFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; return; } Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; // Add zones List<pointZone*> pz(1); // Add an empty zone for cut points pz[0] = new pointZone ( "cutPointZone", labelList(0), 0, pointZones() ); // Do face zones for slider List<faceZone*> fz(3); // 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; }
void Foam::multiMixerFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 ) { Info<< "void multiMixerFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; if (topoChanger_.size() == 0 && useTopoSliding()) { FatalErrorIn ( "void multiMixerFvMesh::addZonesAndModifiers()" ) << "Mesh modifiers not read properly" << abort(FatalError); } return; } Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh. " << rotors_.size() << " sliders found" << endl; DynamicList<pointZone*> pz(rotors_.size()); DynamicList<faceZone*> fz(3*rotors_.size()); DynamicList<cellZone*> cz(rotors_.size()); // Create region split: mark every cell with its topological region regionSplit rs(*this); Info << "Adding point, face and cell zones" << endl; forAll (rotors_, rotorI) { rotors_[rotorI].addZones(pz, fz, cz, rs); }
void Foam::mixerFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if (cellZones().size() > 0) { Info<< "void mixerFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; // Check definition of the modifier if ( pointZones().size() > 0 || faceZones().size() > 0 ) { if (topoChanger_.size() == 0) { FatalErrorIn ( "void mixerFvMesh::addZonesAndModifiers()" ) << "Mesh modifiers not read properly. " << "pointZones = " << pointZones().size() << " faceZones = " << faceZones().size() << abort(FatalError); } } return; } // Find patches and check sizes // Moving slider const word movingSliderName(dict_.subDict("slider").lookup("moving")); label movingSliderIndex = boundaryMesh().findPatchID(movingSliderName); if (movingSliderIndex < 0) { FatalErrorIn("void mixerFvMesh::addZonesAndModifiers() const") << "Moving slider patch not found in boundary" << abort(FatalError); } const word staticSliderName(dict_.subDict("slider").lookup("static")); label staticSliderIndex = boundaryMesh().findPatchID(staticSliderName); if (staticSliderIndex < 0) { FatalErrorIn("void mixerFvMesh::addZonesAndModifiers() const") << "Static slider patch not found in boundary" << abort(FatalError); } const polyPatch& movingSlider = boundaryMesh()[movingSliderIndex]; const polyPatch& staticSlider = boundaryMesh()[staticSliderIndex]; List<pointZone*> pz; List<faceZone*> fz; bool addSlider = false; if (movingSlider.size() > 0 && staticSlider.size() > 0) { addSlider = true; pz.setSize(1); fz.setSize(3); Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; // Add zones // Add an empty zone for cut points pz[0] = new pointZone ( "cutPointZone", labelList(0), 0, pointZones() ); // Do face zones for slider // Moving slider labelList isf(movingSlider.size()); forAll (isf, i) { isf[i] = movingSlider.start() + i; }
void Foam::movingConeTopoFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if ( pointZones().size() || faceZones().size() || cellZones().size() || topoChanger_.size() ) { Info<< "void movingConeTopoFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; return; } Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; const vectorField& fc = faceCentres(); const vectorField& fa = faceAreas(); labelList zone1(fc.size()); boolList flipZone1(fc.size(), false); label nZoneFaces1 = 0; labelList zone2(fc.size()); boolList flipZone2(fc.size(), false); label nZoneFaces2 = 0; forAll(fc, faceI) { if ( fc[faceI].x() > -0.003501 && fc[faceI].x() < -0.003499 ) { if ((fa[faceI] & vector(1, 0, 0)) < 0) { flipZone1[nZoneFaces1] = true; } zone1[nZoneFaces1] = faceI; Info<< "face " << faceI << " for zone 1. Flip: " << flipZone1[nZoneFaces1] << endl; nZoneFaces1++; } else if ( fc[faceI].x() > -0.00701 && fc[faceI].x() < -0.00699 ) { zone2[nZoneFaces2] = faceI; if ((fa[faceI] & vector(1, 0, 0)) > 0) { flipZone2[nZoneFaces2] = true; } Info<< "face " << faceI << " for zone 2. Flip: " << flipZone2[nZoneFaces2] << endl; nZoneFaces2++; } } zone1.setSize(nZoneFaces1); flipZone1.setSize(nZoneFaces1); zone2.setSize(nZoneFaces2); flipZone2.setSize(nZoneFaces2); Info<< "zone: " << zone1 << endl; Info<< "zone: " << zone2 << endl; List<pointZone*> pz(0); List<faceZone*> fz(2); List<cellZone*> cz(0); label nFz = 0; fz[nFz] = new faceZone ( "rightExtrusionFaces", zone1, flipZone1, nFz, faceZones() ); nFz++; fz[nFz] = new faceZone ( "leftExtrusionFaces", zone2, flipZone2, nFz, faceZones() ); nFz++; fz.setSize(nFz); Info<< "Adding mesh zones." << endl; addZones(pz, fz, cz); // Add layer addition/removal interfaces List<polyMeshModifier*> tm(2); label nMods = 0; tm[nMods] = new layerAdditionRemoval ( "right", nMods, topoChanger_, "rightExtrusionFaces", readScalar ( motionDict_.subDict("right").lookup("minThickness") ), readScalar ( motionDict_.subDict("right").lookup("maxThickness") ) ); nMods++; tm[nMods] = new layerAdditionRemoval ( "left", nMods, topoChanger_, "leftExtrusionFaces", readScalar ( motionDict_.subDict("left").lookup("minThickness") ), readScalar ( motionDict_.subDict("left").lookup("maxThickness") ) ); nMods++; tm.setSize(nMods); Info<< "Adding " << nMods << " mesh modifiers" << endl; topoChanger_.addTopologyModifiers(tm); write(); }
void Foam::layerAR::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston motion if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 ) { Info<< "void layerAR::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; if (topoChanger_.size() == 0) { FatalErrorIn ( "void layerAR::addZonesAndModifiers()" ) << "Mesh modifiers not read properly" << abort(FatalError); } setVirtualPistonPosition(); checkAndCalculate(); return; } checkAndCalculate(); Info<< "Time = " << engTime().theta() << endl << "Adding zones to the engine mesh" << endl; //fz = 1: faces where layer are added/removed //pz = 2: points below the virtual piston faces and head points List<pointZone*> pz(2); List<faceZone*> fz(1); List<cellZone*> cz(0); label nPointZones = 0; label nFaceZones = 0; // Add the piston zone if (piston().patchID().active() && offSet() > SMALL) { // Piston position label pistonPatchID = piston().patchID().index(); scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z(); scalar zPistV = zPist + offSet(); labelList zone1(faceCentres().size()); boolList flipZone1(faceCentres().size(), false); label nZoneFaces1 = 0; bool foundAtLeastOne = false; scalar zHigher = GREAT; scalar dh = GREAT; scalar dl = GREAT; forAll (faceCentres(), faceI) { scalar zc = faceCentres()[faceI].z(); vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]); scalar dd = n & vector(0,0,1); if (dd > 0.1) { if (zPistV - zc > 0 && zPistV - zc < dl) { dl = zPistV - zc; } if (zc - zPistV > 0 && zc - zPistV < dh) { zHigher = zc; dh = zc - zHigher; } if ( zc > zPistV - delta() && zc < zPistV + delta() ) { foundAtLeastOne = true; if ((faceAreas()[faceI] & vector(0,0,1)) < 0) { flipZone1[nZoneFaces1] = true; } zone1[nZoneFaces1] = faceI; nZoneFaces1++; } } }
void Foam::simpleTwoStroke::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston motion if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 ) { Info<< "Time = " << engTime().theta() << endl; Info<< "void simpleTwoStroke::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; if (topoChanger_.size() == 0) { FatalErrorIn ( "void simpleTwoStroke::addZonesAndModifiers()" ) << "Mesh modifiers not read properly" << abort(FatalError); } setVirtualPistonPosition(); checkAndCalculate(); return; } Info << "checkAndCalculate()" << endl; checkAndCalculate(); Info<< "Time = " << engTime().theta() << endl << "Adding zones to the engine mesh" << endl; //fz = 4: virtual piston, outSidePort, insidePort, cutFaceZone //pz = 2: piston points, cutPointZone //cz = 1: moving mask List<pointZone*> pz(3); List<faceZone*> fz(4); List<cellZone*> cz(1); label nPointZones = 0; label nFaceZones = 0; label nCellZones = 0; // Add the piston zone if (piston().patchID().active()) { // Piston position Info << "Adding face zone for piston layer addition/removal" << endl; label pistonPatchID = piston().patchID().index(); scalar zPist = max(boundary()[pistonPatchID].patch().localPoints()).z(); scalar zPistV = zPist + offSet(); labelList zone1(faceCentres().size()); boolList flipZone1(faceCentres().size(), false); label nZoneFaces1 = 0; bool foundAtLeastOne = false; scalar zHigher = GREAT; scalar dh = GREAT; scalar dl = GREAT; forAll (faceCentres(), faceI) { // The points have to be in the cylinder and not in the ports.... scalar zc = faceCentres()[faceI].z(); scalar xc = faceCentres()[faceI].x(); scalar yc = faceCentres()[faceI].y(); vector n = faceAreas()[faceI]/mag(faceAreas()[faceI]); scalar dd = n & vector(0,0,1); if(sqrt(sqr(xc)+sqr(yc)) < 0.5 * engTime().bore().value()) { if (dd > 0.1) { if (zPistV - zc > 0 && zPistV - zc < dl) { dl = zPistV - zc; } if (zc - zPistV > 0 && zc - zPistV < dh) { zHigher = zc; dh = zc - zHigher; } if ( zc > zPistV - delta() && zc < zPistV + delta() ) { foundAtLeastOne = true; if ((faceAreas()[faceI] & vector(0,0,1)) < 0) { flipZone1[nZoneFaces1] = true; } zone1[nZoneFaces1] = faceI; nZoneFaces1++; } } } }
void Foam::movingBodyTopoFvMesh::addZonesAndModifiers() { // Add zones and modifiers for motion action if (topoChanger_.size() > 0) { Info<< "void movingBodyTopoFvMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; return; } // Add layer addition/removal interfaces topoChanger_.setSize(2); label nMods = 0; faceZoneID frontFacesID(frontFacesName_, faceZones()); faceZoneID backFacesID(backFacesName_, faceZones()); if (frontFacesID.active()) { const faceZone& frontFaces = faceZones()[frontFacesID.index()]; if (!frontFaces.empty()) { topoChanger_.set ( nMods, new layerAdditionRemoval ( frontFacesName_ + "Layer", nMods, topoChanger_, frontFacesName_, readScalar ( dict_.subDict("front").lookup("minThickness") ), readScalar ( dict_.subDict("front").lookup("maxThickness") ) ) ); nMods++; } } if (backFacesID.active()) { const faceZone& backFaces = faceZones()[backFacesID.index()]; if (!backFaces.empty()) { topoChanger_.set ( nMods, new layerAdditionRemoval ( backFacesName_ + "Layer", nMods, topoChanger_, backFacesName_, readScalar ( dict_.subDict("back").lookup("minThickness") ), readScalar ( dict_.subDict("back").lookup("maxThickness") ) ) ); nMods++; } } topoChanger_.setSize(nMods); reduce(nMods, sumOp<label>()); Info << "Adding " << nMods << " mesh modifiers" << endl; // Write mesh and modifiers topoChanger_.write(); // No need to write the mesh - only modifiers are added. // HJ, 18/Feb/2011 // write(); }
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++; } }
bool Foam::movingConeTopoFvMesh::update() { // Do mesh changes (use inflation - put new points in topoChangeMap) autoPtr<mapPolyMesh> topoChangeMap = topoChanger_.changeMesh(true); // Calculate the new point positions depending on whether the // topological change has happened or not pointField newPoints; vector curMotionVel_ = motionVelAmplitude_* Foam::sin(time().value()*M_PI/motionVelPeriod_); Pout<< "time:" << time().value() << " curMotionVel_:" << curMotionVel_ << " curLeft:" << curLeft_ << " curRight:" << curRight_ << endl; if (topoChangeMap.valid()) { Info<< "Topology change. Calculating motion points" << endl; if (topoChangeMap().hasMotionPoints()) { Info<< "Topology change. Has premotion points" << endl; //Info<< "preMotionPoints:" << topoChangeMap().preMotionPoints() // << endl; //mkDir(time().timePath()); //{ // OFstream str(time().timePath()/"meshPoints.obj"); // Pout<< "Writing mesh with meshPoints to " << str.name() // << endl; // // const pointField& currentPoints = points(); // label vertI = 0; // forAll(currentPoints, pointI) // { // meshTools::writeOBJ(str, currentPoints[pointI]); // vertI++; // } // forAll(edges(), edgeI) // { // const edge& e = edges()[edgeI]; // str << "l " << e[0]+1 << ' ' << e[1]+1 << nl; // } //} //{ // OFstream str(time().timePath()/"preMotionPoints.obj"); // Pout<< "Writing mesh with preMotionPoints to " << str.name() // << endl; // // const pointField& newPoints = // topoChangeMap().preMotionPoints(); // label vertI = 0; // forAll(newPoints, pointI) // { // meshTools::writeOBJ(str, newPoints[pointI]); // vertI++; // } // forAll(edges(), edgeI) // { // const edge& e = edges()[edgeI]; // str << "l " << e[0]+1 << ' ' << e[1]+1 << nl; // } //} motionMask_ = vertexMarkup ( topoChangeMap().preMotionPoints(), curLeft_, curRight_ ); // Move points inside the motionMask newPoints = topoChangeMap().preMotionPoints() + ( pos(0.5 - mag(motionMask_)) // cells above the body )*curMotionVel_*time().deltaT().value(); } else { Info<< "Topology change. Already set mesh points" << endl; motionMask_ = vertexMarkup ( points(), curLeft_, curRight_ ); // Move points inside the motionMask newPoints = points() + ( pos(0.5 - mag(motionMask_)) // cells above the body )*curMotionVel_*time().deltaT().value(); } } else { Info<< "No topology change" << endl; // Set the mesh motion newPoints = points() + ( pos(0.5 - mag(motionMask_)) // cells above the body )*curMotionVel_*time().deltaT().value(); } // The mesh now contains the cells with zero volume Info << "Executing mesh motion" << endl; movePoints(newPoints); // The mesh now has got non-zero volume cells curLeft_ = average ( faceZones() [ faceZones().findZoneID("leftExtrusionFaces") ]().localPoints() ).x() - SMALL; curRight_ = average ( faceZones() [ faceZones().findZoneID("rightExtrusionFaces") ]().localPoints() ).x() + SMALL; return true; }
void Foam::engineValveSliding::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston motion if ( pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 || topoChanger_.size() > 0 ) { Info<< "Time = " << engTime().theta() << endl; Info<< "void Foam::verticalValvesGambit::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; setVirtualPositions(); // checkAndCalculate(); Info << "Point zones found = " << pointZones().size() << endl; Info << "Face zones found = " << faceZones().size() << endl; Info << "Cell zones found = " << cellZones().size() << endl; return; } Info << "checkAndCalculate()" << endl; Info<< "Time = " << engTime().theta() << endl << "Adding zones to the engine mesh" << endl; /* Point zones 1) Piston points 1) Cut point zone for liner in head nValves* 1) cutPointsV 2) valveTopPoints 3) valveBottomPoints */ DynamicList<pointZone*> pz; /* Face zones 1) Piston layer faces nValves* 1) valveTopLayerFaces 2) valveBottomLayerFaces 3) valveCurtainPort 4) valveCurtainCyl 5) cutFaceV */ DynamicList<faceZone*> fz; /* cell zones 1) moving cells inside piston nValves* 1) moving cells in the top of the valve 2) moving cells in the bottom of the valve */ DynamicList<cellZone*> cz; label nPointZones = 0; label nFaceZones = 0; label nCellZones = 0; /* Adding the following faces zones: 1: pistonLayerFaces nV: pistonLayerFacesV Adding the following cell zones: 1: movingCellsPiston nV: movingCellsPistonV Adding the following point zones: 1: pistonPoints nV: valvePistonPointsV */ # include "addPistonFacesPointZonesEngineValveSliding.H" /* Adding the following face zones: nV: curtainCylZoneV nV: curtainPortZoneV nV: cutFaceZoneV nV: poppetZoneV nV: bottomZoneV Adding the following point zones: nV: cutPointsV */ # include "addValvesFacesPointZonesEngineValveSliding.H" /* Adding the following point zones: nV: valveTopPointsV nV: valveBottomPointsV Adding the following cell zones: nV: movingCellsTopV nV: movingCellsBotV */ # include "addOutputCellsEngineValveSliding.H" Info<< "Adding " << nPointZones << " point, " << nFaceZones << " face zones and " << nCellZones << " cell zones" << endl; pz.setSize(nPointZones); Info << "setSize pz" << endl; fz.setSize(nFaceZones); Info << "setSize fz" << endl; cz.setSize(nCellZones); Info << "setSize cz" << endl; addZones(pz, fz, cz); # include "addMeshModifiersEngineValveSliding.H" // Calculating the virtual positions of piston and valves setVirtualPositions(); Info << " Write mesh " << endl; // Write mesh and modifiers topoChanger_.writeOpt() = IOobject::AUTO_WRITE; write(); Info << " Mesh written " << endl; // Info << "virtualPistonPosition = " << virtualPistonPosition() << endl; // Info << "piston position = " << pistonPosition() << endl; }
void Foam::simpleTwoStroke::calcMovingMasks() const { if (debug) { Info<< "void movingSquaresTM::calcMovingMasks() const : " << "Calculating point and cell masks" << endl; } if (movingPointsMaskPtr_) { FatalErrorIn("void movingSquaresTM::calcMovingMasks() const") << "point mask already calculated" << abort(FatalError); } // Set the point mask movingPointsMaskPtr_ = new scalarField(allPoints().size(), 0); scalarField& movingPointsMask = *movingPointsMaskPtr_; const cellList& c = cells(); const faceList& f = allFaces(); const labelList& cellAddr = cellZones()[cellZones().findZoneID("movingCells")]; forAll (cellAddr, cellI) { const cell& curCell = c[cellAddr[cellI]]; forAll (curCell, faceI) { // Mark all the points as moving const face& curFace = f[curCell[faceI]]; forAll (curFace, pointI) { movingPointsMask[curFace[pointI]] = 1; } } } if(foundScavPorts()) { const word innerScavZoneName ( scavInCylPatchName_ + "Zone" ); const labelList& innerScavAddr = faceZones()[faceZones().findZoneID(innerScavZoneName)]; forAll (innerScavAddr, faceI) { const face& curFace = f[innerScavAddr[faceI]]; forAll (curFace, pointI) { movingPointsMask[curFace[pointI]] = 1; } } const word outerScavZoneName ( scavInPortPatchName_ + "Zone" ); const labelList& outerScavAddr = faceZones()[faceZones().findZoneID(outerScavZoneName)]; forAll (outerScavAddr, faceI) { const face& curFace = f[outerScavAddr[faceI]]; forAll (curFace, pointI) { movingPointsMask[curFace[pointI]] = 0; } } } }
void Foam::linearValveLayersFvMesh::addZonesAndModifiers() { // Inner slider const word innerSliderName(motionDict_.subDict("slider").lookup("inside")); // Outer slider const word outerSliderName ( motionDict_.subDict("slider").lookup("outside") ); bool initialised = false; // Check if zones and modifiers for motion action are present label insideZoneID = faceZones().findZoneID(innerSliderName + "Zone"); label outsideZoneID = faceZones().findZoneID(outerSliderName + "Zone"); if ( insideZoneID > -1 || outsideZoneID > -1 ) { // Zones found. Check topo changer if (topoChanger_.empty()) { FatalErrorIn ( "void linearValveLayersFvMesh::addZonesAndModifiers()" ) << "Mesh modifiers not read properly" << abort(FatalError); } initialised = true; } // Check if slider has been initialised on any of the processors reduce(initialised, orOp<bool>()); if (initialised) { InfoIn("void linearValveLayersFvMesh::addZonesAndModifiers()") << "Zones and modifiers already present. Skipping." << endl; return; } // Add zones and modifiers for motion action Info<< "Time = " << time().timeName() << endl << "Adding zones and modifiers to the mesh" << endl; // Add zones label nPz = 0; label nFz = 0; label nCz = 0; List<pointZone*> pz(pointZones().size() + 1); List<faceZone*> fz(faceZones().size() + 4); List<cellZone*> cz(cellZones().size()); // Add a topology modifier topoChanger_.setSize(2); label nTc = 0; // Copy existing point zones forAll (pointZones(), zoneI) { pz[nPz] = pointZones()[zoneI].clone(pointZones()).ptr(); nPz++; }
// Copy existing face zones forAll (faceZones(), zoneI) { fz[nFz] = faceZones()[zoneI].clone(faceZones()).ptr(); nFz++; }
Foam::tmp<Foam::scalarField> Foam::movingBodyTopoFvMesh::calcMotionMask() const { Info<< "Updating vertex markup" << endl; tmp<scalarField> tvertexMarkup(new scalarField(allPoints().size(), 0)); scalarField& vertexMarkup = tvertexMarkup(); cellZoneID movingCellsID(movingCellsName_, cellZones()); // In order to do a correct update on a mask on processor boundaries, // Detection of moving cells should use patchNeighbourField for // processor (not coupled!) boundaries. This is done by expanding // a moving cell set into a field and making sure that processor patch // points move in sync. Not done at the moment, probably best to do // using parallel update of pointFields. HJ, 19/Feb/2011 // If moving cells are found, perform mark-up if (movingCellsID.active()) { // Get cell-point addressing const labelListList& cp = cellPoints(); // Get labels of all moving cells const labelList& movingCells = cellZones()[movingCellsID.index()]; forAll (movingCells, cellI) { const labelList& curCp = cp[movingCells[cellI]]; forAll (curCp, pointI) { vertexMarkup[curCp[pointI]] = 1; } } } faceZoneID frontFacesID(frontFacesName_, faceZones()); if (frontFacesID.active()) { const faceZone& frontFaces = faceZones()[frontFacesID.index()]; const labelList& mp = frontFaces().meshPoints(); forAll (mp, mpI) { vertexMarkup[mp[mpI]] = 1; } } faceZoneID backFacesID(backFacesName_, faceZones()); if (backFacesID.active()) { const faceZone& backFaces = faceZones()[backFacesID.index()]; const labelList& mp = backFaces().meshPoints(); forAll (mp, mpI) { vertexMarkup[mp[mpI]] = 1; } } return tvertexMarkup; }
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; } fz[1] = new faceZone
void Foam::layerSmooth::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston motion if ( /* pointZones().size() > 0 || faceZones().size() > 0 || cellZones().size() > 0 || topoChanger_.size() > 0 */ pointZones().size() > 0 && faceZones().size() > 0 && topoChanger_.size() > 0 ) { Info<< "Time = " << engTime().theta() << endl; Info<< "void Foam::layerSmooth::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; setVirtualPositions(); checkAndCalculate(); Info << "Point zones found = " << pointZones().size() << endl; Info << "Face zones found = " << faceZones().size() << endl; Info << "Cell zones found = " << cellZones().size() << endl; return; } else { pointZones().setSize(0); faceZones().setSize(0); cellZones().setSize(0); topoChanger_.setSize(0); } if ( engTime().engineDict().found("zOffsetGambit") && engTime().engineDict().found("zDisplGambit") ) { Info << "Assembling the cylinder mesh" << endl; scalar zOffset ( readScalar(engTime().engineDict().lookup("zOffsetGambit")) ); scalar zDispl ( readScalar(engTime().engineDict().lookup("zDisplGambit")) ); const pointField& ap = allPoints(); pointField pDispl = allPoints(); forAll(ap, pointI) { const point p = ap[pointI]; if (p.z() >= zOffset) { pDispl[pointI].z() -= zDispl; } } movePoints(pDispl); write(); resetMotion(); Info << "Cylinder mesh assembled" << endl; }
void Foam::thoboisMesh::addZonesAndModifiers() { // Add the zones and mesh modifiers to operate piston motion if ( pointZones().size() > 0 && faceZones().size() > 0 && topoChanger_.size() > 0 ) { Info<< "Time = " << engTime().theta() << endl; Info<< "void Foam::thoboisMesh::addZonesAndModifiers() : " << "Zones and modifiers already present. Skipping." << endl; setVirtualPositions(); checkAndCalculate(); Info << "Point zones found = " << pointZones().size() << endl; Info << "Face zones found = " << faceZones().size() << endl; Info << "Cell zones found = " << cellZones().size() << endl; return; } else { pointZones().setSize(0); faceZones().setSize(0); cellZones().setSize(0); topoChanger_.setSize(0); } Info << "checkAndCalculate()" << endl; checkAndCalculate(); Info<< "Time = " << engTime().theta() << endl << "Adding zones to the engine mesh" << endl; /* Point zones 1) Piston points */ DynamicList<pointZone*> pz; /* Face zones 1) Piston layer faces */ DynamicList<faceZone*> fz; /* */ DynamicList<cellZone*> cz; label nPointZones = 0; label nFaceZones = 0; label nCellZones = 0; /* Adding the following faces zones: 1: pistonLayerFaces nv: movingFaces nv: staticFaces nv: detachFaces Adding the following point zones: 1: pistonPoints nv: movingValvePoints nv: staticValvePoints */ # include "addPistonFacesPointZonesThoboisMesh.H" //# include "addAttachDetachFacesThoboisMesh.H" Info<< "Adding " << nPointZones << " point, " << nFaceZones << " face zones and " << nCellZones << " cell zones" << endl; # include "addValveFaceZonesThoboisMesh.H" pz.setSize(nPointZones); Info << "setSize pz" << endl; fz.setSize(nFaceZones); Info << "setSize fz" << endl; cz.setSize(nCellZones); Info << "setSize cz" << endl; addZones(pz, fz, cz); # include "addMeshModifiersThoboisMesh.H" // Calculating the virtual positions of piston and valves setVirtualPositions(); // Write mesh and modifiers topoChanger_.writeOpt() = IOobject::AUTO_WRITE; write(); Info << "virtualPistonPosition = " << virtualPistonPosition() << endl; Info << "piston position = " << pistonPosition() << endl; }
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++; }