Skip to content

Array wrapping enhancement#254

Closed
sshiraiwa wants to merge 9 commits intomasterfrom
coefficient-arrray-dev
Closed

Array wrapping enhancement#254
sshiraiwa wants to merge 9 commits intomasterfrom
coefficient-arrray-dev

Conversation

@sshiraiwa
Copy link
Copy Markdown
Member

@sshiraiwa sshiraiwa commented Oct 3, 2024

This PR includes

  1. address recent addition of kernel_dispatch.hpp in MFEM C++.
  • kernel_dispatch.hpp doesn't need to be exposed to Python. But, we need MFEM_REGISTER_KERNELS macro to be
    defined somehow. In this PR, MFEM_REGISTER_KERNELS is replaced to be empty macro. So that SWIG does not
    see the lines containing this macro.
  1. Add CoefficentArray, VectorCoefficientArray, and MatrixCoefficientArray (represent Array<* Coefficient> and so on)
  • Changed Array constructor behavior when list of SWIG-wrapped MFEM objects is passed. SWIG objects passed as an item in list/tuple looses owner ship to underlying C++ MFEM object. Internally, we create a new Array (depending on the length of container) and set each Array element one by one (after setting thisown to False).
  1. Renamed other Array< * MFEM object>.
  • They are used to be named like VectorPtrArray. We simplify it as VectorArray.
  1. SparseMatrixArray2D, DenseMatrixArray2D, HypreParMatrixArray2D are added
  • HypreParMatrixArray2D can be used with mfem.HypreParMatrixFromBlocks
  • DenseMatrixArray2D appears in BlockNonlinearFormIntegrator
  • SparseMatrixArray2D is used wtih MixedBilinearForm::GetBlocks

ToDo:

  • Update Doc
  • Add test/test_array2d.py

@sshiraiwa
Copy link
Copy Markdown
Member Author

PR is made to trigger the test.

@sshiraiwa
Copy link
Copy Markdown
Member Author

sshiraiwa commented Oct 5, 2024

Example asked in #253 can be done as follows.

   tensors =  [mfem.DenseMatrix(np.ones((3,3))*i) for i in range(max_attr)]
   tensor_coefs =  [mfem.MatrixConstantCoefficient(mat) for mat in tensors]
   sigma_array = mfem.MatrixCoefficientArray(tensor_coefs)
   sigma_attr = mfem.intArray([1,2,3,4,5])
   sigmaCoef = mfem.PWMatrixCoefficient(dim, sigma_attr, sigma_array, False)

@justinlaughlin
Copy link
Copy Markdown
Contributor

@sshiraiwa let me know when this is ready I'm happy to test it out.

@sshiraiwa
Copy link
Copy Markdown
Member Author

Closing this one w/o merging, since this version will be baseline of PyMFEM4.8

@sshiraiwa sshiraiwa closed this Apr 12, 2025
@sshiraiwa sshiraiwa mentioned this pull request Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants