mfem


Namemfem JSON
Version 4.2.0.8 PyPI version JSON
download
home_pagehttp://mfem.org
SummaryMFEM + PyMFEM (finite element method library)
upload_time2021-02-15 15:38:17
maintainerS. Shiraiwa
docs_urlNone
authorMFEM developement team
requires_python
licenseBSD-3
keywords scientific computing finite element method
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![badge](https://github.com/GLVis/pyglvis/blob/master/examples/ex1.svg "MFEM's Example 1")](https://mybinder.org/v2/gh/GLVis/pyglvis/HEAD?filepath=examples%2Fex1.ipynb)
[![badge](https://github.com/GLVis/pyglvis/blob/master/examples/ex9.svg "MFEM's Example 9")](https://mybinder.org/v2/gh/GLVis/pyglvis/HEAD?filepath=examples%2Fex9.ipynb)

#  PyMFEM (MFEM Python wrapper)

This package (PyMFEM) is Python wrapper for the MFEM high performance parallel finite element method library.(http://mfem.org/).

Installer downloads a couple of external libraries and build them.
By default, "pip install mfem" downloads and builds the serial version of MFEM and PyMFEM.
See more detail below for other configurations

## Install
```
pip install mfem                    # binary install is available only on linux platforms (Py36-39) 
pip install mfem --no-binary mfem   # install serial MFEM + wrapper
```
The setup script accept various options. TO use it, please download
the package and run the script manually. For example, this below download
and build parallel version of MFEM library (linked with Metis and Hypre)
and install under <prefix>/mfem
```
$ pip3 download mfem
(expand tar.gz file and move to the downloaded directory)
$ python setup.py install --with-parallel # it download and build metis/hypre/mfem
```
Choosing compiler
```
$ python setup.py install --with-parallel --CC=icc --CXX=icpc --MPICC=mpiicc --MPICXX=mpiicpc
```
For other configurations, see docs/install.txt or help
```
$ python setup.py install --help
```

## Usage
Here is an example to solve div(grad(f)) = 1 in a square and to plot the result
with matplotlib (modified from ex1.cpp). Use the badge above to open this in Binder.
```
import mfem.ser as mfem

# create sample mesh for square shape
mesh = mfem.Mesh(10, 10, "TRIANGLE")

# create finite element function space
fec = mfem.H1_FECollection(1, mesh.Dimension())   # H1 order=1
fespace = mfem.FiniteElementSpace(mesh, fec)      

# 
ess_tdof_list = mfem.intArray()
ess_bdr = mfem.intArray([1]*mesh.bdr_attributes.Size())
fespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list)

# constant coefficient 
one = mfem.ConstantCoefficient(1.0)

# define Bilinear and Linear operator
a = mfem.BilinearForm(fespace)
a.AddDomainIntegrator(mfem.DiffusionIntegrator(one))
a.Assemble()
b = mfem.LinearForm(fespace)
b.AddDomainIntegrator(mfem.DomainLFIntegrator(one))
b.Assemble()

# create gridfunction, which is where the solution vector is stored
x = mfem.GridFunction(fespace);
x.Assign(0.0)

# form linear equation (AX=B)
A = mfem.OperatorPtr()
B = mfem.Vector()
X = mfem.Vector()
a.FormLinearSystem(ess_tdof_list, x, b, A, X, B);
print("Size of linear system: " + str(A.Height()))

# solve it using PCG solver and store the solution to x
AA = mfem.OperatorHandle2SparseMatrix(A)
M = mfem.GSSmoother(AA)
mfem.PCG(AA, M, B, X, 1, 200, 1e-12, 0.0)
a.RecoverFEMSolution(X, b, x)

# extract vertices and solution as numpy array
verts = mesh.GetVertexArray()
sol = x.GetDataArray()

# plot solution using Matplotlib

import matplotlib.pyplot as plt
import matplotlib.tri as tri

triang = tri.Triangulation(verts[:,0], verts[:,1])

fig1, ax1 = plt.subplots()
ax1.set_aspect('equal')
tpc = ax1.tripcolor(triang, sol, shading='gouraud')
fig1.colorbar(tpc)
plt.show()
```
![](https://raw.githubusercontent.com/mfem/PyMFEM/pip_install_dev/docs/example_image.png)


## License
PyMFEM is licensed under BSD-3.
Please refer the developers' web sites for the external libraries
* MFEM: https://mfem.org/
* Hypre: https://computing.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods
* METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/overview
            

Raw data

            {
    "_id": null,
    "home_page": "http://mfem.org",
    "name": "mfem",
    "maintainer": "S. Shiraiwa",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "shiraiwa@princeton.edu",
    "keywords": "scientific computing,finite element method",
    "author": "MFEM developement team",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3b/e8/619d9ad81fdbf9099998e1f7686515b62a240e0be5866a06ddc1ee3c9b57/mfem-4.2.0.8.tar.gz",
    "platform": "Mac OS X",
    "description": "[![badge](https://github.com/GLVis/pyglvis/blob/master/examples/ex1.svg \"MFEM's Example 1\")](https://mybinder.org/v2/gh/GLVis/pyglvis/HEAD?filepath=examples%2Fex1.ipynb)\n[![badge](https://github.com/GLVis/pyglvis/blob/master/examples/ex9.svg \"MFEM's Example 9\")](https://mybinder.org/v2/gh/GLVis/pyglvis/HEAD?filepath=examples%2Fex9.ipynb)\n\n#  PyMFEM (MFEM Python wrapper)\n\nThis package (PyMFEM) is Python wrapper for the MFEM high performance parallel finite element method library.(http://mfem.org/).\n\nInstaller downloads a couple of external libraries and build them.\nBy default, \"pip install mfem\" downloads and builds the serial version of MFEM and PyMFEM.\nSee more detail below for other configurations\n\n## Install\n```\npip install mfem                    # binary install is available only on linux platforms (Py36-39) \npip install mfem --no-binary mfem   # install serial MFEM + wrapper\n```\nThe setup script accept various options. TO use it, please download\nthe package and run the script manually. For example, this below download\nand build parallel version of MFEM library (linked with Metis and Hypre)\nand install under <prefix>/mfem\n```\n$ pip3 download mfem\n(expand tar.gz file and move to the downloaded directory)\n$ python setup.py install --with-parallel # it download and build metis/hypre/mfem\n```\nChoosing compiler\n```\n$ python setup.py install --with-parallel --CC=icc --CXX=icpc --MPICC=mpiicc --MPICXX=mpiicpc\n```\nFor other configurations, see docs/install.txt or help\n```\n$ python setup.py install --help\n```\n\n## Usage\nHere is an example to solve div(grad(f)) = 1 in a square and to plot the result\nwith matplotlib (modified from ex1.cpp). Use the badge above to open this in Binder.\n```\nimport mfem.ser as mfem\n\n# create sample mesh for square shape\nmesh = mfem.Mesh(10, 10, \"TRIANGLE\")\n\n# create finite element function space\nfec = mfem.H1_FECollection(1, mesh.Dimension())   # H1 order=1\nfespace = mfem.FiniteElementSpace(mesh, fec)      \n\n# \ness_tdof_list = mfem.intArray()\ness_bdr = mfem.intArray([1]*mesh.bdr_attributes.Size())\nfespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list)\n\n# constant coefficient \none = mfem.ConstantCoefficient(1.0)\n\n# define Bilinear and Linear operator\na = mfem.BilinearForm(fespace)\na.AddDomainIntegrator(mfem.DiffusionIntegrator(one))\na.Assemble()\nb = mfem.LinearForm(fespace)\nb.AddDomainIntegrator(mfem.DomainLFIntegrator(one))\nb.Assemble()\n\n# create gridfunction, which is where the solution vector is stored\nx = mfem.GridFunction(fespace);\nx.Assign(0.0)\n\n# form linear equation (AX=B)\nA = mfem.OperatorPtr()\nB = mfem.Vector()\nX = mfem.Vector()\na.FormLinearSystem(ess_tdof_list, x, b, A, X, B);\nprint(\"Size of linear system: \" + str(A.Height()))\n\n# solve it using PCG solver and store the solution to x\nAA = mfem.OperatorHandle2SparseMatrix(A)\nM = mfem.GSSmoother(AA)\nmfem.PCG(AA, M, B, X, 1, 200, 1e-12, 0.0)\na.RecoverFEMSolution(X, b, x)\n\n# extract vertices and solution as numpy array\nverts = mesh.GetVertexArray()\nsol = x.GetDataArray()\n\n# plot solution using Matplotlib\n\nimport matplotlib.pyplot as plt\nimport matplotlib.tri as tri\n\ntriang = tri.Triangulation(verts[:,0], verts[:,1])\n\nfig1, ax1 = plt.subplots()\nax1.set_aspect('equal')\ntpc = ax1.tripcolor(triang, sol, shading='gouraud')\nfig1.colorbar(tpc)\nplt.show()\n```\n![](https://raw.githubusercontent.com/mfem/PyMFEM/pip_install_dev/docs/example_image.png)\n\n\n## License\nPyMFEM is licensed under BSD-3.\nPlease refer the developers' web sites for the external libraries\n* MFEM: https://mfem.org/\n* Hypre: https://computing.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods\n* METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/overview",
    "bugtrack_url": null,
    "license": "BSD-3",
    "summary": "MFEM + PyMFEM (finite element method library)",
    "version": "4.2.0.8",
    "split_keywords": [
        "scientific computing",
        "finite element method"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "4149136af1a3f68d57ff13545e019c21",
                "sha256": "5818f7a8c3c113dffda469606b2a9829450138c87413bc6d5543a0d5a2c7d84c"
            },
            "downloads": -1,
            "filename": "mfem-4.2.0.8-cp36-cp36m-manylinux2010_x86_64.whl",
            "has_sig": false,
            "md5_digest": "4149136af1a3f68d57ff13545e019c21",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": null,
            "size": 34998642,
            "upload_time": "2021-02-15T15:52:58",
            "upload_time_iso_8601": "2021-02-15T15:52:58.936814Z",
            "url": "https://files.pythonhosted.org/packages/d5/de/11cb9d7228c766ee02ad3d5178b382fbb0cc8974bb61f054066286c4c307/mfem-4.2.0.8-cp36-cp36m-manylinux2010_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "f1fdde517ade56ba7062553d1e60444b",
                "sha256": "625be237a3407f02ea01b9b559e9a9c7991ab93f98fc07ca239dbe9a9bdea84a"
            },
            "downloads": -1,
            "filename": "mfem-4.2.0.8-cp37-cp37m-manylinux2010_x86_64.whl",
            "has_sig": false,
            "md5_digest": "f1fdde517ade56ba7062553d1e60444b",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 35068830,
            "upload_time": "2021-02-15T15:52:29",
            "upload_time_iso_8601": "2021-02-15T15:52:29.138829Z",
            "url": "https://files.pythonhosted.org/packages/3b/48/b76751b7b9319614e6ac0fe17b88330c8b23605fe974b03973bf12f06120/mfem-4.2.0.8-cp37-cp37m-manylinux2010_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "2736635c96c640743a7d952b5bb8449c",
                "sha256": "6f097fa455a49a1ac60124800db9c9e5d3567c9c8bf4d286a28bf1a6496ecb71"
            },
            "downloads": -1,
            "filename": "mfem-4.2.0.8-cp38-cp38-manylinux2010_x86_64.whl",
            "has_sig": false,
            "md5_digest": "2736635c96c640743a7d952b5bb8449c",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": null,
            "size": 35103218,
            "upload_time": "2021-02-15T15:52:01",
            "upload_time_iso_8601": "2021-02-15T15:52:01.809775Z",
            "url": "https://files.pythonhosted.org/packages/d1/6c/7c2862d79b6fbe1ef89c30d96149dba3401bdb4315ba07b37a1f70d06484/mfem-4.2.0.8-cp38-cp38-manylinux2010_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "f5e8ece8e7a97c91aa771b0abafe5ea6",
                "sha256": "4a0f6661ed6d75e5e036171a26c8e67f5dc5d7b4787f8947d98095cc3e9d48a9"
            },
            "downloads": -1,
            "filename": "mfem-4.2.0.8-cp39-cp39-manylinux2010_x86_64.whl",
            "has_sig": false,
            "md5_digest": "f5e8ece8e7a97c91aa771b0abafe5ea6",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": null,
            "size": 35155459,
            "upload_time": "2021-02-15T15:53:34",
            "upload_time_iso_8601": "2021-02-15T15:53:34.343896Z",
            "url": "https://files.pythonhosted.org/packages/82/a4/4f5a82f8322f099b8e4b7b6e0f2e619b6ad5029ba5c72bb6949af5bc44ba/mfem-4.2.0.8-cp39-cp39-manylinux2010_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "15587638af1bc7917eb9cbed81a5af0c",
                "sha256": "93c17919128aecfe4dd129e91c229c1e0ab03db82a84493c00da4ad7b39a4e93"
            },
            "downloads": -1,
            "filename": "mfem-4.2.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "15587638af1bc7917eb9cbed81a5af0c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6074204,
            "upload_time": "2021-02-15T15:38:17",
            "upload_time_iso_8601": "2021-02-15T15:38:17.222967Z",
            "url": "https://files.pythonhosted.org/packages/3b/e8/619d9ad81fdbf9099998e1f7686515b62a240e0be5866a06ddc1ee3c9b57/mfem-4.2.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-02-15 15:38:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "mfem"
}
        
Elapsed time: 0.22798s