1 |
# This file is part of ff3d - http://www.freefem.org/ff3d |
# This file is part of ff3d - http://www.freefem.org/ff3d |
2 |
|
# Copyright (C) 2003 Laboratoire J.-L. Lions UPMC Paris |
3 |
|
|
4 |
# This program is free software; you can redistribute it and/or modify |
# This program is free software; you can redistribute it and/or modify |
5 |
# it under the terms of the GNU General Public License as published by |
# it under the terms of the GNU General Public License as published by |
47 |
|
|
48 |
# Runs ff3d and stores its output into $output |
# Runs ff3d and stores its output into $output |
49 |
$output = `../ff3d test.ff`; |
$output = `../ff3d test.ff`; |
50 |
die "*** ff3d could not be run" if $?; |
if($?){ |
51 |
|
print $output; |
52 |
|
die "*** ff3d crashed"; |
53 |
|
} |
54 |
} |
} |
55 |
|
|
56 |
# Checks that one expected result (expressed as a regexp) is present |
# Checks that one expected result (expressed as a regexp) is present |
60 |
sub LineCheck{ |
sub LineCheck{ |
61 |
my ($expect) = @_; |
my ($expect) = @_; |
62 |
if($output !~ /$expect/m){ |
if($output !~ /$expect/m){ |
63 |
print "*** Error: \"$expect\" not found\n"; |
print "*** Error: Checking regexp \"$expect\" failed\n"; |
64 |
$errors += 1; |
$errors += 1; |
65 |
} |
} |
66 |
} |
} |
81 |
$prec = 0 unless defined $prec; |
$prec = 0 unless defined $prec; |
82 |
die "Precision should be positive" unless $prec >= 0; |
die "Precision should be positive" unless $prec >= 0; |
83 |
|
|
84 |
if($output =~ /$title\s*([0-9\.eE+-]+)/){ |
if($output =~ /$title\s*([0-9\.eE+-]+)/m){ |
85 |
my $value = $1; |
my $value = $1; |
86 |
|
|
87 |
# Is this really a number? |
# Is this really a number? |
97 |
|| ($ref < 0 |
|| ($ref < 0 |
98 |
&& ($value < (1+$prec)*$ref || $value > (1-$prec)*$ref)) |
&& ($value < (1+$prec)*$ref || $value > (1-$prec)*$ref)) |
99 |
){ |
){ |
100 |
print "*** $title $value should be $ref\n"; |
print "*** $title$value (it should be $ref +/- $prec)\n"; |
101 |
$errors += 1; |
$errors += 1; |
102 |
} |
} |
103 |
} |
} |
161 |
} |
} |
162 |
|
|
163 |
/* One smaller sphere, centered on a test point and intersecting the |
/* One smaller sphere, centered on a test point and intersecting the |
164 |
first sphere. A test point is contained in the intersection*/ |
first sphere. A test point is contained in the intersection */ |
165 |
|
|
166 |
sphere{ |
sphere{ |
167 |
<1,0,0>,0.5 |
<1,0,0>,0.5 |
215 |
} |
} |
216 |
|
|
217 |
# Builds a domain, then runs a simple differential equation resolution |
# Builds a domain, then runs a simple differential equation resolution |
218 |
# to differentiate inside points and outside points. |
# to give different values to inside and outside points. |
219 |
|
|
220 |
sub DomainMeshCheck{ |
sub DomainMeshCheck{ |
221 |
|
|
246 |
pde(u) |
pde(u) |
247 |
-div(grad(u)) = 0; |
-div(grad(u)) = 0; |
248 |
|
|
249 |
// Defines a Dirichlet boundary condition on the domain frontier. |
// Defines a Dirichlet boundary condition on the frontier. Its |
250 |
|
// value is 0 on the outside cube, and 1 on the embedded object. |
251 |
|
// Therefore, the correct solution for the above problem is one |
252 |
|
// on all points inside the object, and a value between 0 and 1 |
253 |
|
// at all other points. |
254 |
|
|
255 |
u = 1 on <1,0,0>; |
u = 1 on <1,0,0>; |
256 |
u = 1 on <0,1,0>; |
u = 1 on <0,1,0>; |