Extracting and Merging
Extracting and Merging
1.0
Introduction In The Basics tutorial, we learned how to increase the mesh density in order to improve the model solution. In this tutorial, we will learn another method of increasing the mesh density for the purpose of obtaining a more detailed solution in a particular region of an existing mesh. This process involves a number of steps. First, a boundary is extracted from within a previously solved mesh. This boundary is then used to develop a new submesh with a mesh density that is far greater than its larger parent mesh. A flow solution is then obtained for the submesh independently of the parent mesh. Finally, the solution from the submesh is then inserted into the parent mesh so that the combined solution can be examined. This method of obtaining a more detailed solution in a particular region is a useful tool on a couple of levels. One, it can be used to improve the model solution in a region of the domain without having to rerun the entire domain (unlike the method described in The Basics tutorial). Two, it can be used to assess the quality of the solution in the larger parent mesh, as will be demonstrated at the end of this module. To complete this tutorial we will use the Fortress site along the Kananaskis River in Alberta. This is the same site that was used in The Basics tutorial. All of the files that you will need can be found in the folder, in which you found this document, entitled R2D_Extracting_and_Merging. You will also need R2D_Mesh and River2D programs which you can obtain from the River2D website if you have not already. www.river2d.ca
2.0
Boundary Extraction In order to obtain a solution to the submesh, the boundary conditions along the computational boundary defining the submesh must be known. These include inflow, outflow and no flow boundary conditions. If the extracted boundary extends across the computational domain of the parent mesh, then the boundary conditions are known to be inflow at the upstream end, outflow at the downstream end, and no flow at the sides of the domain. However, if the entire boundary is within the flow, then the problem is no longer trivial. For this reason, the boundary extraction
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002 1
process in River2D involves using the concept of streamlines. Streamlines are lines of constant stream function and are, by definition, no flow boundaries within the flow. Therefore, they are logical locations of no flow boundaries for a submesh. For a more detailed treatment of the theory of stream function and streamlines, please refer to the River2D users manual. Before we can extract a boundary, we must select an area for which we would like to have a more detailed solution. 1 2 3 Launch River2D if you have previously closed it. Open fortnewfinal.cdg. Choose Display > Vector. Set the Vector Plot dialog so that it appears as shown below and then press the OK button.
Zoom in on the area around the island so that you can see the details of the flow around the island as shown below.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
In part 6.0 of River2D: The Basics, we looked at increasing the mesh density to resolve the solution in the left channel. In this part of the tutorial, we will look at obtaining a more detailed solution in the right channel. The solution in this channel might be of interest for fish habitat reasons because the velocities are so low, compared to the left channel, as seen in the figure above.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002 3
In River2D, only simple boundaries can be extracted. That is, ones with only one inflow and one outflow (and therefore two no flow boundaries separating the inflow and outflow). Since the boundary will be defined using streamlines, we must first locate the streamlines in the flow. This is accomplished by calculating the stream function for the domain. The stream function is also a measure of the cumulative discharge across a channel. For this reason, the command for calculating stream function in River2D is called Cumulative Discharge. The cumulative discharge is a function of the discharge intensities of the flow. Therefore, if the discharge intensities are zero, which is the case before a flow solution is obtained (initial conditions), then the cumulative discharge will also be zero. As a result, the cumulative discharge should only be calculated once a converged steady state solution is obtained. The Cumulative Discharge command, which is found under the Flow menu, can be accessed at any time, but the streamlines that result may not represent the no flow boundaries in the steady state solution if solution convergence has not yet been reached. We will now calculate the cumulative discharge for the Fortress site. 5 Choose Flow > Cumulative Discharge. This initiates the calculation of the cumulative discharge. When the calculations are done, you should see the following.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
River2D automatically displays the cumulative discharge as a colour map to indicate to the user that the calculations are complete. 6 Now run the mouse across the colour map from left to right and watch the values of cumulative discharge change in the status bar.
You should see the values increase from 0 to the total discharge in the channel when you move the mouse from right to left across the domain. You should also notice that the values of cumulative discharge are relatively constant when traversing across the island. This makes sense since there is no flow through the island (except maybe a very small
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002 5
amount of groundwater flow) and therefore no discharge should be accumulating across the island. The transitions between the colours in the colour spectrum are lines of constant cumulative discharge or streamlines. The streamlines that we see in the colour map are just the ones that are defined at the transition between one colour to the next in the colour map, which is a function of the range of values each colour represents. In fact there are an infinite number of streamlines in the flow, one for every value of cumulative discharge in the domain. Before we can extract a boundary, we must first decide where we would like this boundary. We have already decided that we are going to improve the solution in the right channel. Therefore we need a boundary that incorporates this region of the computational domain. We must first choose the location of the no flow boundaries. The most logical location for the no flow boundaries is the waters edge on either side of the right channel. This is because the waters edge is physically a no flow boundary and is therefore by definition a streamline. Unfortunately the streamlines that are defined by the cumulative discharge tend to be jagged near the waters edge. Near the waters edge there is little flow and the calculated velocity vectors in this region have a tendency to be a bit erratic. The cumulative discharge solution is based on the velocity vectors, hence the jaggedness of the streamlines in these low flow regions. Unfortunately a jagged streamline would not make a good no flow computational boundary. Smooth streamlines are preferred to give reasonable computational results. We can examine the jaggedness of the streamlines near the waters edge by setting the user defined range in the colour map such that the limits of the range are set to the approximate values of cumulative discharge (representing streamlines) near the waters edge. Examination with the mouse reveals that that the cumulative discharge goes from around 0 to approximately 0.6 in the right channel. Using these values we will now modify the colour map to display this range of cumulative discharge.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
Choose Display > Contour/Colour In the section of the Contour dialog box labelled Colour Range, select radio button that allows a user defined range. Enter the values of 0 and 0.6 in the minimum and maximum edit boxes respectively. Click the OK button to accept the changes and to close the dialog box.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
As you can see these lines of constant cumulative discharge, or streamlines, would not be very reasonable no flow boundaries. 9 Try changing the minimum and maximum values for the colour range until you see a smooth streamlines develop.
Smooth line starts to develop when the minimum and maximum values of the range are set to 0.02 and 0.53 respectively. If you set the user defined range using these values you should see the following.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
These two streamlines define what is called a stream tube. Unfortunately this stream tube only encompasses a portion of the right channel. But we would like to extract a boundary that includes all of the water in the right channel. Although the streamlines are not smooth near the waters edge, the depth contours are. For this reason, River2D has been designed to allow the user to extract a no flow boundary a few different features: a streamline, a depth contour, or a no flow boundary in the parent mesh. This gives the user a little more flexibility in how boundaries are extracted. Because of the poorly defined streamlines in the regions where we would like to locate our no flow boundaries, we will use the depth contours that define the waters edge (which is a physical no flow boundary). The waters edge that you see in River2D is actually the 0.02 m depth contour. To ensure that we incorporate the entire width of water in the right channel we will use the 0.02 depth contour to define both of the no flow boundaries in our submesh. We now need to select locations for the upstream (inflow) and downstream (outflow) boundaries for our stream tube. Both inflow and outflow boundary sections should be located where the velocity vectors are relatively parallel to the chosen no flow boundaries. This is for two reasons. One, hydrodynamic computations in River2D assume that there is no tangential component to the flow at inflow sections; all of the flow is perpendicular to the section. Therefore any tangential component to the flow will be neglected at the inflow section of our stream tube. Two, the flow sections are located by River2D using user defined points, one point for each section. The strike of a section is determined using the direction that is orthogonal to the velocity vector at the user-defined point. At each flow section, the flow boundary conditions must be known. River2D determines these for you. At the inflow section, a constant inflow discharge is assumed. The value of the inflow discharge is calculated as the difference in cumulative discharge across the inflow section. At the outflow section, a constant water surface elevation is assumed across the section. Therefore the outflow section for our stream tube should be located where the water surface elevation is constant between the two defining no flow boundaries. To check whether the water surface elevation is relatively constant at the desired location for the outflow section, set the colour map to display water surface elevation. Run the mouse between the locations of the two chosen no flow
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002 9
boundaries and watch the value of water surface elevation in the status bar. If the values do not change very much between the two boundaries (use your judgement), then the section is probably a reasonable outflow section for the boundary being extracted. In this tutorial, we will use the following points to describe our inflow and outflow sections: Inflow: x1 = 5024.4, y1 = 4977.6 Outflow: x2 = 5017.5, y2 = 5060.1 These points were selected using the above-described criteria for appropriate locations for inflow and outflow boundaries. We now have all the information that Rive2D needs to extract the boundary from the model. 10 Choose Mesh Edit > Extract Boundary This opens the Extract Boundary dialog box. Select the appropriate radio buttons and fill in the fields so that the dialog box appears as shown below.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
10
The last field is the node spacing along the extracted boundary. If this number is too large then the no flow boundaries may be too angular. You may experiment with this value if you like. Here we will use a node spacing of 2.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
11
11 When you have made all the appropriate changes to the dialog box, click the OK button. 12 This will open a Save As dialog box. Navigate to the R2D_Extracting_and_Merging folder and save the boundary as my_boundary.msh. 3.0 Submesh Development Now that we have the boundary defined in a mesh file, we can use R2D_Mesh to create a submesh based on this computational boundary. 1 Launch R2D_Mesh. (If you do not have this program you can obtain it from the River2D website.)
To develop the mesh, we need to open the bed topography file for the Fortress site. 2 Choose File > Open Bed File. This opens an Open dialog box. Navigate to the R2D_Extracting_and_Merging folder and select Fort.bed file to be opened. Click the OK button to close the dialog box and open the file.
Now that we have opened the bed topography we can bring the boundary into the mesh editor and start creating a mesh. 3 Choose File > Open Mesh File. Open my_boundary.msh (or if you are just joining in boundary.msh.)
With both of these files loaded into the R2D_Mesh environment, you should see the following if you zoom into the area around the island.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
12
The mesh development process can be quite an art. But for the purpose of this tutorial we will just create a very simple mesh.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
13
Choose Generate > Uniform Fill. This opens the following dialog.
5 6
Enter a value of 1.0 as the desired spacing and then click the OK button. This opens another dialog box as shown below.
Leave the default value of 0 as the desired angle for the nodes and then click the OK button.
This will fill the boundary will uniformly distributed nodes. We will now triangulate and smooth the mesh. 8 9 Choose Generate > Triangulate or click the the nodes into the mesh. button to incorporate
Choose Generate > Smooth. Repeat until the number of nodes is no longer changing in the status bar.
If you zoom in on the mesh, your mesh should look similar to the one shown below.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
14
We chose a spacing of 1 so that we have a mesh that is significantly denser than the parent mesh from which it was derived. We will now save the mesh to a River2D input file.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
15
10 Choose File > Save As River2D Input File. In the Save As dialog box, navigate to the R2D_Extracting_and_Merging folder and save the file as my_submesh.cdg. Before the file can be saved, the initial water surface profile (for the hydrodynamic computations) must be set. R2D_Mesh generates a planar water surface throughout the domain. The slope of the water surface is determined from the water surface elevation at the downstream boundary and an estimate of the water surface elevation at the upstream boundary. After you have saved the mesh to the cdg file, the following dialog box will appear. We will use an elevation of 199.35 m as our estimate of the water surface elevation at the upstream end. This value is based on the water surface elevation in the Fortress site at the location of the inflow section. This value is intentionally a little greater than the elevation in the model. This is because the hydrodynamic computations progress more quickly if the initial water surface is greater than that of the final steady state solution.
11 Enter a value of 199.35 in the Save As CDG2D File dialog box and click the OK button. We will now save the mesh to .msh file. 12 Choose File > Save As Mesh. Save the mesh my_submesh.msh in the appropriate folder. We will now return to the River2D environment to obtain a hydrodynamic solution for our new submesh.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
16
13 Launch River2D if you closed it earlier and open my_submesh.cdg. Change the display so that water surface elevation is displayed as a colour map. Your mesh should look similar the one shown below.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
17
14 Choose Flow > Run... This will open the run dialog box. Leave all of the parameters as is except for the Final time. Set this to 2000 and then press the Run button. 15 When the model has stopped the Run dialog box should appear as shown below.
Since the Solution change and the Net Outflow fields both have very small numbers, it is fair to say that the solution has converged to steady state. 4.0 Mesh Merging Now that we have a steady state solution, we will now combine the results from our submesh with the results from the original Fortress site so that we may see how the solution has changed from increasing the mesh density.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
18
1 2 3
Choose File > Save As. Save the results as my_submeshfinal.cdg in the R2D_Extracting_and_Merging folder. Open fortnewfinal.cdg Zoom in on the area around the island and set the display so that the mesh is visible.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
19
Choose Mesh Edit > Mesh Merge This will open the Mesh Merging Options dialog box as shown below.
In River2D, there are two ways to combine the results of two meshes. In the Region Replace option the nodes from the primary mesh (in our case, the original Fortress mesh) that are inside the boundary of the secondary mesh (in our case, the submesh) are deleted and all of the nodes from the secondary mesh within the boundary of the primary mesh are inserted into the primary mesh. In the Information Transfer option, all of the information (bed and flow) from the nodes in the secondary mesh within the boundary of the primary mesh is interpolated and transferred to the nodes in the primary mesh. For this tutorial, we will choose the Region Replace option. 5 6 Select the Region Replace radio button and click the OK button. This brings up an Open dialog box. Navigate to the R2D_Extracting_and_Merging folder and select the my_submeshfinal.cdg file (or submeshfinal.cdg if you are just joining in).
Once the meshes have been merged the display will update and should appear as follows.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
20
Note the significant increase in node density in the right channel. With the two meshes combined, we can now look at the changes, if any, to the solution in refined region in comparison to the surrounding coarser region. If you display a colour map of the velocity magnitude you should see the following.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
21
As you can see there the velocities in the refined region have changed. The question we need to ask is Are these changes significant or not? If they are not significant, then we should feel confident accepting the new more refined solution. If they are significant then, it is probable that the parent mesh was too coarse to provide accurate boundary conditions for the submesh, in which case we have two options. One, we could smooth the combined mesh and run it again so that the refined region is not affected by boundary conditions. Two, we could start all over again with an
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002 22
entirely new parent mesh. Although the first option may not be very feasible if the combined mesh has a very large number of nodes (which will take a long time to run). We can also look at the changes in water surface elevation to assess the quality of the solution. For example, if you display a colour map with a user defined colour range (maximum 199.4 and minimum 199.3), you should see the following.
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
23
Notice how the water surface elevation is lower in the refined region than it is in the surrounding region. This is probably because finer discretizations are better at modelling the bed topography, which tends to result in better flow conveyance. Because the discharge is not changing but the conveyance is increasing, the water level has a tendency to drop. Since the Fortress site is not very large, you may wish to try the first option and run the combined mesh. 5.0 Concluding Remarks This concludes the Boundary Extracting and Mesh Merging tutorial. For more information on the topics covered in this tutorial, please refer to the River2D User Manual. If you have any questions regarding this tutorial, please feel free to contact the authors. Julia Blackburn Peter Steffler Email: [email protected] Email:[email protected]
River2D Tutorial Boundary Extracting and Mesh Merging September 30, 2002
24