### Tutorial

In this tutorial we will create the 2D domain skeched below.

1. Start Grid3D and create a new domain.

   Fire up a console and change to the base directory of Grid3D. You can start the program by typing

   java -jar grid3d.jar

   After a short time the main frame appears. Click on the button and enter the following values for the initial domain size: min=(0,0,0), max=(4,0.5,0). A new editor will now appear on Grid3D's desktop.

2. Create the enclosing segment list.

   Open the render options dialog by clicking on the button in the editor toolbar. Make sure that all Draw * entries except Draw boundary faces instead of boundaries are active. On the number tab, you might want to turn on number display for various grid items. Open the snapping tab and click on Add Grid..., and enter (2.5,0.32,1) for spacing. The new grid should appear in the list. Select that grid and choose Snap to selected grid before closing the dialog with Ok.

   Now open the context menu with space or with the middle mouse button and change to the Create SegmentList mouse mode. Alternatively, you can click on toolbar button . Move the mouse to coordinates (0,0,0) using the statusbar as orientation.

   With snapping enabled it should be quite easy to find that position. After a left click a small box should appear marking one point of your segment list. Repeat this for the positions (0, 0.32,0), (2.5,0.32,0) and (2.5,0,0). Open the context menu once again and choose Done!. Using the render options dialog, change the snapping mode to uniform snapping with a snapping factor of 0.01 and remove the grid.

3. Creating the circle.

   Change the mouse mode to Create circles. At position (0.5,0.2,0) click once to set the circle center. Then move the mouse to (0.45,0.2,0) and click again to create a clockwise circle with radius (0.05). A circle with small arrows pointing in clockwise direction appears..

   A counterclockwise circle encloses an area. For our domain we want to exclude the area inside the circle and use a clockwise one because of that. Generally speaking, the interior of a domain is always located to the left of a given boundary with respect to its orientation.

   By now you will probably notice that we created our segment list also clockwise. You can check by looking at the small arrows on the lines of the segment list. They are always pointing away from the enclosed area. Later on we will describe how to change its orientation.

4. Creating the inner nodes.

   The creation of inner nodes is quite simple. Switch to Create Points mode and make sure inner nodes are selected in the context menu. Now click into the domain to position the new nodes. Create two nodes on the left of the circle and five nodes on the right hand side getting more distance between them towards the end. The nodes should approximately be at the same height as the circle center

   Now we will adjust the nodes such that they have exactly the same coordiantes as the circle center. Switch to Select mode and select the inner nodes by drawing a box around them. This is called lasso selection. You can also select them in multiple steps by holding Shift while selecting them. At this point it is worth pointing out that there is a context help for the different mouse modes which may be invoked with F1.

   You can now move the selected nodes moving the mouse with the right mouse button pressed, but even with snapping this is quite tedious. So we use another method.

   Choose Show selection from the context menu and make sure that all seven inner nodes are selected. When you have other items in the list as well, just select an inner node from the list and press the button to deselect all items which are not inner nodes. (The button works the other way round. It deselects all items of that type.)

   Now invoke Browse selection from the context menu. A domain browser appears. Open the inner nodes entry in the tree view and mark all inner nodes by holding Ctrl while clicking on them. The right side of the dialog becomes an InnerNode editor. In the text field labeled Y, enter the new value 0.2 and activate the checkbox. Now click Apply and then Close to change the y coordinate of all selected inner nodes to 0.2.

   Move the mouse cursor above one of your inner nodes until its name appears in the statusbar. Then press Return to open an editor for that inner node. The entry for Y should now be 0.2.

   Finally add six more nodes, two above the circle, two below the circle and two more on the right. The distance between them should be a little less than the diameter of the circle.

5. Checking the domain.

   At this point we will check the domain by opening the validator. Click the button in the editor toolbar.

   On the options page unmark all points and click on Go. On the next page you will see a list of errors in your domain. Currently there should be only two:

   The segment list and the circle have entries with the following message:

   No BoundaryNode at t=0 found.

   FeatFlow needs a boundary node at position t=0 on every boundary to work correctly. We will keep that in mind for the next step.

6. Creating the boundary nodes.

   Now we create boundary nodes. In contrast to inner nodes, these are not positioned absolutely but relatively to a boundary. A boundary node at position t=0.5 on a segment list lies halfway through the first segment. At first, create six boundary nodes on the circle. To do this, use Add multiple parameter nodes (2D)... from the Coarse mesh menu. Select the circle from the Boundary combobox and enter 6 for Number of nodes. Also activate Create edges along boundary, because we have to do anyway later on and want to save time. When you open the validator once again you will see that the entry for the circle disappeared.

   We create the rest of the boundary nodes with the Create Points mouse mode. Switch the point type to Parameterized Boundary Nodes with the context menu. Place a node in every corner of the segment list. Holding Shift while doing so will make it easier for you to place the nodes. It restricts the value for t to multiples of 0.1. Ctrl does the same with multiples of 0.01. Use the domain browser to make sure that one of the nodes is on t=0.

   Place the rest of the boundary nodes next to the inner nodes. Take the picture below as reference.

   So far so good. A good time to save your progress. Select Domain/Save domain as/DevisorXML. You should always choose that format, because it is lossless.

7. Creating the edges.

   Beginning with the boundary node in the lower left corner add the boundary nodes on the segment list to the selection one by one. Be careful to select them in the same order as they are lying on the segment list. Otherwise you can change the order of the selected boundary nodes with the selection editor (Context menu/Show selection). Now choose Add edges cyclic from the context menu to connect every two successive nodes in the selection with edges. Add the other edges by selecting two nodes and choosing Add edges from the context menu (you can also press e to do this). Go on until your domain looks like the domain in the picture below.

8. Creating the quads.

   The creation of the quads is the easiest part. First choose Select all and then Add quads (2D) and you are done with it.

9. Changing the direction of the segment list.

   Surely you remember that we still have to change the direction of the segment list!? So Select all, Show selection, click on the segment list and press the button. The segment list should now be the only selected item. Go on by selecting Operations/Change direction of the selected boundaries and reparameterize from the context menu. That's it! The arrows on the segment list should now point outside.

10. Orthogonalize the elements.

    Now to some finetuning. Switch over to Orthogonalize quads mouse mode. Choose one of the quads which should be rectangular and click into a corner. This corner will be the reference corner. Grid3D now tries to make the quad rectangular. If you are not happy with the result you can press the right mouse button or click on in the editor toolbar to take the changes back.

11. Save in a usable file format.

    By now you should have successfully created the domain. Save it in a format you can use with FEAST (e.g. prm/tri or feast format) and try to run a simulation on the domain.