This repository has been archived by the owner on Apr 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfreefem++doc.tex
21917 lines (19052 loc) · 873 KB
/
freefem++doc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!TEX encoding = IsoLatin9
% pour imprimer 2 pages par pages en A5
% pstops ``[email protected](21cm,0)[email protected](21cm,14.85cm)''
\documentclass[a4paper,twoside,12pt]{book}
\usepackage{pdfsync}
\usepackage{styles}
\usepackage{multirow}
\usepackage{bm}
\usepackage{macroListing}
\newtheorem{remark}{Remark}
\usepackage{enumitem}
\def\VERSION{3.60}
\def\key#1{\emph{#1}\index{#1}}
\def\vec#1{\mbox{\boldmath $#1$}}
\def\C{\mathbb{C}}
\def\N{\mathbb{N}}
\def\Z{\mathbb{Z}}
\def\Z{\mathbb{Z}}
\def\T{\mathbb{T}}
\def\d{\hbox{d}}
\def\x#1{#1\index{#1}}%index
\def\p{\partial}
\def\n{\nabla}
\def\Rel{{\mathcal R}}
\def\setS#1{#1\label{sec:#1}}
\def\refSec#1{Section \ref{sec:#1}}
\def\refChap#1{Chapter \ref{sec:#1}}
\def\borderarray#1#2#3#4#5#6{%
\setbox0\hbox{$\begin{array}{#5}#6\end{array}$}
\setlength{\dimen1}{\wd0}\addtolength{\dimen1}{-#3}\addtolength{\dimen1}{-\arraycolsep}
\setlength{\dimen2}{\ht0}\addtolength{\dimen2}{-#4}
\setbox1\hbox{$\left#1\rule{\dimen1}{0pt}\rule{0pt}{\dimen2}\right#2$}
\setbox0\hbox{\raisebox{\dp0}{\box0}\kern-\dimen1\kern-5pt\raisebox{\dp1}{\ox1}}
\vcenter{\box0}
}
\pagenumbering{arabic}
\title{}
\author{}
\date{}
\makeindex
\def\hrefexample#1#2{\href{http://www.freefem.org/ff++/ff++/examples++-#1/#2}{\color{purple}{\texttt{#2 in #1}}}}
\begin{document}
\graphicspath{{./}{plots/}{figures/}{cpfigs/}}
\ifpdf
\DeclareGraphicsExtensions{.pdf ,.jpg, .png}
\else
\DeclareGraphicsExtensions{.eps }
\fi
%\maketitle
\thispagestyle{empty}
\vbox to 20cm {\begin{center}
\vglue-0.5cm\includegraphics[width=10cm]{titre-ff}
\\ \large \Blue{Third Edition, Version \VERSION }
\\ \vglue 0.7cm
{\large \Blue{\url{http://www.freefem.org/ff++}}} \\ ~
\\~\\
\includegraphics[width=6cm]{ffauteur}
\vglue 1cm
\includegraphics[width=15cm]{chesapeake-2}
\\ \vglue0.5cm
Laboratoire Jacques-Louis Lions, Universit\'{e} Pierre et Marie Curie, Paris
\vglue-2cm
\end{center}}
\clearpage\thispagestyle{empty}\cleardoublepage
\thispagestyle{empty}
\begin{center}
{\Blue{ \TitreFont FreeFem++}} \\ \vglue 0.0cm ~ \\
Third Edition, Version \VERSION
\\ \vglue 0.7cm
{\Large \url{http://www.freefem.org/ff++}} \\
\vglue 0.5cm
\
{ Fr\'{e}d\'{e}ric Hecht\footnote{Laboratoire Jacques-Louis Lions, Universit\'{e} Pierre et Marie Curie, Paris}
\footnote{Projet Alpines, Inria Rocquencourt.} }
\url{mailto:[email protected]}
\url{https://www.ljll.math.upmc.fr/~hecht}
\bigskip
In collaboration with:
{\small
\begin{itemize}
\item {\normalsize Syl an Auliac}, \url{mailto:[email protected]},~\url{http://www.ann.jussieu.fr/auliac}
{is PHD student at LJLL , he do all the new optimization interface with nlopt, ipopt, cmaes, ...}
\item {\normalsize Olivier Pironneau}, \url{mailto:[email protected]},~\url{http://www.ann.jussieu.fr/pironneau}
{Olivier Pironneau is a professor of numerical analysis at the university of Paris VI and at LJLL. His scientific contributions are in numerical methods for fluids. He is a member of the Institut Universitaire de France and of the French Academy of Sciences}
\item {\normalsize Jacques Morice}, \url{mailto:[email protected]}.
Jacaues Morice is a Post-Doct at LJLL. His doing is Thesis in University of Bordeaux I on fast multipole method (FMM).
In this version, he do all three dimensions mesh generation and coupling with medit software.
\item {\normalsize Antoine Le Hyaric}, \url{mailto:[email protected]},~\url{http://www.ann.jussieu.fr/~lehyaric/}
{Antoine Le Hyaric}{ is a research engineer from the "Centre National de la
Recherche Scientifique" (CNRS) at LJLL . He is an expert in software engineering
for scientific applications. He has applied his skills mainly to
electromagnetics simulation, parallel computing and three-dimensional
visualization.}
\item {\normalsize Kohji Ohtsuka},\url{mailto:[email protected]},~ \url{http://www.comfos.org/}
{Kohji Ohtsuka}{ is a professor at the Hiroshima Kokusai Gakuin University, Japan and chairman of the World Scientific and Engineering academy and Society, Japan chapter. His research is in fracture dynamics, modeling and computing.}
\item {\normalsize Pierre Jolivet}, \url{mailto:[email protected]},~\url{http://jolivet.perso.enseeiht.fr/}
{is a CNRS researcher, he did the MPI interface with PETSc, HPDDM...}
\end{itemize}}
\end{center}
\vfill
\hbox to \hsize
{\hss
\includegraphics[height=1.7cm]{LogoLJLL} \hss
\includegraphics[height=1.7cm]{LogoUPMC} \hss
%\includegraphics[height=1.7cm]{LogoCNRS} \hss
\includegraphics[height=1.7cm]{logo-finance-par-anr} \hss
\includegraphics[height=1.7cm]{INRIA-logo} \hss
}
\bigskip
{\small {\bf Acknowledgments}
We are very grateful to l'\'Ecole Polytechnique (Palaiseau, France) for printing the second edition of this manual (\url{http://www.polytechnique.fr} ),
and to l'Agence Nationale de la Recherche (Paris, France)
for funding of the extension of\ \freefempp to a parallel tridimensional version (\url{http://www.agence-nationale-recherche.fr}) R\'{e}f\'{e}rence : ANR-07-CIS7-002-01.}
\cleardoublepage
%%%%%%%%%%
%\setcounter{page}{1}
\tableofcontents
\let\subsubsection\subsection
\let\subsection\section
\let\section\chapter
\section*{Preface}
\hbox to \hsize{\hss\includegraphics[width=7cm]{sanskrit}}
Fruit of a long maturing process, freefem, in its last avatar, \freefempp, is a high level integrated development environment (IDE) for numerically solving partial differential equations (PDE) in dimension 2 and 3. It is the ideal tool for teaching the finite element method but it is also perfect for research to quickly test new ideas or multi-physics and complex applications.
\medskip
\freefempp has an advanced automatic mesh generator, capable of a posteriori mesh adaptation; it has a general purpose elliptic solver interfaced with fast algorithms such as the multi-frontal method UMFPACK, SuperLU, MUMPS . Hyperbolic and parabolic problems are solved by iterative algorithms prescribed by the user with the high level language of \freefempp. It has several triangular finite elements, including discontinuous elements. Finally everything is there in \freefempp to prepare research quality reports: color display online with zooming and other features and postscript printouts.
\medskip
This manual is meant for students at Master level, for researchers at any level, and for engineers (including financial engineering) with some understanding of variational methods for partial differential equations.
\section{Introduction}%\pagenumbering{arabic} \setcounter{page}{1}
A partial differential equation is a relation between a function
of several variables and its (partial) derivatives.
Many problems in physics, engineering, mathematics and even banking
are modeled by one or several partial differential equations.
\\\\
\freefempp is a software to solve these equations numerically. As
its name implies, it is a free software (see the copyrights for full detail)
based on the Finite Element Method; it is not a package, it is an integrated product with its own
high level programming language. This software runs on all UNIX
OS (with g++ 3.3 or later, and OpenGL) , on Window XP, Vista and 7,8,10 and on
MacOS 10 intel \\\\
Moreover \freefempp is highly adaptive. Many phenomena involve
several coupled systems, for example: fluid-structure interactions,
Lorentz forces for aluminium casting and ocean-atmosphere problems are
three such systems. These require different finite element approximations and polynomial
degrees, possibly on different meshes. Some algorithms like
Schwarz' domain decomposition method also require data interpolation
on multiple meshes within one program. \freefempp can handle these
difficulties, i.e. {\it arbitrary finite element spaces on arbitrary
unstructured and adapted bi-dimensional meshes}. \\\\
The characteristics of \freefempp are:
\begin{itemize}
\item Problem description (real or complex valued) by their variational formulations,
with access to the internal vectors and matrices if needed.
%
\item Multi-variables, multi-equations, bi-dimensional and three-dimensional
static or time dependent, linear or nonlinear
coupled systems; however the user is required to describe the
iterative procedures which reduce the problem to a set of linear
problems.
%
\item Easy geometric input by analytic description of boundaries by pieces;
however this part is not a CAD system; for instance when two
boundaries intersect, the user must specify the intersection points.
%
\item Automatic mesh generator, based on the Delaunay-Voronoi
algorithm; the inner point density is proportional to the density of
points on the boundaries \cite{George}.
%
\item Metric-based anisotropic mesh adaptation. The metric can be
computed automatically from the Hessian of any \freefempp function
\cite{bamg}.
%
\item High level user friendly typed input language with an algebra
of analytic and finite element functions.
%
\item Multiple finite element meshes within one application with
automatic interpolation of data on different meshes and possible
storage of the interpolation matrices.
%
\item A large variety of triangular finite elements : linear, quadratic
Lagrangian elements and more, discontinuous P1 and Raviart-Thomas elements,
elements of a non-scalar type, the mini-element,\dots{} (but no quadrangles).
%
\index{mean}
\item Tools to define discontinuous Galerkin finite element formulations
\ttCC{P0},\ttCC{P1dc},\ttCC{P2dc} and keywords: \ttCC{jump}, \ttCC{mean}, \ttCC{intalledges}.
%
\item A large variety of linear direct and iterative solvers
(LU, Cholesky, Crout, CG, GMRES, UMFPACK, MUMPS, SuperLU, ...) and eigenvalue and
eigenvector solvers (ARPARK) .
%
\item Near optimal execution speed (compared with compiled C++
implementations programmed directly).
\item Online graphics, generation of \texttt{,.txt,.eps,.gnu, mesh} files
for further manipulations of input and output data.
%
\item Many examples and tutorials: elliptic, parabolic and hyperbolic problems,
Navier-Stokes flows, elasticity, Fluid structure interactions,
Schwarz's domain decomposition method, eigenvalue problem, residual
error indicator, ...
%
\item A parallel version using \texttt{mpi}
\end{itemize}
\subsection{Installation}
%%%%%%%%%%%%%%%
\subsubsection{For everyone:}
First open the following web page
\begin{center}
\url{http://www.freefem.org/ff++/}
\end{center}
And choose your platform: Linux, Windows, MacOS X,
or go to the end of the page to get the full list of downloads.
\begin{remark}: Binaries are available for Microsoft Windows, Apple
Mac OS X and some Linux systems.
%"\freefempp" at \url{http://www.freefem.org}.
\end{remark}
Install by double click on the appropriate file, under linux and MacOS the
install file are respectively in directory \texttt{/usr/local/bin}, \texttt{/usr/local/share/freefem++}, \texttt{/usr/local/lib/ff++}
\paragraph{Windows binaries install}
First download the windows installation executable, then double click it. to install \freefempp. In most cases just answer yes (or typr return) to all questions. Otherwise in the Additional Task windows, check the box "Add application directory to your system path your system path ." This is required otherwise the program \texttt{ffglut.exe} will not be found.
By now you should have
two new icons on your desktop:
\begin{itemize}
\item \texttt{FreeFem++ (VERSION).exe} the \freefempp application.
% \item \texttt{FreeFem++ (VERSION) GUI.exe} the GUI \freefempp application, see section \ref{GUI} for more information.
\item \texttt{FreeFem++ (VERSION) Examples} a link to the \freefempp folder of examples.
\end{itemize}
where \texttt{(VERSION)} is the version of the files (for example \texttt{3.3-0-P4}).
By default, the installed files are in
\begin{center}
\verb!C:\Programs Files\FreeFem++!
\end{center}
In this directory, you have all the \texttt{.dll} files and
other applications: \texttt{FreeFem++-nw.exe},\texttt{ffglut.exe}, ... the \freefempp application
without graphic windows.
\medskip
The syntax for the command-line tools are the same as those of FreeFem.exe.
%{ \small
%\begin{itemize}
%\item \verb!FreeFem++.exe [-vnn] [-b] [-s] [-n] [-h] [-f] [ filepath ]! where the
% \begin{description}
%\item \verb!-b! no color (black and white plot)
%\item \verb!-n! no edit
%\item \verb!-s! not wait at end of execution
%\item \verb!-vnn! set the level of verbosity to \texttt{nn} before execution of the script.
%\item if no file path then you get a dialog box to choose the edp file.
%\end{description}
%\item \verb!FreeFem++-nw.exe [-v nn] [[-f] filepath]!
%\end{itemize}}
%\medskip
% where the part in \texttt{[]} is optional.
\paragraph{MacOS X binaries install}
Download the MacOS X binary version file, extract all the files with a double click on the
icon of the file, go the the directory and put the \texttt{FreeFem+.app} application in the
\texttt{/Applications} directory.
If you want a terminal access to \freefempp just copy the file \freefempp in a
directory of your \verb!$PATH! shell environment variable.
If you want to automatically launch the \texttt{FreeFem++.app}, double click on a \texttt{.edp} file icon.
Under the finder pick a \texttt{.edp} in directory \texttt{examples++-tutorial} for example,
select menu \texttt{File -> Get Info} an \texttt{change Open with:} (choose FreeFem++.app) and click on button
\texttt{change All...}.
\paragraph{Where to go from here} An integrated environment called \texttt{FreeFem++-cs}, written by Antoine Le Hyaric, is provided with \freefempp. Unless you wish to profile now your own development environment, you may proceed to the next paragraph "How to use FreeFem++".
\subsubsection{For the pros: Installation from sources}
This section is for those who for some reason do not wish to use the binaries and hence need to recompile \freefempp or install it from the source code:
\paragraph{The documentation archive}: The documentation is also open source; to regenerate it you need a \LaTeX{} environment capable of compiling a CVS archive; under MS-Windows you will have to use \texttt{mingw/msys}
\begin{center}
\url{http://www.mingw.org}
\end{center}
and under MacOS X we have used Apple's Developer Tools "Xcode" and \LaTeX{ } from \url{http://www.ctan.org/system/mac/texmac}.
\paragraph{The C++ archive}: \freefempp must be compiled from the source archive, as indicated in \begin{center}
\url{http://www.freefem.org/ff++/index.htm}
\end{center}
To
extract files from the compressed archive \texttt{freefem++-(VERSION).tar.gz}
to a directory called
\begin{center}
\texttt{freefem++-(VERSION)}
\end{center}
enter the following commands in a shell window~:
\bFF
tar zxvf freefem++-(VERSION).tar.gz
cd freefem++-(VERSION)
\eFF
To compile and install \freefempp, just follow the \texttt{INSTALL}
and \texttt{README} files. The following programs are produced,
depending on the system you are running :
\begin{enumerate}
\item \freefempp, standard version, with a graphical interface
based on GLUT/OpenGL (use ffglut visualization tool) or not just add \texttt{ -nw } parameter.
\item \texttt{ffglut} the visualization tools through a pipe of freefem++ (remark: {\it if ffglut is not in the system path,
you will have no plot})
\item \texttt{FreeFem++-nw}, postscript plot output only and ffmedit (batch version, no graphics windows via \texttt{ffglut} )
\item \texttt{FreeFem++-mpi}, parallel version, postscript output only, but you can use the shell script like
\begin{enumerate}
\item \texttt{ff-mpirun -np nbproc mympiscript.edp} \#\# without graphic \index{ff-mpirun}
\item \texttt{ff-mpirun -np nbproc mympiscript.edp -glut ffglut } \#\# with graphic
\item \texttt{ff-mpirun -np nbproc mympiscript.edp -glut ffglut parameters } \#\# with graphic and script parameters
\item \texttt{ff-mpirun -np nbproc mympiscript.edp} -glut ffglut \#\# with graphic
\end{enumerate}
where \texttt{nbproc} in the number of process launch.
%\item \texttt{FreeFem++-glx}, graphics using OpenGL and X11
%\item \texttt{FreeFem++-cs}, integrated development environment
%\item \texttt{FreeFem++-ag}, integrated development environment
%\item Sorry, the integrated development environment is reconstruction with the new architecture
% (please see chapter Graphical User Interface \ref{GUI} for more details).
\item \texttt{/Applications/FreeFem++.app}, the Drag and Drop CoCoa MacOSX
Application
%\item \texttt{FreeFem++-CoCoa}, MacOS Shell script for MacOS OpenGL
%version (MacOS 10.3 or better) (note: it uses
%/Applications/FreeFem++.app)
\item \texttt{bamg} , the bamg mesh generator
\item \texttt{cvmsh2} , a mesh file convertor
\item \texttt{drawbdmesh} , a mesh file viewer
\item \texttt{ffmedit} the freefem++ version of medit software (thanks to P. Frey)
\end{enumerate}
The syntax of tools \freefempp,\texttt{FreeFem++-nw},\texttt{FreeFem++-mpi}, on the command-line are
{ \small
\begin{itemize}
\item \verb!FreeFem++ [-?] [-v nn] [-fglut file1] [-glut file2] [-f] edpfilepath ! where the
\item or \verb!FreeFem++-nw -? [-v nn] [-fglut file1] [-glut file2] [-f] edpfilepath ! where the
\begin{description}
\item \verb!-?! show the usage.
\item \verb!-fglut filename! to store all the data for graphic in file \verb! filename!, and to replay do
\verb!ffglut filename!.
\item \verb!-glut ffglutprogam! to change the visualisator program's.
\item \verb!-nw! no call to ffglut and medit
\item \verb!-v nn! set the level of verbosity to \texttt{nn} before execution of the script.
\item \verb!-ne! no edp script output
\item \verb!-wait! wait an return in text window before closing \freefempp
\item \verb!-nowait! wait an return in text window before closing \freefempp
\item \verb!-ne! no edp script output
\item \verb!-cd! Change directory to script dir (the script path must by global)
\item if no file path then you get a dialog box to choose the edp file on windows systeme.
\end{description}
\end{itemize}}
\medskip
The notation \texttt{[]} means "optional".
%The FreeFem++ parameter command:
%{\small \begin{verbatim}
%Brochet-2:~ hecht$ FreeFem++
% Syntaxe:
% FreeFem++ [ -v verbosity ] [ -fglut filepath ] [ -glut command ] [ -nw] [ -f] filename
% -v verbosity : 0 -- 1000000 level of freefem output
% -fglut filepath : the file name of save all plots (replot with ffglut command )
% -glut command : change the command ffglut
% -gff command : change the command ffglut with space quotting
% -nowait : nowait at the end on text window (
% -wait : wait at the end on text window
% -nw : no ffglut and no medit (=> no graphics windows)
% -ne : no edp script output
% -cd : Change directory to script dir
% with default ffglut : ffglut
%\end{verbatim}
%}
\begin{remark} In most cases you can set the level of output (verbosity\index{verbosity}) to value \texttt{nn} by adding the parameters
\texttt{-v nn} on the command line.
\end{remark}
As an installation test, under unix: go into the directory
\texttt{examples++-tutorial} and run \freefempp on the example script
\texttt{LaplaceP1.edp} with the command~:
\bFF
FreeFem++ LaplaceP1.edp
\eFF
If you are using \texttt{nedit} as your text editor,
do one time \verb!nedit -import edp.nedit! to have coloring syntax for your \ttCC{.edp}
files.
\paragraph{Link with other text editors}
\begin{description}
\item[{emacs}] form \url{https://www.gnu.org/s/emacs}, you can download \texttt{freefem++-mode} here :
\url{https://github.com/rrgalvan/freefem-mode} and follow the instruction to install. s
\item[{notepad++}] form \url{http://notepad-plus.sourceforge.net/uk/site.htm}
\begin{itemize}
\item Open Notepad++ and Enter F5
\item In the new window enter the command
\verb!launchff++ "$(FULL_CURRENT_PATH)"!
\item Click on Save, and enter \freefempp in the box "Name", now choose
the short cut key to launch directly FreeFem++ (for example \texttt{alt+shift+R})
\item To add Color Syntax Compatible with FreeFem++ In Notepad++,
\begin{itemize}
\item In Menu \verb!"Parameters"->"Configuration of the Color Syntax"! proceed as follows:
\item In the list \verb!"Language"! select C++
\item Add "edp" in the field \verb!"add ext"!
\item Select \verb!"INSTRUCTION WORD"! in the list \verb!"Description"! and in the field
\verb!"supplementary key word"!, cut and past the following list:
\Blue{P0 P1 P2 P3 P4 P5 P1dc P2dc P3dc P4dc P5dc RT0 RT1 RT2 RT3 RT4 RT5 macro plot int1d int2d
solve movemesh adaptmesh trunc checkmovemesh on func buildmesh square Eigenvalue min max
imag exec LinearCG NLCG Newton BFGS LinearGMRES
catch try intalledges jump average mean load savemesh convect abs
sin cos tan atan asin acos cotan sinh cosh tanh cotanh atanh asinh acosh pow
exp log log10 sqrt dx dy endl cout}
\item Select "TYPE WORD" in the list "Description" and ... " "supplementary key word",
cut and past the following list
\Blue{mesh real fespace varf matrix problem string border complex ifstream ofstream}
\item Click on \texttt{Save \& Close}. Now nodepad++ is configured.
\end{itemize}
\end{itemize}
%\item[{Crimson}] {\bf Editor}
%availble at \url{http://www.crimsoneditor.com/} and adapted as follows:
%
%\begin{itemize}
%\item Go to the \texttt{Tools/Preferences/File} association menu and add the .edp extension set
%
%\item In the same panel in \texttt{Tools/User} Tools, add a \freefempp item (1st line) with the path
%to \texttt{freefem++.exe} on the second line and \texttt{\$(FilePath)} and \texttt{\$(FileDir)} on third and fourth lines.
%Tick the 8.3 box.
%\item for color syntax, extract file from \texttt{crimson-freefem.zip} and put files in the corresponding sub-folder of
% Crimson folder (\verb.C:\Program Files\Crimson Editor. ).
%\end{itemize}
\item[winedt] for Windows : this is the best but it could be tricky to set up. Download it from
\begin{center}
\url{http://www.winedt.com}
\end{center}
this is a multipurpose text editor with advanced features
such as syntax coloring; a macro is available on \url{www.freefem.org} to localize winedt to \freefempp
without disturbing the winedt functional mode for LateX, TeX, C, etc. However winedt is not free
after the trial period.
\item[TeXnicCenter] for Windows: this is the easiest and will be the best once we find a volunteer
to program the color syntax. Download it from
\begin{center}\url{http://www.texniccenter.org/}\end{center}
It is also an editor for TeX/LaTeX. It has a ``tool'' menu which can be configured to launch
\freefempp programs as in:
\begin{itemize}
\item Select the \texttt{Tools/Customize} item which will bring up a dialog box.
\item Select the \texttt{Tools} tab and create a new item: call it \texttt{freefem}.
\item in the 3 lines below,
\begin{enumerate}
\item search for \texttt{FreeFem++.exe}
\item select Main file with further option then Full path and click also on the \texttt{8.3 box}
\item select main file full directory path with 8.3
\end{enumerate}
\end{itemize}
\item[nedit] on the Mac OS, Cygwin/Xfree and linux, to import the color syntax do
\verb!nedit -import edp.nedit!
\item[textmate 2] for Mac 10.7 or better, download from \url{https://macromates.com/download} and install it, when get the textmate freefem++ syntax from
\url{http://www.freefem.org/ff++/Textmate2-ff++.zip} unzip and follow the explanation given in file \texttt{How\_To.rtf}.
\item[Smultron/fraise] (Obsolete) on the Mac , available at \url{http://smultron.sourceforge.net}. It comes ready with color syntax for .edp file. To teach it to launch \freefempp files, do a "command B" (i.e. the menu Tools/Handle Command/new command) and create a command which does
\begin{verbatim}
/usr/local/bin/FreeFem++-CoCoa %%p
\end{verbatim}
\end{description}
%
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=15cm]{crimpson}
\caption{ Integrated environment for FreeFem++ development with Windows
\label{fig:mi}}
\end{center}
\end{figure}
\subsection{How to use \freefempp}
%\paragraph{Under Windows with Graphic Interfaces}
%The executable \texttt{freefem++.exe} opens a dialog box for
%choosing the input file, then it executes the input file content and produces
%graphics and output files.
%\\\\
%You can create and modify \freefempp programs with your favorite text editor.
%\\\\
%An integrated environment (\freefempp GUI), written by A. Le Hyaric, is also included
%with the distribution. the application name is \texttt{FreeFem++-cs}; note however that
%the graphics display is slower in this mode.
%There are other ways to have an integrated environment. TeX users usually have
%an editor installed; if it is winedt or TeXnicCenter then these can
%be programmed to handle the edit-run-correct cycle of \freefempp with
%color syntax and automatic launch of freefem. If you don't have one of these
%installed the easiest is to download the freeware \texttt{Crimson Editor}.
%\begin{figure}[htbp]
%\begin{center}
%\includegraphics[width=15cm]{csSnapOld}
%\caption{ The 3 panels of the integrated environment \texttt{freefem++-cs}:
%to the top left one has the program (which can be edited?), on the top right the graphic output window, and the bottom pane displays text messages.
%}
%\end{center}
%\end{figure}
\paragraph{Under MacOS X with Graphical Interface}
To test an \texttt{.edp} file, just drag and drop
the file icon on the MacOS application icon \texttt{FreeFem++.app}.
You can also launch this application and use the menu: $\mathtt{File} \rightarrow \mathtt{Open}$.
One of the best ways however on the Mac is to use a text editor like \texttt{Smultron.app}
(see above).
\begin{figure}[htbp] % figure placement: here, top, bottom, or page
\centering
\includegraphics[width=10cm]{mi.jpg}
\caption{The 3 panels of the integrated environment built with the
\texttt{fraise Editor} with \freefempp in action. The Tools menu
has an item to launch \freefempp by a Ctrl+1 command.}
\end{figure}
\paragraph{In Terminal mode}
Choose the type of application from \freefempp, \texttt{FreeFem++-nw}, \texttt{FreeFem++-mpi}, \dots according to your needs. Add at least the path name; for example
\bFF
FreeFem++ your-edp-file-path
\eFF
\subsection{Environment variables, and the init file}
\index{verbosity}\index{includepath}\index{loadpath}\index{load}\index{include}
\freefempp reads a user's init file named \ttCC{freefem++.pref}
to initialize global variables:
\texttt{verbosity}, \texttt{includepath}, \texttt{loadpath}.
\begin{remark} The variable \texttt{verbosity} changes the level of internal printing ($0$, nothing (unless there are syntax errors), $1$ few, $10$ lots, etc. ...),
the default value is $2$.
\\
The include files are searched from the \texttt{includepath} list and the load files
are searched from \texttt{loadpath} list.
\end{remark}
The syntax of the file is:
\begin{verbatim}
verbosity= 5
loadpath += "/Library/FreeFem++/lib"
loadpath += "/Users/hecht/Library/FreeFem++/lib"
includepath += "/Library/FreeFem++/edp"
includepath += "/Users/hecht/Library/FreeFem++/edp"
# comment
load += "funcTemplate"
load += "myfunction"
load += "MUMPS_seq"
\end{verbatim}
The possible paths for this file are
\begin{itemize}
\item under unix and MacOs
\begin{verbatim}
/etc/freefem++.pref
$(HOME)/.freefem++.pref
freefem++.pref
\end{verbatim}
\item under windows
\begin{verbatim}
freefem++.pref
\end{verbatim}
\end{itemize}
We can also use shell environment variable to change verbosity and
the search rule before the init files.
\begin{verbatim}
export FF_VERBOSITY=50
export FF_INCLUDEPATH="dir;;dir2"
export FF_LOADPATH="dir;;dir3""
\end{verbatim}
Remark: the separator between directories must be ";" and not ":" because ":" is used under Windows.
Remark, to show the list of init of \freefempp, do
\begin{verbatim}
export FF_VERBOSITY=100; ./FreeFem++-nw
-- verbosity is set to 100
insert init-files /etc/freefem++.pref $
...
\end{verbatim}
\subsection{History}
The project has evolved from \texttt{MacFem, PCfem}, written in
Pascal. The first C version lead to \texttt{freefem 3.4}; it offered
mesh adaptativity on a single mesh only.
\\\\
A thorough rewriting in C++ led to \texttt{freefem+}
(\texttt{freefem+ 1.2.10} was its last release), which included
interpolation over multiple meshes (functions defined on one mesh
can be used on any other mesh); this software is no longer
maintained but still in use because it handles a problem description
using the strong form of the PDEs. Implementing the interpolation
from one unstructured mesh to another was not easy because it had to
be fast and non-diffusive; for each point, one had to find the
containing triangle. This is one of the basic problems of
computational geometry (see Preparata \& Shamos\cite{Preparata} for
example). Doing it in a minimum number of operations was the
challenge. Our implementation is $O(n\log n)$ and based on a
quadtree. This version also grew out of hand because of the
evolution of the template syntax in C++.
\\\\
We have been working for a few years now on \freefempp, entirely
re-written again in C++ with a thorough usage of {\tt template} and
generic programming
for coupled systems of unknown size at compile time. Like all
versions of \texttt{freefem} it has a high level user friendly input
language which is not too far from the mathematical writing of the
problems.
\\\\
The freefem language allows for a quick specification of any partial
differential system of equations. The language syntax of \freefempp
is the result of a new design which makes use of the STL \cite{cpp},
templates and \texttt{bison} for its implementation; more detail can
be found in \cite{FHcpp}.
The outcome is a
versatile software in which any new finite element can be included
in a few hours; but a recompilation is then necessary. Therefore
the library of finite elements available in \freefempp will grow
with the version number and with the number of users who program
more new elements. So far we have discontinuous $P_0$
elements,linear $P_1$ and quadratic $P_2$ Lagrangian elements,
discontinuous $P_1$ and Raviart-Thomas elements and a few others like bubble elements.
\section{Getting Started}
\label{sec:example}
To illustrate with an example,
let us explain how \freefempp solves
\textbf{Poisson}'s equation: \emph{for a given function $f(x,y)$, find a
function $u(x,y)$ satisfying}
\begin{eqnarray}
\label{eqn:Poisson}
-\Delta u(x,y) &=& f(x,y)\quad \mbox{ for all }(x,y)\in\Omega,
\\ \label{eqn:Dirichlet}
u(x,y) &=& 0\quad \mbox{ for all }(x,y)\mbox{ on }\p\Omega,.
\end{eqnarray}
Here $\partial\Omega$ is the boundary of the bounded open set $\Omega\subset \R^2$
and $ \Delta u = \frac{\p^2 u}{\p x^2 } + \frac{\p^2 u}{\p y^2}$.
The following is a \freefempp program which computes $u$ when
$f(x,y)=xy$ and $\Omega$ is the unit disk. The boundary
$C=\p\Omega$ is
$$
C=\{(x,y)|\; x=\cos(t),\, y=\sin(t),\, 0\le t\le 2\pi\}
$$
Note that in \freefempp the domain $\Omega$ is assumed to described by its boundary
that is on the left side of its boundary oriented by the parameter.
%
%By definition the domain is on the left side of the boundary
%oriented by the parameter $t$.
As illustrated in Fig. \ref{firstU},
we can see the isovalue of $u$ by using \ttCC{@plot} (see line 13
below).
\twoplot[height=5cm]{firstTh}{firstU}{mesh \texttt{Th} by \texttt{build(C(50))}}{isovalue by \texttt{plot(u)}}
\index{clock}
\begin{example}\label{exm:first}~
\bFF
// defining the boundary \hfilll
1: @border C(t=0,2*@pi){@x=cos(t); @y=sin(t);}
// the triangulated domain Th is on the left side of its boundary \hfilll
2: @mesh Th = @buildmesh (C(50));
// the finite element space defined over Th is called here Vh
3; @fespace Vh(Th,@P1);
4: Vh u,v; // defines u and v as piecewise-P1 continuous functions
5: @func f= x*y; // definition of a called f function
6: @real cpu=clock(); // get the clock in second
7: @solve Poisson(u,v,@solver=LU) = // defines the PDE
8: @int2d(Th)(@dx(u)*@dx(v) + @dy(u)*@dy(v)) // bilinear part
9: - @int2d(Th)( f*v) // right hand side
10: + @on(C,u=0) ; // Dirichlet boundary condition
11: @plot(u);
12: @cout << " CPU time = " << clock()-cpu << @endl;
\eFF
\end{example}
Note that the qualifier \texttt{solver=LU} is not required and by default a
multi-frontal LU would have been used. Note also that the lines
containing \texttt{clock} are equally not required. Finally note how
close to the mathematics \freefempp input language is. Line \texttt{8} and \texttt{9}
correspond to the mathematical variational equation
\[
\int_{T_h}(\frac{\p u}{\p x}\frac{\p v}{\p x}
+\frac{\p u}{\p y}\frac{\p v}{\p
y})\d x \d y
=
\int_{T_h}f v\d x\d y
\]
for all $v$ which are in the finite element space $V_h$ and zero on
the boundary $C$.
\paragraph{Exercise}:
Change P1 into P2 and run the program.
\subsubsection{FEM by \freefempp: how does it work?}
This first example shows how \freefempp executes with no effort all
the usual steps required by the finite element method (FEM). Let us
go through them one by one.
\\\\
\textbf{1st line:} the boundary $\Gamma$ is described analytically
by a parametric equation for $x$ and for $y$. When
$\Gamma=\sum_{j=0}^J \Gamma_j$ then each curve $\Gamma_j$, must be
specified and crossings of $\Gamma_j$ are not allowed except at end
points .
The keyword ``label'' can be added to define a group
of boundaries for later use (boundary conditions for instance).
Hence the circle could also have been described as two half circle with
the same label:
\bFF
@border Gamma1(t=0,@pi) {@x=cos(t); @y=sin(t); @label=C}
@border Gamma2(t=@pi,2*@pi){@x=cos(t); @y=sin(t); @label=C}
\eFF
Boundaries can be referred to either by name (\ttCC{Gamma1} for example) or by label (\ttCC{C} here)
or even by its internal number here 1 for the first half circle and 2 for the second
(more examples are in \refSec{Meshing Examples}).
\\\\
\textbf{2nd line:} the triangulation $\mathcal{T}_h$ of $\Omega$ is
automatically generated by \ttCC{@buildmesh(C(50))} using $50$
points on \ttCC{C} as in Fig. \ref{firstTh}.
The domain is assumed to be on the left side of the boundary which is implicitly
oriented by the parametrization. So an elliptic hole can be added by
\bFF
@border C(t=2*@pi,0){@x=0.1+0.3*cos(t); @y=0.5*sin(t);}
\eFF
If by mistake one had written
\bFF
@border C(t=0,2*@pi){@x=0.1+0.3*cos(t); @y=0.5*sin(t);}
\eFF
then the inside of the ellipse would be triangulated as well as the outside.
Automatic mesh generation is
based on the Delaunay-Voronoi algorithm. Refinement of the mesh are
done by increasing the number of points on $\Gamma$, for example,
\ttCC{@buildmesh(C(100))}, because inner vertices are determined
by the density of points on the boundary. Mesh adaptation can be performed also
against a given function \ttCC{f} by calling \ttCC{@adaptmesh(Th,f)}.
Now the name $\mathcal{T}_h$ (\texttt{Th} in \freefempp) refers to
the family $\{T_k\}_{k=1,\cdots,n_t}$ of triangles shown in figure \ref{firstTh}.
Traditionally $h$ refers to the mesh size, $n_t$ to the number of
triangles in $\mathcal{T}_h$ and $n_v$ to the number of vertices, but it is seldom
that we will have to use them explicitly.
If $\Omega$ is not a polygonal domain, a ``skin'' remains between
the exact domain $\Omega$ and its approximation
$\Omega_h=\cup_{k=1}^{n_t}T_k$.
However, we notice that all corners of $\Gamma_h = \p\Omega_h$ are
on $\Gamma$.
\\\\
\textbf{3rd line:} A finite element space is, usually, a space of
polynomial functions on elements, triangles here only, with certain matching properties
at edges, vertices etc. Here \ttCC{@fespace Vh(Th,P1)} defines $V_h$ to be the
space of continuous functions which are affine in $x,y$ on each triangle of $T_h$. As it is a
linear vector space of finite dimension, basis can be found.
The canonical basis is made of functions, called the \index{hat function}\emph{hat functions}
$\phi_k$ which are continuous piecewise affine and are equal to 1 on one vertex and 0 on all others.
A typical hat function is shown on figure \ref{fig-hatFunction}
\footnote{
The easiest way to define $\phi_k$ is by making use of the \index{barycentric coordinates}
\emph{barycentric coordinates}
$\lambda_i(x,y),~i=1,2,3$ of a point $q=(x,y)\in T$, defined by
\[
\sum_i\lambda_i=1,~~~\sum_i\lambda_i\vec q^i=\vec q
\]
where $q^i,~i=1,2,3$ are the 3 vertices of $T$. Then it is easy to see that
the restriction of $\phi_k$ on $T$ is precisely $\lambda_k$.
}.
Then
\begin{equation}
V_h(\mathcal{T}_h,P_1)=\left\{w(x,y)\left|\;
w(x,y)=\sum_{k=1}^{M}w_k\phi_k(x,y),\, w_k\textrm{ are real numbers}\right.\right\}
\label{eq 2.3}\end{equation}
where $M$ is the dimension of $V_h$, i.e. the number of vertices.
The $w_k$ are called the \index{degree of freedom}\emph{degree of freedom} of $w$ and $M$ the number of
the degree of freedom.
\begin{figure}[htbp]
\begin{minipage}{\textwidth}
\begin{minipage}{0.3\textwidth}
\includegraphics[width=\textwidth]{secondT}%
\caption{mesh \texttt{Th}}
\end{minipage}
\hspace{0.5mm}
\begin{minipage}{0.7\textwidth}
\includegraphics[width=\textwidth]{hat}%
\caption{Graph of $\phi_1$ (left) and $\phi_6$ \label{fig-hatFunction}}
\end{minipage}
\end{minipage}
\end{figure}
It is said also that the \index{nodes}\emph{nodes} of this finite element method
are the vertices.
\\
\index{fespace!P0}
\index{fespace!P1}
\index{fespace!P2}
\index{fespace!RT0}
\index{fespace!P1nc}
\index{fespace!P1dc}
\index{fespace!P2dc}
\index{fespace!P1b}
\index{fespace!P2b}
\index{fespace!P3}\index{fespace!P4}\index{fespace!RT1}\index{fespace!BDM1}\index{fespace!Morley}\index{fespace!P3dc}\index{fespace!P4dc}\index{fespace!RT0Ortho}\index{fespace!RT1Ortho}\index{fespace!BDM1Ortho}\index{fespace!P2BR}\index{fespace!P2h}\index{fespace!HCT}
Currently \freefempp implements the following elements \index{elements} in 2d, (see section \ref{finite elements} for the full description)
{\parskip=0cm
\par \ttCC{P0} piecewise constant,
\par \ttCC{P1} continuous piecewise linear,
\par \ttCC{P2} continuous piecewise quadratic,
\par \ttCC{P3} continuous piecewise cubic, (need \ttCC{@load "Element_P3"})
\par \ttCC{P4} continuous piecewise quartic,(need \ttCC{@load "Element_P4"})
\par \ttCC{RT0} Raviart-Thomas piecewise constant,
\par \ttCC{RT1} Raviart-Thomas degree 1 piecewise constant (need \ttCC{@load "Element_Mixte"})
\par \ttCC{BDM1} Brezzi-Douglas-Marini degree 1 piecewise constant (need \ttCC{@load "Element_Mixte"})
\par \ttCC{RT0Ortho} Nedelec type 1 degree 0 piecewise constant
\par \ttCC{RT1Ortho} Nedelec type 1 degree 1 piecewise constant (need \ttCC{@load "Element_Mixte"})
\par \ttCC{BDM1Ortho} Brezzi-Douglas-Marini degree 1 piecewise constant (need \ttCC{@load "Element_Mixte"})
\par \ttCC{P1nc} piecewise linear non-conforming,
\par \ttCC{P1dc} piecewise linear discontinuous,
\par \ttCC{P2dc} piecewise quadratic discontinuous,
\par \ttCC{P2h} quadratic homogene continuous (without P1)
\par \ttCC{P3dc} piecewise cubic discontinuous,(need \ttCC{@load "Element_P3dc"})
\par \ttCC{P4dc} piecewise quartic discontinuous,(need \ttCC{@load "Element_P4dc"})
\par \ttCC{P1b} piecewise linear continuous plus bubble,
\par \ttCC{P2b} piecewise quadratic continuous plus bubble.
\par \ttCC{Morley} Morley finite element (need \ttCC{@load "Morley"})
\par \ttCC{HCT} Hsieh-Clough-Tocher $C^1$ finite element (need \ttCC{@load "Element_HCT"}, version 3.40)
\par \ttCC{P2BR} P2 Bernardi-Raugel finite element (need \ttCC{@load "BernadiRaugel.cpp"})
\par \ttCC{P0edge} a finite element constant per edge
\par \ttCC{P1edge} to \ttCC{P5edge} a finite element polynomial on edge (need \ttCC{@load "Element_PkEdge"})
\par {...} \par
}
\index{fespace!P03d}
\index{fespace!P13d}
\index{fespace!P23d}
\index{fespace!RT03d}
\index{fespace!Edge03d}
\index{fespace!Edge13d}
\index{fespace!Edge23d}
\index{fespace!P1b3d}
Currently \freefempp implements the following elements \index{elements} in 3d, (see section \ref{finite elements} for the full description)
{\parskip=0cm
\par \ttCC{P03d} piecewise constant,
\par \ttCC{P13d} continuous piecewise linear,
\par \ttCC{P23d} continuous piecewise quadratic,
\par \ttCC{RT03d} Raviart-Thomas piecewise constant,
\par \ttCC{Edge03d},\ttCC{Edge13d},\ttCC{Edge23d} The Nedelec Edge element 0,1,2
\par \ttCC{P1b3d} piecewise linear continuous plus bubble,
\par {...} \par
}
To get the full list, in a unix terminal, in directory \texttt{examples++-tutorial} do
\bFF
FreeFem++ dumptable.edp
grep TypeOfFE lestables
\eFF
Note that other elements can be added fairly easily.
\\\\
\textbf{Step3: Setting the problem}
\\
\textbf{4th line:} \texttt{Vh u,v} declares that $u$ and $v$ are approximated as above,
namely
\begin{equation}\label{defu}
u(x,y)\simeq u_h(x,y)=\sum_{k=0}^{M-1} u_k\phi_k(x,y)
\end{equation}
\textbf{5th line:} the right hand side \ttCC{f} is defined analytically using the keyword
\ttCC{@func}.
\textbf{7th--9th lines:} defines the bilinear form of equation (\ref{eqn:Poisson}) and
its Dirichlet boundary conditions (\ref{eqn:Dirichlet}).
\\
This \emph{variational formulation} is derived by
multiplying (\ref{eqn:Poisson}) by $v(x,y)$ and integrating
the result over $\Omega$:
$$
-\int_{\Omega}v\Delta u \,\d x\d y = \int_{\Omega} vf\, \d x\d y
$$
Then, by Green's formula, the problem is converted into finding $u$
such that
\begin{eqnarray}
\label{eqn:weakform}
&&a(u,v) - \ell(f,v) = 0
\qquad \forall v \hbox{ satisfying $v=0$ on }\p\Omega.\\
&&\hbox{with }a(u,v)=\int_{\Omega}\nabla u\cdot \nabla v \,\d x\d y ,
\quad \ell(f,v)=\int_{\Omega}fv\, \d x\d y
\label{eqn:bilinear}
\end{eqnarray}
In \freefempp
the \textbf{Poisson} problem can be declared only as in
\bFF
Vh u,v; @problem Poisson(u,v) =
\eFF
and solved later as in
\bFF
...
Poisson; // the problem is solved here
...
\eFF
or declared and solved at the same time as in
\begin{center}
\ttCC{Vh u,v; @solve Poisson(u,v) =@int(...}
\end{center}
and (\ref{eqn:weakform}) is written with \ttCC{@dx}(u) $=\p
u/\p x$, \ttCC{@dy}(u) $=\p u/\p y$ and
\begin{eqnarray*}
&&\int_{\Omega}\nabla u\cdot \nabla v\, \d x\d y \longrightarrow
\ttCC{@int2d(Th)( @dx(u)*@dx(v) + @dy(u)*@dy(v) )}\\
&&\int_{\Omega}fv\, \d x\d y \longrightarrow
\ttCC{@int@2d(Th)( f*v )}\qquad
\textrm{(Notice here, $u$ is unused)}\\
\end{eqnarray*}
In \freefempp {\bf bilinear terms and linear terms should not be under the same integral}; indeed to construct the linear systems
\freefempp finds out which integral contributes to the bilinear form by checking if both terms , the unknown (here \texttt{u}) and test functions (here \texttt{v}) are present.
\\\\
\textbf{Step4: Solution and visualization}\\
\textbf{6th line:} The current time in seconds is stored into the real-valued variable \ttCC{cpu}.
\textbf{7th line} The problem is solved.
\textbf{11th line:} The visualization is done as illustrated in Fig. \ref{firstU}
(see \refSec{Plot} for zoom, postscript and other commands).
\textbf{12th line:} The computing time (not counting graphics) is written on the console
Notice the C++-like syntax; the user needs not study C++ for using \freefempp,
but it helps to guess what is allowed in the language.
\\\\
\textbf{Access to matrices and vectors}
\\
Internally \freefempp will solve a linear system of the type
\begin{eqnarray}
\label{eqn:Equation}
\sum_{j=0}^{M-1} A_{ij}u_j - F_i=0 ,\quad i=0,\cdots,M-1;\qquad
F_i=\int_{\Omega}f\phi_i\, \d x\d y
\end{eqnarray}
which is found by using (\ref{defu}) and replacing $v$ by $\phi_i$
in (\ref{eqn:weakform}).