Skip to content

Commit

Permalink
Merge pull request #219 from mfem/attribute_sets_dev
Browse files Browse the repository at this point in the history
Attribute sets dev
  • Loading branch information
sshiraiwa authored Jun 25, 2024
2 parents 98227f8 + 93c8fa8 commit 4ec05da
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/ex5p.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def EvalValue(self, x):
u_sock << "parallel " << num_procs << " " << myid << "\n"
u_sock.precision(8)
u_sock << "solution\n" << pmesh << u << "window_title 'Velocity'\n"
MPI.Barrier()
MPI.COMM_WORLD.Barrier()
p_sock = mfem.socketstream("localhost", 19916)
p_sock << "parallel " << num_procs << " " << myid << "\n"
p_sock.precision(8)
Expand Down
31 changes: 31 additions & 0 deletions mfem/_par/arrays_by_name.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%module(package="mfem._par") arrays_by_name
%{
#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_GENERAL_ARRAYS_BY_NAME
%init %{
import_array();
%}

%include "exception.i"
%include "../common/exception.i"

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

%include "general/arrays_by_name.hpp"
%ignore mfem::ArraysByName::begin;
%ignore mfem::ArraysByName::end;

%template(intArraysByName) mfem::ArraysByName<int>;
#endif
29 changes: 29 additions & 0 deletions mfem/_par/attribute_sets.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%module(package="mfem._par") attribute_sets
%{
#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_MESH_ATTRIBUTE_SETS

%init %{
import_array();
%}

%include "exception.i"
%include "../common/exception.i"

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

%include "mesh/attribute_sets.hpp"

#endif
21 changes: 13 additions & 8 deletions mfem/_par/mesh.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import_array();

%import "matrix.i"
%import "array.i"
%import "attribute_sets.i"
%import "sort_pairs.i"
%import "ncmesh.i"
%import "vector.i"
Expand Down Expand Up @@ -217,30 +218,34 @@ def GetFaceElements(self, Face):
return Elem1.value(), Elem2.value()
%}
%feature("shadow") mfem::Mesh::GetElementTransformation %{
def GetElementTransformation(self, i):
def GetElementTransformation(self, i, Tr=None):
from mfem.par import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
%feature("shadow") mfem::Mesh::GetBdrElementTransformation %{
def GetBdrElementTransformation(self, i):
def GetBdrElementTransformation(self, i, Tr=None):
from mfem.par import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
%feature("shadow") mfem::Mesh::GetFaceTransformation %{
def GetFaceTransformation(self, i):
def GetFaceTransformation(self, i, Tr=None):
from mfem.par import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
%feature("shadow") mfem::Mesh::GetEdgeTransformation %{
def GetEdgeTransformation(self, i):
def GetEdgeTransformation(self, i, Tr=None):
from mfem.par import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
Expand Down
4 changes: 2 additions & 2 deletions mfem/_par/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def get_extensions():
"tmop", "tmop_amr", "tmop_tools", "qspace", "qfunction",
"quadinterpolator", "quadinterpolator_face",
"submesh", "transfermap", "staticcond","sidredatacollection",
"psubmesh", "ptransfermap", "enzyme"]

"psubmesh", "ptransfermap", "enzyme",
"attribute_sets", "arrays_by_name"]
if add_pumi == '1':
from setup_local import puminc, pumilib
modules.append("pumi")
Expand Down
31 changes: 31 additions & 0 deletions mfem/_ser/arrays_by_name.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%module(package="mfem._ser") arrays_by_name
%{
#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_GENERAL_ARRAYS_BY_NAME
%init %{
import_array();
%}

%include "exception.i"
%include "../common/exception.i"

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

%include "general/arrays_by_name.hpp"
%ignore mfem::ArraysByName::begin;
%ignore mfem::ArraysByName::end;

%template(intArraysByName) mfem::ArraysByName<int>;
#endif
29 changes: 29 additions & 0 deletions mfem/_ser/attribute_sets.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%module(package="mfem._ser") attribute_sets
%{
#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_MESH_ATTRIBUTE_SETS

%init %{
import_array();
%}

%include "exception.i"
%include "../common/exception.i"

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

%include "mesh/attribute_sets.hpp"

#endif
21 changes: 13 additions & 8 deletions mfem/_ser/mesh.i
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import_array();
%import "matrix.i"
%import "mem_manager.i"
%import "array.i"
%import "attribute_sets.i"
%import "sort_pairs.i"
%import "ncmesh.i"
%import "vector.i"
Expand Down Expand Up @@ -222,30 +223,34 @@ def GetFaceElements(self, Face):
return Elem1.value(), Elem2.value()
%}
%feature("shadow") mfem::Mesh::GetElementTransformation %{
def GetElementTransformation(self, i):
def GetElementTransformation(self, i, Tr=None):
from mfem.ser import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
%feature("shadow") mfem::Mesh::GetBdrElementTransformation %{
def GetBdrElementTransformation(self, i):
def GetBdrElementTransformation(self, i, Tr=None):
from mfem.ser import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
%feature("shadow") mfem::Mesh::GetFaceTransformation %{
def GetFaceTransformation(self, i):
def GetFaceTransformation(self, i, Tr=None):
from mfem.ser import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
%feature("shadow") mfem::Mesh::GetEdgeTransformation %{
def GetEdgeTransformation(self, i):
def GetEdgeTransformation(self, i, Tr=None):
from mfem.ser import IsoparametricTransformation
Tr = IsoparametricTransformation()
if Tr is None:
Tr = IsoparametricTransformation()
$action(self, i, Tr)
return Tr
%}
Expand Down
3 changes: 2 additions & 1 deletion mfem/_ser/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def get_extensions():
"tmop", "tmop_amr", "tmop_tools", "qspace", "qfunction",
"quadinterpolator", "quadinterpolator_face",
"submesh", "transfermap", "staticcond",
"sidredatacollection", "enzyme"]
"sidredatacollection", "enzyme",
"attribute_sets", "arrays_by_name"]

if add_cuda == '1':
from setup_local import cudainc
Expand Down
4 changes: 4 additions & 0 deletions mfem/common/bilininteg_ext.i
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ namespace mfem {
self._coeff = args
%}

%pythonappend ElasticityComponentIntegrator::ElasticityComponentIntegrator %{
self._coeff = parent_
%}

%pythonappend DGTraceIntegrator::DGTraceIntegrator %{
self._coeff = args
%}
Expand Down

0 comments on commit 4ec05da

Please sign in to comment.