📄 print_problemstructure.c
字号:
#define RCSID "$Id: Print_ProblemStructure.c,v 1.41 2006/02/26 00:42:54 geuzaine Exp $"/* * Copyright (C) 1997-2006 P. Dular, C. Geuzaine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * * Please report all bugs and problems to <getdp@geuz.org>. * * Contributor(s): * David Colignon * Johan Gyselinck * Ruth Sabariego */#include "GetDP.h"#include "Data_Active.h"#include "Data_DefineE.h"#include "Print_ProblemStructure.h"#include "Treatment_Formulation.h"#include "CurrentData.h"#include "GmshClient.h"static int NbrBlk=-1;char * Get_ExpressionName(struct Problem * Problem, int Index) { GetDP_Begin("Get_ExpressionName"); GetDP_Return( ((struct Expression *)List_Pointer(Problem->Expression, Index))->Name );}void Print_WholeQuantity(struct Problem * Problem, List_T * WholeQuantity, List_T * DQ_L) { int j, k ; struct WholeQuantity * WQ ; GetDP_Begin("Print_WholeQuantity"); WQ = (struct WholeQuantity*)List_Pointer(WholeQuantity, 0) ; for (k = 0 ; k < List_Nbr(WholeQuantity) ; k++) { switch ((WQ+k)->Type) { case WQ_OPERATORANDQUANTITY : Msg(CHECK, " {%s %s}", Get_StringForDefine (Operator_Type, (WQ+k)->Case.OperatorAndQuantity.TypeOperator), ((struct DefineQuantity *) List_Pointer(DQ_L, (WQ+k)->Case.OperatorAndQuantity.Index)) ->Name) ; break ; case WQ_OPERATORANDQUANTITYEVAL : Msg(CHECK, " {%s %s} ExplicitEvaluation", Get_StringForDefine (Operator_Type, (WQ+k)->Case.OperatorAndQuantity.TypeOperator), ((struct DefineQuantity *) List_Pointer(DQ_L, (WQ+k)->Case.OperatorAndQuantity.Index)) ->Name) ; break ; case WQ_BINARYOPERATOR : switch ((WQ+k)->Case.Operator.TypeOperator) { case OP_PLUS : Msg(CHECK, " +") ; break ; case OP_MINUS : Msg(CHECK, " -") ; break ; case OP_TIME : Msg(CHECK, " *") ; break ; case OP_DIVIDE : Msg(CHECK, " /") ; break ; case OP_MODULO : Msg(CHECK, " %%") ; break ; case OP_POWER : Msg(CHECK, " ^") ; break ; case OP_CROSSPRODUCT : Msg(CHECK, " x") ; break ; case OP_LESS : Msg(CHECK, " <") ; break ; case OP_GREATER : Msg(CHECK, " >") ; break ; case OP_LESSOREQUAL : Msg(CHECK, " <=") ; break ; case OP_GREATEROREQUAL : Msg(CHECK, " >=") ; break ; case OP_EQUAL : Msg(CHECK, " ==") ; break ; case OP_NOTEQUAL : Msg(CHECK, " !=") ; break ; default : Msg(CHECK, " UnknownBinaryOperator[]") ; break ; } break ; case WQ_UNARYOPERATOR : switch ((WQ+k)->Case.Operator.TypeOperator) { case OP_NEG : Msg(CHECK, " -(unary)") ; break ; case OP_NOT : Msg(CHECK, " !") ; break ; default : Msg(CHECK, " UnknownUnaryOperator[]") ; break ; } break; case WQ_EXPRESSION : Msg(CHECK, " %s[]", ((struct Expression *) List_Pointer(Problem->Expression, (WQ+k)->Case.Expression.Index))->Name) ; break ; case WQ_BUILTINFUNCTION : case WQ_EXTERNBUILTINFUNCTION : Msg(CHECK, " %s", Get_StringForFunction2Nbr(F_Function, (WQ+k)->Case.Function.Fct)) ; if ((WQ+k)->Type == WQ_EXTERNBUILTINFUNCTION) Msg(CHECK, "[.]") ; if ((WQ+k)->Case.Function.NbrParameters) { Msg(CHECK, "{") ; for (j = 0 ; j < (WQ+k)->Case.Function.NbrParameters ; j++) { if (j) Msg(CHECK, ",") ; Msg(CHECK, " %.10g", (WQ+k)->Case.Function.Para[j]) ; } Msg(CHECK, " }") ; } break ; case WQ_CONSTANT : Msg(CHECK, " %.8g", (WQ+k)->Case.Constant) ; break ; case WQ_TIMEDERIVATIVE : Msg(CHECK, " Dt[") ; Print_WholeQuantity(Problem, (WQ+k)->Case.TimeDerivative.WholeQuantity, DQ_L) ; Msg(CHECK, " ]") ; break ; case WQ_TRACE : Msg(CHECK, " Trace[") ; Print_WholeQuantity(Problem, (WQ+k)->Case.Trace.WholeQuantity, DQ_L) ; Msg(CHECK, " , %s ]", ((struct Group*) List_Pointer(Problem->Group, (WQ+k)->Case.Trace.InIndex))->Name) ; break ; case WQ_CAST : if(!(WQ+k)->Case.Cast.NbrHar) Msg(CHECK, " <%s>[", ((struct FunctionSpace *) List_Pointer(Problem->FunctionSpace, (WQ+k)->Case.Cast.FunctionSpaceIndexForType))->Name) ; else Msg(CHECK, " <Real>[") ; Print_WholeQuantity(Problem, (WQ+k)->Case.Cast.WholeQuantity, DQ_L) ; Msg(CHECK, " ]") ; break ; case WQ_CURRENTVALUE : Msg(CHECK, " $%s", Get_StringForPointer(Current_Value, (void *)((WQ+k)->Case.CurrentValue.Value))) ; break ; case WQ_ARGUMENT : Msg(CHECK, " $%d", (WQ+k)->Case.Argument.Index) ; break ; case WQ_TEST : Msg(CHECK, " ?") ; Print_WholeQuantity(Problem, (WQ+k)->Case.Test.WholeQuantity_True , DQ_L) ; Msg(CHECK, " :") ; Print_WholeQuantity(Problem, (WQ+k)->Case.Test.WholeQuantity_False, DQ_L) ; break ; case WQ_SAVEVALUE : Msg(CHECK, " ->#%d", (WQ+k)->Case.SaveValue.Index + 1) ; break ; case WQ_VALUESAVED : Msg(CHECK, " #%d", (WQ+k)->Case.ValueSaved.Index + 1) ; break ; case WQ_SHOWVALUE : Msg(CHECK, " ->show with prefix #%d", (WQ+k)->Case.ShowValue.Index + 1) ; break ; default : Msg(CHECK, " ???") ; break ; } } GetDP_End ;}/* ------------------------------------------------------- *//* --> P r i n t _ G r o u p *//* ------------------------------------------------------- */void Print_Group(struct Problem * Problem) { int i, Nbr, j ; struct Group *GR ; GetDP_Begin("Print_Group"); Nbr = List_Nbr(Problem->Group) ; Msg(CHECK, "Group { /* nbr = %d */\n", Nbr) ; Msg(CHECK, "\n") ; for (i = 0 ; i < Nbr ; i++) { GR = (struct Group*)List_Pointer(Problem->Group, i) ; Msg(CHECK, " %s = %s [", GR->Name, Get_StringForDefine(FunctionForGroup_Type, GR->FunctionType)) ; if (GR->InitialList != NULL) { Msg(CHECK, " {") ; for (j = 0 ; j < List_Nbr(GR->InitialList) ; j++) Msg(CHECK, " %d", *((int *)List_Pointer(GR->InitialList, j)) ) ; Msg(CHECK, " }") ; } else Msg(CHECK, " All") ; if (GR->InitialSuppList != NULL) { if (GR->SuppListType != SUPPLIST_INSUPPORT) { Msg(CHECK, ", %s {", Get_StringForDefine(FunctionForGroup_SuppList, GR->SuppListType)) ; for (j = 0 ; j < List_Nbr(GR->InitialSuppList) ; j++) Msg(CHECK, " %d", *((int *)List_Pointer(GR->InitialSuppList, j)) ) ; Msg(CHECK, " }") ; } else { Msg(CHECK, ", %s", Get_StringForDefine(FunctionForGroup_SuppList, GR->SuppListType)) ; Msg(CHECK, " %s", ((struct Group *) List_Pointer(Problem->Group, *((int *)List_Pointer(GR->InitialSuppList, 0)))) ->Name) ; } } Msg(CHECK, " ]") ; if (GR->Type == MOVINGBAND2D) { Msg(CHECK, " = MovingBand2D [ {"); for (j = 0 ; j < List_Nbr(GR->MovingBand2D->InitialList1) ; j++) Msg(CHECK, " %d", *((int *)List_Pointer(GR->MovingBand2D->InitialList1, j)) ) ; Msg(CHECK, " } , {") ; for (j = 0 ; j < List_Nbr(GR->MovingBand2D->InitialList2) ; j++) Msg(CHECK, " %d", *((int *)List_Pointer(GR->MovingBand2D->InitialList2, j)) ) ; Msg(CHECK, " } ]") ; } Msg(CHECK, " ; /* Num %d */\n", i) ; } Msg(CHECK, "\n"); Msg(CHECK, "}\n") ; GetDP_End ;}/* ------------------------------------------------------- *//* --> P r i n t _ E x p r e s s i o n *//* ------------------------------------------------------- */void Print_Expression(struct Problem * Problem) { int i, Nbr, j ; struct Expression *EX ; struct ExpressionPerRegion *EXPR ; GetDP_Begin("Print_Expression"); Nbr = List_Nbr(Problem->Expression) ; Msg(CHECK, "Function { /* nbr = %d */\n", Nbr) ; Msg(CHECK, "\n") ; for (i = 0 ; i < Nbr ; i++) { EX = (struct Expression*)List_Pointer(Problem->Expression, i) ; switch (EX->Type) { case CONSTANT : Msg(CHECK, " %s = %.10g ;\n", EX->Name, EX->Case.Constant) ; break ; case WHOLEQUANTITY : Msg(CHECK, " %s = ", EX->Name) ; Print_WholeQuantity(Problem, EX->Case.WholeQuantity, NULL) ; Msg(CHECK, " ;\n") ; break ; case PIECEWISEFUNCTION : for (j = 0 ; j < List_Nbr(EX->Case.PieceWiseFunction.ExpressionPerRegion) ; j++) { EXPR = (struct ExpressionPerRegion*) List_Pointer(EX->Case.PieceWiseFunction.ExpressionPerRegion, j) ; Msg(CHECK, " %s [%d] = Exp[%s] ;\n", EX->Name, EXPR->RegionIndex, Get_ExpressionName(Problem, EXPR->ExpressionIndex)) ; } if (!List_Nbr(EX->Case.PieceWiseFunction.ExpressionPerRegion)) Msg(CHECK, " DefineFunction[ %s ] ;\n", EX->Name) ; break ; case UNDEFINED_EXP : Msg(CHECK, " DefineFunction[ %s ] ;\n", EX->Name) ; break ; default : Msg(CHECK, "??? ;\n") ; break ; } } Msg(CHECK, "\n"); Msg(CHECK, "}\n") ; GetDP_End ;}/* ------------------------------------------------------- *//* --> P r i n t _ C o n s t r a i n t *//* ------------------------------------------------------- */void Print_Network(struct MultiConstraintPerRegion * MCPR_P) { int i, j ; struct ConstraintActive *CA ; GetDP_Begin("Print_Network"); CA = MCPR_P->Active ; Msg(CHECK, "NbrNode = %d, NbrBranch = %d\n", CA->Case.Network.NbrNode, CA->Case.Network.NbrBranch) ; Msg(CHECK, "\n") ; Msg(CHECK, "MatNode (NbrNode x NbrBranch):\n"); for (i = 0 ; i < CA->Case.Network.NbrNode ; i++) { for (j = 0 ; j < CA->Case.Network.NbrBranch ; j++) { Msg(CHECK, "%2d ", CA->Case.Network.MatNode[i][j]) ; } Msg(CHECK, "\n"); } Msg(CHECK, "\n"); Msg(CHECK, "MatLoop (NbrLoop x NbrBranch):\n"); for (i = 0 ; i < CA->Case.Network.NbrLoop ; i++) { for (j = 0 ; j < CA->Case.Network.NbrBranch ; j++) { Msg(CHECK, "%2d ", CA->Case.Network.MatLoop[i][j]) ; } Msg(CHECK, "\n"); } GetDP_End ;}void Print_Constraint(struct Problem * Problem) { int i, Nbr, j, Nbrj, k, Nbrk ; struct Constraint *CO ; struct ConstraintPerRegion *CPR ; struct MultiConstraintPerRegion MCPR_S ; GetDP_Begin("Print_Constraint"); Nbr = List_Nbr(Problem->Constraint) ; Msg(CHECK, "Constraint { /* nbr = %d */\n", Nbr) ; Msg(CHECK, "\n") ; for (i = 0 ; i < Nbr ; i++) { Msg(CHECK, " /* Num : %d */\n", i) ; CO = (struct Constraint*)List_Pointer(Problem->Constraint, i) ; Msg(CHECK, " { Name %s ; Type %s ;\n", CO->Name, Get_StringForDefine(Constraint_Type, CO->Type)) ; if (CO->Type == NETWORK){ Nbrk = List_Nbr(CO->MultiConstraintPerRegion) ; for (k = 0 ; k < Nbrk ; k++) { List_Read(CO->MultiConstraintPerRegion, k, &MCPR_S) ; Msg(CHECK, " Case %s {\n", MCPR_S.Name) ; Nbrj = List_Nbr(MCPR_S.ConstraintPerRegion) ; for (j = 0 ; j < Nbrj ; j++) { CPR = (struct ConstraintPerRegion*) List_Pointer(MCPR_S.ConstraintPerRegion, j) ; Msg(CHECK, " { Region %s ;", ((struct Group *) List_Pointer(Problem->Group, CPR->RegionIndex))->Name) ; Msg(CHECK, " Branch { %d, %d } ;", CPR->Case.Network.Node1, CPR->Case.Network.Node2) ; Msg(CHECK, " }\n") ; } if (!MCPR_S.Active) MCPR_S.Active = Generate_Network(MCPR_S.ConstraintPerRegion) ; Print_Network(&MCPR_S) ; } } else { Msg(CHECK, " Case {\n") ; Nbrj = List_Nbr(CO->ConstraintPerRegion) ; for (j = 0 ; j < Nbrj ; j++) { CPR = (struct ConstraintPerRegion*)List_Pointer(CO->ConstraintPerRegion, j) ; Msg(CHECK, " { Region %s ;", ((struct Group *)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -