QString PhysicalBoundaryCondition::getFoamNut(QString version)
{
  QString str;
  QTextStream s(&str, QIODevice::WriteOnly);
  if (m_Type == "symmetry") {
    s << "        type symmetryPlane;\n";
  }
  if (m_Type == "wall") {
    if (version >= "2.1") {
      s << "        type    nutkWallFunction;\n";
      s << "        Cmu     0.09;\n";
      s << "        kappa   0.41;\n";
      s << "        E       9.8;\n";
      s << "        value   uniform 0;\n";
    } else {
      EG_BUG;
    }
  }
  if (m_Type == "slip") {
    s << "        type zeroGradient;\n";
  }
  if (m_Type == "inlet") {
    double k       = 1.5*sqr(getVarValue(0)*getVarValue(1));
    double epsilon = (pow(0.09, 0.75)*pow(k, 1.5))/getVarValue(2);
    double omega   = epsilon/(0.09*k);
    s << "        type  calculated;\n";
    s << "        value uniform 0;\n";
  }
  if (m_Type == "outlet") {
    s << "        type zeroGradient;\n";
  }
  return str;
}
QString PhysicalBoundaryCondition::getFoamK(QString version)
{
  QString str;
  QTextStream s(&str, QIODevice::WriteOnly);
  if (m_Type == "symmetry") {
    s << "        type symmetryPlane;\n";
  }
  if (m_Type == "wall") {
    if (version >= "2.1") {
      s << "        type    kqRWallFunction;\n";
      s << "        value   uniform 0;\n";
    } else {
      s << "        type zeroGradient;\n";
    }
  }
  if (m_Type == "slip") {
    s << "        type zeroGradient;\n";
  }
  if (m_Type == "inlet") {
    double k       = 1.5*sqr(getVarValue(0)*getVarValue(1));
    double epsilon = (pow(0.09, 0.75)*pow(k, 1.5))/getVarValue(2);
    s << "        type  fixedValue;\n";
    s << "        value uniform " << k << ";\n";
  }
  if (m_Type == "outlet") {
    s << "        type zeroGradient;\n";
  }
  return str;
}
예제 #3
0
int
getSessionVarValue( char *action, char *varName, ruleExecInfo_t *rei,
                    char **varValue ) {
    char *varMap;
    int i, vinx;
    Res *res;

    Region *r = make_region( 0, NULL );
    vinx = getVarMap( action, varName, &varMap, 0 );
    while ( vinx >= 0 ) {
        i = getVarValue( varMap, rei, &res, r );
        if ( i >= 0 ) {
            free( varMap );
            *varValue = convertResToString( res );
            region_free( r );
            return( i );
        }
        else if ( i == NULL_VALUE_ERR ) {
            free( varMap );
            vinx = getVarMap( action, varName, &varMap, vinx + 1 );
        }
        else {
            free( varMap );
            region_free( r );
            return( i );
        }
    }
    region_free( r );
    if ( vinx < 0 ) {
        return( vinx );
    }
    return( i );
}
예제 #4
0
int
getSessionVarValue (char *action, char *varName, ruleExecInfo_t *rei,
char **varValue)
{
  char *varMap;
  int i, vinx;

  vinx = getVarMap (action,varName, &varMap, 0);
  while (vinx >= 0) {
    i = getVarValue (varMap, rei, varValue);
    if (i >= 0) {
      free(varMap);
      return(i);
    } else if (i == NULL_VALUE_ERR) {
      free(varMap);
      vinx = getVarMap (action,varName, &varMap, vinx+1);
    } else {
      free(varMap);
      return(i);
    }
  }
  if (vinx < 0) {
    return(vinx);
  }
  return(i);
}
예제 #5
0
	virtual bool findNext(unsigned int varIndex, unsigned int value=0) {
		while(findNext()) {
			if(getVarValue(varIndex)==value) {
				return true;
			}
		}
		return false;
	}
예제 #6
0
	virtual bool findNext(const char *varName, unsigned int value=0) {
		while(findNext()) {
			if(getVarValue(varName)==value) {
				return true;
			}
		}
		return false;
	}
QString PhysicalBoundaryCondition::getFoamU(QString, vec3_t n)
{
  QString str;
  QTextStream s(&str, QIODevice::WriteOnly);
  if (m_Type == "symmetry") {
    s << "        type symmetryPlane;\n";
  }
  if (m_Type == "wall") {
    s << "        type  fixedValue;\n";
    s << "        value uniform (0 0 0);\n";
  }
  if (m_Type == "slip") {
    s << "        type slip;\n";
  }
  if (m_Type == "inlet") {
    s << "        type  fixedValue;\n";
    s << "        value uniform (" << getVarValue(0)*n[0] << " " << getVarValue(0)*n[1] << " " << getVarValue(0)*n[2] << ");\n";
  }
  if (m_Type == "outlet") {
    s << "        type zeroGradient;\n";
  }
  return str;
}
예제 #8
0
int ComboWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = CmdWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: { QString _r = text();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 1: setText((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: updateCombo(); break;
        case 3: updateComboVariableSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: updateComboVariableSafet(); break;
        case 5: updateComboAutofilterSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: updateComboAutofilterSafet(); break;
        case 7: updateComboRecursivefilterSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: updateComboRecursivefilterSafet(); break;
        case 9: updateComboListTable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 10: updateComboListTable(); break;
        case 11: updateComboListLiteral(); break;
        case 12: updateVarGlobal((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 13: updateComboFlow((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: updateComboFlow(); break;
        case 15: updateComboConffileSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 16: updateComboConffileSafet(); break;
        case 17: updateComboColorSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 18: updateComboColorSafet(); break;
        case 19: viewdoc(); break;
        case 20: selColor(); break;
        case 21: insertAndClose(); break;
        case 22: { QString _r = getRealValue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 23: { QString _r = getVarValue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 24: itemsValueList(); break;
        case 25: itemsRealValueList(); break;
        case 26: { QComboBox* _r = combo();
            if (_a[0]) *reinterpret_cast< QComboBox**>(_a[0]) = _r; }  break;
        case 27: { QString _r = findkeyvalue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        }
        _id -= 28;
    }
    return _id;
}
예제 #9
0
const IR::Node* DoBindTypeVariables::postorder(IR::MethodCallExpression* expression) {
    if (!expression->typeArguments->empty())
        return expression;
    auto type = typeMap->getType(expression->method, true);
    BUG_CHECK(type->is<IR::IMayBeGenericType>(), "%1%: unexpected type %2% for method",
              expression->method, type);
    auto mt = type->to<IR::IMayBeGenericType>();
    if (mt->getTypeParameters()->empty())
        return expression;
    auto typeArgs = new IR::Vector<IR::Type>();
    for (auto p : mt->getTypeParameters()->parameters) {
        auto type = getVarValue(p, expression);
        if (type == nullptr)
            return expression;
        typeArgs->push_back(type);
    }
    expression->typeArguments = typeArgs;
    return expression;
}
예제 #10
0
const IR::Node* DoBindTypeVariables::postorder(IR::Declaration_Instance* decl) {
    if (decl->type->is<IR::Type_Specialized>())
        return decl;
    auto type = typeMap->getType(getOriginal(), true);
    BUG_CHECK(type->is<IR::IMayBeGenericType>(), "%1%: unexpected type %2% for declaration",
              decl, type);
    auto mt = type->to<IR::IMayBeGenericType>();
    if (mt->getTypeParameters()->empty())
        return decl;
    auto typeArgs = new IR::Vector<IR::Type>();
    for (auto p : mt->getTypeParameters()->parameters) {
        auto type = getVarValue(p, decl);
        if (type == nullptr)
            return decl;
        typeArgs->push_back(type);
    }
    decl->type = new IR::Type_Specialized(
        decl->type->srcInfo, decl->type->to<IR::Type_Name>(), typeArgs);
    return decl;
}
예제 #11
0
const IR::Node* DoBindTypeVariables::postorder(IR::ConstructorCallExpression* expression) {
    if (expression->constructedType->is<IR::Type_Specialized>())
        return expression;
    auto type = typeMap->getType(getOriginal(), true);
    BUG_CHECK(type->is<IR::IMayBeGenericType>(), "%1%: unexpected type %2% for expression",
              expression, type);
    auto mt = type->to<IR::IMayBeGenericType>();
    if (mt->getTypeParameters()->empty())
        return expression;
    auto typeArgs = new IR::Vector<IR::Type>();
    for (auto p : mt->getTypeParameters()->parameters) {
        auto type = getVarValue(p, expression);
        if (type == nullptr)
            return expression;
        typeArgs->push_back(type);
    }
    expression->constructedType = new IR::Type_Specialized(
        expression->constructedType->srcInfo,
        expression->constructedType->to<IR::Type_Name>(), typeArgs);
    return expression;
}
예제 #12
0
QString PhysicalBoundaryCondition::getFoamT(QString version)
{
  QString str;
  QTextStream s(&str, QIODevice::WriteOnly);
  if (m_Type == "symmetry") {
    s << "        type symmetryPlane;\n";
  }
  if (m_Type == "wall") {
    s << "        type zeroGradient;\n";
  }
  if (m_Type == "slip") {
    s << "        type zeroGradient;\n";
  }
  if (m_Type == "inlet") {
    s << "        type  fixedValue;\n";
    s << "        value uniform " << getVarValue(3) << ";\n";
  }
  if (m_Type == "outlet") {
    s << "        type zeroGradient;\n";
  }
  return str;
}
예제 #13
0
int
getSessionVarValue( char *action, char *varName, ruleExecInfo_t *rei,
                    char **varValue ) {
    Region *r = make_region( 0, NULL );
    char *varMap;
    int vinx = getVarMap( action, varName, &varMap, 0 );
    while ( vinx >= 0 ) {
        Res *res;
        int i = getVarValue( varMap, rei, &res, r );
        free( varMap );
        if ( i != NULL_VALUE_ERR ) {
            if ( i >= 0 ) {
                *varValue = convertResToString( res );
            }
            region_free( r );
            return i;
        }
        vinx = getVarMap( action, varName, &varMap, vinx + 1 );
    }
    free( varMap );
    region_free( r );
    return vinx;
}
예제 #14
0
int
OPTrecyclerImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
	int i, j, cnt, tp, c, actions = 0, marks = 0, delta = 0;
	Lifespan span;
	InstrPtr *old, q;
	int limit, updstmt = 0;
	char *recycled;
	short app_sc = -1, in = 0;
	ValRecord cst;

	(void) cntxt;
	(void) stk;

	limit = mb->stop;
	old = mb->stmt;

	for (i = 1; i < limit; i++) {
		p = old[i];
		if (getModuleId(p) == sqlRef &&
				(getFunctionId(p) == affectedRowsRef ||
				 getFunctionId(p) == exportOperationRef ||
				 getFunctionId(p) == appendRef ||
				 getFunctionId(p) == updateRef ||
				 getFunctionId(p) == deleteRef))
			updstmt = 1;
	}

	span = setLifespan(mb);
	if (span == NULL)
		return 0;

	/* watch out, newly created instructions may introduce new variables */
	recycled = GDKzalloc(sizeof(char) * mb->vtop * 2);
	if (recycled == NULL)
		return 0;
	if (newMalBlkStmt(mb, mb->ssize) < 0) {
		GDKfree(recycled);
		return 0;
	}
	pushInstruction(mb, old[0]);
	mb->recid = recycleSeq++;

	/* create a handle for recycler */
	(void) newFcnCall(mb, "recycle", "prelude");
	in = 1;
	for (i = 1; i < limit; i++) {
		p = old[i];
		if (hasSideEffects(p, TRUE) || isUpdateInstruction(p) || isUnsafeFunction(p)) {
			if (getModuleId(p) == recycleRef) { /*don't inline recycle instr. */
				freeInstruction(p);
				continue;
			}
			pushInstruction(mb, p);
			/*  update instructions are not recycled but monitored*/
			if (isUpdateInstruction(p)) {
				if (getModuleId(p) == batRef &&
					(getArgType(mb, p, 1) == TYPE_bat
					 || isaBatType(getArgType(mb, p, 1)))) {
					recycled[getArg(p, 1)] = 0;
					q = newFcnCall(mb, "recycle", "reset");
					pushArgument(mb, q, getArg(p, 1));
					actions++;
				}
				if (getModuleId(p) == sqlRef) {
					if (getFunctionId(p) == appendRef) {
						if (app_sc >= 0)
							continue;
						else
							app_sc = getArg(p, 2);
					}
					VALset(&cst, TYPE_int, &delta);
					c = defConstant(mb, TYPE_int, &cst);
					q = newFcnCall(mb, "recycle", "reset");
					pushArgument(mb, q, c);
					pushArgument(mb, q, getArg(p, 2));
					pushArgument(mb, q, getArg(p, 3));
					if (getFunctionId(p) == updateRef)
						pushArgument(mb, q, getArg(p, 4));
					actions++;
				}
			}
			/* take care of SQL catalog update instructions */
			if (getModuleId(p) == sqlRef && getFunctionId(p) == catalogRef) {
				tp = *(int *) getVarValue(mb, getArg(p, 1));
				if (tp == 22 || tp == 25) {
					delta = 2;
					VALset(&cst, TYPE_int, &delta);
					c = defConstant(mb, TYPE_int, &cst);
					q = newFcnCall(mb, "recycle", "reset");
					pushArgument(mb, q, c);
					pushArgument(mb, q, getArg(p, 2));
					if (tp == 25)
						pushArgument(mb, q, getArg(p, 3));
					actions++;
				}
			}
			continue;
		}
		if (p->token == ENDsymbol || p->barrier == RETURNsymbol) {
			if (in) {
				/*
				if (updstmt && app_sc >= 0) {
					q = newFcnCall(mb, "recycle", "reset");
					pushArgument(mb, q, app_sc);
					pushArgument(mb, q, app_tbl);
				}
				 */
				(void) newFcnCall(mb, "recycle", "epilogue");
				in = 0;
			}
			pushInstruction(mb, p);
			continue;
		}

		if (p->barrier && p->token != CMDcall) {
			/* never save a barrier unless it is a command and side-effect free */
			pushInstruction(mb, p);
			continue;
		}

		/* don't change instructions in update statements */
		if (updstmt) {
			pushInstruction(mb, p);
			continue;
		}

		/* skip simple assignments */
		if (p->token == ASSIGNsymbol) {
			pushInstruction(mb, p);
			continue;
		}

		if (getModuleId(p) == octopusRef &&
			(getFunctionId(p) == bindRef || getFunctionId(p) == bindidxRef)) {
			recycled[getArg(p, 0)] = 1;
			p->recycle = recycleMaxInterest;
			marks++;
		}
		/* During base table recycling skip marking instructions other than octopus.bind */
		if (baseTableMode) {
			pushInstruction(mb, p);
			continue;
		}

		/* general rule: all arguments are constants or recycled,
		   ignore C pointer arguments from mvc */
		cnt = 0;
		for (j = p->retc; j < p->argc; j++)
			if (recycled[getArg(p, j)] || isVarConstant(mb, getArg(p, j))
					|| ignoreVar(mb, getArg(p, j)))
				cnt++;
		if (cnt == p->argc - p->retc) {
			OPTDEBUGrecycle {
				mnstr_printf(cntxt->fdout, "#recycle instruction\n");
				printInstruction(cntxt->fdout, mb, 0, p, LIST_MAL_ALL);
			}
			marks++;
			p->recycle = recycleMaxInterest; /* this instruction is to be monitored */
			for (j = 0; j < p->retc; j++)
				if (getLastUpdate(span, getArg(p, j)) == i)
					recycled[getArg(p, j)] = 1;
		}
		/*
		 * The expected gain is largest if we can re-use selections
		 * on the base tables in SQL. These, however, are marked as
		 * uselect() calls, which only produce the oid head.
		 * For cheap types we preselect using select() and re-map uselect() back
		 * over this temporary.
		 * For the time being for all possible selects encountered
		 * are marked for re-use.
		 */
		/* take care of semantic driven recyling */
		/* for selections check the bat argument only
		   the range is often template parameter*/
		if ((getFunctionId(p) == selectRef ||
					getFunctionId(p) == antiuselectRef ||
					getFunctionId(p) == likeselectRef ||
					getFunctionId(p) == likeRef ||
					getFunctionId(p) == thetaselectRef) &&
				recycled[getArg(p, 1)])
		{
			p->recycle = recycleMaxInterest;
			marks++;
			if (getLastUpdate(span, getArg(p, 0)) == i)
				recycled[getArg(p, 0)] = 1;
		}
		if ((getFunctionId(p) == uselectRef || getFunctionId(p) == thetauselectRef)
				&& recycled[getArg(p, 1)])
		{
			if (!ATOMvarsized(getGDKType(getArgType(mb, p, 2)))) {
				q = copyInstruction(p);
				getArg(q, 0) = newTmpVariable(mb, TYPE_any);
				if (getFunctionId(p) == uselectRef)
					setFunctionId(q, selectRef);
				else
					setFunctionId(q, thetaselectRef);
				q->recycle = recycleMaxInterest;
				marks++;
				recycled[getArg(q, 0)] = 1;
				pushInstruction(mb, q);
				getArg(p, 1) = getArg(q, 0);
				setFunctionId(p, projectRef);
				p->argc = 2;
			}
			p->recycle = recycleMaxInterest;
			marks++;
			if (getLastUpdate(span, getArg(p, 0)) == i)
				recycled[getArg(p, 0)] = 1;
		}

		if (getModuleId(p) == pcreRef) {
			if ((getFunctionId(p) == selectRef && recycled[getArg(p, 2)]) ||
				(getFunctionId(p) == uselectRef && recycled[getArg(p, 2)])) {
				p->recycle = recycleMaxInterest;
				marks++;
				if (getLastUpdate(span, getArg(p, 0)) == i)
					recycled[getArg(p, 0)] = 1;
			} else if (getFunctionId(p) == likeuselectRef && recycled[getArg(p, 1)]) {
				q = copyInstruction(p);
				getArg(q, 0) = newTmpVariable(mb, TYPE_any);
				setFunctionId(q, likeselectRef);
				q->recycle = recycleMaxInterest;
				recycled[getArg(q, 0)] = 1;
				pushInstruction(mb, q);
				getArg(p, 1) = getArg(q, 0);
				setFunctionId(p, projectRef);
				setModuleId(p, algebraRef);
				p->argc = 2;
				p->recycle = recycleMaxInterest;
				marks += 2;
				if (getLastUpdate(span, getArg(p, 0)) == i)
					recycled[getArg(p, 0)] = 1;
			}
		}

		/*
		 * The sql.bind instructions should be handled carefully
		 * The delete and update BATs should not be recycled,
		 * because they may lead to view dependencies that later interferes
		 * with the transaction commits.
		 */
		/* enable recycling of delta-bats
		if (getModuleId(p) == sqlRef &&
				(((getFunctionId(p) == bindRef || getFunctionId(p) == putName("bind_idxbat", 11)) &&
				  getVarConstant(mb, getArg(p, 5)).val.ival != 0) ||
				 getFunctionId(p) == binddbatRef)) {
			recycled[getArg(p, 0)] = 0;
			p->recycle = REC_NO_INTEREST;
		}
		*/

/*
 * The sql.bind instructions should be handled carefully
 * The delete and update BATs should not be recycled,
 * because they may lead to view dependencies that later interferes
 * with the transaction commits.
 */
/* enable recycling of delta-bats
		if (getModuleId(p)== sqlRef && 
			(((getFunctionId(p)==bindRef || getFunctionId(p) == putName("bind_idxbat",11)) && 
				getVarConstant(mb, getArg(p,5)).val.ival != 0) ||
				getFunctionId(p)== binddbatRef) ) {
				recycled[getArg(p,0)]=0;
				p->recycle = REC_NO_INTEREST; 
			}
*/

		pushInstruction(mb, p);
	}
예제 #15
0
    unsigned int getVarValue(const char *varName) {
	return getVarValue(getVarIndex(varName));
    }