kinnala / scikit-fem

Simple finite element assemblers
https://scikit-fem.readthedocs.io
BSD 3-Clause "New" or "Revised" License
503 stars 80 forks source link

Examples/snippets demonstrating the integrations #474

Closed kinnala closed 3 years ago

kinnala commented 4 years ago

I'd like to keep a track of the libraries that can be integrated to scikit-fem with ease. How about having a single example which simply demonstrates the possible integrations? Or should it be a collection of snippets instead? If the latter, how is it tested in pytest?

gdmcbain commented 4 years ago

I think a collection; the integrations serve diverse ends.

For pytest, I've seen this idiom:

netCDF4 = pytest.importorskip("netCDF4")

https://github.com/nschloe/meshio/blob/3a380fc1100827ed38b8f38960087a066c4aab26/test/test_exodus.py#L6

kinnala commented 4 years ago

So basically in practice we could have have something like docs/integrations/pygmsh.py, docs/integrations/dmsh.py, and so on, make sure that these are collected by pytest, and then maybe have docs/snippets.rst which includes all these in the Sphinx documentation?

gdmcbain commented 4 years ago

Yes, I think so. That directory structure should make it easy to find the case of interest.

Is there a catch with trying to import pygmsh from inside a file.called pygmsh.py or from another file in a directory with that file?

kinnala commented 4 years ago

Yeah, let's call them mesh_pygmsh.py, mesh_dmsh.py, solver_pacopy.py, and so on, i.e. try to have a 'category' which describes the type of integration?

kinnala commented 4 years ago

Here are some integrations that come to mind:

I'm sure there are others. Feel free to add to the list.

Edit: I'm sure there are also those that might be hard to test in our test suite such as reading a mesh from FEniCS or ngsolve. Not sure if we should include those or only what we are willing to test?

kinnala commented 4 years ago

Some additional urls for consideration:

gdmcbain commented 4 years ago

There's a start on PETSc in #236 .

After that recent question about pressure boundary conditions for the Stokes equation #466 , which referred to a FEniCS example using MUMPS, I started looking at PyMumps.

nschloe has a new package picking up from krypy: Krylov.

I've been looking at pyMOR; besides it being useful for scikit-fem applications, I think scikit-fem.could be useful for it. It has bindings to FEniCS, deal.ii, and NGSolve, and its own little pythonic FEM implementation but that's rather limited.

I like the idea of coupling to a finite volume solver. For finite differences, there's scikit-fdiff. A boundary element code could be really useful too.

gdmcbain commented 4 years ago

I had been that thinking optimesh might be useful with the new MeshTri.init_circle #475 in examples #476 but actually it doesn't seem to be required #477 .

kinnala commented 4 years ago

I think that in near future I might be reimplementing one specific algorithm from optimesh that I'm very fond of and also using in https://github.com/kinnala/adaptmesh.

gdmcbain commented 3 years ago

For external reasons but possibly of interest here, I've posted an example of integration with OpenFOAM.

It generates a quasi-two-dimensional hexahedral mesh using OpenFOAM's blockMesh as in the OpenFOAM tutorial basic/potentialFoam/cylinder, one hexahedron thick in the z-direction, which is how two dimensions is done in OpenFOAM. This is then parsed in a small general Python submodule to create a skfem.MeshQuad for the domain with .boundaries for the inlet. The inlet boundary is also saved as a trace mesh (#530 #687) and the discrete finite volume inlet velocity boundary condition computed in scikit-fem and written for potentialFoam. The same problem is then solved in both codes.

The creation of the skfem.Mesh for domain and boundary and their writing and rereading was greatly simplified following the recent improvements to skfem.io.meshio #680.