This example demonstrates how to fit a 2D surface mesh to a cloud of data points. As the cloud of data points describe the surface of a truncated cone we use bicubic hermite surface elements to describe the curved surface.
The data points were generated from a perl script which is included along with the other files for this example. The script is not a shining example of how to generate data points but it does the job. Note that perl lends itself to quick and dirty development. It is excellent at getting the job done but when you write stuff in a hurry it is not always easy to understand. You may prefer to generate data points for regular meshes using softare such as Matlab.
The principal behind fitting is relatively simple but the difficulty in using cmiss to fit something is knowing exactly what syntax to use. I suggest if you are trying to accomplish a task similar to this example that you copy all the files from this directory and use it as a starting point. It is a lot easier to start from something that works and modify it to do what you want than to write something from scratch.
One point to note about the fitting in this example is that sobolev smoothing is used to avoid excessive wrinkling. This is not really necessary for this simple case of a truncated cone but I have included it as it can be required for more complicated geometries. If fitting a more complicated geometry you may want to change the sobelov smoothing factors to get a better fit. This will require a little experimentation to see what the effect of varying each is.
Also note that I have fixed the position of the bottom nodes of the truncated cone but NOT the top nodes. A better fit would be obtained by editing the ipnode file so that the top nodes were originally in the correct position and then holding their positions as fixed during the fit. However, it is instructive to see what happens at a boundary when nodes are not fixed, so I have left the narrower end free so that you can see what happens.
If you would like to view the initial mesh, data points and fitted mesh then run the cmgui comfile view_truncated_cone.com. It displays the original mesh as a wire frame, the data points in green and the fitted mesh as a gold surface, as shown in the image below:
Created by Peter Bier, May 2007.
# Example_21m Fitting a 2D bicubic hermite surface mesh to data points # on the surface of a truncated cone # Define a 3d rectangular cartesian coordinate system fem def coord 3,1 # Read the .ipbase file to define a bicubic hermite basis function # for the 2D elements fem def base;r;cylinder;example # Read in the .ipnode and .ipelem files that describe the initial mesh # which is to be deformed to fit the data. fem def node;r;cylinder;example fem def elem;r;cylinder;example # Note that although our basis function is bicubic hermite, # the initial mesh has nodal derivative values which are all zero, # which means it will be displayed as a linear mesh. # This is because the original ipnode file I used had NO derivative values # If you read in an ipnode file with no derivatives and then use a # cubic hermite basis you will get a warning from cmgui # (and the cmgui-debug-clear-malloc tests may fail) # To get rid of the warning simply write out your ipnode file # and it will write one with zeros for all the derivative values. # # The mesh is a linear approximation to a cylinder with a height of 2 # and a radius of 1, using 24 nodes and 16 elements # Around the circumference of the tube 8 elements are used # The tube is 2 elements high. # Export the unfitted nodes and elements to .exnode and .exelmem format # to view in cmgui. # This will allow us to compare the unfitted mesh against the fitted one fem export node;cylinder as cylinder fem export elem;cylinder as cylinder # Read in the .ipdata file to define the data points we will fit the mesh to. fem def data;r;truncated_cone;example # These data points are spread reguarly over the surface # of a truncated cone so were easily generated from a perl script. # Data points are often created using a tool like the zinc digitiser but # for regular geometries it can be quicker to write some computer # code to generate the points. Perl is a good language to use but # you could also easily write code to generate an ipdata file using matlab or # another language of your choice. # Calculate the xi projections of these data points onto the elements. # These projections are to be minimised (The basic idea behind fitting) fem def xi;c close # list out the error between the data points and the current mesh fem list data error # Define a default field for the nodes and elements # to create room for the fit variables fem def field;d fem def elem;d field # Define the fitting procedure by reading in the .ipfit file. fem def fit;r;truncated_cone;example geometry # You will notice in the .ipfit file there are parameters there # for smoothing via Sobolev weights on the derivatives. # These weights are used to remove excessive 'wrinkling' of the fitted # surface to your data. The smaller these numbers are, the closer # the fit 'hugs' the data and the more wrinkled it can become. # A good range for some examples seems to be between 10.0E-1 to 10.0E-6 # Also notice that the bottom 8 nodes have had their coordinates fixed # (but not their derivatives) # If you observe the postion of the bottom of the cone compared to the top # once it has been fitted you can then see the advantage of fixing # nodal positions on known boundaries. # Fit once, recalculate the xi projections and list the new error fem fit fem update node fit fem def xi;c close fem li data error # To get a better fit we can take the newly fitted mesh and fit it # again. Doing this several times usually results in a better fit. # Fit twice, recalculate the xi projections and list the new error fem fit fem update node fit fem def xi;c close fem li data error # Fit thrice, recalculate the xi projections and list the new error fem fit fem update node fit fem def xi;c close fem li data error # Write out the fitted node and elements to .ipnode and .ipelem format fem def node;w;"truncated_cone" fem def elem;w;"truncated_cone" # The fitted mesh is often written out to .ipnode and .ipelem format # for later use with cmiss. Remember it can be time consuming # to do a large fit, so once a fitted mesh is generated it is usual # to write it out to a format cmiss can read. # Export the nodes, elements and data points to view in cmgui fem export node;truncated_cone as truncated_cone fem export elem;truncated_cone as truncated_cone fem export data;truncated_cone as data # The .exnode .exelem and .exdata files for the truncated_cone can now # be read in to cmgui using the view_truncated_cone.com comfile. fem quit
Name Modified Size
example_21m.com 29-May-2007 4.4k create_truncated_cone_data.pl 23-May-2007 2.4k cylinder.exelem 23-May-2007 11k cylinder.exnode 23-May-2007 8.0k cylinder.ipbase 23-May-2007 1.5k cylinder.ipelem 23-May-2007 5.2k cylinder.ipnode 29-May-2007 21k tract.ipbase 23-May-2007 1.5k tract.ippara 23-May-2007 6.0k truncated_cone.ipdata 23-May-2007 73k truncated_cone.ipfit 23-May-2007 2.9k view_truncated_cone.com 23-May-2007 541
Name Modified Size
examples_2_21_21m.tar.gz 13-Jun-2007 127k
Status | Tested | Real time (s) | |
i686-linux | |||
cm | Success | Sun Mar 6 00:02:58 2016 | 1 |
cm-debug | Success | Sat Mar 5 00:12:45 2016 | 5 |
mips-irix | |||
cm | Success | Sun Aug 19 01:45:03 2007 | 14 |
cm-debug | Success | Wed Aug 15 01:46:43 2007 | 48 |
cm-debug-clear-malloc | Success | Sat Aug 18 01:56:30 2007 | 75 |
cm-debug-clear-malloc7 | Failure | Fri Jun 15 14:11:00 2007 | 1601696 |
last break | Mon May 28 01:16:00 2007 | 1601696 | |
last success | Mon Jun 11 01:59:00 2007 | 74 | |
cm64 | Success | Sun Aug 19 01:45:41 2007 | 14 |
cm64-debug | Success | Tue Aug 21 01:46:31 2007 | 50 |
rs6000-aix | |||
cm | Success | Wed Mar 4 01:08:01 2009 | 2 |
cm-debug | Success | Mon Mar 2 01:13:05 2009 | 15 |
cm64 | Success | Wed Mar 4 01:08:49 2009 | 2 |
cm64-debug | Success | Tue Mar 3 01:16:55 2009 | 16 |
x86_64-linux | |||
cm | Success | Sun Mar 6 00:01:01 2016 | 1 |
cm-debug | Success | Sat Mar 5 00:01:47 2016 | 3 |
i686-linux | |||
Success | cm: | ndiff test: no significant differences with generic answer. | |
Success | cm-debug: | ndiff test: no significant differences with generic answer. | |
mips-irix | |||
Success | cm: | ndiff test: no significant differences with generic answer. | |
Success | cm-debug: | ndiff test: no significant differences with generic answer. | |
Success | cm-debug-clear-malloc: | ndiff test: no significant differences with generic answer. | |
Success | cm-debug-clear-malloc7: | ndiff test: no significant differences with generic answer. | |
Success | cm64: | ndiff test: no significant differences with generic answer. | |
Success | cm64-debug: | ndiff test: no significant differences with generic answer. | |
rs6000-aix | |||
Success | cm: | ndiff test: no significant differences with generic answer. | |
Success | cm-debug: | ndiff test: no significant differences with generic answer. | |
Success | cm64: | ndiff test: no significant differences with generic answer. | |
Success | cm64-debug: | ndiff test: no significant differences with generic answer. | |
x86_64-linux | |||
Success | cm: | ndiff test: no significant differences with generic answer. | |
Success | cm-debug: | ndiff test: no significant differences with generic answer. |
Html last generated: Sun Mar 6 05:50:11 2016
Input last modified: Tue Jun 12 09:59:21 2007