Git Product home page Git Product logo

pymfem's Introduction

                Finite Element Discretization Library
                               __
                   _ __ ___   / _|  ___  _ __ ___
                  | '_ ` _ \ | |_  / _ \| '_ ` _ \
                  | | | | | ||  _||  __/| | | | | |
                  |_| |_| |_||_|   \___||_| |_| |_|

                           https://mfem.org

MFEM is a modular parallel C++ library for finite element methods. Its goal is to enable high-performance scalable finite element discretization research and application development on a wide variety of platforms, ranging from laptops to supercomputers.

We welcome contributions and feedback from the community. Please see the file CONTRIBUTING.md for additional details about our development process.

  • For building instructions, see the file INSTALL, or type "make help".

  • Copyright and licensing information can be found in files LICENSE and NOTICE.

  • The best starting point for new users interested in MFEM's features is to review the examples and miniapps at https://mfem.org/examples.

  • Instructions for learning with Docker are in config/docker.

Conceptually, MFEM can be viewed as a finite element toolbox that provides the building blocks for developing finite element algorithms in a manner similar to that of MATLAB for linear algebra methods. In particular, MFEM provides support for arbitrary high-order H1-conforming, discontinuous (L2), H(div)-conforming, H(curl)-conforming and NURBS finite element spaces in 2D and 3D, as well as many bilinear, linear and nonlinear forms defined on them. It enables the quick prototyping of various finite element discretizations, including Galerkin methods, mixed finite elements, Discontinuous Galerkin (DG), isogeometric analysis, hybridization and Discontinuous Petrov-Galerkin (DPG) approaches.

MFEM includes classes for dealing with a wide range of mesh types: triangular, quadrilateral, tetrahedral and hexahedral, as well as surface and topologically periodical meshes. It has general support for mesh refinement, including local conforming and non-conforming (AMR) adaptive refinement. Arbitrary element transformations, allowing for high-order mesh elements with curved boundaries, are also supported.

When used as a "finite element to linear algebra translator", MFEM can take a problem described in terms of finite element-type objects, and produce the corresponding linear algebra vectors and fully or partially assembled operators, e.g. in the form of global sparse matrices or matrix-free operators. The library includes simple smoothers and Krylov solvers, such as PCG, MINRES and GMRES, as well as support for sequential sparse direct solvers from the SuiteSparse library. Nonlinear solvers (the Newton method), eigensolvers (LOBPCG), and several explicit and implicit Runge-Kutta time integrators are also available.

MFEM supports MPI-based parallelism throughout the library, and can readily be used as a scalable unstructured finite element problem generator. Starting with version 4.0, MFEM offers support for GPU acceleration, and programming models, such as CUDA, HIP, OCCA, RAJA and OpenMP. MFEM-based applications require minimal changes to switch from a serial to a highly-performant MPI-parallel version of the code, where they can take advantage of the integrated linear solvers from the hypre library. Comprehensive support for other external packages, e.g. PETSc, SUNDIALS and libCEED is also included, giving access to additional linear and nonlinear solvers, preconditioners, time integrators, etc.

For examples of using MFEM, see the examples/ and miniapps/ directories, as well as the OpenGL visualization tool GLVis which is available at https://glvis.org.

License

MFEM is distributed under the terms of the BSD-3 license. All new contributions must be made under this license. See LICENSE and NOTICE for details.

SPDX-License-Identifier: BSD-3-Clause
LLNL Release Number: LLNL-CODE-806117
DOI: 10.11578/dc.20171025.1248

pymfem's People

Contributors

andersonw1 avatar benzwick avatar cwsmith avatar goodman17c avatar idoakkerman avatar justinlaughlin avatar kennyweiss avatar kmittal2 avatar niklasfreymuth avatar psocratis avatar siuwuncheung avatar sshiraiwa avatar tbridel avatar tkoyama010 avatar tzanio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymfem's Issues

`pip3 install mfem --install-option="--with-parallel"` not working

When I install PyMFEM using pip3 install mfem --install-option="--with-parallel" --verbose I cannot import mfem.ser or mfem.par:

In [1]: import mfem.ser
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-d6ad452c785f> in <module>
----> 1 import mfem.ser

ModuleNotFoundError: No module named 'mfem.ser'

In [2]: import mfem.par
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-6f8793407d7f> in <module>
----> 1 import mfem.par

ModuleNotFoundError: No module named 'mfem.par'

Despite the installation appearing to be successful:

...
  byte-compiling /home/ben/.local/local/lib/python3.10/dist-packages/mfem/_par/communication.py to communication.cpython-310.pyc
  byte-compiling /home/ben/.local/local/lib/python3.10/dist-packages/mfem/_par/fe_nurbs.py to fe_nurbs.cpython-310.pyc
  byte-compiling /home/ben/.local/local/lib/python3.10/dist-packages/mfem/_par/datacollection.py to datacollection.cpython-310.pyc
  byte-compiling /home/ben/.local/local/lib/python3.10/dist-packages/mfem/_par/gslib.py to gslib.cpython-310.pyc
  byte-compiling /home/ben/.local/local/lib/python3.10/dist-packages/mfem/_par/eltrans.py to eltrans.cpython-310.pyc
  byte-compiling /home/ben/.local/local/lib/python3.10/dist-packages/mfem/__sha__.py to __sha__.cpython-310.pyc
  running install_egg_info
  running egg_info
  writing mfem.egg-info/PKG-INFO
  writing dependency_links to mfem.egg-info/dependency_links.txt
  deleting mfem.egg-info/requires.txt
  writing top-level names to mfem.egg-info/top_level.txt
  reading manifest file 'mfem.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching 'external/README.txt'
  adding license file 'LICENSE'
  writing manifest file 'mfem.egg-info/SOURCES.txt'
  removing '/home/ben/.local/local/lib/python3.10/dist-packages/mfem-4.4.0.1-py3.10.egg-info' (and everything under it)
  Copying mfem.egg-info to /home/ben/.local/local/lib/python3.10/dist-packages/mfem-4.4.0.1-py3.10.egg-info
  running install_scripts
  writing list of installed files to '/tmp/pip-record-9fs919kq/install-record.txt'
  Running setup.py install for mfem ... done
Successfully installed mfem

Modify the neo-Hookean solid code for more general hyperelastic model

Hello,

I just tried the PyFEM on the Expanse cluster supported by SDSC. It is very convenient to install the software, which is very nice. Thanks a lot for your effort. I tested the ex10p and found it works well. I have a general question for implementing more complicated hyperelastic models, such as Arruda–Boyce model and Gent model, which are similar to the neo-Hookean model. It is also interesting to know how to code other models based on more different formulas, such as Ogden model.

In addition, I am also interested in Multiphysics problems, such as hydrogel swelling. I am wondering whether there is a general strategy to achieve these goals? I guess the technique questions are: Can we achieve this through python script only? If we need to modify the c++ MFEM code, how should I create a new function? The current examples are very impressive, but I did not find one to teach how to configure a multiphysics solver yet.

Thanks a lot.

Best,
Teng

Tasks to be done..

  • Clean up old files.
  • PIP support ?
  • Strumpack
  • Support numba function for coefficient
  • Perform tests using examples
  • gz compressed files
  • Binary release for Mac
  • libCeed support
  • DenseMatrix Constructor from numpy array
  • hypre mixedint support?
  • ex0, ex0p
  • ex20, ex20p
  • ex21, ex21p
  • ex22, ex22p
  • ex23
  • ex24, ex24p
  • ex25
  • ex26, ex26p
  • ex27, ex27p
  • ex28, ex28p
  • ex29, ex29p
    ====
    Below is memo to report later...
    ex23 -r is either ref-levels or ref_dir?

Incompatible numpy API versions with Python 3.7 and 3.8

I am using PyMFEM through Google Colab, and it looks like they just updated the Python version to 3.8.16 (I believe 3.7.x was the default before).

Now when I try pip install mfem the PyMFEM package is successfully installed, but import mfem.ser as mfem results in

module compiled against API version 0x10 but this version of numpy is 0xe

The numpy version is 1.21.6, which used to be working with the older version of Python.

Updating numpy with pip install -U numpy fixes the problem for me, but I feel like this should be caught at the pip install mfem stage.

It looks like the issue is that the 3.7 binary is built with numpy 1.21.6 (see here) but the 3.8 binary is built with numpy 1.23.3 (see here).

Maybe the numpy version requirements need to be changed in requirements.txt?

(An ideal solution for me would allow the 3.8 binary to work with numpy 1.21.6, since this is what is available by default in Colab, and upgrading to a newer numpy version requires restarting the runtime)

Thanks!

Hypre link error with parallel builds

I'm having trouble building the code this way on LLNL's rzgenie machine:
virtualenv python3.7 myenv
source myenv/bin/activate.csh
pip3 download mfem
pip setup.py install --with-parallel

Seems to get quite far, though fails with an mpic+++ link error:
mpic++ -pthread -shared -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/sqlite-3.26.0-a7m6nmm5j2swmqfafff6ajhbilnn6vn5/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/zlib-1.2.11-3r4cfkmx3wwfqeof4bc244yduu2mz4ur/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/bzip2-1.0.6-ocokiv4gyfgsngehfu2xclts4sh3az73/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/ncurses-6.1-hqxqcpqjsvrp5zupkgw5vlleevj5yh5t/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/expat-2.2.5-osfcbgccvn6hpz7bseedtglebyfi5qc4/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/openssl-1.1.1a-onzwgt3njper5sjgn7odvpxpxsgiokga/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/xz-5.2.4-m5oetwxbcqb6ptsufia2v5lekrn5xcxi/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/libffi-3.2.1-af4a54r5gq5mbnjzazcbrcapqmrxijak/lib64 -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/readline-7.0-e5jqqjmcjknidgwvi353pd6umpixzxr2/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/gdbm-1.18.1-e2zcux636yhdpibo6ufjywbq6woale4c/lib build/temp.linux-x86_64-3.7/io_stream_wrap.o -L/usr/WS2/olson45/pyranda/HYPRE_SAND/py3.7/mfem/par/lib -L/usr/WS2/olson45/pyranda/HYPRE_SAND/py3.7/mfem/lib -L/usr/WS2/olson45/pyranda/HYPRE_SAND/py3.7/mfem/lib -L/collab/usr/gapps/python/build/spack-toss3.3/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/python-3.7.2-asydydmavj2puklmx5t6cu3ruzmg2b3a/lib -Wl,-R/usr/WS2/olson45/pyranda/HYPRE_SAND/py3.7/mfem/par/lib -Wl,-R/usr/WS2/olson45/pyranda/HYPRE_SAND/py3.7/mfem/lib -Wl,-R/usr/WS2/olson45/pyranda/HYPRE_SAND/py3.7/mfem/lib -lmfem -lHYPRE -lmetis -lpython3.7m -o /usr/WS2/olson45/pyranda/HYPRE_SAND/PyMFEM/mfem/_par/_io_stream.cpython-37m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lHYPRE

A colleague independently verified the error I'm seeing.

Any ideas? Thanks

Error when importing PyMFEM installed using pip

First of all, I want to say that it's amazing that there is now such an easy way to install PyMFEM using pip!

I tried to install this on Ubuntu 20.04 using the following command:

$ pip3 install mfem --no-binary mfem   # install serial MFEM + wrapper
Collecting mfem
  Using cached mfem-4.2.0.1.tar.gz (6.2 MB)
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from mfem) (1.17.4)
Skipping wheel build for mfem, due to binaries being disabled for it.
Installing collected packages: mfem
    Running setup.py install for mfem ... done
Successfully installed mfem-4.2.0.1

which appeared to be successful.

Then I tried to run example 1 but it failed with the following error:

$ ipython3 
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sys 
   ...: from os.path import expanduser, join 
   ...: import numpy as np                                                                                                                                                                                                                  

In [2]: from mfem.common.arg_parser import ArgParser                                                                                                                                                                                        

In [3]: from mfem import path                                                                                                                                                                                                               

In [4]: import mfem.ser as mfem                                                                                                                                                                                                             
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-bda064bf5c1a> in <module>
----> 1 import mfem.ser as mfem

~/.local/lib/python3.8/site-packages/mfem/ser.py in <module>
----> 1 from  mfem._ser.globals import *
      2 from  mfem._ser.mem_manager import *
      3 from  mfem._ser.device import *
      4 from  mfem._ser.hash import *
      5 from  mfem._ser.array import *

~/.local/lib/python3.8/site-packages/mfem/_ser/globals.py in <module>
     11 # Import the low-level C/C++ module
     12 if __package__ or "." in __name__:
---> 13     from . import _globals
     14 else:
     15     import _globals

ImportError: libmfem.so.4.2.0: cannot open shared object file: No such file or directory

Do you know what I might have done wrong or could there a problem with the setup.py file?

How to modify swig files to sync with mfem master

I am using PyMFEM in a project with @psocratis and @gillette7 where we commonly add new features to an older mfem branch and swig generates the corresponding wrapper. We would like to update our old MFEM branch with the current version of master, but run into problems when linking with swig. For example, when linking MFEM's master to PyMFEM's master, we run into an issue with the function PrintMatlab:

handle_wrap.cxx:6306:16: error: call to member function 'PrintMatlab' is ambiguous
      (*arg1)->PrintMatlab(*arg2);
      ~~~~~~~~~^~~~~~~~~~~
/Users/keith10/Work/mfem/mfem/include/mfem/fem/ceed/../../linalg/operator.hpp:245:9: note: candidate function
   void PrintMatlab(std::ostream & out, int n = 0, int m = 0) const;
        ^
/Users/keith10/Work/mfem/mfem/include/mfem/fem/ceed/../../linalg/operator.hpp:248:17: note: candidate function
   virtual void PrintMatlab(std::ostream & out) const;
                ^
1 warning and 1 error generated.

We'd like to learn how to resolve this issue, and other similar issues in the future, but don't know enough about swig and how it works to be able to do so. Any help would be appreciated. Please advise.

Failing to run parallel tests/examples on a parallel installation

Hello,

I installed PyMFEM with parallel support using python setup.py install --mfem-branch=master --with-parallel --CC=cc --CXX=c++ --MPICC=mpicc --MPICXX=mpicx, and while the parallel examples in C seem to run properly, the PyMFEM ported examples all fail. When I execute python run_examples.py -parallel to compare PyMFEM and MFEM example outputs, every C example runs and properly generates output files, while every python example fails to generate any. Running any of the python parallel examples (ex0.py here) gives the same error:

Traceback (most recent call last):
  File "/home/joseph/Programs/MFEM-test/PyMFEM/examples/ex0p.py", line 24, in <module>
    import mfem.par as mfem
  File "/home/joseph/miniconda3/lib/python3.9/site-packages/mfem/par.py", line 12, in <module>
    from  mfem._par.globals import *
  File "/home/joseph/miniconda3/lib/python3.9/site-packages/mfem/_par/globals.py", line 13, in <module>
    from . import _globals
ImportError: /home/joseph/miniconda3/lib/python3.9/site-packages/mfem/external/par/lib/libmfem.so.4.4.0: undefined symbol: hypre_IntArrayDestroy

Running the example test script in serial mode works perfectly, so the error lies somewhere in the parallel installation and more specifically likely in hypre. I have tried doing a fresh re-installation of PyMFEM and have the same issue. I have also ensured that I properly set LD_LIBRARY_PATH according to my MPI installation, and tried re-installing without explicitly supplying the compilers to use.

I am running Ubuntu 22.04, Conda 4.13.0, Python 3.9.7, GCC 11.2.0, CMAKE 3.22.1.

Support libCEED

As part of the upgrade to mfem-4.3, can we enable the libCEED support?

Segmentation fault when assembling linear form with MatrixVectorProductCoefficient

I am trying to use MatrixVectorProductCoefficient in a DomainLFGradIntegrator as follows but I get a segmentation fault:

With Numba:

import mfem.ser as mfem
import numpy as np
from numba import cfunc, carray

mesh = mfem.Mesh(10, 10, 10, "HEXAHEDRON")
sdim = mesh.SpaceDimension()
ndim = mesh.Dimension()

fec = mfem.H1_FECollection(1, mesh.Dimension())
fespace = mfem.FiniteElementSpace(mesh, fec)

k = 2.0
C = mfem.MatrixConstantCoefficient([[ k, 0., 0.],
                                    [0.,  k, 0.],
                                    [0., 0.,  k]])

@cfunc(mfem.vector_sig)
def v_func(x, out, sdim, vdim):
    out_array = carray(out, (vdim, ))
    out_array[0] = x[0]
    out_array[1] = x[1]
    out_array[2] = x[2]

v_coef = mfem.VectorNumbaFunction(v_func, sdim, ndim).GenerateCoefficient()
f = mfem.MatrixVectorProductCoefficient(C, v_coef)

b = mfem.LinearForm(fespace)
b.AddDomainIntegrator(mfem.DomainLFGradIntegrator(f))
b.Assemble()

Without Numba:

import mfem.ser as mfem
import numpy as np

mesh = mfem.Mesh(10, 10, 10, "HEXAHEDRON")
ndim = mesh.Dimension()

fec = mfem.H1_FECollection(1, mesh.Dimension())
fespace = mfem.FiniteElementSpace(mesh, fec)

k = 2.0
C = mfem.MatrixConstantCoefficient([[ k, 0., 0.],
                                    [0.,  k, 0.],
                                    [0., 0.,  k]])

class v_func(mfem.VectorPyCoefficient):
    def __init__(self):
       mfem.VectorPyCoefficient.__init__(self, ndim)
    def EvalValue(self, x):
       return (x[1], x[2], x[0])

v_coef = v_func()
f = mfem.MatrixVectorProductCoefficient(C, v_coef)

b = mfem.LinearForm(fespace)
b.AddDomainIntegrator(mfem.DomainLFGradIntegrator(f))
b.Assemble()

Does anyone know what is going wrong here?

EDIT: simplified the example and added non-Numba version.

(Done) MFEM 4.5

This is a ToDo list for PyMFEM 4.5.

At moment, python3 setup.py install --mfem-branch=master seems working.

  • support / test sub-mesh feature
  • imporove mfem.jit to allow for using GridFunctionCoefficient inside numba-JITed coefficient
  • check with SWIG 4.1.0
  • fix the broken option of building MFEM with Lapack
  • #157
  • #160
  • #150

segfault in ncmesh interface

The minimal C++ test program to call the method GetElementDepth() on ncmesh:

#include "mfem.hpp"
using namespace mfem;

int main()
{
   Mesh *mesh = new Mesh("./mfem/data/star.mesh", 1, 1);
   mesh->EnsureNCMesh();

   int depth = mesh->ncmesh->GetElementDepth(0);
   printf("depth = %d\n",depth);
}

produces the expected output of "depth = 0" with a clean exit.

But what I think is the equivalent program in PyMFEM:

import mfem.ser as mfem

mesh = mfem.Mesh("./mfem/data/star.mesh",1,1)
mesh.EnsureNCMesh()

depth = mesh.ncmesh.GetElementDepth(0)
print("depth = %d" % depth)

results in a segfault at the call to GetElementDepth.

Any thoughts on this?

Output vtk with solution data (how to call PrintVTK or PrintVTU?)

So I can get a working output vtk file by doing the following:

mesh.PrintVTK("outmesh.vtk")

But I am not sure how to get it to print out the solution. So if I were to have the solution in sol and verts - just like in the example- how would I format mesh.PrintVTK or PrintVTU to show the solution in a field- say in ParaView?

Thank you for your time and help.

PyMFEM on M1

Hi All,

First, thank you for PyMFEM! I use it on ubuntu, and it's great. But, I'm having issues installing on an M1 Mac, with homebrew underneath.

First, I had to update the CMakeLists.txt that appears in external/mfem/miniapps/performance to use
-mcpu=apple-m1
instead of
-march=native

And that resolved a clang error. But, now while installing, it seems that I've hit a Swig bug ( I think).

++++++++++++++++
array_wrap.cxx:3377:42: error: no matching constructor for initialization of 'mfem::Array'
result = (mfem::Array< int > *)new mfem::Array< int >(arg1,arg2);
^ ~~~~~~~~~
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:76:11: note: candidate constructor not viable: no known conversion from 'int' to 'int *' for 1st argument; take the address of the argument with &
inline Array(T *data_, int asize)
^
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:67:11: note: candidate constructor not viable: requires single argument 'mt', but 2 arguments were provided
inline Array(MemoryType mt) : size(0) { data.Reset(mt); }
^
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:70:20: note: candidate constructor not viable: requires single argument 'asize', but 2 arguments were provided
explicit inline Array(int asize)
^
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:81:11: note: candidate constructor not viable: requires single argument 'src', but 2 arguments were provided
inline Array(const Array &src);
^
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:85:11: note: candidate constructor template not viable: requires single argument 'src', but 2 arguments were provided
inline Array(const Array &src);
^
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:89:20: note: candidate constructor template not viable: requires single argument 'values', but 2 arguments were provided
explicit inline Array(const CT (&values)[N]);
^
/Users/jacobschroder/.local/lib/ser/include/mfem/general/array.hpp:64:11: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
inline Array() : size(0) { data.Reset(); }

Anyway, I'm installing only PyMFEM serial from the current repo head with
$ python3 setup.py install --prefix=~/.local/lib/ --CC=gcc --CXX=g++
And my Swig is version 4.02 from Homebrew.
+++++++++++++

Any advice would be much appreciated!

Steps toward MFEM 4.0 and Python 3 support

  • branch name MFEM4_dev
  • Absorb Python 2.7 and 3.7 C API difference

  • Add future detectives, remove raw_input and other Python 3.7

  • Check existing tests

  • Eliminate libboost dependency

  • Add ex20, ex21 ex20p, ex21p

  • Clean up old files.

  • PIP support ?

  • Strumpack

  • Test on ubuntu18, centos7

  • Test on macOS

Inheritance and Dynamic casting in python

@sshiraiwa

Assuming that I have all the wrappers implemented, what would be the best way to achieve the equivalent of the following C++ code in python:

ParMesh *pmesh = new ParPumiMesh(MPI_COMM_WORLD, pumi_mesh); 
ParPumiMesh* pmesh2 = dynamic_cast<ParPumiMesh*>(pmesh); 

Here ParPumiMesh is a subclass of ParMesh.

Memory problem DenseMatrix.Assign(np.array)

Hi,
I was using a derived class from MatrixPyCoefficient and ran into memory problems. Using tracemalloc I tracked it down to the method EvalValue and the Assign method for DenseMatrix in _EvalPy. Using _EvalPy directly instead of creating an intermediate np.array in EvalValue solved the problem. To confirm the problem I wrote a small test program:

import numpy as np
import mfem.ser as mfem

n = 4 * 1024 // 8
d = 1024
K = mfem.DenseMatrix(d,d)
for i in range(n): 
    K.Assign(np.diag(d * np.ones(d)))

input("Press Enter to continue...")

When started it uses 4 GB of memory: it seems that all the intermediate n=512 matrices with each 8 MB = 8*1024**2 byte are kept. As far as I understand these matrices should be freed, right? Or is there something wrong with my code?
Thanks
Andras

Compile successfully but import error

I compile this project with python setup.py install --mfem-branch=master on CentOS sucessfully.
But when I try to import mfem.ser I got

    from . import _cpointers
    ImportError: libmpi.so.12: cannot open shared object file: No such file or directory

My enviroment:

  • CentOS 7.9.2009 (Core)
  • Conda 4.10.3
  • Python 3.8.12
    • six 1.16.0
    • numpy 1.21.2
  • GCC 8.1.0
  • CMake 3.17.0

Any possible solution for this? Thanks advance.

SaveVTK and PrintVTK wrappers

Are wrappers for Mesh::void PrintVTK(std::ostream &out, int ref, int field_data=0); and GridFunction::SaveVTK(std::ostream &out, const std::string &field_name, int ref); , implemented in PyMFEM? If yes, how should one create a std::ostream object in python and pass it to the corresponding wrapper?

module 'mfem.par' has no attribute 'QuadratureSpace'

This was working about a year ago, but now QuadratureSpace is not available:

In [1]: import mfem.par as mfem
   ...: mesh = mfem.Mesh(10, 10, "TRIANGLE")
   ...: qspace = mfem.QuadratureSpace(mesh, 0)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-fee26b20964c> in <module>
      1 import mfem.par as mfem
      2 mesh = mfem.Mesh(10, 10, "TRIANGLE")
----> 3 qspace = mfem.QuadratureSpace(mesh, 0)

AttributeError: module 'mfem.par' has no attribute 'QuadratureSpace'

ToDo for PyMFEM 4.4

ToDo list

  • DenseTensor Constructor from numpy array (4.3.0.1)
  • hypre mixedint support?
  • ex25, ex25p, ex30, ex30p
  • ex31, ex31p, ex32p
  • HYPRE_USE_CUDA
  • gslib
  • distant_solver
  • migrate test in cuda 11.5
  • symmat.hpp
  • redo Array constructor to support MemoryType

After 4.4

  • Strumpack
  • Binary release for Mac
  • libCeed Algebraic Solver

Getting DOF vertex locations

Hi All,

Thank you for PyMFEM. I've really been enjoying it, so far.

I'm currently generating some FEM matrices from example 9, and let's call the matrices that I get "A".

I would also like to get a list of vertex locations for each of A's degrees-of-freedom. That is, if A is (n x n), I'd like to get an array of size (n x 2) of the x and y locations for each of A's degrees-of-freedom.

I have a hack right now, that seems to mostly work, but only for certain mesh files.

Is there a recommended way to do this?

Thanks!

Jacob

how does "pip install mfem" should work????

Since PyMFEM 4.2 passed my test, I started looking into the idea of making mfem + wrapper install-able from pip.

And I would like to have your input in terms of how/what PIP installer should do.
My current thought is following.

For the wrapper to work, at the very minimum, the following three should happen

  1. Install a specific version of mfem
  2. built it as a dynamic library
  3. build the wrapper code and install it.

It looks doable to write setup.py to do all of them, and because the wrapper requires a
specific version of mfem, probably it makes sense to do this all together, instead of asking
a user to install mfem separately and specify the library path.

My question is about how we should be handling dependency libraries.

I could support very basic things such as METIS and Hypre, since I have a mechanism to install
them (https://github.com/piScope/TwoPi). However, considering ever growing number of dependency and
the fact that several package tools are available, I am inclined to leave a user to install them
separately. This would keep the setup script reasonably compact, and maintainable.

Please let me know what you think about this plan. Any suggestion/question (or even throwing
wrench into this ;D) s welcome.

Build fails with latest setuptools

With setuptools v60.0.3
Python 3.7 and 3.8 fails with this

ImportError: cannot import name 'sdist' from 'setuptools._distutils.command' 

Python 3.9 fails with

 Traceback (most recent call last):
    File "/root/PyMFEM/mfem/_ser/setup.py", line 22, in <module>
      from distutils.core import *
    File "/usr/local/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 92, in create_module
      return importlib.import_module('setuptools._distutils')
    File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 16, in <module>
      import setuptools.version
    File "/usr/local/lib/python3.9/site-packages/setuptools/version.py", line 1, in <module>
      import pkg_resources
    File "/usr/local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 33, in <module>
      import email.parser
    File "/usr/local/lib/python3.9/email/parser.py", line 12, in <module>
      from email.feedparser import FeedParser, BytesFeedParser
    File "/usr/local/lib/python3.9/email/feedparser.py", line 27, in <module>
      from email._policybase import compat32
    File "/usr/local/lib/python3.9/email/_policybase.py", line 9, in <module>
      from email.utils import _has_surrogates
    File "/usr/local/lib/python3.9/email/utils.py", line 29, in <module>
      import socket
    File "/usr/local/lib/python3.9/socket.py", line 548, in <module>
      import array
    File "/root/PyMFEM/mfem/_ser/array.py", line 15, in <module>
      import _array
  ModuleNotFoundError: No module named '_array'

mesh.GetBoundingBox() does not work in parallel

I get the following error:

NameError                                 Traceback (most recent call last)
~/projects/EEG/mfem-eeg-python/eeg_leadfield.py in <module>
     60 print("done.")
     61 
---> 62 print("Mesh bounding box: ", mesh.GetBoundingBox())
     63 
     64 # create finite element function space

~/.local/lib/python3.8/site-packages/mfem/_par/pmesh.py in GetBoundingBox(self, ref)
    313         min = Vector()
    314         max = Vector()
--> 315         _mesh.Mesh_GetBoundingBox(self, min, max, ref)
    316         return min.GetDataArray().copy(), max.GetDataArray().copy()
    317 

NameError: name '_mesh' is not defined

It looks to me like _mesh should be replaced with _pmesh here:

_mesh.Mesh_GetBoundingBox(self, min, max, ref)

and also here:

count = _mesh.Mesh_FindPoints(self, M, elem_ids, int_points, warn, inv_trans)

Use of GetCoarseToFineMap() interface

Is it currently possible to use the GetCoarseToFineMap() interface to mfem::CoarseFineTransformations?

I am able to call:
cft = mesh.GetRefinementTransforms()

but then I can't figure out how to call:

cft.GetCoarseToFineMap(mesh, coarse_to_fine, coarse_to_ref_type, ref_type_to_matrix, ref_type_to_geom)

without getting a type error on the ref_type_to_geom argument, which expects an mfem::Array< mfem::Geometry::Type > &. I am not sure what to do there.

Install with STRUMPACK fails

Attempting to install PyMFEM with option --with-strumpack as follows:

python3 setup.py install --with-parallel --with-strumpack --user

fails with the following error:

Moving to a directory : /home/ben/projects/mfem/PyMFEM/external/mfem/cmbuild_par
calling ... cmake .. -DCMAKE_VERBOSE_MAKEFILE=1 -DBUILD_SHARED_LIBS=1 -DMFEM_ENABLE_EXAMPLES=1 -DMFEM_ENABLE_MINIAPPS=1 -DCMAKE_SHARED_LINKER_FLAGS=-L/home/ben/.local/mfem/lib -L/home/ben/.local/mfem/lib -DMFEM_USE_ZLIB=1 -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_CXX_COMPILER=mpic++ -DMFEM_USE_EXCEPTIONS=0 -DCMAKE_INSTALL_PREFIX=/home/ben/.local/mfem/par -DMFEM_USE_MPI=1 -DMFEM_USE_METIS_5=1 -DHYPRE_DIR=/home/ben/.local/mfem -DMETIS_DIR=/home/ben/.local/mfem -DMFEM_USE_STRUMPACK=1 -STRUMPACK_DIR=/home/ben/.local/mfem
CMake Error: The source directory "/home/ben/projects/mfem/PyMFEM/external/mfem/cmbuild_par/TRUMPACK_DIR=/home/ben/.local/mfem" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Failed when calling command: cmake .. -DCMAKE_VERBOSE_MAKEFILE=1 -DBUILD_SHARED_LIBS=1 -DMFEM_ENABLE_EXAMPLES=1 -DMFEM_ENABLE_MINIAPPS=1 -DCMAKE_SHARED_LINKER_FLAGS=-L/home/ben/.local/mfem/lib -L/home/ben/.local/mfem/lib -DMFEM_USE_ZLIB=1 -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_CXX_COMPILER=mpic++ -DMFEM_USE_EXCEPTIONS=0 -DCMAKE_INSTALL_PREFIX=/home/ben/.local/mfem/par -DMFEM_USE_MPI=1 -DMFEM_USE_METIS_5=1 -DHYPRE_DIR=/home/ben/.local/mfem -DMETIS_DIR=/home/ben/.local/mfem -DMFEM_USE_STRUMPACK=1 -STRUMPACK_DIR=/home/ben/.local/mfem
Traceback (most recent call last):
  File "setup.py", line 1110, in <module>
    main()
  File "setup.py", line 1106, in main
    run_setup()
  File "setup.py", line 1094, in run_setup
    setup(
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 916, in run
    _install.run(self)
  File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 65, in run
    orig.install.run(self)
  File "/usr/lib/python3.8/distutils/command/install.py", line 589, in run
    self.run_command('build')
  File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 948, in run
    cmake_make_mfem(serial=False)
  File "setup.py", line 438, in cmake_make_mfem
    cmake('..', **cmake_opts)
  File "setup.py", line 283, in cmake
    make_call(command)
  File "setup.py", line 211, in make_call
    subprocess.check_call(command, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '..', '-DCMAKE_VERBOSE_MAKEFILE=1', '-DBUILD_SHARED_LIBS=1', '-DMFEM_ENABLE_EXAMPLES=1', '-DMFEM_ENABLE_MINIAPPS=1', '-DCMAKE_SHARED_LINKER_FLAGS=-L/home/ben/.local/mfem/lib -L/home/ben/.local/mfem/lib', '-DMFEM_USE_ZLIB=1', '-DCMAKE_CXX_FLAGS=-std=c++11', '-DCMAKE_CXX_COMPILER=mpic++', '-DMFEM_USE_EXCEPTIONS=0', '-DCMAKE_INSTALL_PREFIX=/home/ben/.local/mfem/par', '-DMFEM_USE_MPI=1', '-DMFEM_USE_METIS_5=1', '-DHYPRE_DIR=/home/ben/.local/mfem', '-DMETIS_DIR=/home/ben/.local/mfem', '-DMFEM_USE_STRUMPACK=1', '-STRUMPACK_DIR=/home/ben/.local/mfem']' returned non-zero exit status 1.

Cloning MFEM using git protocol requires public key

When I tried to install the mfem-4.3-dev branch as suggested in #88 (comment) I got the following error:

calling ... git clone [email protected]:mfem/mfem.git
Cloning into 'mfem'...
Warning: Permanently added the RSA host key for IP address '52.64.108.95' to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

subprocess.CalledProcessError: Command '['git', 'clone', '[email protected]:mfem/mfem.git']' returned non-zero exit status 128.

I got it working by simply replacing git with https in setup.py:

 repo_releases = {"mfem": "https://github.com/mfem/mfem/archive/v4.2.tar.gz",
                  "metis": "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz",
                  "hypre": "https://github.com/hypre-space/hypre/archive/v2.20.0.tar.gz",}
-repos = {"mfem": "[email protected]:mfem/mfem.git", }
+repos = {"mfem": "https://github.com/mfem/mfem.git", }
 
 rootdir = os.path.abspath(os.path.dirname(__file__))
 extdir = os.path.join(rootdir, 'external')

Note that when trying to do this manually on GitHub there is this message:

You don't have any public SSH keys in your GitHub account. You can add a new public key, or try cloning this repository via HTTPS.

Should the change be made in setup.py to use https to avoid this problem?

How to use FunctionCoefficient

I'm trying to use FunctionCoefficient in pymfem. For regular mfem, the syntax I've used succesfully is:

double myfunction(const Vector &x)
{
   return (x(0) + x(1))
}

and then

FunctionCoefficient *u = new FunctionCoefficient(myfunction)

How does the syntax work for pymfem? I tried this:

def myfunction(input_point):
     return (input_point[0] + input_point[1])

myFunCoeff = mfem.FunctionCoefficient(myfunction)

but I get this error:

TypeError: Wrong number or type of arguments for overloaded function 'new_FunctionCoefficient'.
  Possible C/C++ prototypes are:
    mfem::FunctionCoefficient::FunctionCoefficient(std::function< double (mfem::Vector const &) >)
    mfem::FunctionCoefficient::FunctionCoefficient(std::function< double (mfem::Vector const &,double) >)
    mfem::FunctionCoefficient::FunctionCoefficient(double (*)(mfem::Vector &))
    mfem::FunctionCoefficient::FunctionCoefficient(double (*)(mfem::Vector &,double))

Thanks for any help!

Specify numpy version for dependencies

It looks like the binaries installed with pip install mfem require matching versions of numpy, however these are not specified anywhere so pip does not seem to enforce this. The result is that, in a new environment after installing mfem 4.2.0.8 and numpy 1.19.2 I get the following error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-1d0a07aa8d3a> in <module>
      1 # import numpy as np
----> 2 import mfem.ser as mfem
      3 import matplotlib.pyplot as plt
      4 
      5 get_ipython().run_line_magic('matplotlib', 'widget')

~/.conda/envs/mfem/lib/python3.8/site-packages/mfem/ser.py in <module>
----> 1 from  mfem._ser.globals import *
      2 from  mfem._ser.mem_manager import *
      3 from  mfem._ser.device import *
      4 from  mfem._ser.hash import *
      5 from  mfem._ser.array import *

~/.conda/envs/mfem/lib/python3.8/site-packages/mfem/_ser/globals.py in <module>
     11 # Import the low-level C/C++ module
     12 if __package__ or "." in __name__:
---> 13     from . import _globals
     14 else:
     15     import _globals

ImportError: numpy.core.multiarray failed to import

For now, I'll just play around with numpy versions until it works, but it would be better if dependencies were resolved automatically.

Changing viz options for with socketstream

Is there a way to change the visualization options for a glvis call by sending pre-set keyboard commands? For instance, this works for changing the title of the window:
title = "Pretty picture"
sol_sock.send_text("window_title '" + title)
I'd like to pass a string of characters indicating how I'd like glvis to do the rendering, akin to the interactive visualization - e.g. gRc - but it never seems to work. Am I getting the syntax wrong here or is this not the right method for doing this? Thanks.

Compilation error: rpath are broken

Hello everyone,

I am on a Darwin platform with the apple M1 CPU and for other reasons I have to stick with the compiler suite by llvm and the interface of open-mpi for parallelism - as for versions, they are as follow:

Homebrew clang version 15.0.1
Target: arm64-apple-darwin21.5.0
==> open-mpi: stable 4.1.4 (bottled), HEAD
High performance message passing library
https://www.open-mpi.org/
/opt/homebrew/Cellar/open-mpi/4.1.4_2 (758 files, 17.6MB) *

I am trying to compile PyMFEM with pre-installed MFEM, HYPRE & METIS v5.1.0 distributions.
MFEM is installed with the following options:

${CMAKE} \
-DMFEM_USE_MPI=YES -DMFEM_MPI_NP=2 -DMFEM_USE_OPENMP=YES \
-DHYPRE_DIR=${CODE_DIR}/${SUB_DIR}/hypre/src/hypre \
-DMETIS_DIR=${CODE_DIR}/${SUB_DIR}/metis-${METIS_VERSION}/build \
-DMETIS_INCLUDE_DIRS=${CODE_DIR}/${SUB_DIR}/metis-${METIS_VERSION}/build/include \
-DMETIS_LIBRARIES=${METIS_LIBRARIES} \
-DMFEM_USE_METIS_5=TRUE \
-DCMAKE_CXX_COMPILER=${CXX} \
-DMPI_CXX_COMPILER=${MPICXX} \
-DBUILD_SHARED_LIBS=ON \
${@} \
-S .. -B .

I have had a lot of trouble with the build and the install of PyMFEM -- actually, truth be told, I started 2 days ago and for now it is still not working.
The only way I managed to get it running till the end is with the following command:

python3 setup.py install --no-serial --with-parallel --mfem-prefix=<absolute/path/to>/mfem/build --mfem-source=<absolute/path/to>//mfem --CXX=/opt/homebrew/opt/llvm/bin/clang++ --CC=/opt/homebrew/opt/llvm/bin/clang --MPICXX=/opt/homebrew/opt/open-mpi/bin/mpicxx --MPICC=/opt/homebrew/opt/open-mpi/bin/mpicc --hypre-prefix=<absolute/path/to>//hypre/src/cmbuild --metis-prefix=<absolute/path/to>/metis-5.1.0/build

along with the following modifications of PyMFEM source code:

# mfem/_ser/setup.py
...
include_dirs = [mfemserbuilddir, mfemserincdir, mfemsrcdir, numpyinc, hypreinc, metisinc,]
library_dirs = [mfemserlnkdir, hyprelib, metis5lib,]
...
# Makefile
...
HYPRELNKFLAG = -L$(HYPRELIB) -lHYPRE
METISINCFLAG = -I$(METISINC)
METISLNKFLAG = -L$(METISLIB) -lmetis
#MPIINCFLAG  = -I$(MPIINC)
...
# mfem/_ser/Makefile
...
%_wrap.cxx: %.i
	$(SWIG) -I$(MFEMSERBUILDDIR) $(SWIGFLAG) $(MFEMSERINCFLAG) $(HYPREINCFLAG) $(METISINCFLAG) $<
...
# mfem/_par/Makefile
...
%_wrap.cxx: %.i
	$(SWIG) -I$(MFEMBUILDDIR) $(SWIGFLAG) $(MPI4PYINCFLAG) $(MFEMINCFLAG) $(HYPREINCFLAG) $(METISINCFLAG) -I$(STRUMPACK_INCLUDE) $<
...

With all this, the build process finishes correctly, and then the install finishes as well.
But !
The rpath in the libraries are all wrong, making the whole installed package unusable ... Here is an example for _std_vectors.cpython-310-darwin.so (arbitrary, same problem occurs for all of the *.so):

# otool -L _std_vectors.cpython-310-darwin.so
_std_vectors.cpython-310-darwin.so:
	/usr/local/lib/libmfem.4.4.1.dylib (compatibility version 4.4.1, current version 4.4.1)
	@rpath/libHYPRE.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/local/lib/libmetis.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/homebrew/opt/open-mpi/lib/libmpi.40.dylib (compatibility version 71.0.0, current version 71.4.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.23.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

The first, second and third lines should point to the libraries I specified in the python3 setup.py install ... command (see above). And actually during the link, the command executed shows the right -L and -Wl,-rpath, annotations:

/opt/homebrew/opt/open-mpi/bin/mpicxx -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk build/temp.macosx-12-arm64-cpython-310/std_vectors_wrap.o -L<absolute/path/to>/mfem/build/lib -L<absolute/path/to>/hypre/src/cmbuild/lib -L<absolute/path/to>/metis-5.1.0/build/lib -Wl,-rpath,<absolute/path/to>/mfem/build/lib -Wl,-rpath,<absolute/path/to>/hypre/src/cmbuild/lib -Wl,-rpath,<absolute/path/to>/metis-5.1.0/build/lib -lmfem -lHYPRE -lmetis -o build/lib.macosx-12-arm64-cpython-310/_std_vectors.cpython-310-darwin.so

So the link command is right, but somehow the rpath do not make it to the library object itself.
Could you please advise, I direly need this MFEM wrapper by the middle of the week ... ?

Thank you everyone & take care !

compilation error using intel compilers

I have been compiling PyMFEM successfully using intel compilers but now I am getting a compilation error. Has anybody faced the same issue?

Five days ago the compilation with intel was still working.

Any clues?

Assigning a constant to ParGridFunction objects

How can the following C++ assignment operator be used in python version of the code

ParGridFunction& mfem::ParGridFunction::operator=(double value)

having a ParGridFunction object gf in python and the following expression

gf = 0

cause the type of gf to change.

@sshiraiwa

cxx11flag in mfem/_ser/setup.py

In the line:

extra_compile_args = [cxx11flag, '-DSWIG_TYPE_TABLE=PyMFEM']

where is cxx11flag supposed to come from? It errors out as an undefined name for me when I invoke make ser.

Question: What is the equivalent of C++ arrays in the wrappers

@sshiraiwa

What would be the best way to achieve the equivalent of the following c++ code using the python wrappers:

   int ip_cnt = 0;
   IntegrationRule vert_template(4);
   IntegrationPoint& ip = vert_template.IntPoint(ip_cnt++);
   double pt_crd[3] = {0., 0., 0.};
   ip.Set(pt_crd, 3); 

More specifically, the last 2 lines.

Install issues

Hi - I'm trying to use pymfem on the supercomputer clusters at LLNL. I'm using a virtual environment and had no issue with the command pip install mfem. But then, it seems it's not working as a python package:

(merlin) [gillette@syrah256:delSp-dev]$ pip list | grep mfem
mfem               4.2.0.8
(merlin) [gillette@syrah256:delSp-dev]$ python -q
>>> import mfem
>>> mesh = mfem.Mesh(10, 10, "TRIANGLE")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'mfem' has no attribute 'Mesh'
>>> 

I also tried this:

(merlin) [gillette@syrah256:delSp-dev]$ python -q
>>> import mfem.ser as mfem
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/g/g12/gillette/projects/intro2merlin/merlin_venv/lib/python3.7/site-packages/mfem/ser.py", line 1, in <module>
    from  mfem._ser.globals import *
  File "/g/g12/gillette/projects/intro2merlin/merlin_venv/lib/python3.7/site-packages/mfem/_ser/globals.py", line 13, in <module>
    from . import _globals
ImportError: numpy.core.multiarray failed to import

I feel like I'm missing something basic... any suggestions? Thanks!

pymfem with gslib

Hi,
Are there active plans to introduce the gslib FindPoints routine in PyMFEM?

4.4 Preparation

ToDo list

  • regenerate wrapper with latest
  • pass build_test_with_mfem44
  • ex31, ex31p, ex32p
  • HYPRE_USE_CUDA
  • gslib
  • distant_solver
  • GetCooArrayData() to extract data to construct scipy.coo_matrix
  • Include CUDA built HYPRE in test

After 4.4

  • Strumpack
  • Binary release for Mac
  • libCeed Algebraic Solver

Is it possible to create a mesh object from an array of mesh objects?

This constructor exists in c++ ( Mesh::Mesh(Mesh *mesh_array[], int num_pieces) ) and it seems to e available in the python bindings. However I have to been able to make it work.
I have multiple grids obtained from a parallel run and want to build a new grid using a subset of those grids. Any clue?

Read mesh from GMSH into PyMFEM

Dear Sir,

I have a mesh generated using GMSH (in .msh) format. I can view it using glvis. But I do not understand how to import it into MFEM. What changes need to be done in the statement
"mesh=mfem.Mesh(meshfile,1,1) ?
Sorry for basic question.
Thank you very much.
Best,
Pratik

Cannot use CurlGridFunctionCoefficient

Hi PyMFEM team,

First of all, thank you for this very nice Python wrapper for the MFEM library. I would like to compute the curl of a vector-valued ParGridFunction, for which I tried to use CurlGridFunctionCoefficient. Please see below a very simplified example:

import mfem.par as mfem  # mfem.ser produces the same output

gf = mfem.ParGridFunction()  # passing a ParFiniteElementSpace also does not change the output
curl_gf_coeff = mfem.CurlGridFunctionCoefficient(gf)

Doing so raises the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.9/site-packages/mfem/_ser/coefficient.py", line 608, in __init__
    raise AttributeError("No constructor defined - class is abstract")
AttributeError: No constructor defined - class is abstract

Is this supposed to happen? I'm using PyMFEM in an Apple M1 computer. Thanks in advance for your time,

Aurelio

Support for p-refinement in PyMFEM

I'm working with some folks on a project where we'd like to use p-refinement within PyMFEM. p-refinement is supported in the upcoming MFEM release (v. 4.3) but we'd like to develop the PyMFEM hooks now. My student Justin Crum who is at LLNL (virtually) for the summer will start tackling this. Any concerns or questions, please contact me. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.