Example ed2: 2D potential gradient domain solution

This example demonstrates potential gradient domain solutions in two dimensions on a circular BEM mesh solving Laplace's equation with an analytic solution. It is the same as example ed1 except that gradients and not potentials are calculated. This example also includes a perl subroutine which is called within the comfile.


The comfile run by this example is as follows:

#
# Created by Martin Buist
# August 2001
#

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

fem define para;r;$example/bemcircle
fem define regi;r;$example/bemcircle
fem define node;r;$example/bemcircle reg 1
fem define node;r;$example/test reg 2
fem define base;r;$example/test
fem define elem;r;$example/bemcircle reg 1
fem define elem;r;$example/test reg 2
fem define grid;r;$example/test reg 2
fem update grid geometry reg 2

fem define equa;r;$example/bemcircle reg 1 cl 1 lock
fem define equa;r;$example/test reg 2 cl 2 lock
fem define mate;r;$example/bemcircle reg 1
fem define anal;r;$example/bemcircle reg 1
fem define init;g reg 1
fem define solv;r;$example/bemcircle reg 1

# Solve the BEM problem
fem solve reg 1
# Domain solution calculation - normal
fem eval solu grid elem 31 cpcutoff 0.9 gradient
fem export elem;test-debug as test reg 2 cl 2 field iy 2
fem export elem;test-debug2 as test reg 2 cl 2 field iy 3

# Domain solution calculation - optimised with adaptive integration
fem eval solu grid elem 31 opti cpcutoff 0.9 gradient

# Export dphi/dx
fem export elem;test-opti as test reg 2 cl 2 field iy 2
# Export dphi/dy
fem export elem;test-opti2 as test reg 2 cl 2 field iy 3

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

#Combine the two directions into a single file

sub WriteGradPhiExelem {

  my ( $DXFILENAME, $DYFILENAME, $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,"<$example"."/"."$DXFILENAME" ) or die( "ERROR: Unable to open DX input file\n" );

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

				$Found2 = 0;
        CORE::open( INPUTFILE2,"<$example"."/"."$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 );

				print( OUTPUTFILE "$Inputline" );
			}
			if( !$Found ) {
				print( OUTPUTFILE $_ );
			} elsif( $First ) {
        print( OUTPUTFILE ' 1) gradphi, field, rectangular cartesian, #Components=2'."\n");
        print( OUTPUTFILE '   x.  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, no modify, grid based.'."\n");
				print( OUTPUTFILE $_ );
			}
			if(( /Element/ ) && $Found ) {
				print( OUTPUTFILE $_ );
				$Found = 0;	
			}
	}
  CORE::close( INPUTFILE );
  CORE::close( OUTPUTFILE );
  
} # WriteGradPhiExelem

$DXFILENAME = "test-opti.exelem";
$DYFILENAME = "test-opti2.exelem";
$OUTPUTNAME = "gradients.exelem";

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

Additional testing commands:



Files used by this example are:

Name                Modified     Size

example_ed2.com 04-Sep-2001 2.9k bemcircle.ipanal 04-Sep-2001 492 bemcircle.ipelem 04-Sep-2001 4.1k bemcircle.ipequa 26-May-2003 1.2k bemcircle.ipmate 04-Sep-2001 54 bemcircle.ipnode 04-Sep-2001 5.1k bemcircle.ippara 12-Nov-2002 5.9k bemcircle.ipregi 04-Sep-2001 93 bemcircle.ipsolv 13-Apr-2007 1.4k gradients.exelem 04-Sep-2001 11k streamlines.com 04-Sep-2001 27k test-debug.exelem 04-Sep-2001 6.1k test-debug2.exelem 04-Sep-2001 6.1k test-opti.exelem 04-Sep-2001 6.1k test-opti2.exelem 04-Sep-2001 6.1k test.exelem 04-Sep-2001 1.4k test.exnode 04-Sep-2001 481 test.ipbase 04-Sep-2001 2.2k test.ipelem 04-Sep-2001 341 test.ipequa 26-May-2003 1.2k test.ipgrid 06-Mar-2003 538 test.ipnode 04-Sep-2001 805 test_output.com 04-Sep-2001 0

Download the entire example:

Name                      Modified     Size

examples_e_ed_ed2.tar.gz 14-Apr-2007 18k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:02:49 20161
cm-debugSuccessSat Mar 5 00:04:50 20161
mips-irix
cmSuccessSun Aug 19 01:31:07 20074
cm-debugSuccessWed Aug 15 01:27:58 200710
cm-debug-clear-mallocSuccessSat Aug 18 01:32:18 200714
cm-debug-clear-malloc7SuccessMon Aug 20 01:30:03 200714
cm64SuccessSun Aug 19 01:31:07 20075
cm64-debugSuccessTue Aug 21 01:26:42 200711
cm64-debug-clear-mallocSuccessThu Apr 1 12:28:39 20045
rs6000-aix
cmSuccessWed Mar 4 01:08:29 20091
cm-debugSuccessMon Mar 2 01:07:30 20093
cm64SuccessWed Mar 4 01:08:29 20091
cm64-debugSuccessTue Mar 3 01:12:22 20093
x86_64-linux
cmSuccessSun Mar 6 00:01:08 20160
cm-debugSuccessSat Mar 5 00:01:39 20160

Testing status by file:


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

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


CMISS Help / Examples / e / ed / ed2