File Exchange

FELICITY

version 1.2.7.0 (12.1 MB) by Shawn Walker

Shawn Walker (view profile)

Finite ELement Implementation and Computational Interface Tool for You

20 Downloads

Updated 21 Mar 2018

View License

See the GitHub Wiki:
http://github.com/walkersw/felicity-finite-element-toolbox/wiki
for tutorials and more.
Also see the new Discussion Forum:

https://groups.google.com/forum/#!forum/felicity-finite-element-toolbox-discuss

for more information.

The following utilities are included:
- 3-D mesh generator for iso-surfaces.
- Closest point searching on meshes, including surface triangulations in 3-D.
NOTE: fixed error with MATLAB's triangulation class.
- Now includes H(curl) elements! Nedelec's 1st kind finite element is implemented.

Shawn Walker

Shawn Walker (view profile)

Hello Graham.

I have not used the matlab PDE toolbox, so I cannot say. Perhaps something wasn't set properly. You probably want to check things on a square first. Also, check that the boundary conditions (in the actual solution) are correct.

-Shawn

Graham Griffiths

Graham Griffiths (view profile)

Hi Shawn,
I have solved the three hole Poisson equation problem using radial basis functions (RBFs) and I get a solution very close to the Felicity solution. However, interestingly, when I solve the same problem with the Matlab pde toolbox there appears to be a significant difference. Not sure which solution is correct, if any.

Shawn Walker

Shawn Walker (view profile)

Thanks Graham. If you have any questions, post them at the forum.

-Shawn

Graham Griffiths

Graham Griffiths (view profile)

Hi Shawn,
Thanks for all your effort in creating such a great toolbox.
- Graham

Caleb Gannon

Caleb Gannon (view profile)

Hey Shawn,
The issue seems to be with the new version of Matlab (2017b) keeping F as the input variable in the output string, which is then parsed later on as a variable and causes an error. When I type ffoo into Matlab it outputs the (F) explicitly like this.

ffoo(F) = foo(pi*geomSigma_X3)
which is picked up by symvar later
symvar(ffoo)
ans =[ F, geomSigma_X3]

It only seems to affect the 1D matrix assemble test, I can run everything I need just fine. I'm not well versed in the symbolic toolbox but probably just clearing the argument variables would solve it. Just a heads up for future releases or anyone else trying this on Matlab 2017b. Code looks great by the way, thanks a lot for putting this together.
-Caleb

Shawn Walker

Shawn Walker (view profile)

Hello Caleb.

Try changing this line: ffoo = subs(foo, 'F', C1 * gf.X(3) );

to: ffoo = subs(foo, F, C1 * gf.X(3) );

I suspect this is an error with the newest version of Matlab. The old thing works with Version R2016b.

-Shawn

Caleb Gannon

Caleb Gannon (view profile)

Shawn,

I'm trying to run the test_FELICITY.m file, everything seems to be compiling just fine but I get the error
var_name := "F" is not recognized!
The given var_name does *not* match the following VALID Test, Trial,
Coef, or GeoFunc functions:

Test Function: v
GeoFunc Function: geomSigma

Make sure you include a *valid* Test, Trial, Coef,
and/or GeoFunc function when defining this Integral!

It comes from the last line in the MatAssem_interval code below

Body_Force_Matrix = Linear(Scalar_P2);
syms F foo(F);
ffoo = subs(foo, 'F', C1 * gf.X(3) );
Body_Force_Matrix = Body_Force_Matrix + Integral(Sigma,v.val * ffoo);

any idea what might be causing this?

-Caleb

youxing fu

Shawn Walker

Shawn Walker (view profile)

Nicolas,

Sorry I forgot you were doing the curl-curl problem. Ok, I will keep this in mind.

- Shawn

Nicolas Schmit

Nicolas Schmit (view profile)

Shawn,
I contacted the AGMG team. They told be that the algorithm has been designed for discrete scalar elliptic PDEs (Poisson like problems), and works poorly for curl-curl problems. Therefore, it would probably not help for what I am doing.
I think a better option would be a GPU implementation of an iterative solver.
- Nicolas

Shawn Walker

Shawn Walker (view profile)

Nicolas,

I'm not doing anything special; just CPU. You should definitely check out AGMG.

- Shawn

Nicolas Schmit

Nicolas Schmit (view profile)

Shawn
A few seconds? Are you using a GPU or some other kind of parallel computing ?
- Nicolas

Shawn Walker

Shawn Walker (view profile)

Nicolas,

15 minutes is kind of slow. AGMG will solve it in a few seconds with that many unknowns.

- Shawn

Nicolas Schmit

Nicolas Schmit (view profile)

Hello Shawn

I set the tolerance to 1e-8. Calculation time is less than 15min for a linear system of 1,000,000 unknowns.

Nicolas

Shawn Walker

Shawn Walker (view profile)

Hey Nicolas.

Thanks for the info. I assume you used a reasonable tolerance?

- Shawn

Nicolas Schmit

Nicolas Schmit (view profile)

Hello Shawn

Sorry for my late response. I did not notice your post.

Here is the solver that I am using now with lagrange_deg1_dim3 elements.
L = ichol(MAT);
X= minres(MAT, RHS, Tol, Maxit, L, L');
I do not have the AGMG solver, so I cannot compare with it. Since it is an iterative solver, you do have a for loop inside. However, I think the heaviest part of the calculus is the matrix multiplication at each iteration, and the matrix multiplication is already optimized in MATLAB. Im am not sure if compiling the complete solver in a MEX file would speed up that much (though it would be interested to check).
Something you could probably do to speed up the calculations, although I have not tried it yet, is to perform the calculations on a GPU. Since MATLAB’s matrix multiplication function supports sparse arrays on GPU, you could theoretically do the sparse matrix multiplications on a GPU. This should be way faster than on a CPU.

Nicolas

Nicolas Schmit

Nicolas Schmit (view profile)

Shawn

The generation of MEX files used for matrix assembly crashes when there is a space character in the file path.
I could fix the problem with the following modifications.

replace
eval(['cd ' Main_Dir]);
with
eval("cd '" + Main_Dir + "'");

replace
eval(['cd ' current_path]) ;
with
eval("cd '" + current_path + "'");

replace
[status, result] = system([COPY_STR, ' ', File1, ' ', File2]);
with
[status, result] = system([COPY_STR, ' "', File1, '" "', File2, '"']);

I suggest you consider these modifications in the next release.

Nicolas

Shawn Walker

Shawn Walker (view profile)

Nicolas,

But how does this compare to AGMG? My experience with the iterative solvers in MATLAB is they are still FOR loop based, so can be slower than a C code equivalent. Is this true?

- Shawn

- Shawn

Nicolas Schmit

Nicolas Schmit (view profile)

Hello Shawn

I managed to solve sparse linear systems with 4 million variables. The problem was to calculate a 3D vector field on a 110x110x110 MeshTetrahedron with Lagrange elements of degree 1.

I did not use a pre-conditioner. Beyond 5 million variables, I run into memory problems: even with a sparse structure, the stiffness matrix is just too big to fit in memory (16GBytes).

From my understanding of the iterative methods, you do not need to load the complete mass matrix in memory to calculate the solution. Therefore, I am trying to modify the iterative solver to store the mass matrix on the hard drive, and load the matrix one small chunk at a time in the limits of what the RAM can handle.

- Nicolas

Shawn Walker

Shawn Walker (view profile)

Hello Nicolas.

Thanks for the note. I have not compared the MATLAB iterative solvers with AGMG. How big a system did you solve? Did you need an pre-conditioner?

- Shawn

Nicolas Schmit

Nicolas Schmit (view profile)

Hello Shawn

Great toolbox. The matrix assembly and solution interpolation using mex files are very fast.

For systems too big to be solved using "backslash", you can use one of the iterative solvers of MATLAB. I use the biconjugate gradients stabilized method "bicgstab" to solve 3D magnetostatics problems.

Did you compare the performances of the MATLAB iterative solvers with the AGMG solver?

Nicolas

Shawn Walker

Shawn Walker (view profile)

Hello Ahmed.

There is now a tutorial on solving Laplace-Beltrami on a piecewise quadratic surface, with piecewise quadratic elements:

https://github.com/walkersw/felicity-finite-element-toolbox/wiki/Laplace_Beltrami_Open_Surface_1

You can simplify this to your case of piecewise quadratics for Laplace in 1-D.

- Shawn

yongchao

yongchao (view profile)

Dear Shawn,
I want to implement some adaptive mesh for solving my PDE with the toolbox, so I'm wondering is there one example using the adaptive mesh?

Best,
yongchao

Shawn Walker

Shawn Walker (view profile)

Hello Ahmed.

There is a tutorial here on solving the Stokes eqn in 2-D. That involves a piecewise quadratic finite element space:

http://github.com/walkersw/felicity-finite-element-toolbox/wiki/Solve_Stokes_2D_1

You can also find more info here:

http://github.com/walkersw/felicity-finite-element-toolbox/wiki/Managing_DoFs_1

On managing DoFs for higher order finite element spaces.

- Shawn

Ahmed Ismaeel

Ahmed Ismaeel (view profile)

Hello Shawn,
Thank you very much for this great toolbox.
Can you please send me modified two m files (MatAssem_Laplace_1D.m and test_Laplace_1D.m) to solve the same problem but using piecewise quadratic space.
Thank you very much
a.ismaeel.1@research.gla.ac.uk

Shawn Walker

Shawn Walker (view profile)

Hello Jesse.

Thanks for the comment.

As for citing, you can cite the GitHub or Wiki site. There is no official paper for it yet. If you use the TIGER mesher, there is a paper for that

jesse chan

jesse chan (view profile)

Hi Shawn
Tried out FELICITY - installed and tests all passed! One small note - on the tutorial (https://github.com/walkersw/felicity-finite-element-toolbox/wiki/Mesh_Generation_with_TIGER_1), when generating a 3D volumetric mesh for the sphere, the line "LS.Param.sign=1" is missing from the tutorial.

Also, how do we cite FELICITY if we use it?

Charles Nelatury

Shawn Walker

Shawn Walker (view profile)

I'm not sure what is wrong. Make sure you verify that your version of MATLAB supports the compiler. If it is a recent version R2010 or later, then you should be fine. But double check the version/compiler compatibility on the MATLAB web site.

Also, did you try this link:

http://www.mathworks.com/support/solutions/en/data/1-ECUGQX/

They walk you through the full install.

If that doesn't work, you should email the MATLAB helpdesk.

Robin Jens

Robin Jens (view profile)

Hi Shawn

Now I installed the following version of Microsoft Windows SDK 7.1

x64 ISO File Name: GRMSDKX_EN_DVD.iso

CRC#: 0x04F59E55

SHA1: 0x9203529F5F70D556A60C37F118A95214E6D10B5A

First I installed Microsoft Visual C++ 2010 Express as you proposed, but still it cannot find the C++ compiler in matlab when I write mex -setup

Shawn Walker

Shawn Walker (view profile)

Let me add another comment. You have to install TWO things (separately) to make MATLAB see MS Visual C++. They are:

1. Microsoft Visual C++ 2010 Express

2. Microsoft Windows SDK 7.1

Both are free and must be installed in that order (sorry I forgot about this).

The following link should be useful for those who want to use MS Visual C++ (Windows):

Shawn Walker

Shawn Walker (view profile)

Here is the link I found:

Visual C++ 2010 Express:

http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express

It says that it supports 64bit versions, and Windows 7. You may have to register as a user, but that isn't a big deal. Once you have it installed, MATLAB should see it by typing "mex -setup".

Robin Jens

Robin Jens (view profile)

Hi Shawn

Which version of Visual C++ edition did you install? In fact I have a 64bit version of matlab R2010a on a Windows 7 computer. Could you send a link where I can download a 64 bit version of Visual C++ express for free?

Shawn Walker

Shawn Walker (view profile)

YES, you do need a 64-bit compiler. When I tested this on Windows 7, I installed Visual C++ express edition (64-bit), and it worked.

Robin Jens

Robin Jens (view profile)

Hi Shawn

I have a 64-bit version of matlab installede and tried to install Visual C++ 2010 Express from the following link:http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express.
When I wrote m -setup in the command window it could not find the compiler. Do you know if I need a 64bit compiler?

Updates

 21 Mar 2018 1.2.7.0 Fixed minor bug in unit test with symbolic functions. Fixed another bug in unit test with newer version of Matlab. 14 Mar 2018 1.2.6.0 update links. 14 Mar 2018 1.2.6.0 Updated http links. 14 Mar 2018 1.2.6.0 updated google-group discussion page. 15 Feb 2018 1.2.6.0 Added functionality for symbolic constants matrix assembly code and interpolation, i.e. these constants are specified at runtime by being provided by the user when calling the MEX file. Cleaned up the interface to the TIGER mesh generator. 6 Dec 2017 1.2.5.0 Added functionality to make DoF allocation code more automatic. Cleaned up comments and two demos (for the FELICITY paper). 17 Aug 2017 1.2.4.0 Added demo for local finite element matrices. Fixed bug with text replacement in code generation (bug happened when geometry is represented by an element with 10 or more basis functions). 30 May 2017 1.2.3.0 Fixed a minor bug with one of the unit tests. 24 Apr 2017 1.2.2.0 Added GeoElementSpace for higher order meshes; added three more demos (two are on the wiki). Updated the manual, quick-ref guide, and wiki. 5 Apr 2017 1.2.1.0 Updated FEL_SaveLoad class. Changed ReferenceFiniteElement and FiniteElementSpace, i.e. now you specify the number of components in FiniteElementSpace. Changed the syntax of code generation (it is better now!). Updated the manual and wiki. 17 Nov 2016 1.2.0.0 Modified mesh class to use MATLAB's triangulation class. Automated point searches on meshes. Changed m-file format for storing/defining a finite element. Implemented H(curl) in 2-D and 3-D! Updated the manual. See readme for more info. 16 Jun 2016 1.1.5.0 Modified the C++ matrix assembly to be more efficient when lots of sub-matrices are present; this only modifies the internals of FELICITY. This is an initial step to implementing OpenMP for matrix assembly. 20 May 2016 1.1.3.0 Updated compile script for generating MEX files to assemble forms/matrices. Completed the move to GitHub's wiki for the tutorials. Fixed a minor bug with the symbolic toolbox for MATLAB r2016a. 19 Mar 2016 1.1.2.0 Added routine for making equilateral triangle meshes in the plane. Moved Google-Code page to GitHub. Added error detection code when given cell indices are out of range (for matrix assembly and interpolation MEX files). Other minor changes. 17 Jan 2016 1.1.1.0 Fixed some minor bugs that stopped the unit tests. 5 Oct 2015 1.1.0.0 Moved software version number format to "standard" format; we've made it to version 1.1.0! Added test routine for quadrature rules. Fixed tolerance issue with point searching in meshes. See VERSION_HISTORY.txt. 23 Aug 2015 1.0.953.0 Added unit test for solving the heat equation on a surface. Updated image segmentation demo. Fixed bug when matching variable text names (this was in the code generation part of FELICITY). Made some other minor functionality changes. 12 Jan 2015 1.33.0.0 fixed minor bug with some unit tests. 12 Jan 2015 1.32.0.0 fixed minor bug with some unit tests. 12 Jan 2015 1.31.0.0 fixed minor bug with some unit tests. 12 Jan 2015 1.30.0.0 fixed required products. 9 Jan 2015 1.29.0.0 Fixed minor bugs. Implemented the second derivative, hessian operator for functions defined on 1-D, 2-D, and 3-D domains (includes curves and surfaces embedded in 3-D). Added the shape operator. Updated FEL_SaveLoad and FEL_Visualize class. 4 Aug 2014 1.28.0.0 fixed some minor bugs. Added a point searcher for 1-D, 2-D, and 3-D meshes (this includes curves and surfaces embedded in 3-D). Added a quick reference PDF, updated the manual, and Google-Code page. 10 Jun 2014 1.27.0.0 Can mix geometric information from different sub-domains when defining bilinear and linear forms. Added helper classes for saving and loading simulation data, and for running a FE simulation. 17 Jan 2014 1.26.0.0 Implemented a point-region (PR) binary tree, quadtree, and octree for fast point searching and nearest neighbors. 16 Jan 2014 1.25.0.0 Implemented a point-region (PR) binary tree, quadtree, and octree for fast point searching and nearest neighbors. 9 Aug 2013 1.20.0.0 Made the generated MEX file for DoF allocation easier to use. Various bug fixes. 17 May 2013 1.19.0.0 Fixed a stupid bug when using Append_Subdomain in the mesh classes. Added tutorials to Google-Code page and made other changes. Updated PDF manual. Made some improvements to the error checking and error messages in the FiniteElementSpace class. 25 Apr 2013 1.18.0.0 Fixed a bug with matrix re-assembly. Added a mesh smoother (optimizer). Added tutorials to the Google-Code page. 6 Mar 2013 1.17.0.0 Added **a lot** of help comments. Now you use MATLAB's help command to get useful information for the user relevant classes. Cleaned up some internal code. 13 Feb 2013 1.16.0.0 Added automatic code generation for interpolating finite element coefficient functions. Added unit tests, demos, and docs for this. Added tutorial on the Google-Code page. Also added a discussion forum for FELICITY (link is on Google-Code page). 10 Jan 2013 1.15.0.0 Fixed a bug related to MATLAB not successfully copying files. Also updated TIGER meshing interface, as well as the meshing tutorials on the Google-Code page. 15 Oct 2012 1.13.0.0 FELICITY now includes a stand-alone 3-D tetrahedral mesh generator for iso-surfaces. See the Google-Code page for more details. 10 Sep 2012 1.12.0.0 Fixed a few minor bugs. Added some methods to the FiniteElementSpace class (useful for sorting through DoF indices on sub-domains, etc.). Added a chapter in the manual discussing the FiniteElementSpace class and some other convenience routines. 3 Jul 2012 1.11.0.0 Major rewrite of code generation for matrix assembly. Can now define bilinear, linear, and ``real'' forms that involve integrating over multiple sub-domains of different topological dimensions within the same script file. Updated documentation. 2 May 2012 1.10.0.0 Fixed some minor bugs. Added some helper classes. Updated the documentation. 25 Apr 2012 1.9.0.0 Fixed some minor bugs related to the matrix assembly code generation. 28 Mar 2012 1.8.0.0 I cleaned up the internal code considerably; should make future additions easier. This new version now has a framework for H(div) elements, with lowest order Raviart-Thomas (RT0) implemented. 9 Feb 2012 1.7.0.0 Fixed a few minor issues. Fixed a missing file problem that caused the unit tests to crash on other people's MATLAB installation. 22 Sep 2011 1.6.0.0 Fully integrated Rivara bisection of triangular meshes with the MeshTriangle class. Also included an Eikonal solver. Various other bug fixes. 4 Aug 2011 1.4.0.0 Updated web-site to include a brief online tutorial. 28 Jul 2011 1.3.0.0 I replaced the .fml input file (for matrix assembly) by an easier to use MATLAB script. 24 Apr 2011 1.1.0.0 just changed how my web-site is referenced.
MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Example MATLAB class wrapper for a C++ class

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor