INT NS_DIM_PREFIX CheckPartitioning (MULTIGRID *theMG) { INT i,_restrict_; ELEMENT *theElement; ELEMENT *theFather; GRID *theGrid; _restrict_ = 0; /* reset used flags */ for (i=TOPLEVEL(theMG); i>0; i--) { theGrid = GRID_ON_LEVEL(theMG,i); for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if (LEAFELEM(theElement)) { theFather = theElement; while (EMASTER(theFather) && ECLASS(theFather)!=RED_CLASS && LEVEL(theFather)>0) { theFather = EFATHER(theFather); } /* if element with red element class does not exist */ /* or is ghost -> partitioning must be restricted */ if (!EMASTER(theFather)) { UserWriteF(PFMT "elem=" EID_FMTX " cannot be refined\n", me,EID_PRTX(theFather)); _restrict_ = 1; continue; } if (COARSEN(theFather)) { /* level 0 elements cannot be coarsened */ if (LEVEL(theFather)<=1) continue; if (!EMASTER(EFATHER(theFather))) { UserWriteF(PFMT "elem=" EID_FMTX " cannot be coarsened\n", me,EID_PRTX(theFather)); _restrict_ = 1; } } } } } _restrict_ = UG_GlobalMaxINT(_restrict_); if (me==master && _restrict_==1) { UserWriteF("CheckPartitioning(): partitioning is not valid for refinement\n"); UserWriteF(" cleaning up ...\n"); } return(_restrict_); }
static void ClearVertexMarkers(MULTIGRID *mg) { VERTEX *v; int i; for (i = 0; i <= TOPLEVEL(mg); i++) for (v = FIRSTVERTEX(GRID_ON_LEVEL(mg, i)); v != NULL; v = SUCCV(v)) SETUSED(v,0); }
static INT FillCoviseHeader (MULTIGRID *theMG, COVISE_HEADER *covise) { /* extract multigrid statistics */ /* currently no negative levels, complete grid up to TOPLEVEL */ covise->min_level = 0; covise->max_level = TOPLEVEL(theMG); /* extract surface grid statistics */ ComputeSurfaceGridStats(theMG, covise); /* extract solution descriptions */ GetSolutionDescs(theMG, covise); return(0); }
FOREIGN ("gimp-scale-tool-dialog", TRUE, FALSE), FOREIGN ("gimp-shear-tool-dialog", TRUE, FALSE), FOREIGN ("gimp-text-tool-dialog", TRUE, TRUE), FOREIGN ("gimp-threshold-tool-dialog", TRUE, FALSE), FOREIGN ("gimp-perspective-tool-dialog", TRUE, FALSE), FOREIGN ("gimp-toolbox-color-dialog", TRUE, FALSE), FOREIGN ("gimp-gradient-editor-color-dialog", TRUE, FALSE), FOREIGN ("gimp-palette-editor-color-dialog", TRUE, FALSE), FOREIGN ("gimp-colormap-editor-color-dialog", TRUE, FALSE), FOREIGN ("gimp-controller-editor-dialog", FALSE, TRUE), FOREIGN ("gimp-controller-action-dialog", FALSE, TRUE), /* ordinary toplevels */ TOPLEVEL ("gimp-image-new-dialog", dialogs_image_new_new, FALSE, TRUE, FALSE), TOPLEVEL ("gimp-file-open-dialog", dialogs_file_open_new, TRUE, TRUE, TRUE), TOPLEVEL ("gimp-file-open-location-dialog", dialogs_file_open_location_new, FALSE, TRUE, FALSE), TOPLEVEL ("gimp-file-save-dialog", dialogs_file_save_new, FALSE, TRUE, TRUE), /* singleton toplevels */ TOPLEVEL ("gimp-preferences-dialog", dialogs_preferences_get, TRUE, TRUE, FALSE), TOPLEVEL ("gimp-keyboard-shortcuts-dialog", dialogs_keyboard_shortcuts_get, TRUE, TRUE, TRUE), TOPLEVEL ("gimp-module-dialog", dialogs_module_get, TRUE, TRUE, TRUE), TOPLEVEL ("gimp-palette-import-dialog",
INT NS_DIM_PREFIX CheckNP (MULTIGRID *theMG, INT argc, char **argv) { MATDATA_DESC *A; VECDATA_DESC *x,*y; INT i,level,nerr; char value[VALUELEN]; VEC_SCALAR damp; DOUBLE nrm,diff; if (ReadArgvChar("A",value,argc,argv) == 0) { A = GetMatDataDescByName(theMG,value); if (A == NULL) { UserWriteF("ERROR: no matrix %s in npckeck\n",value); return(1); } if (ReadArgvOption("S",argc,argv)) { for (level=theMG->bottomLevel; level<=TOPLEVEL(theMG); level++) if (CheckSymmetryOfMatrix(GRID_ON_LEVEL(theMG,level),A)) UserWriteF("matrix %s not symmetric on level %d\n", ENVITEM_NAME(A),level); return(0); } if (ReadArgvOption("G",argc,argv)) { if (ReadArgvChar("x",value,argc,argv)) { UserWriteF("ERROR: no vector in npckeck\n"); return(1); } x = GetVecDataDescByName(theMG,value); if (x == NULL) { UserWriteF("ERROR: no vector %s in npckeck\n",value); return(1); } level = CURRENTLEVEL(theMG); if (level == BOTTOMLEVEL(theMG)) { UserWriteF("ERROR: no GalerkinCheck," "level %d is bottomlevel\n",level); return(1); } if (AllocVDFromVD(theMG,level-1,level,x,&y)) return(1); dmatset(theMG,level-1,level-1,ALL_VECTORS,A,0.0); dset(theMG,level,level,ALL_VECTORS,x,0.0); dset(theMG,level-1,level,ALL_VECTORS,y,0.0); AssembleGalerkinByMatrix(GRID_ON_LEVEL(theMG,level),A,0); for (i=0; i<VD_NCOMP(x); i++) damp[i] = 1.0; InterpolateCorrectionByMatrix(GRID_ON_LEVEL(theMG,level),x,x,damp); if (dmatmul(theMG,level,level,ALL_VECTORS,y,A,x) != NUM_OK) return(1); RestrictByMatrix(GRID_ON_LEVEL(theMG,level),y,y,damp); IFDEBUG(np,1) UserWriteF("x %d\n",level-1); PrintVector(GRID_ON_LEVEL(theMG,level-1),x,3,3); UserWriteF("x %d\n",level); PrintVector(GRID_ON_LEVEL(theMG,level),x,3,3); UserWriteF("y %d\n",level); PrintVector(GRID_ON_LEVEL(theMG,level),y,3,3); UserWriteF("y %d\n",level-1); PrintVector(GRID_ON_LEVEL(theMG,level-1),y,3,3); ENDDEBUG if (dmatmul_minus(theMG,level-1,level-1,ALL_VECTORS,y,A,x)!=NUM_OK) return(1); IFDEBUG(np,1) UserWriteF("y %d\n",level-1); PrintVector(GRID_ON_LEVEL(theMG,level-1),y,3,3); ENDDEBUG dnrm2(theMG,level-1,level-1,ALL_VECTORS,x,&nrm); dnrm2(theMG,level-1,level-1,ALL_VECTORS,y,&diff); UserWriteF("Galerkin test: nrm(x) = %f nrm(Ax-RAPx) = %f\n", nrm,diff); return(0); } }
INT NS_DIM_PREFIX RestrictPartitioning (MULTIGRID *theMG) { INT i,j; ELEMENT *theElement; ELEMENT *theFather; ELEMENT *SonList[MAX_SONS]; GRID *theGrid; /* reset used flags */ for (i=TOPLEVEL(theMG); i>=0; i--) { theGrid = GRID_ON_LEVEL(theMG,i); for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { SETUSED(theElement,0); } } /* set flags on elements which violate restriction */ for (i=TOPLEVEL(theMG); i>=0; i--) { theGrid = GRID_ON_LEVEL(theMG,i); for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if (GLEVEL(theGrid) == 0) break; if (LEAFELEM(theElement) || USED(theElement)) { theFather = theElement; while (EMASTER(theFather) && ECLASS(theFather)!=RED_CLASS && LEVEL(theFather)>0) { theFather = EFATHER(theFather); } /* if father with red refine class is not master */ /* partitioning must be restricted */ if (!EMASTER(theFather)) { /* the sons of father will be sent to partition of father */ SETUSED(theFather,1); } /* if element is marked for coarsening and father */ /* of element is not master -> restriction is needed */ if (COARSEN(theFather)) { /* level 0 elements are not coarsened */ if (LEVEL(theFather)<=1) continue; if (!EMASTER(EFATHER(theFather))) SETUSED(EFATHER(theFather),1); } } } /* transfer restriction flags to master copies of father */ DDD_IFAOneway(ElementVHIF,GRID_ATTR(theGrid),IF_BACKWARD,sizeof(INT), Gather_ElementRestriction, Scatter_ElementRestriction); } /* send restricted sons to partition of father */ for (i=0; i<=TOPLEVEL(theMG); i++) { theGrid = GRID_ON_LEVEL(theMG,i); /* transfer (new) partitions of elements to non master copies */ DDD_IFAOnewayX(ElementVHIF,GRID_ATTR(theGrid),IF_FORWARD,sizeof(INT), Gather_RestrictedPartition, Scatter_RestrictedPartition); for (theElement=PFIRSTELEMENT(theGrid); theElement!=NULL; theElement=SUCCE(theElement)) { if (!USED(theElement)) continue; /* push partition to the sons */ GetAllSons(theElement,SonList); for (j=0; SonList[j]!=NULL; j++) { SETUSED(SonList[j],1); if (EMASTER(SonList[j])) PARTITION(SonList[j]) = PARTITION(theElement); } } } if (TransferGrid(theMG) != 0) RETURN(GM_FATAL); return(GM_OK); }
static INT TecplotCommand (INT argc, char **argv) { INT i,j,k,v; /* counters etc. */ INT counter; /* for formatting output */ char item[1024],it[256]; /* item buffers */ INT ic=0; /* item length */ VECTOR *vc; /* a vector pointer */ ELEMENT *el; /* an element pointer */ MULTIGRID *mg; /* our multigrid */ char filename[NAMESIZE]; /* file name for output file */ PFILE *pf; /* the output file pointer */ INT nv; /* number of variables (eval functions) */ EVALUES *ev[MAXVARIABLES]; /* pointers to eval function descriptors */ char ev_name[MAXVARIABLES][NAMESIZE]; /* names for eval functions */ char s[NAMESIZE]; /* name of eval proc */ char zonename[NAMESIZE+7] = ""; /* name for zone (initialized to empty string) */ INT numNodes; /* number of data points */ INT numElements; /* number of elements */ INT gnumNodes; /* number of data points globally */ INT gnumElements; /* number of elements globallay */ PreprocessingProcPtr pre; /* pointer to prepare function */ ElementEvalProcPtr eval; /* pointer to evaluation function */ DOUBLE *CornersCoord[MAX_CORNERS_OF_ELEM]; /* pointers to coordinates */ DOUBLE LocalCoord[DIM]; /* is one of the corners local coordinates */ DOUBLE local[DIM]; /* local coordinate in DOUBLE */ DOUBLE value; /* returned by user eval proc */ INT oe,on; INT saveGeometry; /* save geometry flag */ /* get current multigrid */ mg = GetCurrentMultigrid(); if (mg==NULL) { PrintErrorMessage('W',"tecplot","no multigrid open\n"); return (OKCODE); } /* scan options */ nv = 0; saveGeometry = 0; for(i=1; i<argc; i++) { switch(argv[i][0]) { case 'e' : /* read eval proc */ if (nv>=MAXVARIABLES) { PrintErrorMessage('E',"tecplot","too many variables specified\n"); break; } sscanf(argv[i],"e %s", s); ev[nv] = GetElementValueEvalProc(s); if (ev[nv]==NULL) { PrintErrorMessageF('E',"tecplot","could not find eval proc %s\n",s); break; } if (sscanf(argv[i+1],"s %s", s) == 1) { strcpy(ev_name[nv],s); i++; } else strcpy(ev_name[nv],ev[nv]->v.name); nv++; break; case 'z' : sscanf(argv[i],"z %s", zonename+3); memcpy(zonename, "T=\"", 3); memcpy(zonename+strlen(zonename), "\", \0", 4); break; case 'g' : sscanf(argv[i],"g %d", &saveGeometry); if (saveGeometry<0) saveGeometry=0; if (saveGeometry>1) saveGeometry=1; break; } } if (nv==0) UserWrite("tecplot: no variables given, printing mesh data only\n"); /* get file name and open output file */ if (sscanf(argv[0],expandfmt(CONCAT3(" tecplot %",NAMELENSTR,"[ -~]")),filename)!=1) { PrintErrorMessage('E',"tecplot","could not read name of logfile"); return(PARAMERRORCODE); } pf = pfile_open(filename); if (pf==NULL) return(PARAMERRORCODE); /********************************/ /* TITLE */ /********************************/ ic = 0; sprintf(it,"TITLE = \"UG TECPLOT OUTPUT\"\n"); strcpy(item+ic,it); ic+=strlen(it); sprintf(it,"VARIABLES = \"X\", \"Y\""); strcpy(item+ic,it); ic+=strlen(it); if (DIM==3) { sprintf(it,", \"Z\""); strcpy(item+ic,it); ic+=strlen(it); } for (i=0; i<nv; i++) { sprintf(it,", \"%s\"",ev[i]->v.name); strcpy(item+ic,it); ic+=strlen(it); } sprintf(it,"\n"); strcpy(item+ic,it); ic+=strlen(it); pfile_master_puts(pf,item); ic=0; /********************************/ /* compute sizes */ /********************************/ /* clear VCFLAG on all levels */ for (k=0; k<=TOPLEVEL(mg); k++) for (vc=FIRSTVECTOR(GRID_ON_LEVEL(mg,k)); vc!=NULL; vc=SUCCVC(vc)) SETVCFLAG(vc,0); /* run thru all levels of elements and set index */ numNodes = numElements = 0; for (k=0; k<=TOPLEVEL(mg); k++) for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { if (!EstimateHere(el)) continue; /* process finest level elements only */ numElements++; /* increase element counter */ for (i=0; i<CORNERS_OF_ELEM(el); i++) { vc = NVECTOR(CORNER(el,i)); if (VCFLAG(vc)) continue; /* we have this one already */ VINDEX(vc) = ++numNodes; /* number of data points, begins with 1 ! */ SETVCFLAG(vc,1); /* tag vector as visited */ } } #ifdef ModelP gnumNodes = TPL_GlobalSumINT(numNodes); gnumElements = TPL_GlobalSumINT(numElements); on=get_offset(numNodes); oe=get_offset(numElements); /* clear VCFLAG on all levels */ for (k=0; k<=TOPLEVEL(mg); k++) for (vc=FIRSTVECTOR(GRID_ON_LEVEL(mg,k)); vc!=NULL; vc=SUCCVC(vc)) SETVCFLAG(vc,0); /* number in unique way */ for (k=0; k<=TOPLEVEL(mg); k++) for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { if (!EstimateHere(el)) continue; /* process finest level elements only */ for (i=0; i<CORNERS_OF_ELEM(el); i++) { vc = NVECTOR(CORNER(el,i)); if (VCFLAG(vc)) continue; /* we have this one already */ VINDEX(vc) += on; /* add offset */ SETVCFLAG(vc,1); /* tag vector as visited */ } } #else gnumNodes = numNodes; gnumElements = numElements; oe=on=0; #endif /********************************/ /* write ZONE data */ /* uses FEPOINT for data */ /* uses QUADRILATERAL in 2D */ /* and BRICK in 3D */ /********************************/ /* write zone record header */ if (DIM==2) sprintf(it,"ZONE %sN=%d, E=%d, F=FEPOINT, ET=QUADRILATERAL\n", zonename, gnumNodes,gnumElements); if (DIM==3) sprintf(it,"ZONE %sN=%d, E=%d, F=FEPOINT, ET=BRICK\n", zonename, gnumNodes,gnumElements); strcpy(item+ic,it); ic+=strlen(it); pfile_master_puts(pf,item); ic=0; /* write data in FEPOINT format, i.e. all variables of a node per line*/ for (k=0; k<=TOPLEVEL(mg); k++) for (vc=FIRSTVECTOR(GRID_ON_LEVEL(mg,k)); vc!=NULL; vc=SUCCVC(vc)) SETVCFLAG(vc,0); /* clear all flags */ counter=0; for (k=0; k<=TOPLEVEL(mg); k++) for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { if (!EstimateHere(el)) continue; /* process finest level elements only */ for (i=0; i<CORNERS_OF_ELEM(el); i++) CornersCoord[i] = CVECT(MYVERTEX(CORNER(el,i))); /* x,y,z of corners */ for (i=0; i<CORNERS_OF_ELEM(el); i++) { vc = NVECTOR(CORNER(el,i)); if (VCFLAG(vc)) continue; /* we have this one alre ady */ SETVCFLAG(vc,1); /* tag vector as visited */ sprintf(it,"%g",(double)XC(MYVERTEX(CORNER(el,i)))); strcpy(item+ic,it); ic+=strlen(it); sprintf(it," %g",(double)YC(MYVERTEX(CORNER(el,i)))); strcpy(item+ic,it); ic+=strlen(it); if (DIM == 3) { sprintf(it," %g",(double)ZC(MYVERTEX(CORNER(el,i)))); strcpy(item+ic,it); ic+=strlen(it); } /* now all the user variables */ /* get local coordinate of corner */ LocalCornerCoordinates(DIM,TAG(el),i,local); for (j=0; j<DIM; j++) LocalCoord[j] = local[j]; for (v=0; v<nv; v++) { pre = ev[v]->PreprocessProc; eval = ev[v]->EvalProc; /* execute prepare function */ /* This is not really equivalent to the FEBLOCK-version sinc we call "pre" more often than there. D.Werner */ if (pre!=NULL) pre(ev_name[v],mg); /* call eval function */ value = eval(el,(const DOUBLE **)CornersCoord,LocalCoord); sprintf(it," %g",value); strcpy(item+ic,it); ic+=strlen(it); } sprintf(it,"\n"); strcpy(item+ic,it); ic+=strlen(it); pfile_tagged_puts(pf,item,counter+on); ic=0; counter++; } } pfile_sync(pf); /* end of segment */ sprintf(it,"\n"); strcpy(item+ic,it); ic+=strlen(it); pfile_master_puts(pf,item); ic=0; /* finally write the connectivity list */ counter=0; for (k=0; k<=TOPLEVEL(mg); k++) for (el=FIRSTELEMENT(GRID_ON_LEVEL(mg,k)); el!=NULL; el=SUCCE(el)) { if (!EstimateHere(el)) continue; /* process finest level elements only */ switch(DIM) { case 2 : switch(TAG(el)) { case TRIANGLE : sprintf(it,"%d %d %d %d\n", VINDEX(NVECTOR(CORNER(el,0))), VINDEX(NVECTOR(CORNER(el,1))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,2))) ); break; case QUADRILATERAL : sprintf(it,"%d %d %d %d\n", VINDEX(NVECTOR(CORNER(el,0))), VINDEX(NVECTOR(CORNER(el,1))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,3))) ); break; default : UserWriteF("tecplot: unknown 2D element type with tag(el) = %d detected. Aborting further processing of command tecplot\n", TAG(el)); return CMDERRORCODE; break; } break; case 3 : switch(TAG(el)) { case HEXAHEDRON : sprintf(it,"%d %d %d %d " "%d %d %d %d\n", VINDEX(NVECTOR(CORNER(el,0))), VINDEX(NVECTOR(CORNER(el,1))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,3))), VINDEX(NVECTOR(CORNER(el,4))), VINDEX(NVECTOR(CORNER(el,5))), VINDEX(NVECTOR(CORNER(el,6))), VINDEX(NVECTOR(CORNER(el,7))) ); break; case TETRAHEDRON : sprintf(it,"%d %d %d %d " "%d %d %d %d\n", VINDEX(NVECTOR(CORNER(el,0))), VINDEX(NVECTOR(CORNER(el,1))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,3))), VINDEX(NVECTOR(CORNER(el,3))), VINDEX(NVECTOR(CORNER(el,3))), VINDEX(NVECTOR(CORNER(el,3))) ); break; case PYRAMID : sprintf(it,"%d %d %d %d " "%d %d %d %d\n", VINDEX(NVECTOR(CORNER(el,0))), VINDEX(NVECTOR(CORNER(el,1))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,3))), VINDEX(NVECTOR(CORNER(el,4))), VINDEX(NVECTOR(CORNER(el,4))), VINDEX(NVECTOR(CORNER(el,4))), VINDEX(NVECTOR(CORNER(el,4))) ); break; case PRISM : sprintf(it,"%d %d %d %d " "%d %d %d %d\n", VINDEX(NVECTOR(CORNER(el,0))), VINDEX(NVECTOR(CORNER(el,1))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,2))), VINDEX(NVECTOR(CORNER(el,3))), VINDEX(NVECTOR(CORNER(el,4))), VINDEX(NVECTOR(CORNER(el,5))), VINDEX(NVECTOR(CORNER(el,5))) ); break; default : UserWriteF("tecplot: unknown 3D element type with tag(el) = %d detected. Aborting further processing of command tecplot\n", TAG(el)); return CMDERRORCODE; break; } break; } strcpy(item+ic,it); ic+=strlen(it); pfile_tagged_puts(pf,item,counter+oe); ic=0; counter++; } pfile_sync(pf); /* end of segment */ /********************************/ /* GEOMETRY */ /* we will do this later, since */ /* domain interface will change */ /********************************/ pfile_close(pf); return(OKCODE); }