# PyFreeFEM
PyFreeFEM is a python package interfacing
[FreeFEM](https://freefem.org/) scripts with Python. `.edp` scripts
become small modules that can be used as building blocks of a main
python project.
> PyFreeFEM is different from the alternative
> [pyFreeFEM](https://github.com/odevauchelle/pyFreeFem) module from
> Olivier Devauchelle, which has been developped rather simultaneously for
> similar purposes.
[Official documentation](https://pyfreefem.readthedocs.io/en/latest/index.html)
## Features
PyFreeFEM has the following capabilities:
- **Running FreeFEM** `.edp` **scripts that support python input
parameters:**
```python
from pyfreefem import FreeFemRunner
FreeFemRunner("script.edp").execute({'f':'x+1','N':10, 'THREEDIM':0})
```
- **Executing portions of** `.edp` **scripts conditionally to python
input parameters by using special preprocessing instructions:**
```freefem
DEFAULT (THREEDIM,0)
IF THREEDIM
mesh3 Th=cube($N,$N,$N);
ELSE
mesh Th=square($N,$N);
ENDIF
```
- **Automated imports and exports of data structures (floats, arrays,
matrices, meshes) from FreeFEM to Python and vice-versa:**
```python
from pyfreefem import FreeFemRunner
fem_matrix="""
IMPORT "io.edp"
mesh Th=square($N,$N);
fespace Fh1(Th,P1);
varf laplace(u,v)=int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v));
matrix A = laplace(Fh1,Fh1,tgv=-2);
exportMatrix(A);"""
#Get the sparse matrix (scipy csc_matrix format) A:
runner = FreeFemRunner(fem_matrix)
exports = runner.execute({'N':100})
A = exports['A']
print('A=\n',A.todense())
```
- **Flexible debugging and capturing of FreeFEM standard output**:
running the previous script with
```python
runner = FreeFemRunner(fem_matrix,debug=10)
exports = runner.execute({'N':100},verbosity=0)
```
yields the following output:
``` console
$ python test.py
Write /tmp/pyfreefem_xsd1x5dw/run.edp
Reset directory /tmp/pyfreefem_xsd1x5dw/ffexport
FreeFem++ /tmp/pyfreefem_xsd1x5dw/run.edp -v 0 -nw
Saved /tmp/pyfreefem_xsd1x5dw/ffexport/matrix_A
Finished in (0.06s)
A=
[[ 1. -0.5 0. ... 0. 0. 0. ]
[-0.5 2. -0.5 ... 0. 0. 0. ]
[ 0. -0.5 2. ... 0. 0. 0. ]
...
[ 0. 0. 0. ... 2. -0.5 0. ]
[ 0. 0. 0. ... -0.5 2. -0.5]
[ 0. 0. 0. ... 0. -0.5 1. ]]
```
## Contribute and support
- Issue tracker:
<https://gitlab.com/florian.feppon/pyfreefem/-/issues>
- Source code: <https://gitlab.com/florian.feppon/pyfreefem>
If I am not responding on the issue tracker, feel free to send me an
email to florian.feppon\[at\]kuleuven.be
## Citation
Please cite the following reference when using this package:
> FEPPON, Florian. *Shape and topology optimization of multiphysics
> systems.* 2019. Université Paris-Saclay. Thèse préparée à l'École
> polytechnique.
``` bibtex
@phdthesis{feppon2020,
author = {Feppon, Florian},
title = {Shape and topology optimization of multiphysics systems},
school = {Th\`{e}se de doctorat de l'Universit'{e} Paris-Saclay pr'{e}par'{e}e
\`a l''{E}cole polytechnique},
year = {2019}
}
```
## Licence
PyFreeFEM is a free software distributed under the terms of the GNU
General Public Licence
[GPL3](https://www.gnu.org/licenses/gpl-3.0.html).
Raw data
{
"_id": null,
"home_page": "https://pyfreefem.readthedocs.io/en/latest/",
"name": "pyfreefem",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "FreeFEM",
"author": "Florian Feppon",
"author_email": "florian.feppon@kuleuven.be",
"download_url": "",
"platform": null,
"description": "# PyFreeFEM\n\nPyFreeFEM is a python package interfacing\n[FreeFEM](https://freefem.org/) scripts with Python. `.edp` scripts\nbecome small modules that can be used as building blocks of a main\npython project.\n\n> PyFreeFEM is different from the alternative\n> [pyFreeFEM](https://github.com/odevauchelle/pyFreeFem) module from\n> Olivier Devauchelle, which has been developped rather simultaneously for\n> similar purposes.\n\n[Official documentation](https://pyfreefem.readthedocs.io/en/latest/index.html)\n\n## Features\n\nPyFreeFEM has the following capabilities:\n\n- **Running FreeFEM** `.edp` **scripts that support python input\n parameters:**\n\n ```python \n from pyfreefem import FreeFemRunner \n FreeFemRunner(\"script.edp\").execute({'f':'x+1','N':10, 'THREEDIM':0})\n ```\n\n- **Executing portions of** `.edp` **scripts conditionally to python\n input parameters by using special preprocessing instructions:**\n\n ```freefem \n DEFAULT (THREEDIM,0) \n\n IF THREEDIM \n mesh3 Th=cube($N,$N,$N);\n ELSE \n mesh Th=square($N,$N);\n ENDIF\n ```\n\n- **Automated imports and exports of data structures (floats, arrays,\n matrices, meshes) from FreeFEM to Python and vice-versa:**\n\n ```python\n from pyfreefem import FreeFemRunner \n\n fem_matrix=\"\"\" \n IMPORT \"io.edp\"\n mesh Th=square($N,$N); \n fespace Fh1(Th,P1); \n varf laplace(u,v)=int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v)); \n matrix A = laplace(Fh1,Fh1,tgv=-2); \n\n exportMatrix(A);\"\"\" \n\n #Get the sparse matrix (scipy csc_matrix format) A: \n runner = FreeFemRunner(fem_matrix)\n exports = runner.execute({'N':100}) \n A = exports['A']\n print('A=\\n',A.todense())\n ```\n\n- **Flexible debugging and capturing of FreeFEM standard output**:\n running the previous script with\n\n ```python\n runner = FreeFemRunner(fem_matrix,debug=10)\n exports = runner.execute({'N':100},verbosity=0) \n ```\n\n yields the following output:\n\n ``` console\n $ python test.py \n Write /tmp/pyfreefem_xsd1x5dw/run.edp\n Reset directory /tmp/pyfreefem_xsd1x5dw/ffexport\n FreeFem++ /tmp/pyfreefem_xsd1x5dw/run.edp -v 0 -nw\n Saved /tmp/pyfreefem_xsd1x5dw/ffexport/matrix_A\n Finished in (0.06s)\n A=\n [[ 1. -0.5 0. ... 0. 0. 0. ]\n [-0.5 2. -0.5 ... 0. 0. 0. ]\n [ 0. -0.5 2. ... 0. 0. 0. ]\n ...\n [ 0. 0. 0. ... 2. -0.5 0. ]\n [ 0. 0. 0. ... -0.5 2. -0.5]\n [ 0. 0. 0. ... 0. -0.5 1. ]]\n ```\n\n## Contribute and support\n\n- Issue tracker:\n <https://gitlab.com/florian.feppon/pyfreefem/-/issues>\n- Source code: <https://gitlab.com/florian.feppon/pyfreefem>\n\nIf I am not responding on the issue tracker, feel free to send me an\nemail to florian.feppon\\[at\\]kuleuven.be\n\n## Citation\n\nPlease cite the following reference when using this package:\n\n> FEPPON, Florian. *Shape and topology optimization of multiphysics\n> systems.* 2019. Universit\u00e9 Paris-Saclay. Th\u00e8se pr\u00e9par\u00e9e \u00e0 l'\u00c9cole\n> polytechnique.\n\n``` bibtex\n@phdthesis{feppon2020,\n author = {Feppon, Florian},\n title = {Shape and topology optimization of multiphysics systems},\n school = {Th\\`{e}se de doctorat de l'Universit'{e} Paris-Saclay pr'{e}par'{e}e\n \\`a l''{E}cole polytechnique},\n year = {2019}\n}\n```\n\n## Licence\n\nPyFreeFEM is a free software distributed under the terms of the GNU\nGeneral Public Licence\n[GPL3](https://www.gnu.org/licenses/gpl-3.0.html).\n",
"bugtrack_url": null,
"license": "GNU GPL version 3",
"summary": "Package PyFreeFEM for interfacing Python and FreeFEM.",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://pyfreefem.readthedocs.io/en/latest/"
},
"split_keywords": [
"freefem"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1e03f932514871761d5f2353c10a1e72f794266b637a61f0e75033ce29a0f2b4",
"md5": "9cbe96948ff198ff43e68a2596bc06d6",
"sha256": "568e487a183bfaf87a3f10ae916308edcf012409065f2a1f902219b68bac79e2"
},
"downloads": -1,
"filename": "pyfreefem-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9cbe96948ff198ff43e68a2596bc06d6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 29601,
"upload_time": "2023-05-09T08:06:00",
"upload_time_iso_8601": "2023-05-09T08:06:00.918149Z",
"url": "https://files.pythonhosted.org/packages/1e/03/f932514871761d5f2353c10a1e72f794266b637a61f0e75033ce29a0f2b4/pyfreefem-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-09 08:06:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pyfreefem"
}