How should the finite element method (FEM) framework in the language be extended to be more useful?
With the release of version 12.0 all fundamental FEM solvers (linear, nonlinear, stationary, transient, harmonic, parametric, eigensolver) are implemented. As many of you know I am a developer of the FEM in Mathematica. As such I do not have questions about the language or framework to ask here; my primary purpose on this site is to help you make the most of the FEM framework. However, I would like to give people on this site that are actively using the FEM framework a voice in what you think could be useful extensions/improvements for the framework.
What are suggestions for improvement or missing functionality that you think would make your work with the FEM easier?
When you write an answer, please try to be as specific as you can, possibly show code that illustrates the problem. Limit your answer to one item, multiple entries are of course OK. Try to be reasonable. Suggestions do not need to be complicated; it can be as simple as tutorial XYZ should have a sentence about ZZZ. With up votes given to various suggestions I will hopefully get an idea what is useful to most people and can prioritize accordingly. Also, please understand that I can not give a commitment that everything requested will/can be implemented and it may take some time before things requested actually see the light of day in the product.
Update 14.1:
The PDE modeling framework has been extended further:
- There is a new overview monograph Electromagnetism that explains what functions to use in which scenarios. An in detail explained decision diagram helps with that.
There is a new monograph on Electric Currents that accompanies the new function ElectricCurrentPDEComponent and related boundary conditions
The new function VonMisesStress computes, well, the von Mises Stress
The SolidMechanicsPDEComponent now has extended support for non axes aligned material. These now support thermal and/or initial strains and there are new examples explaining the functionality.
There are example of how to couple SystemModeler with the PDEModeling. SystemModeler drives the PDEModel example Room Heating and a PDEModel drives SystemModeler example Beam - Spring - Mass
New application examples Electrostatically actuated MEMS device, Thermal Contact, Blood flow modeling in cerebral aneurysm, ....
OpenCascadeLink now supports 2D Drafting:
now supports 2D graphics primitives such as Disk, Annulus, etc
now supports 2D boundary graphics primitives such as Circle, Line, Splines, etc
Update 14.0:
The PDE modeling framework has been extended further:
The SolidMechanicsPDEComponent now supports transversely isotropic material models. This is useful for modeling fiber reinforced material or material properties that are not axis aligned, such as wood.
The SolidMechanicsPDEComponent now supports more hyperelastic material models. Compressible and nearly incompressible models are available. Multiplicative decompositions are now supported, to allow coupling of several fields of physics. We have given special attention to make model calibration dead easy.
New application models have been added to showcase the functionality, for example a Hyperelastic Model Comparison or the Hygroscopic Swelling that shows hyperelasticity with moisture and thermal effects.
We started to explore electromagnetism. As a first step we support electrostatics and added an electrostatics monograph and functions such as ElectrostaticPDEComponent. We will see more of this field in the future.
We added support for fluid dynamics. A monograph on Laminar Flow is available. This shows how to set up the Navier-Stokes equations, couple them with other fields of physics. Non-Newtonian flow is supported with build in models, that can be extended. The main function is FluidFowPDEComponent
The physicists among you will hopefully enjoy the new SchrodingerPDEComponent
Many other updates went into the PDEModels.
FEM related updates:
- There is the new DiscontinuousInterpolatingFunction, that serves two purposes: To handle discontinuous functions and when the derivative of a function is discontinuous. This is best explained with an example.
We have a two material region:
Needs["NDSolve`FEM`"]
mesh = ToElementMesh[
ToBoundaryMesh[
"Coordinates" -> {{0, 0}, {1, 0}, {1, 1/2}, {1, 1}, {0, 1}, {0,
1/2}}, "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3,
4}, {4, 5}, {5, 6}, {6, 1}, {3, 6}}]}], MaxCellMeasure -> 1,
"RegionMarker" -> {{{1/2, 1/3}, 1}, {{1/2, 2/3}, 2}}];
mesh["Wireframe"[
"MeshElementStyle" -> {FaceForm[LightGreen], FaceForm[LightRed]}]]
Now, we evaluate a discontinuous function over the mesh:
function = If[ElementMarker == 1, 0, 1];
(* old behaviour *)
ifunOLD =
EvaluateOnElementMesh[{x, y}, function, mesh,
"DiscontinuousInterpolation" -> False];
ifunNEW = EvaluateOnElementMesh[{x, y}, function, mesh];
Plot3D[{ifunOLD[x, y], ifunNEW[x, y]}, {x, 0, 1}, {y, 0, 1},
PlotRange -> All]
You see the new function sharply represents the discontinuity.
You can precisely control which parts of the boundary belong to which sub-region. Here is a more elaborate example.
Update 13.3:
The PDE modeling framework has been extended further:
The SolidMechanicsPDEComponent now supports axisymmetric models.
The SolidMechanicsPDEComponent now supports the nearly incompressible Yeoh material model. The Hyperelasticity monograph has been extended to explain the Yeoh model and build the infrastructure for more hyperelastic materials to be added.
The following PDE model application examples have been added to the PDEModels Overview:
A Passive Dew Condenser (Fluid Dynamics + Heat Transfer)
A Contactless Anemometer (Heat Transfer)
A Quantum Ring makes the first example in the new 'Physics' category. This section also showcases two more elaborate documentation examples: One on Avoided Crossings and one on Eigenfunction clustering
In the solid mechanics domain, there is the Biaxial Tensile Test of Hyperelastic Tissue and the Layered Vascular Vessel with Yeoh Constitutive Model both featuring hyperelastic material models. The Disc Brake has been updated and now also features an axisymmetric solid mechanics model. Note, that the parameter
ModelFunction
has been renamed toSolidMechanicsModelFunction
. The same rename holds true for the parametersModelForm
which was renamed toSolidMechanicsModelForm
Old code will continue to work, but you should be aware of this change. Further more functionality to computeElasticEnergy
has been added.
Updates for the FEM code include the following:
It has be come simpler to specify mesh elements with markers. Previously, each element needed it's own marker. There is now a simplification if each element uses the same marker the the marker needs to be specified only once. This now works:
Needs["NDSolve`FEM`"]
bmesh = ToBoundaryMesh[
"Coordinates" -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}}, 1],
LineElement[{{4, 1}}, 2]}];
BoundaryUnitNormal
is now documented.
Update 13.2:
One of the most important updates in 13.2 is actually a system wide improvement. Consider this code:
NDSolveValue[{Laplacian[u[x, y], {x, y}] == 1},
u[x, y], {x, y} \[Element] Disk[]]
Note the circle-i
at the end of two of the three messages. This information link is only present iff the error message given has a message reference page. If you click on the circle-i, it will take you to the respective message reference page. There you will find hints for isolating and solving the issue at hand. Again, this circle-i is only issued if there is such a message ref page. This should help to better understand why NDSolve issued a message and how to fix it. Kudos go to the FrontEnd team for implementing this for me.
The PDE modeling framework has been extended further:
Almost all PDEComponents and PDETerms now support "RegionSymmetry"->"Axisymmetric". The only exception is the SolidMechanicsPDEComponent which will provide "RegionSymmetry" support in the next version (13.3)
The SolidMechanics monograph now has a section explaining the minimal number of constraints needed for solid mechanics modeling.
The SolidMechanicsPDEComponent now supports Kirchhoff stresses.
A new acoustics model, the Helmholtz Resonator has been added.
Here is a Video on the usage of axisymmetry and hyperelasticity
A new workflow for creating finite element meshes from elevation data (contours) has been added.
OpenCascadeLink has been updated to use OpenCascade 7.6.0
now supports closed B-spline conversions as long as the knots and weights are set to Automatic.
now allows for surface mesh simplifications (elimination of unnecessary edges and faces) after boolean options.
now allows shape simplifications
now provides shape healing capabilities
Overview presentation: If you'd like to get a very rough overview of the FEM functionality in version 13.2 have a look at the PDE Modeling overview talk I gave.
Update 13.1:
The PDE modeling framework has been extended further:
The linear elastic SolidMechanics monograph has been extended. The paragraphs added or modified are marked as such.
The SolidMechanicsPDEComponent has been extended to allow for hyperelastic material models. Specifically, a St. Venant-Kirchhoff and a neo-Hookean model have been implemented. There is a new monograph on Hyperelasticity that explains how these models work and shows how to add your own models.
The SolidMechanicsPDEComponent has been extended to handle Rayleigh Damping.
The basic xyzPDETerms and the MassTransportPDEComponent and HeatTransferPDEComponent now accept a parameter
<|"RegionSymmetry"->"Axisymmetric"|>
that generates the PDE for a truncated cylindrical coordinate system to make use of axisymmetric geometries. Other xyzPDEComponents will follow suite in the next releases.Besides the ref pages there are three new models that show case the use of this: Spherical Capacitor, Thermal Analysis of a Disc Brake and Radial Effects in a Tubular Reactor
There is a new multi material model: Heat Conduction in a Multilayer Sphere
ParametricFunction can now take an option during function evaluation when the FEM is used. This is useful to give the solver needs an updated initial seed to find the solution of a highly nonlinear problem. Here is a pseudo code:
The parametric function is constructed as usual
pfun = ParametricNDSolve[FEMModel, {u[x, ...], ..},
Element[{x, ..}, mesh], p];
Previously, one could not give an option when the pfun is evaluated and you can now.
pfun[pNew, "InitialSeeding" -> {u[x, ..] == oldUSolution, ..}]
This is useful for solving extremely nonlinear PDEs where the solution can not be found in one go. You can then iterate to the solution like show in the following:
{uSolution, ..} = {0 &, ..};
Do[
pNew = step*pMax/nsteps;
{uSolution, ..} =
pfun[pNew, "InitialSeeding" -> {u[x, ..] == uSolution, ..}];
, {step, 1, nsteps, 1}]
All this is explained and showcased in a section on the Hyperleastic Material Models. One caveat: You can not use symbolic expressions for the restart of the initial seed, as that would mess up analysis that ParametricNDSolve does when called.
When you use ClearSystemCache[]
then the FEM case will also be cleared in some cases this can reduce the memory footprint.
Update 13.0:
- The PDE modeling framework has been extended by the field of linear elastic SolidMechanics; There is a SolidMechanics monograph and a verification notebook and a set of companion functions to set up the SolidMechanicsPDEComponent, compute the SolidMechanicsStrain and SolidMechanicsStress and boundary conditions. Here is a recording of a Solid Mechanics presentation.
- There are two new electromagnetics models: Single aperture scalar diffraction and MultipleApertureVectorDiffraction
- There is the new element type PrismElement
- ElementMeshRegionProduct does the same as RegionProduct just for ElementMesh.
- ToGradedMesh generates graded (anisotropic) meshes 1D and is to be used with ElementMeshRegionProduct
- There is a speed improvement when using interpolating functions as PDE coefficients. If these interpolating functions are based on the same
ElementMesh
as the PDE is to be solved over, then a speed up is attained.
For example running this code:
mesh = ToElementMesh[Rectangle[], MaxCellMeasure -> 0.0005];
fun = ElementMeshInterpolation[mesh, Sqrt[Total[mesh["Coordinates"]^2, {2}]]];
RepeatedTiming[
sol = NDSolveValue[{-Laplacian[u[x, y], {x, y}] + fun[x, y]*u[x, y] ==1, DirichletCondition[u[x, y] == 0, x == 0]}, u,
Element[{x, y}, mesh]];]
Takes about 0.16 seconds with version 12.3.1 and 0.08 seconds in version 13.0. (and 0.04 seconds with the coefficient Sqrt[x^2+y^2]
). So using interpolating functions (with the same mesh) is much more performant then before.
Update 12.3:
- The "OpenCascade" boundary mesh generator is now the default for boolean regions in 3D.
- The OpenCascadeLink has been improved and extended. Example CAD models have been added. A CAD model of simple book shelf bracket and a CAD model a complicated Helical bevel gear are available.
- Working with multimaterials in PDEComponents has been made easier.
This now works:
HeatTransferPDEComponent[{T[t, x, y], t, {x, y}}, <|
"Material" -> {{y <= 1, Entity["Element", "Tungsten"]}, {y > 1,
Entity["Element", "Titanium"]}}|>]
- As requested in comments under this answer, convex hull and Delaunay meshes can now also be generated
ToBoundaryMesh["Coordinates" -> pts]
andToElementMesh["Coordinates" -> pts]
Update 12.2:
- At the Virtual Wolfram Technology conference 2020 I held a FEM Meetup where I discussed questions and suggestions collected on this page. You can see the Video of the FEM Meetup 2020.
- We started to implement a PDE modeling framework (Overview Video). The purpose of this is to make PDE setup easier. The framework consists of basic PDE terms that can be combined to more extensive 'PDE components' to make PDE models from various fields of physics. Currently implemented are Acoustics, HeatTransfer and MassTransport. What is new is that each of those are accompanied by area specific boundary conditions that evaluate to the proper
NeumannValue
orDirichletCondition
.
This is how something then looks like:
vars = {p[t, x], t, {x}};
pars = <|"Material" -> Entity["Element", "Tungsten"]|>;
AcousticPDEComponent[vars, pars] ==
AcousticAbsorbingValue[x == 1, vars, pars]
- All in all 32 (!) new reference pages with details about the PDE terms and components.
- There is a new mass transport model about Gas Absorption and all other PDE modeling related tutorial and monographs have been updated to make use of the PDE modeling framework and some got new sections like the Interphase Mass Transfer
- The OpenCascadeLink got a few updates, bug fixes and documentation improvements. For example, OCL can now deal with
TransformedRegion
and got aTorus
graphics primitive.
Update 12.1.1:
- A new Mass Transport PDE model tutorial has been added. Accompanying the tutorial two application examples have been added: Microscale Simulation of Catalyst Deactivation and Catalytic Converter
- The OpenCascadeLink got a few updates and is now available from the Wolfram GitHub page