Exemplo n.º 1
0
BSONObj KeyPattern::extendRangeBound(const BSONObj& bound, bool makeUpperInclusive) const {
    BSONObjBuilder newBound(bound.objsize());

    BSONObjIterator src(bound);
    BSONObjIterator pat(_pattern);

    while (src.more()) {
        massert(16649,
                str::stream() << "keyPattern " << _pattern << " shorter than bound " << bound,
                pat.more());
        BSONElement srcElt = src.next();
        BSONElement patElt = pat.next();
        massert(16634,
                str::stream() << "field names of bound " << bound
                              << " do not match those of keyPattern "
                              << _pattern,
                str::equals(srcElt.fieldName(), patElt.fieldName()));
        newBound.append(srcElt);
    }
    while (pat.more()) {
        BSONElement patElt = pat.next();
        // for non 1/-1 field values, like {a : "hashed"}, treat order as ascending
        int order = patElt.isNumber() ? patElt.numberInt() : 1;
        // flip the order semantics if this is an upper bound
        if (makeUpperInclusive)
            order *= -1;

        if (order > 0) {
            newBound.appendMinKey(patElt.fieldName());
        } else {
            newBound.appendMaxKey(patElt.fieldName());
        }
    }
    return newBound.obj();
}
void shiftFieldGeneralPluginFunction<Type,Order>::doEvaluation()
{
    const fvMesh &origMesh=this->mesh();
    fvMesh shiftMesh(
        IOobject(
            origMesh.name()+"Shifted",
            origMesh.polyMesh::instance(),
            origMesh.polyMesh::db()
        ),
#ifdef FOAM_LIST_HAS_MOVABLE_CONSTRUCT
        pointField(origMesh.points()),
        faceList(origMesh.faces()),
        labelList(origMesh.faceOwner()),
        labelList(origMesh.faceNeighbour())
#else
        Xfer<pointField>(origMesh.points()),
        Xfer<faceList>(origMesh.faces()),
        Xfer<labelList>(origMesh.faceOwner()),
        Xfer<labelList>(origMesh.faceNeighbour())
#endif
    );
    {
        const polyBoundaryMesh &origBound=origMesh.boundaryMesh();
        List<polyPatch*> newBound(origBound.size(),NULL);
        forAll(origBound,patchI) {
            newBound[patchI]=origBound[patchI].clone(shiftMesh.boundaryMesh()).ptr();
        }
        shiftMesh.removeFvBoundary();

#ifdef FOAM_MESHTOMESH_OLD_STYLE
        shiftMesh.addFvPatches(newBound);
#else
        shiftMesh.addPatches(newBound);
#endif

#ifdef FOAM_MESHTOMESH_HAS_CORRECTEDCELLVOLUMEWEIGHT
        shiftMesh.fvSchemes::merge(
            origMesh.schemesDict()
        );

        shiftMesh.fvSchemes::readOpt()=IOobject::READ_IF_PRESENT;
        shiftMesh.fvSchemes::read();

        //        const_cast<dictionary&>(shiftMesh.schemesDict())=origMesh.schemesDict();
        // Info << origMesh.schemesDict() << endl;
        // Info << shiftMesh.schemesDict().name() << endl;
        // Info << shiftMesh.schemesDict() << endl;
        // Info << shiftMesh.gradScheme("valsShift") << endl;
#endif
    }