⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getdp.y

📁 cfd求解器使用与gmsh网格的求解
💻 Y
📖 第 1 页 / 共 5 页
字号:
Comma : /* none */ | ',' ;DefineDimension :    '{' '#' FExpr '}'    { $$ = (int)$3 ; }  ;MultipleIndex :    /* none */ { Flag_MultipleIndex = 0 ; }  | '{' '}'    { Flag_MultipleIndex = 1 ; }  ;Index :    '{' FExpr '}'    { $$ = (int)$2 ; }  ;/* ------------------------------------------------------------------------ *//*  F u n c t i o n                                                         *//* ------------------------------------------------------------------------ */Functions :    /* none */  | Functions Function  ;Function :    tDefineFunction '[' DefineFunctions ']' tEND   | tSTRING '[' ']' tDEF Expression tEND    {      if ( (i = List_ISearchSeq	    (Problem_S.Expression, $1, fcmp_Expression_Name)) >= 0 ) {	if (((struct Expression *)List_Pointer(Problem_S.Expression, i))->Type ==	    UNDEFINED_EXP) {	  Free(((struct Expression *)List_Pointer(Problem_S.Expression, i))->Name) ;	  List_Read (Problem_S.Expression, $5, &Expression_S) ;	  List_Write(Problem_S.Expression,  i, &Expression_S) ;	  ((struct Expression *)List_Pointer(Problem_S.Expression, i))->Name = $1 ;	  List_Pop(Problem_S.Expression) ;	}	else  { vyyerror("Redefinition of Function: %s", $1) ; }      }      else {  /* new identifier */	Free(((struct Expression *)List_Pointer(Problem_S.Expression, $5))->Name) ;	((struct Expression *)List_Pointer(Problem_S.Expression, $5))->Name = $1 ;      }    }  | tSTRING '[' GroupRHS ']' tDEF Expression tEND    {      if ( (i = List_ISearchSeq	    (Problem_S.Expression, $1, fcmp_Expression_Name)) < 0 ) {	/* Si le nom n'existe pas : */	i = List_Nbr(Problem_S.Expression) ;	Expression_S.Type = PIECEWISEFUNCTION ;	Expression_S.Case.PieceWiseFunction.ExpressionPerRegion =	  List_Create( 5, 5, sizeof(struct ExpressionPerRegion)) ;	Expression_S.Case.PieceWiseFunction.NumLastRegion = -1 ;	Add_Expression(&Expression_S, $1, 0) ;	Expression_P = (struct Expression*)List_Pointer(Problem_S.Expression, i) ;      }      else {	Expression_P = (struct Expression*)List_Pointer(Problem_S.Expression, i) ;	if (Expression_P->Type == UNDEFINED_EXP) {	  Expression_P->Type = PIECEWISEFUNCTION ;	  Expression_P->Case.PieceWiseFunction.ExpressionPerRegion =	    List_Create( 5, 5, sizeof(struct ExpressionPerRegion)) ;	  Expression_P->Case.PieceWiseFunction.NumLastRegion = -1 ;	}	else if (Expression_P->Type != PIECEWISEFUNCTION)	  vyyerror("Not piece-wise Expression: %s", $1) ;	Free($1) ;      }      if ($3 >= 0 || $3 == -1) {	ExpressionPerRegion_S.ExpressionIndex = $6 ;	for (i = 0 ; i < List_Nbr(Group_S.InitialList) ; i++) {	  List_Read(Group_S.InitialList, i, &ExpressionPerRegion_S.RegionIndex) ;	  if (List_Search(Expression_P->Case.PieceWiseFunction.ExpressionPerRegion,			  &ExpressionPerRegion_S.RegionIndex, fcmp_int))	    vyyerror("Redefinition of piece-wise Function: %s [%d]",		     Expression_P->Name, ExpressionPerRegion_S.RegionIndex) ;	  else	    List_Add(Expression_P->Case.PieceWiseFunction.ExpressionPerRegion,		     &ExpressionPerRegion_S) ;	}	if ($3 == -1) { List_Delete(Group_S.InitialList) ; }      }      else  vyyerror("Bad Group right hand side") ;    }  | Affectation  | Loop  ;DefineFunctions :    /* none */  | DefineFunctions Comma tSTRING    {      if ( (i = List_ISearchSeq	    (Problem_S.Expression, $3, fcmp_Expression_Name)) < 0 ) {	Expression_S.Type = UNDEFINED_EXP ;	Add_Expression(&Expression_S, $3, 0) ;      }      else  Free($3) ;    }  ;/* ------------------------------------------------------------------------     E x p r e s s i o n s                                                      ------------------------------------------------------------------------ */Expression :  /* expressions constantes: evaluees lors de l'analyse syntaxique */    tConstant '[' FExpr ']'    { Expression_S.Type = CONSTANT ;  Expression_S.Case.Constant = $3 ;      $$ = Add_Expression(&Expression_S, "Exp_Cst", 1) ;    }  /* reutilisation de fonctions deja definies en amont */  | tFunction '[' tSTRING ']'    { if((i = List_ISearchSeq(Problem_S.Expression, $3, fcmp_Expression_Name)) < 0)	vyyerror("Unknown name of Expression: %s", $3) ;      Free($3) ;  $$ = i ;    }  /* whole quantity */  | { Current_DofIndexInWholeQuantity = -2 ;        List_Reset(ListOfPointer_L) ; List_Reset(ListOfPointer2_L) ; }    WholeQuantityExpression    { Expression_S.Type = WHOLEQUANTITY ;  Expression_S.Case.WholeQuantity = $2 ;      $$ = Add_Expression(&Expression_S, "Exp_Fct", 1) ; }  ;ListOfExpression :    /* none */  { List_Reset(ListOfInt_L) ; }  /* shift/reduce   | Expression  { List_Reset(ListOfInt_L) ;  List_Add(ListOfInt_L, &($1)) ; }  */  | '{' RecursiveListOfExpression '}'  ;RecursiveListOfExpression :    Expression    { List_Reset(ListOfInt_L) ;  List_Add(ListOfInt_L, &($1)) ; }  | RecursiveListOfExpression ',' Expression    { List_Add(ListOfInt_L, &($3)) ; }  ;WholeQuantityExpression :    { Current_WholeQuantity_L = List_Create( 5, 5, sizeof(struct WholeQuantity)) ;      List_Add(ListOfPointer_L, &Current_WholeQuantity_L) ;    }    WholeQuantity    { $$ = *((List_T **)List_Pointer(ListOfPointer_L, List_Nbr(ListOfPointer_L)-1)) ;      List_Pop(ListOfPointer_L) ;    }  ;WholeQuantity :    WholeQuantity_Single  |  WholeQuantity '?'     {      WholeQuantity_S.Type = WQ_TEST ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;      WholeQuantity_P = (struct WholeQuantity*)	List_Pointer(Current_WholeQuantity_L, List_Nbr(Current_WholeQuantity_L)-1);      List_Add(ListOfPointer2_L, &WholeQuantity_P);      List_Add(ListOfPointer2_L, &WholeQuantity_P);      Current_WholeQuantity_L = List_Create( 5, 5, sizeof(struct WholeQuantity)) ;      List_Add(ListOfPointer_L, &Current_WholeQuantity_L) ;    }    WholeQuantity tDOTS     {      WholeQuantity_P = 	*((struct WholeQuantity**)	  List_Pointer(ListOfPointer2_L, List_Nbr(ListOfPointer2_L)-1)) ;      List_Pop(ListOfPointer2_L) ;      WholeQuantity_P->Case.Test.WholeQuantity_True =	*((List_T **)List_Pointer(ListOfPointer_L, List_Nbr(ListOfPointer_L)-1)) ;      List_Pop(ListOfPointer_L) ;      Current_WholeQuantity_L = List_Create( 5, 5, sizeof(struct WholeQuantity)) ;      List_Add(ListOfPointer_L, &Current_WholeQuantity_L) ;    }      WholeQuantity    {      WholeQuantity_P = 	*((struct WholeQuantity**)	  List_Pointer(ListOfPointer2_L, List_Nbr(ListOfPointer2_L)-1)) ;      List_Pop(ListOfPointer2_L) ;      WholeQuantity_P->Case.Test.WholeQuantity_False =	*((List_T **)List_Pointer(ListOfPointer_L, List_Nbr(ListOfPointer_L)-1)) ;      List_Pop(ListOfPointer_L) ;      List_Read(ListOfPointer_L, List_Nbr(ListOfPointer_L)-1,		&Current_WholeQuantity_L) ;    }  | WholeQuantity '*' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_TIME ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_ProductValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tCROSSPRODUCT WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_CROSSPRODUCT ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_CrossProductValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | tCrossProduct '[' WholeQuantity ',' WholeQuantity ']'    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_CROSSPRODUCT ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_CrossProductValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '/' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_DIVIDE ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_DivideValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '+' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_PLUS ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_AddValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '-' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_MINUS ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_SubstractValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '%' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_MODULO ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_ModuloValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '^' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_POWER ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_PowerValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '<' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_LESS ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_LessValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity '>' WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_GREATER ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_GreaterValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tLESSOREQUAL WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_LESSOREQUAL ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_LessOrEqualValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tGREATEROREQUAL WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_GREATEROREQUAL ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_GreaterOrEqualValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tEQUAL WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_EQUAL ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_EqualValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tNOTEQUAL WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_NOTEQUAL ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_NotEqualValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tAPPROXEQUAL WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_APPROXEQUAL ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_ApproxEqualValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tAND WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_AND ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_AndValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | WholeQuantity tOR WholeQuantity    { WholeQuantity_S.Type = WQ_BINARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_OR ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_OrValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;     }  | '-' WholeQuantity %prec UNARYPREC    { WholeQuantity_S.Type = WQ_UNARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_NEG ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_NegValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ; }  | '+' WholeQuantity %prec UNARYPREC  | '!' WholeQuantity    { WholeQuantity_S.Type = WQ_UNARYOPERATOR ;      WholeQuantity_S.Case.Operator.TypeOperator = OP_NOT ;      WholeQuantity_S.Case.Operator.Function = (void (*)())Cal_NotValue ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ; }  ;WholeQuantity_Single :    '(' WholeQuantity ')'  | OneFExpr    { WholeQuantity_S.Type = WQ_CONSTANT ;      WholeQuantity_S.Case.Constant = $1 ;      List_Add(Current_WholeQuantity_L, &WholeQuantity_S) ;    }  | NameForFunction ArgumentsForFunction ParametersForFunction    {      /* Expression */      if ((i = List_ISearchSeq(Problem_S.Expression, $1,fcmp_Expression_Name)) >= 0) {  	WholeQuantity_S.Type = WQ_EXPRESSION ;	WholeQuantity_S.Case.Expression.Index = i ;	WholeQuantity_S.Case.Expression.NbrArguments = $2 ;	if ($2 < 0)  vyyerror("Uncompatible argument for Function: %s", $1) ;      }      /* Built in functions */      else { 	Get_Function2NbrForString(F_Function, $1, &FlagError,				  &WholeQuantity_S.Case.Function.Fct,				  &WholeQuantity_S.Case.Function.NbrParameters,				  &WholeQuantity_S.Case.Function.NbrArguments) ;	WholeQuantity_S.Case.Function.Active = NULL ;	if (!FlagError) {	  /* arguments */	  if ($2 >= 0) {	    if ($2 == WholeQuantity_S.Case.Function.NbrArguments) {	      WholeQuantity_S.Type = WQ_BUILTINFUNCTION ;	    }	    else if (WholeQuantity_S.Case.Function.NbrArguments == -1  ||		     (WholeQuantity_S.Case.Function.NbrArguments == -2 )) { 	      /* && ($2)%2 == 0)) { */	      WholeQuantity_S.Type = WQ_BUILTINFUNCTION ;	      WholeQuantity_S.Case.Function.NbrArguments = $2 ;	    }	    else {	      vyyerror("Wrong number of arguments for Function '%s' (%d instead of %d)", 		       $1, $2, WholeQuantity_S.Case.Function.NbrArguments) ;	    }	  }	  else {	    WholeQuantity_S.Type = WQ_EXTERNBUILTINFUNCTION ;	  }	  /* parameters */	  if (WholeQuantity_S.Case.Function.NbrParameters >= 0 &&	      WholeQuantity_S.Case.Function.NbrParameters != List_Nbr($3)) {	    vyyerror("Wrong number of parameters for Function '%s' (%d instead of %d)", 		     $1, List_Nbr($3), WholeQuantity_S.Case.Function.NbrParameters) ;	  }	  else if (WholeQuantity_S.Case.Function.NbrParameters == -2 && List_Nbr($3)%2 != 0) {	    vyyerror("Wrong number of parameters for Function '%s' (%d is not even)",		     $1, List_Nbr($3)) ;	  }	  else {	    WholeQuantity_S.Case.Function.NbrParameters = List_Nbr($3) ;	    if (WholeQuantity_S.Case.Function.NbrParameters > 0) {	      WholeQuantity_S.Case.Function.Para =		(double *)Malloc		(WholeQuantity_S.Case.Function.NbrParameters * sizeof(double)) ;	      for (i = 0 ; i < WholeQuantity_S.Case.Function.NbrParameters ; i++)		List_Read($3, i, &WholeQuantity_S.Case.Function.Para[i]) ;	    }	  }	}	else {	  vyyerror("Unknown Function: %s", $1) ;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -