int main() { int n,m,k,i,j; long long ans=1; scanf("%d%d%d",&n,&m,&k); for (i=1;i<=n;i++) par[i]=i; for (i=1;i<=n-k+1;i++) for (j=1;j<=k/2;j++) par[fnd(i+j-1)]=fnd(i+k-j); for (i=1;i<=n;i++) if (par[i]==i) ans=ans*m%1000000007; printf("%I64d",ans); return 0; }
// Find the new owner of facei (since the original cell has been split into // newCells Foam::label Foam::cellSplitter::newOwner ( const label facei, const Map<labelList>& cellToCells ) const { label oldOwn = mesh_.faceOwner()[facei]; Map<labelList>::const_iterator fnd = cellToCells.find(oldOwn); if (fnd == cellToCells.end()) { // Unsplit cell return oldOwn; } else { // Look up index of face in the cells' faces. const labelList& newCells = fnd(); const cell& cFaces = mesh_.cells()[oldOwn]; return newCells[findIndex(cFaces, facei)]; } }
Foam::label Foam::cellSplitter::newNeighbour ( const label faceI, const Map<labelList>& cellToCells ) const { label oldNbr = mesh_.faceNeighbour()[faceI]; Map<labelList>::const_iterator fnd = cellToCells.find(oldNbr); if (fnd == cellToCells.end()) { // Unsplit cell return oldNbr; } else { // Look up index of face in the cells' faces. const labelList& newCells = fnd(); const cell& cFaces = mesh_.cells()[oldNbr]; return newCells[findIndex(cFaces, faceI)]; } }
Foam::functionObject* Foam::functionObjectList::remove ( const word& key, label& oldIndex ) { functionObject* ptr = 0; // Find index of existing functionObject HashTable<label>::iterator fnd = indices_.find(key); if (fnd != indices_.end()) { oldIndex = fnd(); // retrieve the pointer and remove it from the old list ptr = this->set(oldIndex, 0).ptr(); indices_.erase(fnd); } else { oldIndex = -1; } return ptr; }
void ChatBackend::addMessage(std::wstring name, std::wstring text) { // Note: A message may consist of multiple lines, for example the MOTD. WStrfnd fnd(text); while (!fnd.atend()) { std::wstring line = fnd.next(L"\n"); m_console_buffer.addLine(name, line); m_recent_buffer.addLine(name, line); } }
Foam::label Foam::PrimitivePatch<Face, FaceList, PointField, PointType>:: whichPoint ( const label gp ) const { Map<label>::const_iterator fnd = meshPointMap().find(gp); if (fnd != meshPointMap().end()) { return fnd(); } else { // Not found return -1; } }
bool Foam::HashTable<T, Key, Hash>::operator== ( const HashTable<T, Key, Hash>& rhs ) const { // Sizes (number of keys) must match if (size() != rhs.size()) { return false; } for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { const_iterator fnd = find(iter.key()); if (fnd == cend() || fnd() != iter()) { return false; } } return true; }
void check(F *f) { int caught; // try with whole object caught = 0; try { fnf(f); } catch(A *p) { abort(); } // A is ambiguous catch(F *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnf(f); } catch(A *p) { abort(); } // A is ambiguous catch(E *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnf(f); } catch(A *p) { abort(); } // A is ambiguous catch(D *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnf(f); } catch(A *p) { abort(); } // A is ambiguous catch(B *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnf(f); } catch(A *p) { abort(); } // A is ambiguous catch(C *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); // try with D object caught = 0; try { fnd(f); } catch(A *p) { abort(); } // A is ambiguous catch(D *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd(f); } catch(A *p) { abort(); } // A is ambiguous catch(B *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd(f); } catch(A *p) { abort(); } // A is ambiguous catch(C *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); // try with E object caught = 0; try { fne(f); } catch(A *p) { caught = 1; if (p != (E *)f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(f); } catch(E *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(f); } catch(F *p) { abort(); } catch(...) { caught = 1; } if (!caught) abort(); // try with an A object caught = 0; try { fna((B *)f); } catch(B *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (B *)f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fna((C *)f); } catch(C *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (C *)f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fna((E *)f); } catch(E *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (E *)f) abort();} catch(...) { abort(); } if (!caught) abort(); // try with B object caught = 0; try { fnb((B *)f); } catch(A *p) { caught = 1; if (p != (B *)f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnb((B *)f); } catch(B *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnb((B *)f); } catch(C *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); // try with C object caught = 0; try { fnc((C *)f); } catch(A *p) { caught = 1; if (p != (C *)f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnc((C *)f); } catch(C *p) { caught = 1; if (p != f) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnc((C *)f); } catch(B *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); return; }
bool Foam::fileFormats::TRIsurfaceFormatCore::read ( const fileName& filename ) { this->clear(); sorted_ = true; IFstream is(filename); if (!is.good()) { FatalErrorIn ( "fileFormats::TRIsurfaceFormatCore::read(const fileName&)" ) << "Cannot read file " << filename << exit(FatalError); } // uses similar structure as STL, just some points // the rest of the reader resembles the STL binary reader DynamicList<point> dynPoints; DynamicList<label> dynZones; DynamicList<label> dynSizes; HashTable<label> lookup; // place faces without a group in zone0 label zoneI = 0; dynSizes.append(zoneI); lookup.insert("zoneI", zoneI); while (is.good()) { string line = this->getLineNoComment(is); // handle continuations ? // if (line[line.size()-1] == '\\') // { // line.substr(0, line.size()-1); // line += this->getLineNoComment(is); // } IStringStream lineStream(line); point p ( readScalar(lineStream), readScalar(lineStream), readScalar(lineStream) ); if (!lineStream) break; dynPoints.append(p); dynPoints.append ( point ( readScalar(lineStream), readScalar(lineStream), readScalar(lineStream) ) ); dynPoints.append ( point ( readScalar(lineStream), readScalar(lineStream), readScalar(lineStream) ) ); // zone/colour in .tri file starts with 0x. Skip. // ie, instead of having 0xFF, skip 0 and leave xFF to // get read as a word and name it "zoneFF" char zero; lineStream >> zero; word rawName(lineStream); word name("zone" + rawName(1, rawName.size()-1)); HashTable<label>::const_iterator fnd = lookup.find(name); if (fnd != lookup.end()) { if (zoneI != fnd()) { // group appeared out of order sorted_ = false; } zoneI = fnd(); } else { zoneI = dynSizes.size(); lookup.insert(name, zoneI); dynSizes.append(0); } dynZones.append(zoneI); dynSizes[zoneI]++; } // skip empty groups label nZone = 0; forAll(dynSizes, zoneI) { if (dynSizes[zoneI]) { if (nZone != zoneI) { dynSizes[nZone] = dynSizes[zoneI]; } nZone++; } } // truncate addressed size dynSizes.setCapacity(nZone); // transfer to normal lists points_.transfer(dynPoints); zoneIds_.transfer(dynZones); sizes_.transfer(dynSizes); return true; }
Path::Path(QPointF a, QPointF b, QWorld* w) { Finder fnd(a, b, w, 8); m_points = fnd.path(); }
bool Foam::fileFormats::NASsurfaceFormat<Face>::read ( const fileName& filename ) { const bool mustTriangulate = this->isTri(); this->clear(); IFstream is(filename); if (!is.good()) { FatalErrorIn ( "fileFormats::NASsurfaceFormat::read(const fileName&)" ) << "Cannot read file " << filename << exit(FatalError); } // Nastran index of points DynamicList<label> pointId; DynamicList<point> dynPoints; DynamicList<Face> dynFaces; DynamicList<label> dynZones; DynamicList<label> dynSizes; Map<label> lookup; // assume the types are not intermixed // leave faces that didn't have a group in 0 bool sorted = true; label zoneI = 0; // Name for face group Map<word> nameLookup; // Ansa tags. Denoted by $ANSA_NAME. // These will appear just before the first use of a type. // We read them and store the PSHELL types which are used to name // the zones. label ansaId = -1; word ansaType, ansaName; // A single warning per unrecognized command HashSet<word> unhandledCmd; while (is.good()) { string line; is.getLine(line); // Ansa extension if (line.substr(0, 10) == "$ANSA_NAME") { string::size_type sem0 = line.find (';', 0); string::size_type sem1 = line.find (';', sem0+1); string::size_type sem2 = line.find (';', sem1+1); if ( sem0 != string::npos && sem1 != string::npos && sem2 != string::npos ) { ansaId = readLabel ( IStringStream(line.substr(sem0+1, sem1-sem0-1))() ); ansaType = line.substr(sem1+1, sem2-sem1-1); string rawName; is.getLine(rawName); if (rawName[rawName.size()-1] == '\r') { rawName = rawName.substr(1, rawName.size()-2); } else { rawName = rawName.substr(1, rawName.size()-1); } string::stripInvalid<word>(rawName); ansaName = rawName; // Info<< "ANSA tag for NastranID:" << ansaId // << " of type " << ansaType // << " name " << ansaName << endl; } } // Hypermesh extension // $HMNAME COMP 1"partName" if ( line.substr(0, 12) == "$HMNAME COMP" && line.find ('"') != string::npos ) { label groupId = readLabel ( IStringStream(line.substr(16, 16))() ); IStringStream lineStream(line.substr(32)); string rawName; lineStream >> rawName; string::stripInvalid<word>(rawName); word groupName(rawName); nameLookup.insert(groupId, groupName); // Info<< "group " << groupId << " => " << groupName << endl; } // Skip empty or comment if (line.empty() || line[0] == '$') { continue; } // Check if character 72 is continuation if (line.size() > 72 && line[72] == '+') { line = line.substr(0, 72); while (true) { string buf; is.getLine(buf); if (buf.size() > 72 && buf[72] == '+') { line += buf.substr(8, 64); } else { line += buf.substr(8, buf.size()-8); break; } } } // Read first word IStringStream lineStream(line); word cmd; lineStream >> cmd; if (cmd == "CTRIA3") { triFace fTri; label groupId = readLabel(IStringStream(line.substr(16,8))()); fTri[0] = readLabel(IStringStream(line.substr(24,8))()); fTri[1] = readLabel(IStringStream(line.substr(32,8))()); fTri[2] = readLabel(IStringStream(line.substr(40,8))()); // Convert groupID into zoneId Map<label>::const_iterator fnd = lookup.find(groupId); if (fnd != lookup.end()) { if (zoneI != fnd()) { // pshell types are intermixed sorted = false; } zoneI = fnd(); } else { zoneI = dynSizes.size(); lookup.insert(groupId, zoneI); dynSizes.append(0); // Info<< "zone" << zoneI << " => group " << groupId <<endl; } dynFaces.append(fTri); dynZones.append(zoneI); dynSizes[zoneI]++; } else if (cmd == "CQUAD4") { face fQuad(4); UList<label>& f = static_cast<UList<label>&>(fQuad); label groupId = readLabel(IStringStream(line.substr(16,8))()); fQuad[0] = readLabel(IStringStream(line.substr(24,8))()); fQuad[1] = readLabel(IStringStream(line.substr(32,8))()); fQuad[2] = readLabel(IStringStream(line.substr(40,8))()); fQuad[3] = readLabel(IStringStream(line.substr(48,8))()); // Convert groupID into zoneId Map<label>::const_iterator fnd = lookup.find(groupId); if (fnd != lookup.end()) { if (zoneI != fnd()) { // pshell types are intermixed sorted = false; } zoneI = fnd(); } else { zoneI = dynSizes.size(); lookup.insert(groupId, zoneI); dynSizes.append(0); // Info<< "zone" << zoneI << " => group " << groupId <<endl; } if (mustTriangulate) { dynFaces.append(triFace(f[0], f[1], f[2])); dynFaces.append(triFace(f[0], f[2], f[3])); dynZones.append(zoneI); dynZones.append(zoneI); dynSizes[zoneI] += 2; } else { dynFaces.append(Face(f)); dynZones.append(zoneI); dynSizes[zoneI]++; } } else if (cmd == "GRID") { label index = readLabel(IStringStream(line.substr(8,8))()); scalar x = parseNASCoord(line.substr(24, 8)); scalar y = parseNASCoord(line.substr(32, 8)); scalar z = parseNASCoord(line.substr(40, 8)); pointId.append(index); dynPoints.append(point(x, y, z)); } else if (cmd == "GRID*") { // Long format is on two lines with '*' continuation symbol // on start of second line. // Typical line (spaces compacted) // GRID* 126 0 -5.55999875E+02 -5.68730474E+02 // * 2.14897901E+02 label index = readLabel(IStringStream(line.substr(8,16))()); scalar x = parseNASCoord(line.substr(40, 16)); scalar y = parseNASCoord(line.substr(56, 16)); is.getLine(line); if (line[0] != '*') { FatalErrorIn ( "fileFormats::NASsurfaceFormat::read(const fileName&)" ) << "Expected continuation symbol '*' when reading GRID*" << " (double precision coordinate) format" << nl << "Read:" << line << nl << "File:" << is.name() << " line:" << is.lineNumber() << exit(FatalError); } scalar z = parseNASCoord(line.substr(8, 16)); pointId.append(index); dynPoints.append(point(x, y, z)); } else if (cmd == "PSHELL") { // pshell type for zone names with the Ansa extension label groupId = readLabel(IStringStream(line.substr(8,8))()); if (groupId == ansaId && ansaType == "PSHELL") { nameLookup.insert(ansaId, ansaName); // Info<< "group " << groupId << " => " << ansaName << endl; } } else if (unhandledCmd.insert(cmd)) { Info<< "Unhandled Nastran command " << line << nl << "File:" << is.name() << " line:" << is.lineNumber() << endl; } }
Foam::regionCoupledBaseGAMGInterface::regionCoupledBaseGAMGInterface ( const label index, const lduInterfacePtrsList& coarseInterfaces, const lduInterface& fineInterface, const labelField& localRestrictAddressing, const labelField& neighbourRestrictAddressing, const label fineLevelIndex, const label coarseComm ) : GAMGInterface ( index, coarseInterfaces ), fineRegionCoupledLduInterface_ ( refCast<const regionCoupledLduInterface>(fineInterface) ) { // Construct face agglomeration from cell agglomeration { // From coarse face to cell DynamicList<label> dynFaceCells(localRestrictAddressing.size()); // From face to coarse face DynamicList<label> dynFaceRestrictAddressing ( localRestrictAddressing.size() ); Map<label> masterToCoarseFace(localRestrictAddressing.size()); forAll(localRestrictAddressing, ffi) { label curMaster = localRestrictAddressing[ffi]; Map<label>::const_iterator fnd = masterToCoarseFace.find ( curMaster ); if (fnd == masterToCoarseFace.end()) { // New coarse face label coarseI = dynFaceCells.size(); dynFaceRestrictAddressing.append(coarseI); dynFaceCells.append(curMaster); masterToCoarseFace.insert(curMaster, coarseI); } else { // Already have coarse face dynFaceRestrictAddressing.append(fnd()); } } faceCells_.transfer(dynFaceCells); faceRestrictAddressing_.transfer(dynFaceRestrictAddressing); }
void check(D *d) { int caught; // try with whole object caught = 0; try { fnd(d); } catch(A *p) { abort(); } // A is ambiguous catch(D *p) { caught = 1; if (p != d) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd(d); } catch(A *p) { abort(); } // A is ambiguous catch(B *p) { caught = 1; if (p != d) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd(d); } catch(A *p) { abort(); } // A is ambiguous catch(C *p) { caught = 1; if (p != d) abort();} catch(...) { abort(); } if (!caught) abort(); // try with an A object caught = 0; try { fna((B *)d); } catch(B *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (B *)d) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fna((A *)(C *)d); } catch(C *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (A *)(C *)d) abort();} catch(...) { abort(); } if (!caught) abort(); // try with B object caught = 0; try { fnb((B *)d); } catch(A *p) { caught = 1; if (p != (B *)d) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnb((B *)d); } catch(B *p) { caught = 1; if (p != d) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnb((B *)d); } catch(C *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); caught = 0; try { fnc((C *)d); } catch(A *p) { abort();} catch(C *p) { caught = 1; if (p != d) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnc((C *)d); } catch(B *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); return; }
bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY ( istream& is, const off_t dataFileSize ) { sorted_ = true; // Read the STL header char header[headerSize]; is.read(header, headerSize); // Check that stream is OK, if not this may be an ASCII file if (!is.good()) { FatalErrorIn ( "fileFormats::STLsurfaceFormatCore::readBINARY(IFstream&)" ) << "problem reading header, perhaps file is not binary " << exit(FatalError); } // Read the number of triangles in the STl file // (note: read as int so we can check whether >2^31) int nTris; is.read(reinterpret_cast<char*>(&nTris), sizeof(unsigned int)); // Check that stream is OK and number of triangles is positive, // if not this maybe an ASCII file // // Also compare the file size with that expected from the number of tris // If the comparison is not sensible then it may be an ASCII file if ( !is || nTris < 0 || nTris < (dataFileSize - headerSize)/50 || nTris > (dataFileSize - headerSize)/25 ) { FatalErrorIn ( "fileFormats::STLsurfaceFormatCore::readBINARY(istream&)" ) << "problem reading number of triangles, perhaps file is not binary" << exit(FatalError); } #ifdef DEBUG_STLBINARY Info<< "# " << nTris << " facets" << endl; label prevZone = -1; #endif points_.setSize(3*nTris); zoneIds_.setSize(nTris); Map<label> lookup; DynamicList<label> dynSizes; label ptI = 0; label zoneI = -1; forAll(zoneIds_, faceI) { // Read an STL triangle STLtriangle stlTri(is); // transcribe the vertices of the STL triangle -> points points_[ptI++] = stlTri.a(); points_[ptI++] = stlTri.b(); points_[ptI++] = stlTri.c(); // interprete stl attribute as a zone const label origId = stlTri.attrib(); Map<label>::const_iterator fnd = lookup.find(origId); if (fnd != lookup.end()) { if (zoneI != fnd()) { // group appeared out of order sorted_ = false; } zoneI = fnd(); } else { zoneI = dynSizes.size(); lookup.insert(origId, zoneI); dynSizes.append(0); } zoneIds_[faceI] = zoneI; dynSizes[zoneI]++; #ifdef DEBUG_STLBINARY if (prevZone != zoneI) { if (prevZone != -1) { Info<< "endsolid zone" << prevZone << nl; } prevZone = zoneI; Info<< "solid zone" << prevZone << nl; } Info<< " facet normal " << stlTri.normal() << nl << " outer loop" << nl << " vertex " << stlTri.a() << nl << " vertex " << stlTri.b() << nl << " vertex " << stlTri.c() << nl << " outer loop" << nl << " endfacet" << endl; #endif }
int D<T>::D2::fnd2() { return fnd(); }
void check(E *e) { int caught; // try with whole object caught = 0; try { fne(e); } catch(A *p) { abort(); } // A is ambiguous catch(D *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(e); } catch(A *p) { abort(); } // A is ambiguous catch(B *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(e); } catch(A *p) { abort(); } // A is ambiguous catch(C *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(e); } catch(A *p) { abort(); } // A is ambiguous catch(AA *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); // try with D oject caught = 0; try { fnd((D *)e); } catch(A *p) { abort(); } // A is ambiguous catch(D *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd((D *)e); } catch(A *p) { abort(); } // A is ambiguous catch(B *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd((D *)e); } catch(A *p) { abort(); } // A is ambiguous catch(C *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnd((D *)e); } catch(A *p) { abort(); } // A is ambiguous catch(AA *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); // try with an A object caught = 0; try { fna((B *)e); } catch(B *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (B *)e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fna((C *)e); } catch(C *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (C *)e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fna((AA *)e); } catch(AA *p) { abort(); } // throw type is static type catch(A *p) { caught = 1; if (p != (AA *)e) abort();} catch(...) { abort(); } if (!caught) abort(); // try with B object caught = 0; try { fnb((B *)e); } catch(A *p) { caught = 1; if (p != (B *)e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnb((B *)e); } catch(B *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnb((B *)e); } catch(C *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); // try with C object caught = 0; try { fnc((C *)e); } catch(A *p) { caught = 1; if (p != (C *)e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnc((C *)e); } catch(C *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnc((C *)e); } catch(B *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); // try with AA object caught = 0; try { fnaa((AA *)e); } catch(A *p) { caught = 1; if (p != (AA *)e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnaa((AA *)e); } catch(AA *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fnaa((AA *)e); } catch(C *p) { abort(); } catch(B *p) { abort(); } catch(D *p) { abort(); } catch(...) { caught =1; } if (!caught) abort(); return; }
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]; } }
Foam::processorGAMGInterface::processorGAMGInterface ( const label index, const lduInterfacePtrsList& coarseInterfaces, const lduInterface& fineInterface, const labelField& localRestrictAddressing, const labelField& neighbourRestrictAddressing, const label fineLevelIndex, const label coarseComm ) : GAMGInterface ( index, coarseInterfaces ), comm_(coarseComm), myProcNo_(refCast<const processorLduInterface>(fineInterface).myProcNo()), neighbProcNo_ ( refCast<const processorLduInterface>(fineInterface).neighbProcNo() ), forwardT_(refCast<const processorLduInterface>(fineInterface).forwardT()), tag_(refCast<const processorLduInterface>(fineInterface).tag()) { // From coarse face to coarse cell DynamicList<label> dynFaceCells(localRestrictAddressing.size()); // From fine face to coarse face DynamicList<label> dynFaceRestrictAddressing ( localRestrictAddressing.size() ); // From coarse cell pair to coarse face HashTable<label, labelPair, labelPair::Hash<> > cellsToCoarseFace ( 2*localRestrictAddressing.size() ); forAll(localRestrictAddressing, ffi) { labelPair cellPair; // Do switching on master/slave indexes based on the owner/neighbour of // the processor index such that both sides get the same answer. if (myProcNo() < neighbProcNo()) { // Master side cellPair = labelPair ( localRestrictAddressing[ffi], neighbourRestrictAddressing[ffi] ); } else { // Slave side cellPair = labelPair ( neighbourRestrictAddressing[ffi], localRestrictAddressing[ffi] ); } HashTable<label, labelPair, labelPair::Hash<> >::const_iterator fnd = cellsToCoarseFace.find(cellPair); if (fnd == cellsToCoarseFace.end()) { // New coarse face label coarseI = dynFaceCells.size(); dynFaceRestrictAddressing.append(coarseI); dynFaceCells.append(localRestrictAddressing[ffi]); cellsToCoarseFace.insert(cellPair, coarseI); } else { // Already have coarse face dynFaceRestrictAddressing.append(fnd()); } }
int fnd(int k) { return par[k]==k?k:par[k]=fnd(par[k]); }