Exemplo n.º 1
0
Foam::polyLine::polyLine(const pointField& ps, const bool)
:
    points_(ps),
    lineLength_(0.0),
    param_(0)
{
    calcParam();
}
Exemplo n.º 2
0
void VISIBILITY_HIDDEN
findValidSubdimInit(SubDimInfo* sd)
{
    bool n = false;
    do {
        n = false;
        calcParam(sd);
        sd->valid = sd->isValid(sd);
        if (!sd->valid) {
            n = !next(sd->var);
            sd->valid = false;
        }
    } while (n);
}
Exemplo n.º 3
0
bool
nextSubdim(SubDimInfo* sd, int maxParam, double time)
{
    int i;
    int j;
    double minW = -5000;
    int vari = 0;
    double midTime;
    int iCount = 0;
    double maxTime;
    const int MAX_WEIGHT = 99;

    Variant* v0 = sd->curVar;   // Current variant
    Variant* varNext = NULL;    // Next Variant

    if (sd->count >= maxParam) {
        return false;
    }

    if (sd->returnAll) {
        bool ret = nextSubdimElem (sd);
        calcParam(sd);
        sd->curVarID = sd->count;
        return ret;
    }

    v0->time = time;
    sd->sumTime += time;

    midTime = sd->sumTime/(sd->count + 1);

    if (time > 0)  {
        sd->minTime = fmin(sd->minTime, (float)time);
    }

    maxTime = fmax(2.1*midTime - sd->minTime,  sd->minTime*5);

    /* Initialize all groups */
    for (j = 0; j < sd->infoCount; j++ ) {
        GroupStatInfo* si = &sd->info[j];
        si->allTime = 0;
        si->count   = 0;
        si->minTime = 1e9;
    }

    /* Calculate an estimate for the groups */
    for (i = 0; i < sd->varCount; ++i) {
        Variant* vi = &sd->allVariant[i];
        /* If time for variant is measured*/
        if (vi->time > 0) {
            for (j = 0; j < sd->infoCount; j++ ) {
                GroupStatInfo* gsi = &sd->info[j];
                // For each group, if variant is member this group
                if (isMemberOfGroup(gsi, vi)) {
                    gsi->minTime = fmin(gsi->minTime, vi->time);
                    gsi->allTime += fmin(vi->time, maxTime);
                    gsi->count ++;
                    gsi->minTime = calcMinExpectedTimeForGroup(gsi);
                }
           }
        }
        vi->minTime = 0;
        vi->maxTime = 5000;
        vi->weight  = MAX_WEIGHT;
    }

    /*
     * Calculate the estimate run-time variant
     */
    for (i = 0; i < sd->varCount; ++i) {
        Variant* vi = &sd->allVariant[i];

        vi->weight = MAX_WEIGHT;
        if (vi->time == 0) {
            double kgroup = 1.0;

            for (j = 0; j < sd->infoCount; j++ ) {
                GroupStatInfo* gsi = &sd->info[j];
                // if the variant included of the group
                if (isMemberOfGroup(gsi, vi)) {
                    if (gsi->count > 0) {
                        vi->minTime = fmax(vi->minTime, gsi->minTime);
                        vi->weight  = sd->minTime/vi->minTime;
                    }
                    else {
                        /*
                         * If variant don't included of the group
                         * then to reduce estimated time
                         */
                        kgroup *= 1.1;
                    }
                }
            }
            vi->weight *= kgroup;
            vi->minTime /= kgroup;
        }
    }

    /* Find variant with minimal run time */

    for (i = 0; i < sd->varCount; ++i)
    {
        Variant* vi = &sd->allVariant[i];
        if (vi->time == 0 && vi->weight >= 0.01 ) {
            iCount ++;

            if (minW < vi->weight) {
                minW = vi->weight;
                varNext = vi;
                vari = i;
            }
        }
    }

    //
    if (varNext == NULL) {
        return false;
    }

    sd->curVar =  varNext;
    sd->curVarID = vari;
#ifdef TEST_LOG
    printf ("%4d %6.2f [%6.2f:%5.2f ]",iCount, sd->minTime,
            sd->curVar->minTime, sd->curVar->weight);
#endif

    for(j = 0; j < V_COUNT; ++j) {
        sd->var[j].curId = varNext->var[j];
    }

    calcParam(sd);
    sd->count++;
    return true;
}