Skip to content

Commit

Permalink
Merge pull request #153 from mfem/add_qspace_dev
Browse files Browse the repository at this point in the history
(WIP) added i-files for qfunction, quadinterpolator, quadinterpolator_face
  • Loading branch information
sshiraiwa authored Oct 11, 2022
2 parents 3610cac + b3f32df commit a15726f
Show file tree
Hide file tree
Showing 16 changed files with 229 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_with_MFEM_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
#python-version: ["3.10"]
#os: [ubuntu-latest]
os: [ubuntu-20.04]
Expand Down
2 changes: 1 addition & 1 deletion mfem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ def debug_print(message):

print(message)

__version__ = '4.4.0.2'
__version__ = '4.4.0.3'

36 changes: 36 additions & 0 deletions mfem/_par/qfunction.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%module(package="mfem._par") qfunction
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
#include "pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "numpy/arrayobject.h"
%}

%include "../common/existing_mfem_headers.i"
#ifdef FILE_EXISTS_FEM_QFUNCTION

%init %{
import_array();
%}
%include "exception.i"
%import "fe.i"
%import "fe_fixed_order.i"
%import "element.i"
%import "mesh.i"
%import "qspace.i"
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/numpy_int_typemap.i"
%import "../common/io_stream_typemap.i"
OSTREAM_TYPEMAP(std::ostream&)
ISTREAM_TYPEMAP(std::istream&)

%ignore mfem::QuadratureFunction::SetSpace;

%include "fem/qfunction.hpp"
OSTREAM_ADD_DEFAULT_FILE(QuadratureFunction, Save)
#endif


9 changes: 7 additions & 2 deletions mfem/_par/qspace.i
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%module(package="mfem._ser") qspace
%module(package="mfem._par") qspace
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
Expand All @@ -21,9 +21,14 @@ import_array();
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/io_stream_typemap.i"
OSTREAM_TYPEMAP(std::ostream&)
ISTREAM_TYPEMAP(std::istream&)

%include "fem/qspace.hpp"

#endif
OSTREAM_ADD_DEFAULT_STDOUT_FILE(QuadratureSpace, Save)

#endif


29 changes: 29 additions & 0 deletions mfem/_par/quadinterpolator.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%module(package="mfem._par") quadinterpolator
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
#include "pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "numpy/arrayobject.h"
%}

%include "../common/existing_mfem_headers.i"
#ifdef FILE_EXISTS_FEM_QUADINTERPOLATOR_FACE

%init %{
import_array();
%}
%include "exception.i"
%import "fe.i"
%import "fe_fixed_order.i"
%import "element.i"
%import "mesh.i"
%import "qspace.i"
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/numpy_int_typemap.i"

%include "fem/quadinterpolator.hpp"

#endif
29 changes: 29 additions & 0 deletions mfem/_par/quadinterpolator_face.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%module(package="mfem._par") quadinterpolator_face
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
#include "pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "numpy/arrayobject.h"
%}

%include "../common/existing_mfem_headers.i"
#ifdef FILE_EXISTS_FEM_QUADINTERPOLATOR_FACE

%init %{
import_array();
%}
%include "exception.i"
%import "fe.i"
%import "fe_fixed_order.i"
%import "element.i"
%import "mesh.i"
%import "qspace.i"
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/numpy_int_typemap.i"

%include "fem/quadinterpolator_face.hpp"

#endif
3 changes: 2 additions & 1 deletion mfem/_par/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def get_extensions():
"hypre", "restriction", "prestriction",
"fespacehierarchy", "multigrid", "constraints",
"transfer", "dist_solver", "std_vectors", "auxiliary",
"tmop", "tmop_amr", "tmop_tools", "qspace"]
"tmop", "tmop_amr", "tmop_tools", "qspace", "qfunction",
"quadinterpolator", "quadinterpolator_face"]

if add_pumi == '1':
from setup_local import puminc, pumilib
Expand Down
34 changes: 34 additions & 0 deletions mfem/_ser/qfunction.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%module(package="mfem._ser") qfunction
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
#include "pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "numpy/arrayobject.h"
%}

%include "../common/existing_mfem_headers.i"
#ifdef FILE_EXISTS_FEM_QFUNCTION

%init %{
import_array();
%}
%include "exception.i"
%import "fe.i"
%import "fe_fixed_order.i"
%import "element.i"
%import "mesh.i"
%import "qspace.i"
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/numpy_int_typemap.i"
%import "../common/io_stream_typemap.i"
OSTREAM_TYPEMAP(std::ostream&)
ISTREAM_TYPEMAP(std::istream&)

%ignore mfem::QuadratureFunction::SetSpace;

%include "fem/qfunction.hpp"
OSTREAM_ADD_DEFAULT_FILE(QuadratureFunction, Save)
#endif
6 changes: 6 additions & 0 deletions mfem/_ser/qspace.i
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ import_array();
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/io_stream_typemap.i"
OSTREAM_TYPEMAP(std::ostream&)
ISTREAM_TYPEMAP(std::istream&)

%include "fem/qspace.hpp"

OSTREAM_ADD_DEFAULT_STDOUT_FILE(QuadratureSpace, Save)

#endif


Expand Down
29 changes: 29 additions & 0 deletions mfem/_ser/quadinterpolator.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%module(package="mfem._ser") quadinterpolator
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
#include "pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "numpy/arrayobject.h"
%}

%include "../common/existing_mfem_headers.i"
#ifdef FILE_EXISTS_FEM_QUADINTERPOLATOR

%init %{
import_array();
%}
%include "exception.i"
%import "fe.i"
%import "fe_fixed_order.i"
%import "element.i"
%import "mesh.i"
%import "qspace.i"
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/numpy_int_typemap.i"

%include "fem/quadinterpolator.hpp"

#endif
29 changes: 29 additions & 0 deletions mfem/_ser/quadinterpolator_face.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%module(package="mfem._ser") quadinterpolator_face
%{
#include "mfem.hpp"
#include "../common/io_stream.hpp"
#include "pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "numpy/arrayobject.h"
%}

%include "../common/existing_mfem_headers.i"
#ifdef FILE_EXISTS_FEM_QUADINTERPOLATOR_FACE

%init %{
import_array();
%}
%include "exception.i"
%import "fe.i"
%import "fe_fixed_order.i"
%import "element.i"
%import "mesh.i"
%import "qspace.i"
%include "../common/typemap_macros.i"
%include "../common/exception.i"

%import "../common/numpy_int_typemap.i"

%include "fem/quadinterpolator_face.hpp"

#endif
5 changes: 3 additions & 2 deletions mfem/_ser/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ def get_extensions():
"nonlininteg", "nonlinearform", "restriction",
"fespacehierarchy", "multigrid", "constraints",
"transfer", "std_vectors",
"tmop", "tmop_amr", "tmop_tools", "qspace"]

"tmop", "tmop_amr", "tmop_tools", "qspace", "qfunction",
"quadinterpolator", "quadinterpolator_face"]

if add_cuda == '1':
from setup_local import cudainc
include_dirs.append(cudainc)
Expand Down
6 changes: 6 additions & 0 deletions mfem/common/lininteg_ext.i
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace mfem {
%pythonappend VectorDomainLFIntegrator::VectorDomainLFIntegrator %{
self._coeff = QF
%}
%pythonappend VectorDomainLFGradIntegrator::VectorDomainLFGradIntegrator %{
self._coeff = QF
%}
%pythonappend VectorBoundaryLFIntegrator::VectorBoundaryLFIntegrator %{
self._coeff = QG
%}
Expand Down Expand Up @@ -53,6 +56,9 @@ namespace mfem {
%pythonappend DGElasticityDirichletLFIntegrator::DGElasticityDirichletLFIntegrator %{
self._coeff = uD_
%}
%pythonappend WhiteGaussianNoiseDomainLFIntegrator::WhiteGaussianNoiseDomainLFIntegrator %{
self._coeff = args
%}
%pythonappend VectorQuadratureLFIntegrator::VectorQuadratureLFIntegrator %{
self._coeff = args
%}
Expand Down
3 changes: 3 additions & 0 deletions mfem/par.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
from mfem._par.constraints import *
from mfem._par.transfer import *
from mfem._par.qspace import *
from mfem._par.qfunction import *
from mfem._par.quadinterpolator import *
from mfem._par.quadinterpolator_face import *

from mfem._par.fe_base import *
from mfem._par.fe_h1 import *
Expand Down
3 changes: 3 additions & 0 deletions mfem/ser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
from mfem._ser.constraints import *
from mfem._ser.transfer import *
from mfem._ser.qspace import *
from mfem._ser.qfunction import *
from mfem._ser.quadinterpolator import *
from mfem._ser.quadinterpolator_face import *

from mfem._ser.fe_base import *
from mfem._ser.fe_h1 import *
Expand Down
19 changes: 11 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,17 @@ def abspath(path):


def external_install_prefix(verbose=True):

if hasattr(site, "getusersitepackages"):
usersite = site.getusersitepackages()
else:
usersite = site.USER_SITE

if verbose:
print("running external_install_prefix with this parameters", sys.argv, sys.prefix, site.getusersitepackages())
print("running external_install_prefix with this parameters", sys.argv, sys.prefix, usersite)

if '--user' in sys.argv:
paths = (site.getusersitepackages(),)
paths = (usersite,)
else:
py_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
paths = (s % (py_version) for s in (
Expand Down Expand Up @@ -807,12 +814,8 @@ def write_setup_local():
mfemser = mfems_prefix
mfempar = mfemp_prefix

hyprelibpath = os.path.dirname(
find_libpath_from_prefix(
'HYPRE', hypre_prefix)) if build_hypre else ''
metislibpath = os.path.dirname(
find_libpath_from_prefix(
'metis', metis_prefix)) if build_metis else ''
hyprelibpath = os.path.dirname(find_libpath_from_prefix('HYPRE', hypre_prefix))
metislibpath = os.path.dirname(find_libpath_from_prefix('metis', metis_prefix))

mfems_tpl = read_mfem_tplflags(mfems_prefix)
mfemp_tpl = read_mfem_tplflags(mfemp_prefix) if build_parallel else ''
Expand Down

0 comments on commit a15726f

Please sign in to comment.