File Exchange

image thumbnail

FELICITY

version 1.3.1.0 (11.9 MB) by Shawn Walker
Finite ELement Implementation and Computational Interface Tool for You

28 Downloads

Updated 27 Jun 2020

View Version History

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.

Cite As

Shawn Walker (2021). FELICITY (https://www.mathworks.com/matlabcentral/fileexchange/31141-felicity), MATLAB Central File Exchange. Retrieved .

Walker, Shawn W. “FELICITY: A Matlab/C\Mathplus\Mathplus Toolbox for Developing Finite Element Methods and Simulation Modeling.” SIAM Journal on Scientific Computing, vol. 40, no. 2, Society for Industrial & Applied Mathematics (SIAM), Jan. 2018, pp. C234–C257, doi:10.1137/17m1128745.

View more styles

Comments and Ratings (42)

Fatih Nurcin

Amitava Biswas

lin li

Terence

Hello Shawn.

Thank you for your response. I can correctly run and modify your test examples to apply to new problems. I'm just curious about how to use the MATLAB scripts directly.

-Terence

Shawn Walker

Hello Terence.

All of the demos (and unit tests) have a main "test" file that runs everything. If you check the Wiki, there are also tutorials. The only thing you need to do is make sure you have a C++ compiler that Matlab can find, and configure mex with "mex -setup". There are many resources on the internet for configuring Matlab's mex stuff.

-Shawn

Terence

Terence

Hello Prof. Shawn.

I'm interested in the FEM tool you wrote, but I don't know much about the mex files.
Is there any example that can be run directly without compiling into mex files?

- Terence

Shawn Walker

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 W Griffiths

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

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

-Shawn

Graham W Griffiths

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

Caleb Gannon

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

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

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

Nicolas,

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

- Shawn

Nicolas Schmit

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

Nicolas,

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

- Shawn

Nicolas Schmit

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

Shawn Walker

Nicolas,

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

- Shawn

Nicolas Schmit

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

Hey Nicolas.

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

- Shawn

Nicolas Schmit

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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):

http://www.mathworks.com/support/compilers/R2011a/win64.html

Shawn Walker

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

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

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

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 R2018a
Compatible with R2018a to R2020a
Platform Compatibility
Windows macOS Linux
Acknowledgements

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

FELICITY

FELICITY/Classes

FELICITY/Classes/FEM

FELICITY/Classes/FEM/@FELSymBasisCalc

FELICITY/Classes/FEM/@FELSymBasisCalc/private

FELICITY/Classes/FEM/@FELSymFunc

FELICITY/Classes/FEM/@FEMatrixAccessor

FELICITY/Classes/FEM/@FiniteElementSpace

FELICITY/Classes/FEM/@FiniteElementSpace/private

FELICITY/Classes/FEM/@GeoElementSpace

FELICITY/Classes/FEM/@GeoElementSpace/private

FELICITY/Classes/FEM/@ParametricMesh_2D

FELICITY/Classes/FEM/@ParametricMesh_2D/private

FELICITY/Classes/FEM/@PointSearchMesh

FELICITY/Classes/FEM/@PointSearchMesh/private

FELICITY/Classes/FEM/@ReferenceFiniteElement

FELICITY/Classes/FEM/@ReferenceFiniteElement/private

FELICITY/Classes/FEM/Unit_Test

FELICITY/Classes/FEM/Unit_Test/Dim_2

FELICITY/Classes/FEM/Unit_Test/Point_Searching/TopDim_2_GeoDim_2

FELICITY/Classes/FEM/Unit_Test/Point_Searching/TopDim_2_GeoDim_3

FELICITY/Classes/ManageSim

FELICITY/Classes/ManageSim/@FEL_AbstractDataManagement

FELICITY/Classes/ManageSim/@FEL_AbstractSim

FELICITY/Classes/ManageSim/@FEL_SaveLoad

FELICITY/Classes/ManageSim/@FEL_SaveLoad/private

FELICITY/Classes/ManageSim/@FEL_Sim_Template

FELICITY/Classes/ManageSim/@FEL_Visualize

FELICITY/Classes/ManageSim/Unit_Test/Test_SaveLoad

FELICITY/Classes/ManageSim/Unit_Test/Test_Visualize

FELICITY/Classes/Mesh

FELICITY/Classes/Mesh/@AbstractMesh

FELICITY/Classes/Mesh/@AbstractMesh/private

FELICITY/Classes/Mesh/@EdgeRep

FELICITY/Classes/Mesh/@MeshInterval

FELICITY/Classes/Mesh/@MeshInterval/private

FELICITY/Classes/Mesh/@MeshTetrahedron

FELICITY/Classes/Mesh/@MeshTetrahedron/private

FELICITY/Classes/Mesh/@MeshTriangle

FELICITY/Classes/Mesh/@MeshTriangle/private

FELICITY/Classes/Mesh/Unit_Test

FELICITY/Classes/Mesh/Unit_Test/Dim_1/Bary_Plot

FELICITY/Classes/Mesh/Unit_Test/Dim_1/Curve

FELICITY/Classes/Mesh/Unit_Test/Dim_2/Bary_Plot

FELICITY/Classes/Mesh/Unit_Test/Dim_2/Bisection_2D

FELICITY/Classes/Mesh/Unit_Test/Dim_2/Circle

FELICITY/Classes/Mesh/Unit_Test/Dim_2/Facet

FELICITY/Classes/Mesh/Unit_Test/Dim_2/Mesh_Skeleton

FELICITY/Classes/Mesh/Unit_Test/Dim_2/Square

FELICITY/Classes/Mesh/Unit_Test/Dim_3/Cube

FELICITY/Code_Generation

FELICITY/Code_Generation/@FELCodeHdr

FELICITY/Code_Generation/@FELCodeHdr/private

FELICITY/Code_Generation/@FELInterface

FELICITY/Code_Generation/DoF_Numbering

FELICITY/Code_Generation/DoF_Numbering/@GenDoFNumberingCode

FELICITY/Code_Generation/DoF_Numbering/@GenDoFNumberingCode/private

FELICITY/Code_Generation/DoF_Numbering/Unit_Test/Dim_1

FELICITY/Code_Generation/DoF_Numbering/Unit_Test/Dim_2

FELICITY/Code_Generation/DoF_Numbering/Unit_Test/Dim_3

FELICITY/Code_Generation/Interpolation

FELICITY/Code_Generation/Interpolation/Level_1

FELICITY/Code_Generation/Interpolation/Level_1/@Interpolate

FELICITY/Code_Generation/Interpolation/Level_1/@Interpolations

FELICITY/Code_Generation/Interpolation/Level_1/@Interpolations/private

FELICITY/Code_Generation/Interpolation/Level_1/@PointSearches

FELICITY/Code_Generation/Interpolation/Level_1/@PointSearches/private

FELICITY/Code_Generation/Interpolation/Level_1/Unit_Test

FELICITY/Code_Generation/Interpolation/Level_3/@FELInterpolate

FELICITY/Code_Generation/Interpolation/Level_3/@FELInterpolate/private

FELICITY/Code_Generation/Interpolation/Level_3/@FELInterpolations

FELICITY/Code_Generation/Interpolation/Level_3/@FELPointSearches

FELICITY/Code_Generation/Interpolation/Level_3/@FELPointSearches/private

FELICITY/Code_Generation/Interpolation/Main/@GenFELInterpolationCode

FELICITY/Code_Generation/Interpolation/Main/@GenFELInterpolationCode/private

FELICITY/Code_Generation/Interpolation/Main/@GenFELPtSearchCode

FELICITY/Code_Generation/Interpolation/Main/@GenFELPtSearchCode/private

FELICITY/Code_Generation/Interpolation/Main/@Interp_L1toL3

FELICITY/Code_Generation/Interpolation/Main/@Interp_L1toL3/private

FELICITY/Code_Generation/Interpolation/Main/@PtSearch_L1toL3

FELICITY/Code_Generation/Interpolation/Main/@PtSearch_L1toL3/private

FELICITY/Code_Generation/Interpolation/Unit_Test/Dim_2/Flat_Domain

FELICITY/Code_Generation/Interpolation/Unit_Test/Dim_2/Hdiv

FELICITY/Code_Generation/Interpolation/Unit_Test/Dim_2/Mixed_Geometry

FELICITY/Code_Generation/Interpolation/Unit_Test/Dim_2/Symbolic_Constant

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/Dim_1

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/Dim_2

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/Dim_2_Codim_1

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/Dim_3

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/TopDim_1_GeoDim_2

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/TopDim_1_GeoDim_3

FELICITY/Code_Generation/Interpolation/Unit_Test/Point_Searches/TopDim_2_GeoDim_3

FELICITY/Code_Generation/Interpolation/Unit_Test/TopDim_1_GeoDim_3/Shape_Operator

FELICITY/Code_Generation/Interpolation/Unit_Test/TopDim_2_GeoDim_3/Shape_Operator

FELICITY/Code_Generation/Matrix_Assembly

FELICITY/Code_Generation/Matrix_Assembly/Function/@FiniteElementBasisFunction

FELICITY/Code_Generation/Matrix_Assembly/Function/@FiniteElementBasisFunction/private

FELICITY/Code_Generation/Matrix_Assembly/Function/@FiniteElementCoefFunction

FELICITY/Code_Generation/Matrix_Assembly/Function/@FiniteElementCoefFunction/private

FELICITY/Code_Generation/Matrix_Assembly/Function/@GenericFiniteElementFunction

FELICITY/Code_Generation/Matrix_Assembly/Function/@GenericFiniteElementFunction/private

FELICITY/Code_Generation/Matrix_Assembly/Function/@GeometricElementFunction

FELICITY/Code_Generation/Matrix_Assembly/Function/@GeometricElementFunction/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Bilinear

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Coef

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Domain

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Element

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Element/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@GeoElement

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@GeoElement/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@GeoFunc

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@GeoFunc/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Integral

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Integral/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Linear

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Matrices

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Matrices/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Real

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Test

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@Trial

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@abstractexpr

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@abstractfunc

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@genericform

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@genericform/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@l1func

FELICITY/Code_Generation/Matrix_Assembly/Level_1/@l1func/private

FELICITY/Code_Generation/Matrix_Assembly/Level_1/Unit_Test

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELCoefs

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELDomain

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELDomain/private

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELMatrices

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELMatrices/private

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELMatrix

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELMatrix/private

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELSpaces

FELICITY/Code_Generation/Matrix_Assembly/Level_3/@FELSpaces/private

FELICITY/Code_Generation/Matrix_Assembly/Main/@GenMatrixAssemblyCode

FELICITY/Code_Generation/Matrix_Assembly/Main/@GenMatrixAssemblyCode/private

FELICITY/Code_Generation/Matrix_Assembly/Main/@L1toL3

FELICITY/Code_Generation/Matrix_Assembly/Main/@L1toL3/private

FELICITY/Code_Generation/Matrix_Assembly/Transformer

FELICITY/Code_Generation/Matrix_Assembly/Transformer/@Codim_Map

FELICITY/Code_Generation/Matrix_Assembly/Transformer/@Codim_Map/private

FELICITY/Code_Generation/Matrix_Assembly/Transformer/@Constant_Trans

FELICITY/Code_Generation/Matrix_Assembly/Transformer/@Constant_Trans/private

FELICITY/Code_Generation/Matrix_Assembly/Transformer/@Geometric_Trans