FreeFEM [Old web site] FreeFEM on CoMFoS FreeFEM by JavaScript
Contents in this page are provided with no warranties and no liability. This page is also available on CoMFoS.
This patch adds PDF and SVG output function to the built-in plot() command, which can generate only PostScript files as default.
This feature has been included in official release of FreeFEM 4.12 or later.
By default in FreeFEM ver 4.12, the compression feature is not supported.
In order to generate compressed PDF files,
apply this patch
and recompile from sources.
In FreeFEM ver 4.12,
MUMPS is not correctly downloaded from the specified server
when compiling with the --enable-download
option.
This patch allows you
to download MUMPS from the FreeFEM official site.
In macOS 13.3.1 (Ventura) with Apple clang version 14.0.3
(clang-1403.0.22.14.1, for target arm64-apple-darwin22.4.0)
provided in CommandLineTools,
both FreeFem++
and FreeFem++-nw
cannot be executed due to a segmentation fault error.
They might be failed around in the constructor of
struct StackOfPtr2Free
in src/fflib/ffstack.hpp
.
(After I updated CommandLineTools, I met this error.)
This patch will avoid the error.
FreeFEM-4.11 automatically downloads/compiles/includes PETSc Ver 3.17.0 by configuration. However, I met an error on Linux (Ubuntu 20.04.3) such as:
/usr/bin/ld: .../FreeFem-sources-4.11/3rdparty/ff-petsc/petsc-3.17.0/fc/lib/libpetsc.so: undefined reference to `GOMP_loop_nonmonotonic_guided_start' /usr/bin/ld: .../FreeFem-sources-4.11/3rdparty/ff-petsc/petsc-3.17.0/fc/lib/libpetsc.so: undefined reference to `omp_get_max_threads'(in FreeFem-sources-4.11/3rdparty/ff-petsc/petsc-3.17.0/fc/externalpackages/git.slepc/installed-arch-linux2-c-opt-complex/lib/slepc/conf/configure.log)
tar zxf FreeFem-sources-4.11.tar.gz; cd FreeFem-sources-4.11; patch -c -p1 < FreeFem-sources-4.11-petsc.patch
cd 3rdparty/ff-petsc && make petsc-slepc
As default, FreeFEM uses text file and PostScript to store mesh and numerical results respectively. This module enables us to store them in a single PDF file. Both contours drawing and fill-style output of P0/P1/P1nc/P2 finite elements solutions are available. Meshes are drawn with/without indices (vertex, element, and edge, and boundary labels).
zlib
which is not included as system libraries,
and plotPDF
cannot be loaded by default.plotPDF
, download plotPDF.dll
or zlib123dllx64.zip.
For the later, rename zlibwapi.dll
to zlib1.dll
.
plotPDF.dll
or zlib1.dll
should be placed in the system directory of FreeFEM
(C:\Program Files(x86)\FreeFem++
by default).
ff-c++ -std=c++11 -DWITH_zlib plotPDF.cpp -lz
ff-c++ -static -DWITH_zlib plotPDF.cpp -lz
C:\Program Files (x86)\FreeFem++
, where you installed FreeFEM.bool plotPDF( PDFfilename, mesh Th [, options] );
bool plotPDF( PDFfilename, mesh Th, Vh u [, options] );
bool plotPDF( PDFfilename, mesh Th, Vh<complex> u [, options] );
bool plotPDF( PDFfilename, mesh Th, [Vh u, Vh v] [, options] );
(1) bool plotPDF( PDFfilename, mesh Th [, options] );
Drawing 'mesh Th' only.
(2) bool plotPDF( PDFfilename, mesh Th, Vh u [, options] );
Drawing both 'mesh Th' and 'FE function u'.
(3) bool plotPDF( PDFfilename, mesh Th, Vh u [, options] );
Drawing both 'mesh Th' and 'FE function u'.
(4) bool plotPDF( PDFfilename, mesh Th, [Vh u, Vh v] [, options] );
Drawing both 'mesh Th' and 'FE vector field [u,v]'
Options and Default Values:
--------------------
page control options
--------------------
int size = 512 : figure pane sizes in pixel
real ar = auto : aspect ratio, x/y
bool meshpage = true : true if show mesh page
bool index = false : true if show mesh with index page
bool belabel = false : true if show boundary edge label defined
: by "border ... { label=...; }" in .edp
bool isoline = true : true if show isoline of profile
bool fill = true : true if show profile with fill-style
-------------------------
plot-style control option
-------------------------
bool gray = false : true if monochrome (black white)
bool bw = false : (equivalent to gray)
bool value = true : true if show legend in isoline and fill pages
bool logscale = false : true if plot functions in logarithmic scale
real withmesh = 0.0 : thickness over-layed mesh, 0=white, 1=black
real fontscale = 1.0 : ratio of font size for mesh index and belabel
real[int] viso = [] : values to plot isolines
int nbiso = 12 : number of isolines
real[int] frange = [] : value range in plotting with fill-style
int nbfill = 32 : number of colors (levels) in fill-style
string fetype = "P1" : Finite Element
: P0,P1,P2,P1nc(Crouzeix-Raviart) are available
: If not specified, piecewise linear interpolated
: shape is drawn
string title : title of the output PDF file
string cmm : comment shown on the graph
real[int] fmargin = [0,0,0,0] : margin (left, bottom, right, and top)
int prec = 3 : number of digits in legends
real lw = 1.0 : line width of contour, arrow
real[int,int] palette : color spec. for isoline, fill, and vector
(default : Color Universal Design ver.4.)
palette = [ [r0,g0,b0,], [r1,g1,b1], ..., [rN-1,gN-1,bN-1] ];
[r0,g0,b0,] => fmin, [r_{N-1},g_{N-1},b_{N-1}] => fmax
Inteval fmin and fmax is divided into N-1 subintervals, and
RGB is interpolated in each interval.
If both viso and nbiso are specified, viso is prior to nbiso.
If fetype="P0", then fill and nbfill are ignored.
-------------------------
index page
-------------------------
bool idcell = true : true if show cell (triangle) ID
bool idvert = true : true if show vertex ID
bool idedge = false : true if show edge ID
-------------------------
vector field
-------------------------
real ArrowSize = 1.0 : scale for arrow head size
real coef = 1.0 : scale for arrow length
bool unitarrow = false : true if draw arrows with same length
* fill is ignored.
-------------------------
complex-valued function
-------------------------
bool zreal = true : true if show real part
bool zimag = true : true if show imaginary part
bool zabs = false : true if show modulus (absolue value)
bool zarg = false : true if show argument
* fetype is ignored (isoline, fill are interpolated as P1 type).
A data file which gnuplot can use in 'splot' is generated by this module.
ff-c++ -std=c++11 plotGnuplot.cpp
bool plotGnuplot( Vh(Th,P1) u, mesh Th, "filename.gpt" );
mesh Th = ...;
fespace Vh(Th,P1);
Vh u;
bool ret = plotGnuplot(u, Th, "sample.gpt");
assert( ret == true );
Crouzeix-Raviart Element, known as a "non-conforming finite elements". See difference between P1 and CR2d (in 3D-PDF) which is effectively work on Acrobat/Windows.
ff-c++ -std=c++11 Element_CR.cpp
mesh Th = ...;
load "Element_CR"
fespace Vh( Th, CR2d );
Vh u;
mesh3 Th = ...;
load "Element_CR"
fespace Vh( Th, CR3d );
Vh u;
gnuplot> plot 'Poisson2d_CR-triangle.dat.correct' w l,'Poisson2d_CR-mpt.dat.correct'
Harwell-Boeing is one of popular formats to store a system linear equations. Since it is available in various software e.g. in Matlab, NAG Library, and SparseLib++, users can use favorite environments in order to solve and to examine properties of linear systems discretized with FreeFEM.
ff-c++ -std=c++11 SaveHB.cpp
SaveHB( "filename.hb", matrix A, real[int] b, "title for HB");
border C(...){...}
mesh Th=...;
fespace Vh(Th,...);
varf vP(u,v)=int2d(Th)(...) + on(C,u=...);
matrix A=vP(Vh,Vh);
real[int] b=vP(0,Vh);
load "SaveHB" // without semicolon
SaveHB("filename.hb", A, b, "Title");
Complex Case:
border C(...){...}
mesh Th=...;
fespace Vh(Th,...);
varf vP(u,v)=int2d(Th)(...) + on(C,u=...);
matrix A=vP(Vh,Vh);
complex[int] b=vP(0,Vh);
load "SaveHB" // without semicolon
SaveHB("filename.hb", A, b, "Title");
This module visualizes the time-harmonic viscoelastic wave in a WebGL file with GUI. It is useful for development of MR elastography. Internet connection is required to view on your browsers.
ff-c++ -std=c++11 saveMREmotionWebGL.cpp
mesh3 Th3 = ...;
load "saveMREmotionWebGL"
saveMREmotionWebGL( "mre-nodes.html", Th3 ); // only output nodes (without motion)
mesh3 Th3 = ...;
fespace Vh(Th3,P1);
Vh u1, u2, u3;
// Solve the time-harmonic 3D viscoelastic equation, whose solutions are (u1,u2,u3)
load "saveMREmotionWebGL"
saveMREmotionWebGL( "mre-motion", Th3, u1,u2,u3 ); // the suffix ".html" is automatically added
(1) bool saveMREmotionWebGL( HTMLfilename, mesh Th [, options] );
Drawing vertices used in FEM computation
(2) bool saveMREmotionWebGL( HTMLfilename, mesh Th,
Vh u1, Vh u2, Vh u3 [, options] );
Drawing both 'mesh Th' and 'FE function (u1,u2,u3)'.
Options and Default Values:
int nx = DEFAULT_NUM_X : number of nodes in x-direction
int ny = DEFAULT_NUM_Y : number of nodes in y-direction
int nz = DEFAULT_NUM_Z : number of nodes in z-direction
real[int] xrange = [ xmin,xmax ] : draw area in x-direction
real[int] yrange = [ ymin,ymax ] : draw area in y-direction
real[int] zrange = [ zmin,zmax ] : draw area in z-direction
real[int] radius = [ default,step,min,max ]
real[int] amp = [ default,step,min,max ]
real[int] speed = [ default,step,min,max ]
bool axis = true : true if show axis
bool grid = true : true if show xy-grid on z=0
real[int] bgcolor = [ 0.8, 0.8, 0.8 ] : background color in RGB
string title : title of the output HTML file
string cmm : comment shown on the page