Example ed5: 3D potential gradient domain solution

This example demonstrates potential gradient domain solutions in three dimensions on a spherical BEM mesh solving Laplace's equation with an analytic solution. The gradients are calculated directly from the nodal solutions.


The comfile run by this example is as follows:

#
# Created by Martin Buist
# August 2001
#

if( !$example ) {
  $example = ".";
}

fem define para;r;$example/3dtest
fem define coord 3,1          
fem define regi;r;$example/3dtest
fem define node;r;$example/8x8
fem define node;r;$example/3dtest reg 2
fem define bas;r;$example/test
fem define elem;r;$example/8x8
fem define elem;r;$example/3dtest reg 2
fem define grid;r;$example/3dtest reg 2
fem update grid geometry reg 2
fem define equation;r;$example/bemsphere cl 1 lock
fem define equa;r;$example/3dtest cl 2 lock reg 2
fem define material;r;$example/bemsphere 
fem define anal;r;$example/bemsphere
fem define initial;g 
fem define solve;r;$example/bemsphere
fem solve

fem eval solu grid elem 101 iy 1 gradient
fem export elem;dpotexdebug as test field reg 2 class 2 iy 2
fem export elem;dpoteydebug as test field reg 2 class 2 iy 3
fem export elem;dpotezdebug as test field reg 2 class 2 iy 4

fem eval solu grid elem 101 iy 1 gradient opti
fem export elem;dpotex as test field reg 2 class 2 iy 2
fem export elem;dpotey as test field reg 2 class 2 iy 3
fem export elem;dpotez as test field reg 2 class 2 iy 4

fem export node;geom as test reg 2
fem export elem;geom as test reg 2

sub WriteGradPhiExelem {

 ( $DXFILENAME, $DYFILENAME, $DZFILENAME, $OUTPUTNAME ) = @_;

  my $Found = 0;
  my $Found2 = 0;
  my $First = 1;
  my $InputLine = ' ';

  CORE::open( OUTPUTFILE,">$OUTPUTNAME" ) or die( "ERROR: Unable to open output file\n" );
  CORE::open( INPUTFILE,"<$DXFILENAME" ) or die( "ERROR: Unable to open DX input file\n" );

  while( <INPUTFILE> ) {
		if( /Nodes:/ ) {
			$Inputline = $_;

			$Found2 = 0;
      CORE::open( INPUTFILE2,"<$DYFILENAME" ) or die( "ERROR: Unable to open DY input file\n" );
			while( <INPUTFILE2> ) {
				if( /Nodes:/ ) {
					$Found2 = 0;
				}
				if( $Found2 ) {
					print( OUTPUTFILE "$_" );
				}
				if( /Values:/ ) {
					$Found2 = 1;
				}
			}
			CORE::close( INPUTFILE2 );

			$Found2 = 0;
      CORE::open( INPUTFILE2,"<$DZFILENAME" ) or die( "ERROR: Unable to open DZ input file\n" );
			while( <INPUTFILE2> ) {
				if( /Nodes:/ ) {
					$Found2 = 0;
				}
				if( $Found2 ) {
					print( OUTPUTFILE "$_" );
				}
				if( /Values:/ ) {
					$Found2 = 1;
				}
			}
			CORE::close( INPUTFILE2 );

			print( OUTPUTFILE "$Inputline" );
		}
		if( !$Found ) {
			print( OUTPUTFILE $_ );
		} elsif( $First ) {
      print( OUTPUTFILE ' 1) gradphi, field, rectangular cartesian, #Components=3'."\n");
      print( OUTPUTFILE '   x.  l.Lagrange*l.Lagrange*l.Lagrange, no modify, grid based.'."\n");
			$First = 0;
		} 
		if( /Fields/ ) {
			$Found = 1;
		}
		if( /xi1/ ) {
			print( OUTPUTFILE $_ );
      print( OUTPUTFILE '   y.  l.Lagrange*l.Lagrange*l.Lagrange, no modify, grid based.'."\n");
	  	print( OUTPUTFILE $_ );
      print( OUTPUTFILE '   z.  l.Lagrange*l.Lagrange*l.Lagrange, no modify, grid based.'."\n");
			print( OUTPUTFILE $_ );
		}
		if(( /Element/ ) && $Found ) {
			print( OUTPUTFILE $_ );
			$Found = 0;	
    }
	}
  CORE::close( INPUTFILE );
  CORE::close( OUTPUTFILE );
  
} # WriteGradPhiExelem

$DXFILENAME = "dpotex.exelem";
$DYFILENAME = "dpotey.exelem";
$DZFILENAME = "dpotez.exelem";
$OUTPUTNAME = "GradPhi.exelem";

&WriteGradPhiExelem( $DXFILENAME, $DYFILENAME, $DZFILENAME, $OUTPUTNAME );

Additional testing commands:



Files used by this example are:

Name                Modified     Size

example_ed5.com 04-Sep-2001 3.2k 3dtest.ipbase 04-Sep-2001 2.4k 3dtest.ipelem 04-Sep-2001 422 3dtest.ipequa 26-May-2003 1.2k 3dtest.ipgrid 06-Mar-2003 605 3dtest.ipnode 04-Sep-2001 1.7k 3dtest.ippara 12-Nov-2002 5.9k 3dtest.ipregi 04-Sep-2001 93 8x8.ipelem 04-Sep-2001 21k 8x8.ipnode 04-Sep-2001 52k GradPhi.exelem 04-Sep-2001 42k bemsphere.ipanal 04-Sep-2001 591 bemsphere.ipequa 26-May-2003 1.4k bemsphere.ipmate 04-Sep-2001 54 bemsphere.ipsolv 13-Apr-2007 1.3k dpotex.exelem 04-Sep-2001 15k dpotexdebug.exelem 04-Sep-2001 15k dpotey.exelem 04-Sep-2001 15k dpoteydebug.exelem 04-Sep-2001 15k dpotez.exelem 04-Sep-2001 15k dpotezdebug.exelem 04-Sep-2001 15k geom.exelem 04-Sep-2001 3.6k geom.exnode 04-Sep-2001 1.0k test.ipbase 04-Sep-2001 6.8k test_output.com 04-Sep-2001 0

Download the entire example:

Name                      Modified     Size

examples_e_ed_ed5.tar.gz 14-Apr-2007 27k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:04:46 20165
cm-debugSuccessSat Mar 5 00:37:38 201625
mips-irix
cmSuccessSun Aug 19 02:28:12 200753
cm-debugSuccessWed Aug 15 03:30:20 2007305
cm-debug-clear-mallocSuccessSat Aug 18 03:46:22 2007310
cm-debug-clear-malloc7SuccessMon Aug 20 03:52:26 2007313
cm64SuccessSun Aug 19 02:29:14 200754
cm64-debugSuccessTue Aug 21 02:53:28 2007340
cm64-debug-clear-mallocSuccessThu Apr 1 12:32:04 2004137
rs6000-aix
cmSuccessWed Mar 4 01:13:25 20098
cm-debugSuccessMon Mar 2 01:30:10 2009104
cm64SuccessWed Mar 4 01:13:41 20098
cm64-debugSuccessTue Mar 3 01:34:26 2009108
x86_64-linux
cmSuccessSun Mar 6 00:01:15 20163
cm-debugSuccessSat Mar 5 00:03:39 201614

Testing status by file:


Html last generated: Sun Mar 6 05:51:36 2016

Input last modified: Fri Apr 13 10:43:19 2007


CMISS Help / Examples / e / ed / ed5