Example 21l: Face fitting in volume elements with collapsed nodes and version mapping

Created January 2005 by Glenn Ramsey. Based on example 21h.

This example illustrates face fitting of a volume element which has collapsed nodes with mapping of the common derivative versions between the collapsed nodes.

Example 21h also demonstrates fitting with collapsed nodes but in that example the derivatives of the line connecting the two collapsed nodes are fixed and the line does not get fitted.

Figure 1. shows the initial unfitted mesh. Figure 2 shows the fitted mesh without the C0 continuity having been enforced. Figure 3. shows the element correctly fitted without mesh anomalies. This can be achieved by enforcing C0 continuity either automatically (using fem define coordinates) or manually (using fem define mapping).

See also the comments in the com file.

In some combinations of collapsed elements and inconsistent element coordinate (xi) directions the automatic mappings may not be correctly determined and manual mappings may need to be specified (using fem define mapping), but in this case the automatic mappings are correct.

The large RMS errors in the fitted meshes in this example compared with example 21h may indicate that (some of) the smoothing parameters are too large.

Fig. 1. Initial Mesh.

RMS Error = 10.0 mm

Fig. 2. Fitted mesh without mapping for C0 continuity.

RMS Error = 4.0 mm

Fig. 3. Fitted mesh with mapping for C0 continuity.

RMS Error = 4.1 mm

The comfile run by this example is as follows:

# Face fitting with collapsed nodes and version mapping.
# Created 23/1/2005 by Glenn Ramsey
# Based on example 21h.

set dir example 21l
# Set up a path to use so that the Perl stuff can find the files. I expected
# the above to do this but it doesn't.
$epath = "$ENV{CMISS_EXAMPLES}/2/21/21l/cmiss_input/";

use lib "$ENV{CMISS_ROOT}/cmiss_perl/lib";

use strict;
use warnings;

use CmUtils::File::Ipnode qw( readIpnode);
use CmUtils::File::Ipfiel qw( writeIpfiel );
use CmUtils::File::Ipelem qw( readIpelem );
use CmUtils::File::Ipelfd qw( writeIpelfd );

# 0 for automatic mappings; 1 to read in manual mappings.
$manual_mappings = 0 unless defined $manual_mappings;

$name = 'collapse';

# To use manual mappings; in the ippara file USE_MAPS needs to be set to 1
# and NYYM may need to be increased depending on the problem. 
fem def para;r;${name};example          # Declares array dimensions

fem def coord;r;${name};example         # Defines the coordinate system
# substitute the above line with the one below and see what happens
#fem def coord;r;${name}_nomap;example

fem def base;r;${name}_cubic;example    # Defines tri-cubic Hermite basis funcs.
fem def node;r;${name}_version;example  # Reads nodal information
fem def elem;r;${name}_version;example  # Read 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 update scale_factor normalise;

# export the initial mesh for viewing
fem export node;${name}_initial as ${name}_initial offset $offi;
fem export elem;${name}_initial as ${name}_initial offset_node $offi offset_elem $offi;

# In order for the fitting to work properly you must define some fields
# that have exactly the same topography as the mesh. There are some
# Perl utilities which can help with that, otherwise you'll have to do
# it by hand.

# # Use the Perl utilities to create a field that matches the node geometry.
# # First write out the updated nodes. 
# fem def nodes;w;${name}_version_auto;example 
# # then convert to a field
# @ngr = readIpnode($epath.${name}."_version_auto");
# $options->{fields} = "coordinates";
# $options->{noVersions} = 0;
# $options->{noDerivatives} = 0;
# writeIpfiel($epath.${name}."_version_auto", @ngr, $options);
# # read in the field we just created
# fem def field;r;${name}."_version_auto";example

# If no field already exists then this command creates one matching
# the geometry. If a field that doesn't match the geometry already
# exists then its values are updated but the field is not changed (gotcha!)
fem update field from geometry

# Create a field that matches the elements.
# As of 21/1/2005 the default for "fem define elements;d field" is to copy
# the geometry elements so the code below is not required, but it is left
# here for reference.
# @egr = readIpelem(${name}."_version", @ngr);
# $options->{versions} = 1;
# writeIpelfd(${name}."_version_auto", \@egr, $options);
#fem def elem;r;${name}_version_auto;example field

fem define elements;d field # create an element field matching the geometry 

# Write out the fields so we can check them manually.
fem def field;w;${name}_created_field
fem def elem;w;${name}_created_field field

# The set of faces which will be fitted to the data needs to be defined.
# There are a number of filters which can be used such as XiN high/low,
# external and element groups. Also face numbers can be specified but 
# that is tedious and might need to be redone if the mesh changes.
# E.g. fem group faces all Xi3 high elements MY_ELEM_GROUP
# See fem group faces ? for complete list of options.

# Here we use the external faces which is the same as all in this case.
fem group faces allfaces external as EXT_FACES   # Defines face group of external faces

fem def data;r;${name};example              # Reads in data to fit to

fem def xi;c closest_face faces EXT_FACES   # Projects data onto faces
                                            # only in group EXT_FACES
fem def xi;w;${name} closest_face faces EXT_FACES  # Writes out xi positions
fem li data error;

fem export data;${name} as ${name}

for ($fit_itt=1; $fit_itt<=$tot_itt; $fit_itt++)
    if( $manual_mappings )
	# With manual mappings, the derivatives in the collapsed direction on
	# the collapsed face need to be manually constrained to zero.
	fem def fit;r;${name}_manual_${fit_itt};example geometry faces EXT_FACES;
	fem define mapping;r;${name};example;
	fem def fit;r;${name}_${fit_itt};example geometry faces EXT_FACES;
   fem fit
#   fem list map;${name}-mesh-${fit_itt} using fit
#   fem list map;${name}-solution-${fit_itt} solution using fit
   fem update node fit
   fem update scale_factor normalise
   fem def xi;c closest_face faces EXT_FACES old

   system "echo ' ======================================================' "    
   fem li data error
   system "echo ' ITERATION ${fit_itt} DONE' "
   system "echo ' ======================================================' "
fem export nodes;${name}_fitted as ${name}_fitted offset $off;
fem export elem;${name}_fitted as ${name}_fitted offset_node $off offset_elem $off;
fem quit

Files used by this example are:

Name                     Modified     Size

example_21l.com 29-Aug-2006 5.2k collapse.ipcoor 24-Jan-2005 688 collapse.ipdata 24-Jan-2005 26k collapse.ipmap 24-Jan-2005 7.5k collapse.ippara 24-Jan-2005 5.9k collapse_1.ipfit 13-Apr-2007 2.2k collapse_2.ipfit 13-Apr-2007 2.2k collapse_cubic.ipbase 24-Jan-2005 4.4k collapse_manual_1.ipfit 13-Apr-2007 5.3k collapse_manual_2.ipfit 13-Apr-2007 5.3k collapse_nomap.ipcoor 24-Jan-2005 570 collapse_version.ipelem 24-Jan-2005 1.3k collapse_version.ipnode 24-Jan-2005 13k viewfit.com 24-Jan-2005 1.9k

Download the entire example:

Name                      Modified     Size

examples_2_21_21l.tar.gz 14-Apr-2007 87k

Testing status by version:

StatusTestedReal time (s)
cmSuccessSun Mar 6 00:01:39 20162
cm-debugSuccessSat Mar 5 00:05:04 20162
cmSuccessSun Aug 19 01:37:13 20079
cm-debugSuccessWed Aug 15 01:35:52 200723
cm-debug-clear-mallocSuccessSat Aug 18 01:44:04 200732
cm-debug-clear-malloc7SuccessMon Aug 20 01:39:58 200733
cm64SuccessSun Aug 19 01:37:44 200710
cm64-debugSuccessTue Aug 21 01:33:11 200724
cm64-debug-clear-mallocSuccessTue Aug 29 13:45:51 200642
cmSuccessWed Mar 4 01:09:29 20092
cm-debugSuccessMon Mar 2 01:09:28 20096
cm64SuccessWed Mar 4 01:09:29 20092
cm64-debugSuccessTue Mar 3 01:14:06 20096
cmSuccessSun Mar 6 00:01:01 20161
cm-debugSuccessSat Mar 5 00:01:40 20162

Testing status by file:

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

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

CMISS Help / Examples / 2 / 21 / 21l