File Exchange

## FELICITY

version 1.2.7.0 (12.1 MB) by

Finite ELement Implementation and Computational Interface Tool for You

Updated

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

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)

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

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

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?

##### 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

### MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website