Foam::sampledPatchInternalField::sampledPatchInternalField ( const word& name, const polyMesh& mesh, const dictionary& dict ) : sampledPatch(name, mesh, dict), mappers_(patchIDs().size()) { const scalar distance = readScalar(dict.lookup("distance")); forAll(patchIDs(), i) { label patchI = patchIDs()[i]; mappers_.set ( i, new directMappedPatchBase ( mesh.boundaryMesh()[patchI], mesh.name(), // sampleRegion directMappedPatchBase::NEARESTCELL, // sampleMode word::null, // samplePatch -distance // sample inside my domain ) ); }
void Foam::OutputFilterFunctionObject<OutputFilter>::movePoints ( const polyMesh& mesh ) { if (active() && mesh.name() == regionName_) { ptr_->movePoints(mesh); } }
Foam::labelList Foam::ptscotchDecomp::decompose ( const polyMesh& mesh, const pointField& points, const scalarField& pointWeights ) { if (points.size() != mesh.nCells()) { FatalErrorIn ( "ptscotchDecomp::decompose(const pointField&, const scalarField&)" ) << "Can use this decomposition method only for the whole mesh" << endl << "and supply one coordinate (cellCentre) for every cell." << endl << "The number of coordinates " << points.size() << endl << "The number of cells in the mesh " << mesh.nCells() << exit(FatalError); } // // For running sequential ... // if (Pstream::nProcs() <= 1) // { // return scotchDecomp(decompositionDict_, mesh_) // .decompose(points, pointWeights); // } // Make Metis CSR (Compressed Storage Format) storage // adjncy : contains neighbours (= edges in graph) // xadj(celli) : start of information in adjncy for celli CompactListList<label> cellCells; calcCellCells(mesh, identity(mesh.nCells()), mesh.nCells(), cellCells); // Decompose using default weights List<int> finalDecomp; decomposeZeroDomains ( mesh.time().path()/mesh.name(), cellCells.m(), cellCells.offsets(), pointWeights, finalDecomp ); // Copy back to labelList labelList decomp(finalDecomp.size()); forAll(decomp, i) { decomp[i] = finalDecomp[i]; } return decomp; }
void Foam::meshToMeshNew::writeConnectivity ( const polyMesh& src, const polyMesh& tgt, const labelListList& srcToTargetAddr ) const { Pout<< "Source size = " << src.nCells() << endl; Pout<< "Target size = " << tgt.nCells() << endl; word fName("addressing_" + src.name() + "_to_" + tgt.name()); if (Pstream::parRun()) { fName = fName + "_proc" + Foam::name(Pstream::myProcNo()); } OFstream os(src.time().path()/fName + ".obj"); label vertI = 0; forAll(srcToTargetAddr, i) { const labelList& tgtAddress = srcToTargetAddr[i]; forAll(tgtAddress, j) { label tgtI = tgtAddress[j]; const vector& c0 = src.cellCentres()[i]; const cell& c = tgt.cells()[tgtI]; const pointField pts(c.points(tgt.faces(), tgt.points())); forAll(pts, j) { const point& p = pts[j]; os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl; vertI++; os << "v " << c0.x() << ' ' << c0.y() << ' ' << c0.z() << nl; vertI++; os << "l " << vertI - 1 << ' ' << vertI << nl; } } }
Foam::labelList Foam::ptscotchDecomp::decompose ( const polyMesh& mesh, const labelList& agglom, const pointField& agglomPoints, const scalarField& pointWeights ) { if (agglom.size() != mesh.nCells()) { FatalErrorIn ( "ptscotchDecomp::decompose(const labelList&, const pointField&)" ) << "Size of cell-to-coarse map " << agglom.size() << " differs from number of cells in mesh " << mesh.nCells() << exit(FatalError); } // // For running sequential ... // if (Pstream::nProcs() <= 1) // { // return scotchDecomp(decompositionDict_, mesh) // .decompose(agglom, agglomPoints, pointWeights); // } // Make Metis CSR (Compressed Storage Format) storage // adjncy : contains neighbours (= edges in graph) // xadj(celli) : start of information in adjncy for celli CompactListList<label> cellCells; calcCellCells(mesh, agglom, agglomPoints.size(), cellCells); // Decompose using weights List<int> finalDecomp; decomposeZeroDomains ( mesh.time().path()/mesh.name(), cellCells.m(), cellCells.offsets(), pointWeights, finalDecomp ); // Rework back into decomposition for original mesh labelList fineDistribution(agglom.size()); forAll(fineDistribution, i) { fineDistribution[i] = finalDecomp[agglom[i]]; } return fineDistribution; }
Foam::pointMesh::pointMesh(const polyMesh& pMesh) : MeshObject<polyMesh, Foam::UpdateableMeshObject, pointMesh>(pMesh), GeoMesh<polyMesh>(pMesh), boundary_(*this, pMesh.boundaryMesh()) { if (debug) { Pout<< "pointMesh::pointMesh(const polyMesh&): " << "Constructing from polyMesh " << pMesh.name() << endl; } // Calculate the geometry for the patches (transformation tensors etc.) boundary_.calcGeometry(); }
Foam::label Foam::coupleGroupIdentifier::findOtherPatchID ( const polyMesh& mesh, const polyPatch& thisPatch ) const { const polyBoundaryMesh& pbm = mesh.boundaryMesh(); if (!valid()) { FatalErrorIn ( "coupleGroupIdentifier::findOtherPatchID(const polyPatch&) const" ) << "Invalid coupleGroup patch group" << " on patch " << thisPatch.name() << " in region " << pbm.mesh().name() << exit(FatalError); } HashTable<labelList, word>::const_iterator fnd = pbm.groupPatchIDs().find(name()); if (fnd == pbm.groupPatchIDs().end()) { if (&mesh == &thisPatch.boundaryMesh().mesh()) { // thisPatch should be in patchGroup FatalErrorIn ( "coupleGroupIdentifier::findOtherPatchID" "(const polyMesh&, const polyPatch&) const" ) << "Patch " << thisPatch.name() << " should be in patchGroup " << name() << " in region " << pbm.mesh().name() << exit(FatalError); } return -1; } // Mesh has patch group const labelList& patchIDs = fnd(); if (&mesh == &thisPatch.boundaryMesh().mesh()) { if (patchIDs.size() > 2 || patchIDs.size() == 0) { FatalErrorIn ( "coupleGroupIdentifier::findOtherPatchID" "(const polyMesh&, const polyPatch&) const" ) << "Couple patchGroup " << name() << " with contents " << patchIDs << " not of size < 2" << " on patch " << thisPatch.name() << " region " << thisPatch.boundaryMesh().mesh().name() << exit(FatalError); return -1; } label index = findIndex(patchIDs, thisPatch.index()); if (index == -1) { FatalErrorIn ( "coupleGroupIdentifier::findOtherPatchID" "(const polyMesh&, const polyPatch&) const" ) << "Couple patchGroup " << name() << " with contents " << patchIDs << " does not contain patch " << thisPatch.name() << " in region " << pbm.mesh().name() << exit(FatalError); return -1; } if (patchIDs.size() == 2) { // Return the other patch return patchIDs[1-index]; } else // size == 1 { return -1; } } else { if (patchIDs.size() != 1) { FatalErrorIn ( "coupleGroupIdentifier::findOtherPatchID" "(const polyMesh&, const polyPatch&) const" ) << "Couple patchGroup " << name() << " with contents " << patchIDs << " in region " << mesh.name() << " should only contain a single patch" << " when matching patch " << thisPatch.name() << " in region " << pbm.mesh().name() << exit(FatalError); } return patchIDs[0]; } }
bool Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::interfaceOwner ( const polyMesh& nbrRegion, const polyPatch& nbrPatch ) const { const fvMesh& myRegion = patch().boundaryMesh().mesh(); if (nbrRegion.name() == myRegion.name()) { return patch().index() < nbrPatch.index(); } else { const regionProperties& props = myRegion.objectRegistry::parent().lookupObject<regionProperties> ( "regionProperties" ); label myIndex = findIndex(props.fluidRegionNames(), myRegion.name()); if (myIndex == -1) { label i = findIndex(props.solidRegionNames(), myRegion.name()); if (i == -1) { FatalErrorIn ( "turbulentTemperatureCoupledBaffleFvPatchScalarField" "::interfaceOwner(const polyMesh&" ", const polyPatch&)const" ) << "Cannot find region " << myRegion.name() << " neither in fluids " << props.fluidRegionNames() << " nor in solids " << props.solidRegionNames() << exit(FatalError); } myIndex = props.fluidRegionNames().size() + i; } label nbrIndex = findIndex ( props.fluidRegionNames(), nbrRegion.name() ); if (nbrIndex == -1) { label i = findIndex(props.solidRegionNames(), nbrRegion.name()); if (i == -1) { FatalErrorIn ( "coupleManager::interfaceOwner" "(const polyMesh&, const polyPatch&) const" ) << "Cannot find region " << nbrRegion.name() << " neither in fluids " << props.fluidRegionNames() << " nor in solids " << props.solidRegionNames() << exit(FatalError); } nbrIndex = props.fluidRegionNames().size() + i; } return myIndex < nbrIndex; } }