HomogeneousDOFMap::HomogeneousDOFMap(const Mesh& mesh, const BasisFamily& basis, int numFuncs, int setupVerb) : DOFMapBase(mesh, setupVerb), dim_(mesh.spatialDim()), dofs_(mesh.spatialDim()+1), maximalDofs_(), haveMaximalDofs_(false), localNodePtrs_(mesh.spatialDim()+1), nNodesPerCell_(mesh.spatialDim()+1), totalNNodesPerCell_(mesh.spatialDim()+1, 0), numFacets_(mesh.spatialDim()+1), originalFacetOrientation_(2), basisIsContinuous_(false) { verbosity() = DOFMapBase::classVerbosity(); CellFilter maximalCells = new MaximalCellFilter(); cellSets().append(maximalCells.getCells(mesh)); cellDimOnCellSets().append(mesh.spatialDim()); allocate(mesh, basis, numFuncs); initMap(); }
CellSet connectedNodeSet(const CellFilter& f, const Mesh& mesh) { CellSet cells = f.getCells(mesh); int dim = cells.dimension(); if (dim==0) return cells; Array<int> cellLID; for (CellIterator i=cells.begin(); i!=cells.end(); i++) { cellLID.append(*i); } Array<int> nodes; Array<int> fo; mesh.getFacetLIDs(dim, cellLID, 0, nodes, fo); Set<int> nodeSet; for (int i=0; i<nodes.size(); i++) { nodeSet.put(nodes[i]); } return CellSet(mesh, 0, PointCell, nodeSet); }
bool CellFilter::isSubsetOf(const CellFilter& other, const Mesh& mesh) const { if (isKnownSubsetOf(other)) { return true; } else { CellSet myCells = getCells(mesh); CellSet yourCells = other.getCells(mesh); CellSet inter = myCells.setIntersection(yourCells); if (inter.begin() == inter.end()) return false; CellSet diff = myCells.setDifference(inter); return (diff.begin() == diff.end()); } }
AToCPointLocator::AToCPointLocator(const Mesh& mesh, const CellFilter& subdomain, const std::vector<int>& nx) : dim_(mesh.spatialDim()), mesh_(mesh), nFacets_(mesh.numFacets(dim_, 0, 0)), nx_(nx), low_(nx.size(), 1.0/ScalarTraits<double>::sfmin()), high_(nx.size(), -1.0/ScalarTraits<double>::sfmin()), dx_(nx.size()), table_(), subdomain_(subdomain), neighborSet_() { TimeMonitor timer(pointLocatorCtorTimer()); /* allocate the neighbor set table */ neighborSet_.resize(mesh.numCells(dim_)); /* first pass to find bounding box */ CellSet cells = subdomain.getCells(mesh); for (CellIterator i = cells.begin(); i!= cells.end(); i++) { int cellLID = *i; Array<int> facetLIDs; Array<int> facetOri; mesh.getFacetArray(dim_, cellLID, 0, facetLIDs, facetOri); for (int f=0; f<facetLIDs.size(); f++) { Point x = mesh.nodePosition(facetLIDs[f]); for (int d=0; d<dim_; d++) { if (x[d] < low_[d]) low_[d] = x[d]; if (x[d] > high_[d]) high_[d] = x[d]; } } } /* fudge the bounding box */ for (int d=0; d<dim_; d++) { low_[d] -= 0.01 * (high_[d] - low_[d]); high_[d] += 0.01 * (high_[d] - low_[d]); } /* second pass to put cells in lookup table */ int s = 1; for (int d=0; d<dim_; d++) { dx_[d] = (high_[d] - low_[d])/nx_[d]; s *= nx_[d]; } table_ = rcp(new Array<int>(s, -1)); Array<int> lowIndex; Array<int> highIndex; for (CellIterator i = cells.begin(); i!= cells.end(); i++) { int cellLID = *i; getGridRange(mesh, dim_, cellLID, lowIndex, highIndex); if (dim_==2) { for (int ix=lowIndex[0]; ix<=highIndex[0]; ix++) { for (int iy=lowIndex[1]; iy<=highIndex[1]; iy++) { int index = nx_[1]*ix + iy; (*table_)[index] = cellLID; } } } else { TEST_FOR_EXCEPT(true); } } }
SubmaximalNodalDOFMap ::SubmaximalNodalDOFMap(const Mesh& mesh, const CellFilter& cf, int nFuncs, int setupVerb) : DOFMapBase(mesh, setupVerb), dim_(0), nTotalFuncs_(nFuncs), domain_(cf), domains_(tuple(cf)), nodeLIDs_(), nodeDOFs_(), lidToPtrMap_(), mapStructure_() { Tabs tab0(0); SUNDANCE_MSG1(setupVerb, tab0 << "in SubmaximalNodalDOFMap ctor"); Tabs tab1; SUNDANCE_MSG2(setupVerb, tab1 << "domain " << domain_); SUNDANCE_MSG2(setupVerb, tab1 << "N funcs " << nFuncs); const MPIComm& comm = mesh.comm(); int rank = comm.getRank(); int nProc = comm.getNProc(); dim_ = cf.dimension(mesh); TEUCHOS_TEST_FOR_EXCEPT(dim_ != 0); CellSet nodes = cf.getCells(mesh); int nc = nodes.numCells(); nodeLIDs_.reserve(nc); nodeDOFs_.reserve(nc); Array<Array<int> > remoteNodes(nProc); int nextDOF = 0; int k=0; for (CellIterator c=nodes.begin(); c!=nodes.end(); c++, k++) { int nodeLID = *c; lidToPtrMap_.put(nodeLID, k); nodeLIDs_.append(nodeLID); int remoteOwner = rank; if (isRemote(0, nodeLID, remoteOwner)) { int GID = mesh.mapLIDToGID(0, nodeLID); remoteNodes[remoteOwner].append(GID); for (int f=0; f<nFuncs; f++) nodeDOFs_.append(-1); } else { for (int f=0; f<nFuncs; f++) nodeDOFs_.append(nextDOF++); } } /* Compute offsets for each processor */ int localCount = nextDOF; computeOffsets(localCount); /* Resolve remote DOF numbers */ shareRemoteDOFs(remoteNodes); BasisFamily basis = new Lagrange(1); mapStructure_ = rcp(new MapStructure(nTotalFuncs_, basis.ptr())); }