void MainWindow::ConnectNewDomain(Domain *newDomain) { if (testDomain) { disconnect(testDomain, SIGNAL(Message(QString)), this, SLOT(displayOutput(QString))); disconnect(testDomain, SIGNAL(Instructions(QString)), ui->statusBar, SLOT(showMessage(QString))); disconnect(testDomain, SIGNAL(ToolFinishedDrawing()), ui->statusBar, SLOT(clearMessage())); disconnect(testDomain, SIGNAL(MouseX(float)), this, SLOT(showMouseX(float))); disconnect(testDomain, SIGNAL(MouseY(float)), this, SLOT(showMouseY(float))); disconnect(testDomain, SIGNAL(CircleToolStatsSet(float,float,float)), this, SLOT(showCircleStats(float,float,float))); disconnect(testDomain, SIGNAL(NumNodesDomain(int)), this, SLOT(showNumNodes(int))); disconnect(testDomain, SIGNAL(NumElementsDomain(int)), this, SLOT(showNumElements(int))); disconnect(testDomain, SIGNAL(NumNodesSelected(int)), this, SLOT(showNumSelectedNodes(int))); disconnect(testDomain, SIGNAL(NumElementsSelected(int)), this, SLOT(showNumSelectedElements(int))); disconnect(testDomain, SIGNAL(ToolFinishedDrawing()), glStatusBar, SLOT(clearMessage())); disconnect(testDomain, SIGNAL(EmitMessage(QString)), this, SLOT(displayOutput(QString))); disconnect(testDomain, SIGNAL(UndoAvailable(bool)), ui->undoButton, SLOT(setEnabled(bool))); disconnect(testDomain, SIGNAL(RedoAvailable(bool)), ui->redoButton, SLOT(setEnabled(bool))); } connect(newDomain, SIGNAL(Message(QString)), this, SLOT(displayOutput(QString))); connect(newDomain, SIGNAL(Instructions(QString)), ui->statusBar, SLOT(showMessage(QString))); connect(newDomain, SIGNAL(ToolFinishedDrawing()), ui->statusBar, SLOT(clearMessage())); connect(newDomain, SIGNAL(MouseX(float)), this, SLOT(showMouseX(float))); connect(newDomain, SIGNAL(MouseY(float)), this, SLOT(showMouseY(float))); connect(newDomain, SIGNAL(CircleToolStatsSet(float,float,float)), this, SLOT(showCircleStats(float,float,float))); connect(newDomain, SIGNAL(NumNodesDomain(int)), this, SLOT(showNumNodes(int))); connect(newDomain, SIGNAL(NumElementsDomain(int)), this, SLOT(showNumElements(int))); connect(newDomain, SIGNAL(NumNodesSelected(int)), this, SLOT(showNumSelectedNodes(int))); connect(newDomain, SIGNAL(NumElementsSelected(int)), this, SLOT(showNumSelectedElements(int))); connect(newDomain, SIGNAL(ToolFinishedDrawing()), glStatusBar, SLOT(clearMessage())); connect(newDomain, SIGNAL(EmitMessage(QString)), this, SLOT(displayOutput(QString))); connect(newDomain, SIGNAL(UndoAvailable(bool)), ui->undoButton, SLOT(setEnabled(bool))); connect(newDomain, SIGNAL(RedoAvailable(bool)), ui->redoButton, SLOT(setEnabled(bool))); }
void CreationSelectionLayer::CreateClickTool() { if (!clickTool) clickTool = new ClickTool(); clickTool->SetTerrainLayer(terrainLayer); clickTool->SetCamera(camera); connect(clickTool, SIGNAL(Message(QString)), this, SIGNAL(Message(QString))); connect(clickTool, SIGNAL(Instructions(QString)), this, SIGNAL(Instructions(QString))); connect(clickTool, SIGNAL(ToolFinishedDrawing()), this, SLOT(GetSelectionFromTool())); connect(clickTool, SIGNAL(ToolFinishedDrawing()), this, SIGNAL(ToolFinishedDrawing())); }
void FullDomainSelectionLayer::CreatePolygonTool() { if (!polygonTool) polygonTool = new PolygonTool(); polygonTool->SetFort14(fort14); polygonTool->SetCamera(camera); connect(polygonTool, SIGNAL(Message(QString)), this, SIGNAL(Message(QString))); connect(polygonTool, SIGNAL(Instructions(QString)), this, SIGNAL(Instructions(QString))); connect(polygonTool, SIGNAL(ToolFinishedDrawing()), this, SLOT(GetSelectionFromTool())); connect(polygonTool, SIGNAL(ToolFinishedDrawing()), this, SIGNAL(ToolFinishedDrawing())); }
void FullDomainSelectionLayer::CreateCircleTool() { if (!circleTool) circleTool = new CircleTool(); circleTool->SetFort14(fort14); circleTool->SetCamera(camera); connect(circleTool, SIGNAL(Message(QString)), this, SIGNAL(Message(QString))); connect(circleTool, SIGNAL(Instructions(QString)), this, SIGNAL(Instructions(QString))); connect(circleTool, SIGNAL(ToolFinishedDrawing()), this, SLOT(GetSelectionFromTool())); connect(circleTool, SIGNAL(ToolFinishedDrawing()), this, SIGNAL(ToolFinishedDrawing())); connect(circleTool, SIGNAL(CircleStatsSet(float,float,float)), this, SIGNAL(CircleToolStatsSet(float,float,float))); }
void CreationSelectionLayer::CreateRectangleTool() { if (!rectangleTool) rectangleTool = new RectangleTool(); rectangleTool->SetTerrainLayer(terrainLayer); rectangleTool->SetCamera(camera); connect(rectangleTool, SIGNAL(Message(QString)), this, SIGNAL(Message(QString))); connect(rectangleTool, SIGNAL(Instructions(QString)), this, SIGNAL(Instructions(QString))); connect(rectangleTool, SIGNAL(ToolFinishedDrawing()), this, SLOT(GetSelectionFromTool())); connect(rectangleTool, SIGNAL(ToolFinishedDrawing()), this, SIGNAL(ToolFinishedDrawing())); connect(rectangleTool, SIGNAL(RectangleStatsSet(float,float)), this, SIGNAL(RectangleToolStatsSet(float,float))); }
/** * @brief Actions that are performed when a mouse button is pressed * * Actions that are performed when a mouse button is pressed. In this case, * a left click will drop the center of the circle and make the circle * visible. * * @param event The QMouseEvent object created by the GUI on the click */ void CircleTool::MouseClick(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { visible = true; mousePressed = true; SetCenter(event->x(), event->y()); emit Instructions(QString("Drag to resize circle, drop to select elements")); } }
/** * @brief Actions that are performed when the left mouse button is released * * Actions that are performed when the left mouse button is released. Makes * tool invisible and tells everyone we're finished drawing. * * @param event The QMouseEvent object created by the GUI on the button release */ void ClickTool::MouseRelease(QMouseEvent *) { mousePressed = false; visible = false; if (!mouseMoved) { emit ToolFinishedDrawing(); } else { emit Instructions(QString("Click on any Element to select/deselect it")); } }
int main( ) { char answer; char result; Menu( ); // ***********Answer to playing************* while( answer = playAgain( ) ) { switch( answer ) // The user decides to play the game { case 'y': printf( "Alright! Lets Play!\n\n" ); Instructions( ); // Will jump to the Instuctions Function result = playGame( ); // Will jump to rhe playGame Function // ****************RESULT OF GAME************************* if( result == 'w' ) // After the function playGame returns 'w', the user then won the game. { printf( "\n\nHurray! You Win!\n\n\n" ); } if( result == 'l' ) // Vise versa with the function playGame if it returns 'l'. { printf( "Awwww. I'm sorry but you Lose!\n\n\n" ); } break; case 'n': printf( "Too Bad! Maybe next time!\n" ); //The user decides to not play the game thus the program terminates return 0; case 'v': filePrint( ); break; default: printf( "That was not one of the choices. Please try again.\n\n" ); break; } Menu( ); } }
/** * @brief Actions that are performed when the mouse button is clicked * * Actions that are performed when the mouse button is clicked. Updates the * coordinates of the clicked point and sends them to the GPU * * @param event The QMouseEvent object created by the GUI on the click */ void ClickTool::MouseClick(QMouseEvent *event) { mousePressed = true; mouseMoved = false; visible = true; xPixel = oldX = event->x(); yPixel = oldY = event->y(); UpdateCoordinates(); if (glLoaded) UpdateGL(); emit Instructions(QString("Release to select Element, move to pan")); }
/** * @brief Actions that are performed when the mouse moves * * If the mouse button is pressed, the camera is panned. * */ void ClickTool::MouseMove(QMouseEvent *event) { if (mousePressed && camera) { visible = false; mouseMoved = true; xPixel = event->x(); yPixel = event->y(); camera->Pan(xPixel-oldX, yPixel-oldY); oldX = xPixel; oldY = yPixel; emit Instructions(QString("Move to pan")); } }
void InGameMenuKey() { while (true) { if (_kbhit()) { char mainMenuKey = _getch(); switch (mainMenuKey) { case CREDITS_CONTINUE_CHAR: start = true; break; case SAVE_CHAR: SaveGame(); break; case OPTIONS_CHAR: Options(); break; case FAME_CHAR: HallOfFame(); break; case INSTRUCTIONS_CHAR: Instructions(); break; case MENU_CHAR: Reset(); quit = true; start = true; break; case QUIT_CHAR: quit = true; break; default: toBreak = false; } if (toBreak) { break; } else { toBreak = true; } } } }
//Program waits for the user to press one of the following keys void MainMenuKey() { while (true) { if (_kbhit()) { char mainMenuKey = _getch(); switch (mainMenuKey) { case NEW_GAME_CHAR: PicksDwarfProperties(); break; case LOAD_CHAR: LoadGame(); break; case OPTIONS_CHAR: Options(); break; case FAME_CHAR: HallOfFame(); break; case CREDITS_CONTINUE_CHAR: Credits(); break; case INSTRUCTIONS_CHAR: Instructions(); break; case QUIT_CHAR: quit = true; break; default: toBreak = false; } if (toBreak) { break; } else { toBreak = true; } } } }
bool TokenCreator::isInstruction(Token token) { return Instructions(language).isValid(token.name); }
/** * @brief Function called when the user wants to use to tool * * Function called when the user wants to use to tool. This resets the * tool to default values, preparing it for interaction with the user. * */ void CircleTool::UseTool() { ResetTool(); emit Instructions(QString("Click to drop circle center")); }
/** * @brief Function called when the user wants to use to tool * * Function called when the user wants to use to tool. Initializes the * OpenGL context if it has not already done so. * */ void ClickTool::UseTool() { if (!glLoaded) InitializeGL(); emit Instructions(QString("Click on any Element to select/deselect it")); }
/// Returns the instructions for rendering of faces DrawingInstructions Instructions(Default = Default()) const { return Instructions(PrimitiveType::Triangles); }
/// Returns the instructions for rendering of faces DrawingInstructions Instructions(void) const { return Instructions(PrimitiveType::Triangles); }
int main(int argc, char *argv[]) { int i,j,k,l,inmethod,outmethod,info,errorstat; int nogrids,nomeshes,nofile,dim,elementsredone=0; int nodes3d,elements3d,showmem; Real mergeeps; char prefix[MAXFILESIZE]; struct GridType *grids; struct CellType *cell[MAXCASES]; struct FemType data[MAXCASES]; struct BoundaryType *boundaries[MAXCASES]; struct ElmergridType eg; showmem = TRUE; printf("\nStarting program Elmergrid\n"); InitParameters(&eg); grids = (struct GridType*)malloc((size_t) (MAXCASES)*sizeof(struct GridType)); InitGrid(grids); info = TRUE; if(argc <= 1) { errorstat = LoadCommands(argv[1],&eg,grids,argc-1,info); Instructions(); if(errorstat) Goodbye(); } if(argc == 2) { errorstat = LoadCommands(argv[1],&eg,grids,argc-1,info); if(errorstat) Goodbye(); } else if(argc < 4) { Instructions(); Goodbye(); } else { errorstat = InlineParameters(&eg,argc,argv); if(errorstat) Goodbye(); } if(!eg.outmethod || !eg.inmethod) { printf("Please define the input and output formats\n"); } if(eg.inmethod != 1) { if(eg.outmethod == 1 || eg.outmethod == 8 || eg.outmethod == 9 || eg.outmethod == 10) { printf("input of type %d can't create output of type %d\n", eg.inmethod,eg.outmethod); errorstat++; Goodbye(); } } #if 0 if(eg.inmethod != 8 && eg.outmethod == 5) { printf("To write Easymesh format you need to read easymesh format!\n"); errorstat++; } #endif if(eg.timeron) timer_activate(eg.infofile); /**********************************/ printf("\nElmergrid loading data:\n"); printf( "-----------------------\n"); dim = eg.dim; nofile = 0; nomeshes = 0; nogrids = 0; inmethod = eg.inmethod; outmethod = eg.outmethod; read_another_file: timer_show(); switch (inmethod) { case 1: if(LoadElmergrid(&grids,&nogrids,eg.filesin[nofile],eg.relh,info) == 1) { if(dim == 3) ExampleGrid3D(&grids,&nogrids,info); if(dim == 2) ExampleGrid2D(&grids,&nogrids,info); if(dim == 1) ExampleGrid1D(&grids,&nogrids,info); SaveElmergrid(grids,nogrids,eg.filesin[nofile],info); printf("Because file %s didn't exist, it was created for you.\n",eg.filesin[nofile]); Goodbye(); } LoadCommands(eg.filesin[nofile],&eg,grids,2,info); break; case 2: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if(LoadElmerInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],info)) Goodbye(); nomeshes++; break; case 3: if(LoadSolutionElmer(&(data[nofile]),TRUE,eg.filesin[nofile],info)) Goodbye(); nomeshes++; break; case 4: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); if(LoadAnsysInput(&(data[0]),boundaries[0],eg.filesin[nofile],info)) Goodbye(); nomeshes++; break; case 5: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if(LoadAbaqusInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 6: if(LoadAbaqusOutput(&(data[nofile]),eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 7: if(LoadFidapInput(&(data[nofile]),eg.filesin[nofile],TRUE)) Goodbye(); boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if(0 && !eg.usenames) data[nofile].boundarynamesexist = data[nofile].bodynamesexist = FALSE; ElementsToBoundaryConditions(&(data[nofile]),boundaries[nofile],FALSE,TRUE); RenumberBoundaryTypes(&data[nofile],boundaries[nofile],TRUE,0,info); nomeshes++; break; case 8: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadUniversalMesh(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 9: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if(LoadComsolMesh(&(data[nofile]),eg.filesin[nofile],info)) Goodbye(); ElementsToBoundaryConditions(&(data[nofile]),boundaries[nofile],FALSE,TRUE); nomeshes++; break; case 10: if(LoadFieldviewInput(&(data[nofile]),eg.filesin[nofile],TRUE)) Goodbye(); boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } ElementsToBoundaryConditions(&(data[nofile]),boundaries[nofile],FALSE,TRUE); nomeshes++; break; case 11: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadTriangleInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 12: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadMeditInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 13: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadGidInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 14: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadGmshInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 15: if(info) printf("Partitioned solution is fused on-the-fly therefore no other operations may be performed.\n"); FuseSolutionElmerPartitioned(eg.filesin[nofile],eg.filesout[nofile],eg.decimals,eg.partjoin, eg.saveinterval[0],eg.saveinterval[1],eg.saveinterval[2],info); if(info) printf("Finishing with the fusion of partitioned Elmer solutions\n"); Goodbye(); break; #if 0 case 16: InitializeKnots(&(data[nofile])); if( Easymesh(argc,argv,&data[nofile].noknots, &data[nofile].noelements,&sides)) Goodbye(); data[nofile].dim = 2; data[nofile].coordsystem = COORD_CART2; data[nofile].maxnodes = 3; AllocateKnots(&(data[nofile])); boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if(EasymeshCopy(&(data[nofile]),boundaries[nofile])) Goodbye(); nomeshes++; break; #endif case 17: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadNastranInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; case 18: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if(LoadCGsimMesh(&(data[nofile]),eg.filesin[nofile],info)) Goodbye(); nomeshes++; break; case 19: boundaries[nofile] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) { boundaries[nofile][i].created = FALSE; boundaries[nofile][i].nosides = 0; } if (LoadGeoInput(&(data[nofile]),boundaries[nofile],eg.filesin[nofile],TRUE)) Goodbye(); nomeshes++; break; default: Instructions(); Goodbye(); } nofile++; if(nofile < eg.nofilesin) { printf("\nElmergrid loading data from another file:\n"); goto read_another_file; } /***********************************/ redoelements: printf("\nElmergrid creating and manipulating meshes:\n"); printf( "-------------------------------------------\n"); timer_show(); if(nogrids > nomeshes && outmethod != 1) { nomeshes = nogrids; for(k=0;k<nogrids;k++) { CreateCells(&(grids[k]),&(cell[k]),info); CreateKnots(&(grids[k]),cell[k],&(data[k]),0,0); boundaries[k] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(j=0;j<MAXBOUNDARIES;j++) { boundaries[k][j].created = FALSE; boundaries[k][j].nosides = FALSE; } if(grids[k].noboundaries > 0) { for(j=0;j<grids[k].noboundaries;j++) { if(grids[k].boundsolid[j] < 4) { CreateBoundary(cell[k],&(data[k]),&(boundaries[k][j]), grids[k].boundext[j],grids[k].boundint[j], 1,grids[k].boundtype[j]); } else { CreatePoints(cell[k],&(data[k]),&(boundaries[k][j]), grids[k].boundext[j],grids[k].boundint[j], grids[k].boundsolid[j],grids[k].boundtype[j]); } } } } } /* In some formats the dimension for curved 2D meshes seems to be set to 2. This should fix the problem for all input types. */ if( data->dim < 3 ) { data->dim = GetCoordinateDimension(data,info); } /* Make the discontinous boundary needed, for example, in poor thermal conduction */ for(k=0;k<nomeshes;k++) { if(!eg.discont) { for(j=0;j<grids[k].noboundaries;j++) if(grids[k].boundsolid[j] == 2) { eg.discontbounds[eg.discont] = grids[k].boundtype[j]; eg.discont++; } } if(eg.discont) { for(i=1;i<=eg.discont;i++) SetDiscontinuousBoundary(&(data[k]),boundaries[k],eg.discontbounds[i-1],2,info); } } /* Divide quadrilateral meshes into triangular meshes */ for(k=0;k<nomeshes;k++) if(nogrids && (eg.triangles || grids[k].triangles == TRUE)) { Real criticalangle; criticalangle = MAX(eg.triangleangle , grids[k].triangleangle); ElementsToTriangles(&data[k],boundaries[k],criticalangle,info); } /* Make a boundary layer with two different methods */ if(eg.layers > 0) for(k=0;k<nomeshes;k++) CreateBoundaryLayer(&data[k],boundaries[k],eg.layers, eg.layerbounds, eg.layernumber, eg.layerratios, eg.layerthickness, eg.layerparents, eg.layermove, eg.layereps, info); else if(eg.layers < 0) for(k=0;k<nomeshes;k++) CreateBoundaryLayerDivide(&data[k],boundaries[k],abs(eg.layers), eg.layerbounds, eg.layernumber, eg.layerratios, eg.layerthickness, eg.layerparents, info); /* Take up the infor on rotation */ for(k=0;k<nogrids;k++) if( grids[k].rotatecurve ) { eg.rotatecurve = TRUE; eg.curvezet = grids[k].curvezet; eg.curverad = grids[k].curverad; eg.curveangle = grids[k].curveangle; } if(outmethod != 1 && dim != 2 && eg.dim != 2) { j = MAX(nogrids,1); for(k=0;k<j;k++) { if(grids[k].dimension == 3 || grids[k].rotate) { boundaries[j] = (struct BoundaryType*) malloc((size_t) (MAXBOUNDARIES)*sizeof(struct BoundaryType)); for(i=0;i<MAXBOUNDARIES;i++) boundaries[j][i].created = FALSE; CreateKnotsExtruded(&(data[k]),boundaries[k],&(grids[k]), &(data[j]),boundaries[j],info); if(nogrids) { elements3d = MAX(eg.elements3d, grids[k].wantedelems3d); nodes3d = MAX(eg.nodes3d, grids[k].wantednodes3d); if(elements3d) { if( abs(data[j].noelements - elements3d) / (1.0*elements3d) > 0.01 && elementsredone < 5 ) { grids[k].wantedelems *= pow(1.0*elements3d / data[j].noelements, (2.0/3.0)); elementsredone++; } else elementsredone = 0; } else if(nodes3d) { if( abs(data[j].noknots - nodes3d) / (1.0*nodes3d) > 0.01 && elementsredone < 5 ) { grids[k].wantedelems *= pow(1.0*nodes3d / data[j].noknots, (2.0/3.0)); elementsredone++; } else elementsredone = 0; } if(elementsredone) { nomeshes = 0; for(i=0;i < nogrids;i++) SetElementDivision(&(grids[i]),eg.relh,info); DestroyKnots(&data[j]); DestroyKnots(&data[k]); free(cell[k]); if(info) printf("Iteration %d of elements number targiting %d in 2D\n", elementsredone,grids[k].wantedelems); goto redoelements; } } data[k] = data[j]; boundaries[k] = boundaries[j]; } } } /* If the original mesh was given in polar coordinates make the transformation into cartesian ones */ for(k=0;k<nomeshes;k++) { if(eg.polar || data[k].coordsystem == COORD_POLAR) { if(!eg.polar) eg.polarradius = grids[k].polarradius; PolarCoordinates(&data[k],eg.polarradius,info); } } /* If the original mesh was given in cylindrical coordinates make the transformation into cartesian ones */ for(k=0;k<nomeshes;k++) { if(eg.cylinder || data[k].coordsystem == COORD_CYL) { CylinderCoordinates(&data[k],info); } } if(1) for(k=0;k<nomeshes;k++) RotateTranslateScale(&data[k],&eg,info); /* Rotate may apply to 2d and 3d geometries as well */ for(k=0;k<nomeshes;k++) if(eg.rotatecurve) CylindricalCoordinateCurve(&data[k],eg.curvezet,eg.curverad,eg.curveangle); /* Unite meshes if there are several of them */ if(eg.unitemeshes) { for(k=1;k<nomeshes;k++) UniteMeshes(&data[0],&data[k],boundaries[0],boundaries[k],info); nomeshes = nogrids = 1; } if(eg.clone[0] || eg.clone[1] || eg.clone[2]) { for(k=0;k<nomeshes;k++) { CloneMeshes(&data[k],boundaries[k],eg.clone,eg.clonesize,FALSE,info); mergeeps = fabs(eg.clonesize[0]+eg.clonesize[1]+eg.clonesize[2]) * 1.0e-8; MergeElements(&data[k],boundaries[k],eg.order,eg.corder,mergeeps,TRUE,TRUE); } } if(eg.mirror[0] || eg.mirror[1] || eg.mirror[2]) { for(k=0;k<nomeshes;k++) { MirrorMeshes(&data[k],boundaries[k],eg.mirror,FALSE,eg.clonesize,eg.mirrorbc,info); mergeeps = fabs(eg.clonesize[0]+eg.clonesize[1]+eg.clonesize[2]) * 1.0e-8; MergeElements(&data[k],boundaries[k],eg.order,eg.corder,mergeeps,FALSE,TRUE); } } /* Naming convection for the case of several meshes */ if(nomeshes > 1) { strcpy(prefix,eg.filesout[0]); for(k=0;k<nomeshes;k++) sprintf(eg.filesout[k],"%s%d",prefix,k+1); } for(k=0;k<nomeshes;k++) { if(nogrids && grids[k].reduceordermatmax) { eg.reduce = TRUE; eg.reducemat1 = grids[k].reduceordermatmin; eg.reducemat2 = grids[k].reduceordermatmax; } if(eg.reduce) ReduceElementOrder(&data[k],eg.reducemat1,eg.reducemat2); } for(k=0;k<nomeshes;k++) if(eg.increase) IncreaseElementOrder(&data[k],TRUE); for(k=0;k<nomeshes;k++) { if(eg.merge) MergeElements(&data[k],boundaries[k],eg.order,eg.corder,eg.cmerge,FALSE,TRUE); else if(eg.order == 3) #if PARTMETIS ReorderElementsMetis(&data[k],TRUE); #else printf("Cannot order nodes by Metis as it is not even compiled!\n"); #endif else if(eg.order) ReorderElements(&data[k],boundaries[k],eg.order,eg.corder,TRUE); if(eg.isoparam) IsoparametricElements(&data[k],boundaries[k],TRUE,info); }