All Projects → mfem → PyMFEM

mfem / PyMFEM

Licence: BSD-3-Clause License
Python wrapper for MFEM

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PyMFEM

Mfem
Lightweight, general, scalable C++ library for finite element methods
Stars: ✭ 667 (+632.97%)
Mutual labels:  hpc, parallel-computing, scientific-computing, fem, finite-elements
Feelpp
💎 Feel++: Finite Element Embedded Language and Library in C++
Stars: ✭ 229 (+151.65%)
Mutual labels:  parallel-computing, scientific-computing, fem, finite-elements
Samrai
Structured Adaptive Mesh Refinement Application Infrastructure - a scalable C++ framework for block-structured AMR application development
Stars: ✭ 160 (+75.82%)
Mutual labels:  hpc, parallel-computing, scientific-computing
Solidspy
2D-Finite Element Analysis with Python
Stars: ✭ 142 (+56.04%)
Mutual labels:  scientific-computing, fem, finite-elements
Ngsolve
Netgen/NGSolve is a high performance multiphysics finite element software. It is widely used to analyze models from solid mechanics, fluid dynamics and electromagnetics. Due to its flexible Python interface new physical equations and solution algorithms can be implemented easily.
Stars: ✭ 171 (+87.91%)
Mutual labels:  parallel-computing, fem, finite-elements
bitpit
Open source library for scientific HPC
Stars: ✭ 80 (-12.09%)
Mutual labels:  hpc, parallel-computing, scientific-computing
Elmerfem
Official git repository of Elmer FEM software
Stars: ✭ 523 (+474.73%)
Mutual labels:  parallel-computing, fem, finite-elements
Core
parallel finite element unstructured meshes
Stars: ✭ 124 (+36.26%)
Mutual labels:  hpc, parallel-computing, finite-elements
Opencoarrays
A parallel application binary interface for Fortran 2018 compilers.
Stars: ✭ 151 (+65.93%)
Mutual labels:  hpc, parallel-computing, scientific-computing
Sundials
SUNDIALS is a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. This is a mirror of current releases, and development will move here eventually. Pull requests are welcome for bug fixes and minor changes.
Stars: ✭ 194 (+113.19%)
Mutual labels:  hpc, parallel-computing, scientific-computing
ParallelUtilities.jl
Fast and easy parallel mapreduce on HPC clusters
Stars: ✭ 28 (-69.23%)
Mutual labels:  hpc, parallel-computing
learn-gpgpu
Algorithms implemented in CUDA + resources about GPGPU
Stars: ✭ 37 (-59.34%)
Mutual labels:  parallel-computing, gpu-computing
gardenia
GARDENIA: Graph Analytics Repository for Designing Efficient Next-generation Accelerators
Stars: ✭ 22 (-75.82%)
Mutual labels:  parallel-computing, gpu-computing
CARE
CHAI and RAJA provide an excellent base on which to build portable codes. CARE expands that functionality, adding new features such as loop fusion capability and a portable interface for many numerical algorithms. It provides all the basics for anyone wanting to write portable code.
Stars: ✭ 22 (-75.82%)
Mutual labels:  hpc, gpu-computing
boxtree
Quad/octree building for FMMs in Python and OpenCL
Stars: ✭ 52 (-42.86%)
Mutual labels:  parallel-computing, scientific-computing
raccoon
Massively parallel FEM code for phase-field for fracture by Dolbow Lab at Duke University
Stars: ✭ 21 (-76.92%)
Mutual labels:  parallel-computing, finite-elements
MACSio
A Multi-purpose, Application-Centric, Scalable I/O Proxy Application
Stars: ✭ 28 (-69.23%)
Mutual labels:  hpc, scientific-computing
PSyclone
Domain-specific compiler for Finite Difference/Volume/Element Earth-system models in Fortran
Stars: ✭ 67 (-26.37%)
Mutual labels:  parallel-computing, finite-elements
MinimalFem
podgorskiy.com/spblog/304/writing-a-fem-solver-in-less-the-180-lines-of-code
Stars: ✭ 23 (-74.73%)
Mutual labels:  fem, finite-elements
pcluster-manager
Manage AWS ParallelCluster through an easy to use web interface
Stars: ✭ 67 (-26.37%)
Mutual labels:  hpc, parallel-computing

Binder badge badge

MFEM + PyMFEM (FEM library)

This repository provides Python binding for MFEM. MFEM is a high performance parallel finite element method (FEM) library (http://mfem.org/).

Installer (setup.py) builds both MFEM and binding together. By default, "pip install mfem" downloads and builds the serial version of MFEM and PyMFEM. Additionally, the installer supports building MFEM with specific options together with other external libraries, including MPI version.

Install

pip install mfem                    # binary install is available only on linux platforms (Py36-39) 
pip install mfem --no-binary mfem   # install serial MFEM + wrapper

Using additional features (MPI, GPU, GPU-Hypre, GSLIB, SuiteSparse)

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 /mfem. See also, docs/install.txt

$ 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

Install from github master

git clone https://github.com/mfem/PyMFEM.git
cd PyMFEM
python setup.py install --mfem-branch=master  # build both MFEM and PyMFEM
  
cd test
python test_examples.py -serial

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

License

PyMFEM is licensed under BSD-3. Please refer the developers' web sites for the external libraries

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].