Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include _build_system/*.py
include mfem/*/*.i
include mfem/*/*.cxx
include mfem/*/*.h
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.8.0'
__version__ = '4.8.0.1rc1'

2 changes: 1 addition & 1 deletion mfem/_par/bilininteg.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../common/pybilininteg.hpp"
#include "../common/pyintrules.hpp"
#include "../common/pynonlininteg.hpp"
#include "../common/pylininteg.hpp"
#include "numpy/arrayobject.h"
//using namespace mfem;
%}
Expand Down Expand Up @@ -48,4 +49,3 @@ import_array();

%feature("director") mfem::PyBilinearFormIntegrator;
%include "../common/pybilininteg.hpp"

1 change: 1 addition & 0 deletions mfem/_par/geom.i
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace mfem{
%ignore Array<Geometry::Type>::Save;
%ignore Array<Geometry::Type>::Max;
%ignore Array<Geometry::Type>::Min;
%ignore Array<Geometry::Type>::IsConstant;
%ignore Array<Geometry::Type>::Print;
%ignore Array<Geometry::Type>::Load;
}
Expand Down
29 changes: 29 additions & 0 deletions mfem/_par/integrator.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (c) 2020-2025, Princeton Plasma Physics Laboratory, All rights reserved.
//
%module(package="mfem._par") integrator

%{
#include "mfem.hpp"
#include "numpy/arrayobject.h"
#include "../common/io_stream.hpp"
#include "../common/pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "../common/pyintrules.hpp"
%}

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

%init %{
import_array();
%}
%include "exception.i"
%include "../common/exception.i"

%import "intrules.i"


%include "fem/integrator.hpp"

#endif
4 changes: 2 additions & 2 deletions mfem/_par/lininteg.i
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "../common/pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "../common/pylininteg.hpp"
#include "../common/pynonlininteg.hpp"
#include "../common/pybilininteg.hpp"
#include "../common/pyintrules.hpp"
#include "numpy/arrayobject.h"
%}
Expand Down Expand Up @@ -46,5 +48,3 @@ import_array();

%feature("director") mfem::PyLinearFormIntegrator;
%include "../common/pylininteg.hpp"


1 change: 1 addition & 0 deletions mfem/_par/nonlininteg.i
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import_array();
%import operators.i
%import fespace.i
%import eltrans.i
%import integrator.i
%import "../common/exception_director.i"

%include "fem/nonlininteg.hpp"
Expand Down
2 changes: 1 addition & 1 deletion mfem/_par/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_extensions():
"submesh", "transfermap", "staticcond", "sidredatacollection",
"psubmesh", "ptransfermap", "enzyme",
"attribute_sets", "arrays_by_name",
"hyperbolic", "bounds"]
"hyperbolic", "bounds", "integrator"]

if mpiinc != '':
include_dirs.append(mpiinc)
Expand Down
1 change: 1 addition & 0 deletions mfem/_ser/bilininteg.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../common/pybilininteg.hpp"
#include "../common/pyintrules.hpp"
#include "../common/pynonlininteg.hpp"
#include "../common/pylininteg.hpp"
#include "numpy/arrayobject.h"
//using namespace mfem;
%}
Expand Down
3 changes: 3 additions & 0 deletions mfem/_ser/geom.i
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ ARRAY_LISTTUPLE_INPUT(mfem::Geometry::Type, PyLong_AsLong)

%include "fem/geom.hpp"

%import "../common/array_listtuple_typemap.i"

namespace mfem{
%ignore Array<Geometry::Type>::Union;
%ignore Array<Geometry::Type>::Find;
Expand All @@ -42,6 +44,7 @@ namespace mfem{
%ignore Array<Geometry::Type>::Save;
%ignore Array<Geometry::Type>::Max;
%ignore Array<Geometry::Type>::Min;
%ignore Array<Geometry::Type>::IsConstant;
%ignore Array<Geometry::Type>::Print;
%ignore Array<Geometry::Type>::Load;
}
Expand Down
29 changes: 29 additions & 0 deletions mfem/_ser/integrator.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (c) 2020-2025, Princeton Plasma Physics Laboratory, All rights reserved.
//
%module(package="mfem._ser") integrator

%{
#include "mfem.hpp"
#include "numpy/arrayobject.h"
#include "../common/io_stream.hpp"
#include "../common/pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "../common/pyintrules.hpp"
%}

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

%init %{
import_array();
%}
%include "exception.i"
%include "../common/exception.i"

%import "intrules.i"


%include "fem/integrator.hpp"

#endif
4 changes: 2 additions & 2 deletions mfem/_ser/lininteg.i
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "../common/pyoperator.hpp"
#include "../common/pycoefficient.hpp"
#include "../common/pylininteg.hpp"
#include "../common/pynonlininteg.hpp"
#include "../common/pybilininteg.hpp"
#include "../common/pyintrules.hpp"
#include "numpy/arrayobject.h"
%}
Expand Down Expand Up @@ -42,5 +44,3 @@ import_array();

%feature("director") mfem::PyLinearFormIntegrator;
%include "../common/pylininteg.hpp"


1 change: 1 addition & 0 deletions mfem/_ser/nonlininteg.i
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import_array();
%import "operators.i"
%import "fespace.i"
%import "eltrans.i"
%import "integrator.i"
%import "../common/exception_director.i"

%include "fem/nonlininteg.hpp"
Expand Down
2 changes: 1 addition & 1 deletion mfem/_ser/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def get_extensions():
"attribute_sets", "arrays_by_name",
"hyperbolic",
"complex_densemat", "complexstaticcond", "complexweakform",
"bounds"]
"bounds", "integrator"]

if add_cuda == '1':
from setup_local import cudainc
Expand Down
4 changes: 4 additions & 0 deletions mfem/common/array_instantiation_macro.i
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,13 @@ INSTANTIATE_ARRAY2(XXX, YYY, YYY, USEPTR)
%ignore mfem::Array<XXX>::Save;
%ignore mfem::Array<XXX>::Max;
%ignore mfem::Array<XXX>::Min;
%ignore mfem::Array<XXX>::IsConstant;
%ignore mfem::Array<XXX>::Print;
%ignore mfem::Array<XXX>::PrintGZ;
%ignore mfem::Array<XXX>::SaveGZ;
%ignore mfem::Array<XXX>::Load;
%ignore mfem::Array2D<XXX>::Min;
%ignore mfem::Array2D<XXX>::Max;
%ignore mfem::Array2D<XXX>::Print;
%ignore mfem::Array2D<XXX>::PrintGZ;
%ignore mfem::Array2D<XXX>::SaveGZ;
Expand All @@ -340,6 +343,7 @@ INSTANTIATE_ARRAY2(XXX, YYY, YYY, USEPTR)
%ignore mfem::Array<XXX>::Abs;
%ignore mfem::Array<XXX>::Sum;
%ignore mfem::Array<XXX>::IsSorted;
%ignore mfem::Array<XXX>::IsConstant;
%ignore mfem::Array<XXX>::Save;
%ignore mfem::Array<XXX>::Max;
%ignore mfem::Array<XXX>::Min;
Expand Down
7 changes: 4 additions & 3 deletions mfem/common/bilininteg_ext.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//
// Copyright (c) 2020-2025, Princeton Plasma Physics Laboratory, All rights reserved.
//
namespace mfem {
%pythonappend BilinearFormIntegrator::BilinearFormIntegrator %{
self._coeff = args
Expand Down Expand Up @@ -310,6 +307,10 @@ namespace mfem {
self._coeff = vc
%}

%pythonappend PyBilinearFormIntegrator::PyBilinearFormIntegrator %{
self._ir=ir
%}

%pythonappend SumIntegrator::AddIntegrator %{
if self.own_integs == 1: integ.thisown = 0
%}
Expand Down
35 changes: 19 additions & 16 deletions mfem/common/generate_bilininteg_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,34 @@
cname = (line.split(' ')[1]).split('(')[0]

if line.startswith(" def __init__"):
pp = ""
pp = []
if line.find(", ir=None") != -1:
line = line.replace(", ir=None", "")
pp.append(" self._ir=ir")
if line.find("*args") != -1:
pp = " self._coeff = args"
pp.append(" self._coeff = args")
elif line.find("own_bfi_") != -1:
pp = " if own_bfi_ == 1: bfi_.thisown = 0"
pp.append(" if own_bfi_ == 1: bfi_.thisown = 0")
elif line.find("integ, own_integ=1") != -1:
pp = " if own_integ == 1: integ.thisown = 0"
pp.append(" if own_integ == 1: integ.thisown = 0")
elif line.find("own_integs=1") != -1:
pp = " self.own_integs = own_integs"
pp.append(" self.own_integs = own_integs")
elif line.find(", vq)") != -1:
pp = " self._coeff = vq"
pp.append(" self._coeff = vq")
elif line.find(", q)") != -1:
pp = " self._coeff = q"
pp.append(" self._coeff = q")
elif line.find(", q, a=1.0)") != -1:
pp = " self._coeff = q"
pp.append(" self._coeff = q")
elif line.find(", q, i") != -1:
pp = " self._coeff = q"
pp.append(" self._coeff = q")
elif line.find(", sc)") != -1:
pp = " self._coeff = sc"
pp.append(" self._coeff = sc")
elif line.find(", vc)") != -1:
pp = " self._coeff = vc"
pp.append(" self._coeff = vc")
elif line.find("parent_, i_, j_") != -1:
pp = " self._coeff = parent_"
pp.append(" self._coeff = parent_")
elif line.find("(self)") != -1:
pass
elif line.find("(self, ir=None)") != -1:
pass
elif line.find("(self, fes, e=1.0)") != -1:
pass
elif line.find("(self, vdim_=1)") != -1:
Expand All @@ -44,9 +45,11 @@
print(cname)
print(line)
assert False, "No recipt for this pattern "
if pp != "":

if len(pp) > 0:
out.append("%pythonappend " + cname + "::" + cname + " %{")
out.append(pp)
for x in pp:
out.append(x)
out.append("%}")
out.append("")
fid.close()
Expand Down
39 changes: 20 additions & 19 deletions mfem/common/generate_lininteg_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,43 @@
cname = (line.split(' ')[1]).split('(')[0]

if line.startswith(" def __init__"):
pp = ""
pp = []
if line.find(", ir=None") != -1:
line = line.replace(", ir=None", "")
pp.append(" self._ir=ir")
if line.find("*args") != -1:
pp = " self._coeff = args"
pp.append(" self._coeff = args")
elif line.find("self, seed_=0") != -1:
pp = " self._coeff = QG"
elif line.find("self, vqfc, ir") != -1:
pp = " self._coeff = (vqfc, ir)"
elif line.find("self, qfc, ir") != -1:
pp = " self._coeff = (qfc, ir)"
pp.append(" self._coeff = QG")
elif line.find("self, vqfc") != -1:
pp.append(" self._coeff = vqfc")
elif line.find("self, qfc") != -1:
pp.append(" self._coeff = qfc")
elif line.find(", QG") != -1:
pp = " self._coeff = QG"
pp.append(" self._coeff = QG")
elif line.find(", QF)") != -1:
pp = " self._coeff = QF"
pp.append(" self._coeff = QF")
elif line.find(", F)") != -1:
pp = " self._coeff = F"
pp.append(" self._coeff = F")
elif line.find(", f)") != -1:
pp = " self._coeff = f"
elif line.find(", f, s=1.0, ir=None)") != -1:
pp = " self._coeff = (f, ir)"
pp.append(" self._coeff = f")
elif line.find(", f, s=1.0)") != -1:
pp.append(" self._coeff = f")
elif line.find(", uD_, lambda_, mu_, alpha_, kappa_)") != -1:
pp = " self._coeff = uD_"
pp.append(" self._coeff = uD_")
elif line.find("(self)") != -1:
pass
elif line.find("(self, ir=None)") != -1:
pass
else:
print(cname)
print(line)
assert False, "No recipt for this pattern "
if pp != "":
if len(pp) > 0:
out.append("%pythonappend " + cname + "::" + cname + " %{")
out.append(pp)
for x in pp:
out.append(x)
out.append("%}")
fid.close()
out.append("}")

fid = open("lininteg_ext.i", "w")
fid.write("\n".join(out))
fid.close()
Expand Down
16 changes: 10 additions & 6 deletions mfem/common/lininteg_ext.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//
// Copyright (c) 2020-2025, Princeton Plasma Physics Laboratory, All rights reserved.
//
namespace mfem {
%pythonappend LinearFormIntegrator::LinearFormIntegrator %{
self._coeff = args
Expand All @@ -24,6 +21,7 @@ namespace mfem {
self._coeff = QG
%}
%pythonappend VectorDomainLFIntegrator::VectorDomainLFIntegrator %{
self._ir=ir
self._coeff = QF
%}
%pythonappend VectorDomainLFGradIntegrator::VectorDomainLFGradIntegrator %{
Expand All @@ -42,7 +40,8 @@ namespace mfem {
self._coeff = QF
%}
%pythonappend VectorBoundaryFluxLFIntegrator::VectorBoundaryFluxLFIntegrator %{
self._coeff = (f, ir)
self._ir=ir
self._coeff = f
%}
%pythonappend VectorFEBoundaryFluxLFIntegrator::VectorFEBoundaryFluxLFIntegrator %{
self._coeff = args
Expand All @@ -66,9 +65,14 @@ namespace mfem {
self._coeff = QG
%}
%pythonappend VectorQuadratureLFIntegrator::VectorQuadratureLFIntegrator %{
self._coeff = (vqfc, ir)
self._ir=ir
self._coeff = vqfc
%}
%pythonappend QuadratureLFIntegrator::QuadratureLFIntegrator %{
self._coeff = (qfc, ir)
self._ir=ir
self._coeff = qfc
%}
%pythonappend PyLinearFormIntegrator::PyLinearFormIntegrator %{
self._ir=ir
%}
}
Loading