Example 21g: Face Fitting(geometric) in Volume Elements

This example shows fitting of faces in a volume mesh to a given set of data points. The Volume elements in the mesh are decomposed into faces. These faces are treated as area(2d) elements. Data points are then projected on to the faces such that the distance between a data point to the face is minimum. If the data point is within the purview of the face, the projection is 'orthogonal', otherwise it is non-orthogonal resulting the projection on to a side or on to a vertex of the face. For each face, an objective function is defined as the summation of the distances between each data point to its projection onto the face. Necessary number of linear equations are generated by differentiating the objective function wrt each nodal parameter (i.e. nodal value and derivatives of x,y and z) and equating the resulting expression to zero. In addition to this, Sobelov smoothing is also incorporated to control the arc curvature, arc length and the surface curvature of the face. Once face(element) equations are formulated, they are then assembled to give mesh (global)equations. The assembling is done to satisfy the continuity of the nodal values and nodal derivatives at the nodes common to different elements. For more details of the geometric fitting see Geometric modeling of the human torso using cubic hermite elements, Bradley et. al.

Created by : Kumar Mithraratne. Aug. 2002.

Initial Mesh

RMS Error = 7.427 mm

First Fit

RMS Error = 1.400 mm
Sobelov weights
faces 1,7 - 1.0e-5,7.5e-2,
faces 3..6,8..11 - 1.0e-5,

Second Fit

RMS Error = 1.038 mm
Sobelov weights
faces 1,7 - 1.0e-5,5.0e-2,
faces 3..6,8..11 - 1.0e-5,

Third Fit

RMS Error = 0.857 mm
Sobelov weights
faces 1,7 - 1.0e-5,2.5e-2,
faces 3..6,8..11 - 1.0e-5,

The comfile run by this example is as follows:


fem def para;r;$object;example       # Declares array dimensions   
fem def coord;r;$object;example      # Defines the coordinate system
fem def nodes;r;$object;example      # Reads in nodal information
fem def bases;r;$object;example      # Defines tri-cubic Hermite basis functions
fem def element;r;$object;example    # Reads in element information

fem update nodes derivative 1 linear # Updates the derivatives in all three
fem update nodes derivative 2 linear # xi directions
fem update nodes derivative 3 linear #

fem export node;${object}_initial as ${object}_initial offset $offi
fem export elem;${object}_initial as ${object}_initial offset_node $offi offset_elem $offi

#fem def field;r;$object;example      # Reads in field variables
#fem def elem;r;$object;example field # Defines connectivity of field variables
#fem update field from geometry       # Updates field 

# Instead of using the above 3 lines to read in a predefined field
# the following could be used to create is automatically. The created
# field will have the same topology as the geometry.
fem update field from geometry       # Updates field 
fem def elem;d  field

#fem group faces 1,3..11 as FFFFF     # Defines face group

# The faces could also be grouped using this command which
# avoids having to know what the face numbers are.
fem group faces allfaces external as FFFFF     # Defines face group

fem def data;r;$object;example       # Reads in data information     

fem def xi;c closest_face faces FFFFF           # Projects data onto faces
                                                # only in group FFFFF. 
#fem def xi;w;twocube closest_face faces FFFFF   # Writes out xi positions
                                                # of the projections.
fem export data;${object}_initial_error error as ${object}_initial_error
# Note that *.ipxi should contain DATA PT. NO., ELEM NO., LOCAL FACE NO., xi1, xi2 and xi3.

fem li data error                    # Lists initial data error

# Fitting is done iteratively. In this case three iterations. Since we do linear
# fitting, after each fit, scale factors are updated which results in change   
# in the shape of the fitted mesh. Thus, re-projection of data points onto the 
# new mesh is required prior to determining the error. Also note that for each 
# iteration, a new *.ipfit is read in. This helps to relax the Sobelov weights 
# gradually.
for ($fit_itt=1; $fit_itt<=$tot_itt; $fit_itt=$fit_itt+1)
   fem def fit;r;${object}_${fit_itt};example geometry faces FFFFF 
   fem fit
   fem update node fit
   fem update scale_factor normalise
   fem de xi;c closest_face faces FFFFF #old
   fem li data error
   system "echo ' ================' " 
   system "echo ' ITERATION ${fit_itt} DONE' "
   system "echo ' ================' "

fem export data;${object}_fitted_error error as ${object}_fitted_error offset $offd 
fem export nodes;${object}_fitted as ${object}_fitted offset $off
fem export elem;${object}_fitted as ${object}_fitted offset_node $off offset_elem $off

Additional testing commands:

fem list nodes

Files used by this example are:

Name                    Modified     Size

example_21g.com 31-Mar-2005 3.0k test_output.com 15-Aug-2002 15 twocube.exdata 15-Aug-2002 42k twocube.ipbase 15-Aug-2002 4.4k twocube.ipcoor 15-Aug-2002 570 twocube.ipdata 15-Aug-2002 53k twocube.ipelem 15-Aug-2002 802 twocube.ipelfd 15-Aug-2002 682 twocube.ipfiel 15-Aug-2002 19k twocube.ipnode 15-Aug-2002 18k twocube.ippara 12-Nov-2002 5.9k twocube.ipxi 15-Aug-2002 66k twocube_1.ipfit 13-Apr-2007 1.9k twocube_2.ipfit 13-Apr-2007 1.9k twocube_3.ipfit 13-Apr-2007 1.9k twocube_fitted.exelem 15-Aug-2002 12k twocube_fitted.exnode 15-Aug-2002 15k twocube_initial.exelem 15-Aug-2002 8.7k twocube_initial.exnode 15-Aug-2002 7.8k viewfit.com 21-Mar-2005 2.5k

Download the entire example:

Name                      Modified     Size

examples_2_21_21g.tar.gz 21-Feb-2013 111k

Testing status by version:

StatusTestedReal time (s)
cmSuccessSun Mar 6 00:02:57 20162
cm-debugSuccessSat Mar 5 00:14:22 20165
cmSuccessSun Aug 19 01:46:23 200715
cm-debugSuccessWed Aug 15 01:51:14 200760
cm-debug-clear-mallocSuccessSat Aug 18 02:05:50 200771
cm-debug-clear-malloc7SuccessMon Aug 20 02:07:10 2007124
cm64SuccessSun Aug 19 01:47:12 200716
cm64-debugSuccessTue Aug 21 01:52:06 200766
cm64-debug-clear-mallocSuccessThu Apr 1 10:11:45 200433
cmSuccessWed Mar 4 01:09:06 20092
cm-debugSuccessMon Mar 2 01:13:23 200918
cm64SuccessWed Mar 4 01:08:48 20092
cm64-debugSuccessTue Mar 3 01:18:29 200920
cmSuccessSun Mar 6 00:01:01 20161
cm-debugSuccessSat Mar 5 00:01:51 20162

Testing status by file:

Html last generated: Sun Mar 6 05:50:10 2016

Input last modified: Fri Apr 13 10:31:00 2007

CMISS Help / Examples / 2 / 21 / 21g