//=====================[ assignment to another Pdu object overloaded ]=== Pdu& Pdu::operator=( const Pdu &pdu) { if (this == &pdu) return *this; int z; // looping variable // Initialize all mv's error_status_ = pdu.error_status_; error_index_ = pdu.error_index_; request_id_ = pdu.request_id_; pdu_type_ = pdu.pdu_type_; notify_id_ = pdu.notify_id_; notify_timestamp_ = pdu.notify_timestamp_; notify_enterprise_ = pdu.notify_enterprise_; validity_ = 1; // free up old vbs_ for ( z = 0;z < vb_count_; z++) delete vbs_[z]; vb_count_ = 0; // check for zero case if ( pdu.vb_count_ == 0) { return *this; } // loop through and fill em up for (z = 0; z < pdu.vb_count_; z++) { validity_ = 0; ACE_NEW_RETURN(vbs_[z], Vb ( *(pdu.vbs_[z])), *this); validity_ = 1; } vb_count_ = pdu.vb_count_; return *this; }
void Foam::controlMeshRefinement::initialMeshPopulation ( const autoPtr<backgroundMeshDecomposition>& decomposition ) { if (shapeController_.shapeControlMesh().vertexCount() > 0) { // Mesh already populated. Info<< "Cell size and alignment mesh already populated." << endl; return; } autoPtr<boundBox> overallBoundBox; // Need to pass in the background mesh decomposition so that can test if // a point to insert is on the processor. if (Pstream::parRun()) { // overallBoundBox.set(new boundBox(decomposition().procBounds())); } else { // overallBoundBox.set // ( // new boundBox(geometryToConformTo_.geometry().bounds()) // ); // // mesh_.insertBoundingPoints // ( // overallBoundBox(), // sizeControls_ // ); } Map<label> priorityMap; const PtrList<cellSizeAndAlignmentControl>& controlFunctions = sizeControls_.controlFunctions(); forAll(controlFunctions, fI) { const cellSizeAndAlignmentControl& controlFunction = controlFunctions[fI]; const Switch& forceInsertion = controlFunction.forceInitialPointInsertion(); Info<< "Inserting points from " << controlFunction.name() << " (" << controlFunction.type() << ")" << endl; Info<< " Force insertion is " << forceInsertion.asText() << endl; pointField pts; scalarField sizes; triadField alignments; controlFunction.initialVertices(pts, sizes, alignments); Info<< " Got initial vertices list of size " << pts.size() << endl; List<Vb> vertices(pts.size()); // Clip the minimum size for (label vI = 0; vI < pts.size(); ++vI) { vertices[vI] = Vb(pts[vI], Vb::vtInternalNearBoundary); label maxPriority = -1; scalar size = sizeControls_.cellSize(pts[vI], maxPriority); if (maxPriority > controlFunction.maxPriority()) { vertices[vI].targetCellSize() = max ( size, shapeController_.minimumCellSize() ); } // else if (maxPriority == controlFunction.maxPriority()) // { // vertices[vI].targetCellSize() = max // ( // min(sizes[vI], size), // shapeController_.minimumCellSize() // ); // } else { vertices[vI].targetCellSize() = max ( sizes[vI], shapeController_.minimumCellSize() ); } vertices[vI].alignment() = alignments[vI]; } Info<< " Clipped minimum size" << endl; pts.clear(); sizes.clear(); alignments.clear(); PackedBoolList keepVertex(vertices.size(), true); forAll(vertices, vI) { bool keep = true; pointFromPoint pt = topoint(vertices[vI].point()); if (Pstream::parRun()) { keep = decomposition().positionOnThisProcessor(pt); } if (keep && geometryToConformTo_.wellOutside(pt, SMALL)) { keep = false; } if (!keep) { keepVertex[vI] = false; } } inplaceSubset(keepVertex, vertices); const label preInsertedSize = mesh_.number_of_vertices(); Info<< " Check sizes" << endl; forAll(vertices, vI) { bool insertPoint = false; pointFromPoint pt(topoint(vertices[vI].point())); if ( mesh_.dimension() < 3 || mesh_.is_infinite ( mesh_.locate(vertices[vI].point()) ) ) { insertPoint = true; } const scalar interpolatedCellSize = shapeController_.cellSize(pt); const triad interpolatedAlignment = shapeController_.cellAlignment(pt); const scalar calculatedCellSize = vertices[vI].targetCellSize(); const triad calculatedAlignment = vertices[vI].alignment(); if (debug) { Info<< "Point = " << pt << nl << " Size(interp) = " << interpolatedCellSize << nl << " Size(calc) = " << calculatedCellSize << nl << " Align(interp) = " << interpolatedAlignment << nl << " Align(calc) = " << calculatedAlignment << nl << endl; } const scalar sizeDiff = mag(interpolatedCellSize - calculatedCellSize); const scalar alignmentDiff = diff(interpolatedAlignment, calculatedAlignment); if (debug) { Info<< " size difference = " << sizeDiff << nl << ", alignment difference = " << alignmentDiff << endl; } // @todo Also need to base it on the alignments if ( sizeDiff/interpolatedCellSize > 0.1 || alignmentDiff > 0.15 ) { insertPoint = true; } if (forceInsertion || insertPoint) { const label oldSize = mesh_.vertexCount(); cellShapeControlMesh::Vertex_handle insertedVert = mesh_.insert ( pt, calculatedCellSize, vertices[vI].alignment(), Vb::vtInternalNearBoundary ); if (oldSize == mesh_.vertexCount() - 1) { priorityMap.insert ( insertedVert->index(), controlFunction.maxPriority() ); } } }
void Foam::featurePointConformer::addMasterAndSlavePoints ( const DynamicList<Foam::point>& masterPoints, const DynamicList<Foam::indexedVertexEnum::vertexType>& masterPointsTypes, const Map<DynamicList<autoPtr<plane> > >& masterPointReflections, DynamicList<Vb>& pts, const label ptI ) const { typedef DynamicList<autoPtr<plane> > planeDynList; typedef Foam::indexedVertexEnum::vertexType vertexType; forAll(masterPoints, pI) { // Append master to the list of points const Foam::point& masterPt = masterPoints[pI]; const vertexType masterType = masterPointsTypes[pI]; // Info<< " Master = " << masterPt << endl; pts.append ( Vb ( masterPt, foamyHexMesh_.vertexCount() + pts.size(), masterType, Pstream::myProcNo() ) ); const label masterIndex = pts.last().index(); //meshTools::writeOBJ(strMasters, masterPt); const planeDynList& masterPointPlanes = masterPointReflections[pI]; forAll(masterPointPlanes, planeI) { // Reflect master points in the planes and insert the slave points const plane& reflPlane = masterPointPlanes[planeI](); const Foam::point slavePt = reflPlane.mirror(masterPt); // Info<< " Slave " << planeI << " = " << slavePt << endl; const vertexType slaveType = ( masterType == Vb::vtInternalFeaturePoint ? Vb::vtExternalFeaturePoint // true : Vb::vtInternalFeaturePoint // false ); pts.append ( Vb ( slavePt, foamyHexMesh_.vertexCount() + pts.size(), slaveType, Pstream::myProcNo() ) ); ftPtPairs_.addPointPair ( masterIndex, pts.last().index() ); //meshTools::writeOBJ(strSlaves, slavePt); } } }
void Foam::cellShapeControlMesh::distribute ( const backgroundMeshDecomposition& decomposition ) { DynamicList<Foam::point> points(number_of_vertices()); DynamicList<scalar> sizes(number_of_vertices()); DynamicList<tensor> alignments(number_of_vertices()); DynamicList<Vb> farPts(8); for ( Finite_vertices_iterator vit = finite_vertices_begin(); vit != finite_vertices_end(); ++vit ) { if (vit->real()) { points.append(topoint(vit->point())); sizes.append(vit->targetCellSize()); alignments.append(vit->alignment()); } else if (vit->farPoint()) { farPts.append ( Vb ( vit->point(), -1, Vb::vtFar, Pstream::myProcNo() ) ); farPts.last().targetCellSize() = vit->targetCellSize(); farPts.last().alignment() = vit->alignment(); } } autoPtr<mapDistribute> mapDist = DistributedDelaunayMesh<CellSizeDelaunay>::distribute ( decomposition, points ); mapDist().distribute(sizes); mapDist().distribute(alignments); // Reset the entire tessellation DelaunayMesh<CellSizeDelaunay>::reset(); // Internal points have to be inserted first DynamicList<Vb> verticesToInsert(points.size()); forAll(farPts, ptI) { verticesToInsert.append(farPts[ptI]); }
Foam::DelaunayMesh<Triangulation>::DelaunayMesh ( const Time& runTime, const word& meshName ) : Triangulation(), vertexCount_(0), cellCount_(0), runTime_(runTime) { Info<< "Reading " << meshName << " from " << runTime.timeName() << endl; pointIOField pts ( IOobject ( "points", runTime.timeName(), meshName/polyMesh::meshSubDir, runTime, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ) ); if (pts.headerOk()) { labelIOField types ( IOobject ( "types", runTime.timeName(), meshName, runTime, IOobject::MUST_READ, IOobject::NO_WRITE ) ); // Do not read in indices // labelIOField indices // ( // IOobject // ( // "indices", // runTime.timeName(), // meshName, // runTime, // IOobject::MUST_READ, // IOobject::NO_WRITE // ) // ); labelIOField processorIndices ( IOobject ( "processorIndices", runTime.timeName(), meshName, runTime, IOobject::MUST_READ, IOobject::NO_WRITE ) ); List<Vb> pointsToInsert(pts.size()); forAll(pointsToInsert, pI) { pointsToInsert[pI] = Vb ( toPoint(pts[pI]), pI, static_cast<indexedVertexEnum::vertexType>(types[pI]), processorIndices[pI] ); }