Compare commits

...
Author SHA1 Message Date
Barry Fadness ec3e3e2db0 Print the parts of the dof_truedof matrix 2026-01-12 18:50:34 -08:00
Barry Fadness eae8e49444 Change default command line argument values 2025-09-08 18:13:21 -07:00
Barry Fadness 037dc77bc6 Use different manufactured solution 2025-09-04 20:29:30 -07:00
Barry Fadness bece01008c Add stopwatch to time block-hybridization solver 2025-06-15 19:42:36 -07:00
Barry Fadness f3490c0cab Use automatic variable for prerequisites 2024-07-28 18:41:55 -07:00
Barry Fadness df04a9235d Change manufactured solution 2024-05-27 21:22:11 -07:00
Barry Fadness 33372c6154 Merge branch 'master' into block-hybridization-dev 2023-12-14 18:31:14 -08:00
Tzanio Kolev 5b79224171 Merge pull request #3987 from mfem/mass-integrator-map-type-fix
Use CalcPhysShape in MassIntegrator::AssembleElementMatrix2
2023-12-12 14:07:37 -08:00
Tzanio Kolev 79204fd4a1 Merge pull request #4021 from mfem/mfem-error-noreturn
Mark mfem_error as [[noreturn]]
2023-12-12 14:07:18 -08:00
Tzanio Kolev 757b1ed529 Merge pull request #3976 from mfem/fix-sample-runs
Fix various small issues related to running `config/sample-runs.sh`
2023-12-12 09:33:04 -08:00
Tzanio Kolev 7fe1df7e00 Merge pull request #3918 from mfem/sjg/pfespace-constructor-fix
Remove unused parameter from `ParFiniteElementSpace` constructor
2023-12-10 10:48:48 -08:00
Tzanio Kolev 860c95c2de Merge pull request #3573 from mfem/mesh-builder-tet-tri
Build Tet and Tri meshes by splitting Hexes and Quads, respectively.
2023-12-08 12:08:33 -08:00
Will Pazner fa3b23fc92 Mark mfem_error as [[noreturn]] in declaration only
Remove unnecessary annotation from definition
2023-12-07 15:43:51 -08:00
Will Pazner b13d4d6631 Mark mfem_error as [[noreturn]] 2023-12-07 11:46:20 -08:00
Tzanio Kolev a37c8e3acb Merge pull request #3995 from mfem/tmop-pa-metric-coeff
TMOP: PA support for the Coefficient of the metric integral
2023-12-06 11:30:21 -08:00
Tzanio Kolev 0adecf5596 Merge pull request #3967 from mfem/optimize-discrete-divergence
Improve GPU algorithm in FormDiscreteDivergenceMatrix
2023-12-06 11:30:00 -08:00
Sebastian Grimberg 0fa1275ccf Change default constructor parameter to match previous behavior and add Doxygen comment warning of the differences 2023-12-06 09:55:22 -08:00
Veselin Dobrev 8b44981fa2 Merge pull request #3846 from mfem/sjg/global-variables-threadsafe
Thread-safety for MFEM classes and global instances
2023-12-06 09:39:28 -08:00
Mittal, Ketan 956be1a755 adding brief for doxygen comments 2023-12-05 16:21:08 -08:00
Sebastian Grimberg 9ec30fb48a Revert breaking interface change to ParMesh constructor 2023-12-05 11:47:53 -08:00
Sebastian Grimberg 415033aef2 Revert removal of unused parameter from ParFiniteElementSpace constructor 2023-12-05 11:37:19 -08:00
Sebastian Grimberg 5ee7ab1fd1 Merge branch 'master' into sjg/pfespace-constructor-fix 2023-12-05 11:29:22 -08:00
Sebastian Grimberg 864233213e Update changelog 2023-12-05 11:28:22 -08:00
Will Pazner e52ce5f060 Merge pull request #3984 from mfem/nbeams/update-gko-again
Updates for Ginkgo 1.7+
2023-12-05 11:15:18 -08:00
Sebastian Grimberg c30924731f Merge branch 'master' into sjg/global-variables-threadsafe 2023-12-05 11:12:34 -08:00
Tzanio Kolev 0ddb7aba31 Merge pull request #4005 from mfem/miniapps-gslib-makefile-fix
Fix the shared build in `miniapps/gslib`
2023-12-05 06:33:52 -08:00
Will Pazner 1160bc272b Merge pull request #3981 from mfem/zero_elem_refined
Support for zero element meshes in Mesh::MakeRefined() and L2ProjectionGridTransfer [zero_elem_refined]
2023-12-04 13:26:52 -08:00
Veselin Dobrev 3440025266 In miniapps/gslib/makefile, include defaults.mk to get the
definitions of *_XLINKER.
2023-12-03 06:37:44 -08:00
Tzanio Kolev 7aba8e28ba Merge pull request #3989 from adam-sim-dev/gitignore
Ignore examples/caliper binaries and result files
2023-12-01 15:23:21 -08:00
Will Pazner 422c163466 Merge remote-tracking branch 'origin/master' into zero_elem_refined 2023-12-01 11:41:26 -08:00
Will Pazner 0230285d65 Minor formatting change 2023-12-01 11:41:13 -08:00
Tzanio Kolev 27e681f9e7 Merge pull request #3772 from mfem/elasticity-amg-fix
Minor bugfixes for the BoomerAMG elasticity options
2023-11-30 15:21:23 -08:00
Tzanio Kolev 4a45c70d12 Merge pull request #3901 from mfem/fix-doc-ex23
Fix documentation of `ex23`
2023-11-29 08:38:25 -08:00
Socratis Petrides d6c7698712 added optional argument for pre-processing the interp matrix 2023-11-28 18:25:15 -08:00
Vladimir Z Tomov ba13719aa8 renamed variables 2023-11-28 13:45:27 -08:00
Vladimir Z Tomov 78ae46e9a2 Update of the metric_coeff and lim_coeff when the nodes are moved. 2023-11-28 13:27:12 -08:00
Veselin Dobrev f12fb5522a Merge pull request #3656 from adam-sim-dev/cxxflags
Add $(MFEM_CXXFLAGS) to get_hypre_version and get_mumps_version
2023-11-28 11:48:30 -08:00
Vladimir Z Tomov 65a3108084 updated the metric weight to Q-vector 2023-11-27 14:52:06 -08:00
Tzanio Kolev 91b40c9b78 Merge pull request #3852 from mfem/baecker/cutint
CutIntegrationRules and new example
2023-11-27 08:43:13 -08:00
Sebastian Grimberg a3a73e9ab2 Address PR feedback: Remove unused member variable 2023-11-27 08:40:03 -08:00
Vladimir Z Tomov a3d530f2f0 minor 2023-11-22 18:05:21 -08:00
Vladimir Z Tomov 87494199c0 PA support when the integrator has a ConstantCoefficient. 2023-11-22 17:58:59 -08:00
Sebastian Grimberg c9e112c192 Second revert to unintended breaking interface change 2023-11-22 12:19:31 -08:00
Sebastian Grimberg 59fbc05880 Revert previous commit, cannot overload functions by return type 2023-11-21 11:50:01 -08:00
Sebastian Grimberg 5f85120da4 Revert breaking change for Geometry interface 2023-11-21 11:41:39 -08:00
nbeams f66a16257f Undo accidental commit in Ginkgo example 2023-11-21 14:17:56 -05:00
nbeams baf06bdc93 Adjust mesh path in Ginkg example sample runs 2023-11-21 14:09:46 -05:00
Tzanio Kolev b25c4e30ee minor 2023-11-21 09:55:32 -08:00
Vladimir Z Tomov 9734af90ed added in doc/CodeDocumentation 2023-11-21 09:19:54 -08:00
Tzanio Kolev 5c66134872 Merge pull request #3982 from mfem/fix-cubit-warnings
Fix some Cubit warnings
2023-11-21 09:03:06 -08:00
Vladimir Z Tomov 8e1fd9c27d changed a comment 2023-11-20 12:25:55 -08:00
Tzanio Kolev 8d75a62e65 Merge pull request #3875 from imguoguo/master
Fix build failure on riscv64 architecture
2023-11-19 13:08:50 -08:00
Tzanio Kolev 85e435be84 Merge branch 'master' into fix-doc-ex23 2023-11-17 09:09:15 -08:00
Tzanio Kolev f7f7a46d8e Merge pull request #3973 from mfem/sjg/cmake-cuda-fix
Correct `cusparse`, `cublas` linkage for CMake builds with CUDA
2023-11-17 09:01:29 -08:00
Tzanio Kolev ce09755c75 Merge pull request #3979 from mfem/sjg/glvis-fix
Patch for #3685 to resolve issues with GLVis
2023-11-17 09:00:03 -08:00
adam-sim-dev cdd5d74a7a Merge branch 'master' into cxxflags 2023-11-17 19:44:56 +08:00
adam-sim-dev 672c331189 Ignore binaries and result files 2023-11-17 19:19:24 +08:00
Will Pazner 3e5ad8d18c Use CalcPhysShape in MassIntegrator::AssembleElementMatrix2 2023-11-16 21:47:39 -08:00
Mittal, Ketan 57de5fa684 reviewer comments 2023-11-16 21:39:16 -08:00
nbeams 43804b7e29 Ginkgo updates: Fix build error from method of changing factory parameters;
Address some deprecation warnings in ILU and IC preconditioners
2023-11-16 16:47:49 -05:00
Mittal, Ketan 05683c3cae minor 2023-11-16 11:14:33 -08:00
Mittal, Ketan a769ca1fcb more doxygen comments 2023-11-16 11:13:09 -08:00
Will Pazner 43c7303e45 Pass vectors by reference in ReadCubitBoundaries 2023-11-16 10:55:53 -08:00
Mittal, Ketan fe85793042 brace alignment, resolve conflict due to merge, and doxygen comments 2023-11-16 10:50:22 -08:00
Mittal, Ketan 68067d2f25 minor 2023-11-16 10:34:36 -08:00
Mittal, Ketan 1efe47c8d6 Merge branch 'master' of https://github.com/mfem/mfem into mesh-builder-tet-tri 2023-11-16 10:33:23 -08:00
Mittal, Ketan e3c68a5300 reviewer comments 2023-11-16 10:33:12 -08:00
Will Pazner b1c7fc6b26 Use std::string in Mesh::ReadCubit 2023-11-15 21:08:50 -08:00
Will Pazner 055b807772 Move FinalizeCubitSecondOrderMesh out of the Mesh class 2023-11-15 21:06:47 -08:00
Will Pazner 4779b9a385 Move CreateCubitElement out of the Mesh class
and into the mfem::cubit namespace.

Same for CreateCubitBoundaryElement.
2023-11-15 20:46:34 -08:00
Will Pazner 245e7dc35c Use std::vector instead of int* in Cubit mesh reader 2023-11-15 20:46:34 -08:00
Will Pazner b49f91fa2f Fix warnings in Mesh::ReadCubit 2023-11-15 20:46:34 -08:00
Veselin Dobrev 110bec1507 Merge pull request #3956 from mfem/projectbdr-assert-bug
Wrong assert code in ParGF::ProjectBdrCoefficient
2023-11-15 19:00:47 -08:00
Veselin Dobrev 68635cc1a8 Merge pull request #3081 from mfem/sjg/strumpack-solver-dev
Update STRUMPACK solver interface
2023-11-15 18:58:00 -08:00
Tzanio Kolev 8bb929c2ff Merge pull request #3820 from mfem/sjg/stateless-doftrans-threadsafe
Simplifications to `DofTransformation` and `StatelessDofTransformation`
2023-11-15 17:43:43 -08:00
EB Chin cf9d5bbb9c make it work with cpp11 2023-11-15 17:21:31 -08:00
EB Chin 986a0ac0ca fix style 2023-11-15 17:14:55 -08:00
EB Chin 358cf496ee zero elem fix for H1 transfers 2023-11-15 16:26:39 -08:00
EB Chin 65dc31e51a MakeRefined() on meshes with no elems 2023-11-15 16:09:58 -08:00
Vladimir Z Tomov 7ab0206976 edited the comments in ex38 to avoid testing in sample-runs. 2023-11-15 14:30:35 -08:00
Guoguo 193e603ace re-modify makefile and correct its format. 2023-11-15 21:46:13 +08:00
Vladimir Z Tomov ffd2938cea Merge branch 'master' into baecker/cutint 2023-11-14 15:51:31 -08:00
Tzanio Kolev 4161aac03e Merge pull request #3962 from mfem/tmop-mu14-update
Update to TMOP metric - mu_14
2023-11-14 12:06:34 -08:00
blaz 588ce586db Merge branch 'baecker/cutint' of github.com:mfem/mfem into baecker/cutint 2023-11-14 11:53:27 -08:00
blaz 12c8827cb2 cmake 2023-11-14 11:53:07 -08:00
Mark L. Stowell 26613eec97 Merge pull request #3524 from mfem/sjg/bilinearform-integs-marker
Complete domain integrator marker support
2023-11-14 11:46:37 -08:00
Mark L. Stowell 8a5dbbe3fb Merge branch 'master' into sjg/bilinearform-integs-marker 2023-11-14 11:13:58 -08:00
Sebastian Grimberg b88787c1a1 Patch for #3685 to resolve issues with GLVis 2023-11-14 09:10:25 -08:00
Guoguo 8b2ed54835 revert unnecessary modification of makefile 2023-11-14 14:14:46 +08:00
Sebastian Grimberg ff76f26ce1 Fix missing newline 2023-11-13 17:10:59 -08:00
Sebastian Grimberg 1354c29905 Go back to using configure-time tests to determine if HYPRE was built with CUDA/HIP rather than guessing off of the MFEM configure variables 2023-11-13 17:08:51 -08:00
Socratis Petrides 93fef9d8a4 Merge branch 'master' into elasticity-amg-fix 2023-11-13 10:41:24 -08:00
Sebastian Grimberg a06e19ce7d Remove unneeded cuBLAS dependency, align automated Hypre cuSPARSE and cuRAND (and ROCm counterparts) dependencies for CMake builds 2023-11-13 10:28:54 -08:00
Sebastian Grimberg 4202daa1fa Revert to MPI_Init when the requested threading level does not require MPI_Init_thread 2023-11-13 08:59:04 -08:00
GuoguoandSebastian Grimberg f2a7cb9b7a Apply suggestions from code review
Works on riscv64

Co-authored-by: Sebastian Grimberg <sebastiangrimb@gmail.com>
2023-11-13 05:54:01 -06:00
Vladimir Z Tomov dcf0a01298 minor 2023-11-12 18:12:01 -08:00
Veselin Dobrev 3966255076 Fix various small issues related to running config/sample-runs.sh 2023-11-12 14:04:42 -08:00
Vladimir Z Tomov b5a9fd3df4 changelog 2023-11-12 13:47:37 -08:00
Tzanio Kolev 1c58d6d3d1 Merge pull request #3884 from mfem/lor-surface-meshes
Support surface meshes in batched LOR assembly
2023-11-12 10:30:57 -08:00
Tzanio Kolev b2acd235b2 Merge pull request #3685 from topazus/use-getaddrinfo
Replace deprecated gethostbyname by getaddrinfo
2023-11-12 10:28:31 -08:00
Tzanio Kolev b15d483611 Merge pull request #3968 from mfem/mish2/cmake_generated_headers
Avoid regenerating header files that haven't changed
2023-11-12 10:28:06 -08:00
Vladimir Z Tomov e008f815ae Merge branch 'master' into baecker/cutint 2023-11-11 21:45:45 -08:00
Vladimir Z Tomov 8846587efb doc autotest error 2023-11-11 16:57:03 -08:00
Vladimir Z Tomov 64a01150ee Fixed size error for the 3D volume RHS. This actually didn't change results. 2023-11-11 16:01:05 -08:00
Sebastian Grimberg 83a72b343a Fix cusparse, cublas library dependency linkage for CMake builds with CUDA 2023-11-09 18:02:36 -08:00
Tzanio Kolev ecfab8fe9f Merge pull request #3964 from mfem/extra-semicolon-warnings-fix
Fix warnings about extra semicolons from GCC
2023-11-09 07:05:02 -08:00
Tzanio Kolev 935be38e4f Merge pull request #3966 from mfem/bugfix/rwa/reset-lazy-data-parmesh-ncref
Call ResetLazyData for ParMesh undergoing nonconforming refinement
2023-11-09 07:04:13 -08:00
Tzanio Kolev 23a78751d5 Merge pull request #3811 from mfem/bdr-1d
Unify Mesh::be_to_face
2023-11-09 07:02:22 -08:00
Vladimir Z Tomov 00815df5d0 debug compile warnings 2023-11-08 13:21:32 -08:00
Vladimir Z Tomov ea404352a6 minor comments 2023-11-08 12:21:33 -08:00
Will PaznerandKetan Mittal 21de36604a Fix typo (dim should have been sdim)
Co-authored-by: Ketan Mittal <mittal3@llnl.gov>
2023-11-07 14:24:30 -08:00
Vladimir Z Tomov 21c1d3a54e simplified interface for computing surface transf weights. 2023-11-07 13:45:50 -08:00
Vladimir Z Tomov c0fed5b393 Simplified cut-volume integr interface. 2023-11-07 13:11:51 -08:00
Sam Mish 1420fc6b63 avoid regenerating headers that haven't changed 2023-11-07 12:43:59 -08:00
Vladimir Z Tomov a453d97ab9 Simplified the surface integration interface. 2023-11-07 12:33:16 -08:00
Vladimir Z Tomov 76d3a54a88 removed default constructors, added -vis to the example. 2023-11-07 09:16:38 -08:00
Sebastian Grimberg 723a613236 Clean up unnecessary ;; 2023-11-07 09:08:19 -08:00
Mark L. Stowell fd4c6892a4 Merge branch 'master' into sjg/bilinearform-integs-marker 2023-11-06 15:31:47 -08:00
Robert W. Anderson d6205812cf need a ResetLazyData() when mesh is a pmesh and doing nonconforming refinement 2023-11-06 15:09:08 -08:00
Will Pazner 7de9f15d12 Improve GPU algorithm in FormDiscreteDivergenceMatrix
Allow for more parallelism, threading over every matrix entry rather than just
over every row
2023-11-06 14:59:31 -08:00
Vladimir Z Tomov 1f9f8bd5cb minor comments 2023-11-06 14:31:15 -08:00
Sebastian Grimberg f09f969197 Fix issue with new unit test 2023-11-06 11:18:33 -08:00
Sebastian Grimberg 0857e8e22f Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-11-06 08:30:05 -08:00
Sebastian Grimberg 7e2580f262 Merge branch 'master' into sjg/pfespace-constructor-fix 2023-11-06 08:03:51 -08:00
Vladimir Z Tomov a3c51c8a70 gitignore 2023-11-05 15:47:51 -08:00
Vladimir Z Tomov 05154bad34 minor 2023-11-05 13:08:15 -08:00
Vladimir Z Tomov 8c8b52d572 fix cmake 2023-11-05 12:47:40 -08:00
Vladimir Z Tomov 718bece30c renamed check-tmop-metric to tmop-check-metric 2023-11-05 12:33:30 -08:00
Vladimir Z Tomov 3ce24ea2ba comments and testing function 2023-11-05 12:29:16 -08:00
Veselin Dobrev 62c0444cbf Fix warnings about extra ';' from GCC with '-pedantic' flag 2023-11-04 18:47:52 -07:00
Will Pazner 6594329638 Fix uninitialized be_to_face in 1D ParMesh 2023-11-04 14:07:41 -07:00
blaz 1ae7ced2dc cmake files 2023-11-03 23:15:55 -07:00
Vladimir Z Tomov a5b1b2111d comments and minor edits. 2023-11-03 13:03:25 -07:00
Mittal, Ketan 8ab890b7d7 remove fd option for sample run with mu14 2023-11-03 10:10:59 -07:00
Mittal, Ketan 9166d8fdcb add evalP and AssembleH for mu14 2023-11-03 10:05:17 -07:00
Vladimir Z Tomov a241e4a447 minor 2023-11-03 09:20:29 -07:00
Will Pazner 11aa88c5e0 const correctness
Make num_codim_1 const using IIFE lambda.
2023-11-03 08:26:00 -07:00
Vladimir Z Tomov 79cc10d12b Merge branch 'master' into baecker/cutint 2023-11-02 16:50:50 -07:00
Vladimir Z Tomov 4d247cff97 changed example number. 2023-11-02 16:50:31 -07:00
Will Pazner 81af422efb Replace usage of deprecated function 2023-11-02 16:14:55 -07:00
Will Pazner de0f5a1da4 Replace usage of deprecated function 2023-11-02 15:41:39 -07:00
Will Pazner ed10bed8c8 Merge remote-tracking branch 'origin/master' into bdr-1d
# Conflicts:
#	fem/qspace.cpp
2023-11-02 14:52:08 -07:00
Will Pazner c794dae53b Move Mesh::GetBdrElementFaceIndex to header file
Also improve the Doxygen comment.

Move deprecated function Mesh::GetBdrElementEdgeIndex closer to its replacement
Mesh::GetBdrElementFaceIndex.
2023-11-02 14:47:56 -07:00
Will Pazner 9a70f50e22 Update CHANGELOG 2023-10-31 15:56:32 -07:00
Will Pazner c4957f1907 Merge remote-tracking branch 'origin/master' into lor-surface-meshes 2023-10-31 15:55:59 -07:00
Sebastian Grimberg aa8e466e42 Address PR feedback: Rename IsEmpty -> IsIdentity and clarify code comments 2023-10-31 12:26:35 -07:00
Barry Fadness 7da4561e09 Remove redundant print statements 2023-10-30 12:31:27 -07:00
Vladimir Z Tomov d9937c5b82 Wrong assert code in ParGF::ProjectBdrCoefficient 2023-10-29 17:26:09 -07:00
Barry Fadness 320b1f4022 Improve formatting consistency 2023-10-27 17:58:39 -07:00
Barry Fadness c317677de2 Delete unncecessary pointer assignment 2023-10-27 17:33:33 -07:00
Barry Fadness f983922aba Fix mistake move GetElementVDofs out of else-statement 2023-10-27 17:32:36 -07:00
Barry Fadness 095ea3ab0f Merge branch 'master' into block-hybridization-dev 2023-10-27 17:25:11 -07:00
Sebastian Grimberg 19e016e5d0 Merge branch 'master' into sjg/global-variables-threadsafe 2023-10-27 11:17:59 -07:00
Barry Fadness 62b3b06d33 Make pH owner of its factors 2023-10-25 00:02:50 -07:00
Barry Fadness 3080cba39d Fix mistake move AddSubMatrix 2023-10-24 18:18:21 -07:00
Will Pazner 9863bc5bd6 Change Mesh::GetBdrFace to Mesh::GetBdrElementFaceIndex
Deprecate Mesh::GetBdrFace.
2023-10-24 15:13:45 -07:00
Sebastian Grimberg f4fdd37735 Unify DofTransformation and VDofTransformation classes for further simplification 2023-10-24 13:11:25 -07:00
Barry Fadness 1a77427557 Add MixedBilinearForm::ComputeElementMatrices()
This new class member function is based on
BilinearForm::ComputeElementMatrices().
It was also necessary to make changes to
both MixedBilinearForm::Assemble() and
MixedBilinearForm::ComputeElementMatrix().
2023-10-24 13:09:48 -07:00
Sebastian Grimberg 563084ca0f Merge pull request #3920 from mfem/sjg/pmesh-setcurvature-fix
Fix potential issue with `ParMesh` and `SetCurvature`
2023-10-24 12:08:53 -07:00
Sebastian Grimberg 015a0f2eae Merge pull request #3919 from mfem/sjg/pmesh-constructor-fix
`ParMesh` constructor improvement
2023-10-24 12:08:20 -07:00
Will Pazner 823eef1d9a Deprecate Mesh::GetBdrElementEdgeIndex in favor of Mesh::GetBdrFace 2023-10-24 09:25:59 -07:00
Will Pazner 6118beb9e0 Merge remote-tracking branch 'origin/master' into bdr-1d
# Conflicts:
#	mesh/submesh/psubmesh.cpp
2023-10-24 09:21:28 -07:00
Tzanio Kolev ffc2f31b6f Merge branch 'master' into lor-surface-meshes 2023-10-24 08:56:42 -07:00
Chak Shing Lee a2941b0589 fix random initial values in ess_data_.Block(1) 2023-10-23 13:25:07 -07:00
Chak Shing Lee d362363b6f Merge branch 'block-hybridization-dev' of https://github.com/mfem/mfem into block-hybridization-dev 2023-10-23 11:09:30 -07:00
Chak Shing Lee ebec0673ac fix the way we eliminate Hcurl essential dofs 2023-10-23 11:09:12 -07:00
Sebastian Grimberg a7f7fc94ea Fix bug in pmesh-fitting miniapp uncovered by NonlinearForm markers 2023-10-22 13:03:34 -07:00
Sebastian Grimberg 46c73c8745 Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-10-22 12:00:11 -07:00
Sebastian Grimberg d000d212e5 Revert "ex31p with the -ams option in 2D revealed a bug for DiscreteLinearOperator::Assemble"
This reverts commit ef6074c420.
2023-10-22 11:56:01 -07:00
Sebastian Grimberg 742132da1b Merge branch 'master' into sjg/bilinearform-integs-marker 2023-10-22 11:51:45 -07:00
Sebastian Grimberg 4745f7aa87 Merge branch 'sjg/pmesh-constructor-fix' into sjg/pmesh-setcurvature-fix 2023-10-19 16:01:57 -07:00
Barry Fadness 55f497f3db Replace PtAP with two-step RAP 2023-10-16 13:45:10 -07:00
Sebastian Grimberg 544cf9318b Expose generate_edges, fix_orientations parameters for Mesh::Finalize in the associated ParMesh constructor, fix debug statements in ParMesh::MarkTetMeshForRefinement 2023-10-12 16:23:51 -07:00
Tzanio Kolev 6885a99955 Merge branch 'master' into lor-surface-meshes 2023-10-10 06:26:07 -07:00
Sebastian Grimberg 134ac98216 Fix issue when ParMesh::SetCurvature invalidates existing face neighbor data from previous call to ParMesh::ExchangeFaceNbrData 2023-10-09 10:31:50 -07:00
Sebastian Grimberg 2609ef0306 Expose generate_edges, fix_orientations parameters for Mesh::Finalize in the associated ParMesh constructor, fix debug statements in ParMesh::MarkTetMeshForRefinement 2023-10-09 10:30:35 -07:00
Sebastian Grimberg 7014d7f6d2 Organize friend class declarations and some const-correctness for Mesh and ParMesh 2023-10-04 08:56:34 -07:00
Sebastian Grimberg 86bb7d46e2 Remove unused parameter from ParFiniteElementSpace constructor 2023-10-04 08:56:33 -07:00
Sebastian Grimberg cce556551b Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-10-03 08:05:38 -07:00
Sebastian Grimberg a71509b8ce Merge branch 'master' into sjg/strumpack-solver-dev 2023-10-03 08:05:20 -07:00
Tobias Duswald ac8ea6fe2d Revert previous commit 2023-10-01 00:09:10 +02:00
Barry Fadness 4f2d638993 Fix text output typo 2023-09-29 21:31:25 -07:00
Tobias Duswald e26208c725 Remove using ... 2023-09-29 17:13:49 +02:00
Sebastian Grimberg a8502b5b29 Fix bug for GPU builds when using sparse direct solvers with multiple RHS 2023-09-29 07:30:09 -07:00
Sebastian Grimberg a6b8ca5654 Merge branch 'master' into sjg/strumpack-solver-dev 2023-09-29 07:28:18 -07:00
Sebastian Grimberg 771ae1fc3c Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-09-29 07:27:38 -07:00
Tobias Duswald 4de0b3b1c6 Fix initial state of visualization in for GLVis 2023-09-29 15:39:53 +02:00
Tobias Duswald aef28190b3 Fix documentation ex23 2023-09-29 11:15:59 +02:00
adam-sim-dev 37402a0b4f Merge branch 'master' into cxxflags 2023-09-28 19:08:30 +08:00
Mittal, Ketan 16b9256edd minor 2023-09-27 20:53:03 -07:00
Mittal, Ketan 4fb0372c83 use Vector instead of double 2023-09-27 20:39:12 -07:00
Mittal, Ketan e34090d634 Merge branch 'master' of https://github.com/mfem/mfem into mesh-builder-tet-tri 2023-09-27 20:18:46 -07:00
Mittal, Ketan a7b0edc290 refactor and rename 2023-09-27 20:18:30 -07:00
Sebastian Grimberg 81e5489f5e Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-09-26 08:44:44 -07:00
Sebastian Grimberg 26841dd3e3 Merge branch 'master' into sjg/strumpack-solver-dev 2023-09-26 08:42:32 -07:00
Tzanio Kolev 1ffc187de6 Merge branch 'master' into master 2023-09-22 07:00:52 -07:00
Barry Fadness 6faef3873b Extract block hybridization code 2023-09-20 17:29:59 -07:00
Will Pazner e1666702d4 Add surface mesh tests to batched LOR unit tests 2023-09-20 09:45:31 -07:00
Will Pazner 6c3c25d439 Correctly handle RT metric factors in batched LOR assembly 2023-09-20 09:45:06 -07:00
Will Pazner 13bd25ea34 Support surface meshes in parallel LOR solvers miniapp 2023-09-20 09:09:11 -07:00
Will Pazner e6f54f8b92 Handle space dimension in BatchedLOR_AMS::FormCoordinateVectors 2023-09-20 09:06:55 -07:00
Will Pazner 465e5e784e Support surface meshes in LOR Solvers miniapp 2023-09-20 09:06:55 -07:00
Will Pazner 369e76bd18 Support surface meshes in batched LOR assembly 2023-09-19 19:56:45 -07:00
Guoguo e4af497922 Add support for riscv64, fix g++ error: '-march=native': ISA string must begin with rv32 or rv64 while compiling. 2023-09-16 21:30:21 +08:00
Gabriel Esteban Pinochet Soto 4b7fdcd10a Update BCs in BramblerPasciakSolver
- Create new constructor that ussses the Essential BC for defining
  the linear system and the preconditioner.
- Make style
2023-09-14 15:25:39 -07:00
Gabriel Esteban Pinochet Soto 1c303ee013 Merge branch 'block-solvers/bramble-pasciak-dev' of github.com:mfem/mfem into block-hybridization-dev 2023-09-13 14:33:28 -07:00
Gabriel Esteban Pinochet Soto 1364914e7d Small fix. Use MFEM_LAPACK macro. 2023-09-13 12:22:42 -07:00
Gabriel Esteban Pinochet Soto 84a248e42c Add return nullptr 2023-09-13 11:55:33 -07:00
Gabriel Esteban Pinochet Soto 9d2c4c899c Use MFEM_USE_LAPACK macro. 2023-09-13 10:30:04 -07:00
Gabriel Esteban Pinochet Soto 08b87fd9fe Disable iterative mode in SumOperator 2023-09-12 14:15:12 -07:00
Gabriel Esteban Pinochet Soto 41131c3e0c Remove unused varaible in BramblePasciakSolver 2023-09-12 13:42:36 -07:00
Gabriel Esteban Pinochet Soto bfcb60ccec Override SetPreconditioner. 2023-09-12 12:59:44 -07:00
Gabriel Esteban Pinochet Soto 26a6c3c735 Update tests options in makefiles. 2023-09-12 12:05:08 -07:00
Gabriel Esteban Pinochet Soto 0ec2ea20de Make style. 2023-09-12 10:52:09 -07:00
Gabriel Esteban Pinochet Soto 1a4d4d4a61 Merge branch 'master' of github.com:mfem/mfem into block-solvers/bramble-pasciak-dev 2023-09-12 10:42:56 -07:00
Gabriel Esteban Pinochet Soto ffb58713b1 Small change to SumOperator constructor.
- To decide if we can add two iterative solvers.
2023-09-12 10:32:13 -07:00
Gabriel Esteban Pinochet Soto c90d52d32b Modify makefile. Minor fixes.
- Move assert into ConstructMassPreconditioner
- Update makefile
2023-09-11 17:58:16 -07:00
Gabriel Esteban Pinochet Soto 05ace32f42 Cleaner code.
- Add description to README
- Remove commentaries in BPCG
- Move assert into ConstructMassPreconditioner
2023-09-11 11:21:27 -07:00
Chak Shing Lee bca1919f39 fix typo in documentation 2023-09-06 14:57:35 -07:00
Chak Shing Lee ac495b7490 Merge branch 'block-solvers/bramble-pasciak-dev' of https://github.com/mfem/mfem into block-hybridization-dev 2023-09-06 14:55:47 -07:00
Chak Shing Lee fcc35e6c6f remove one target in makefile 2023-09-06 14:54:28 -07:00
Chak Shing Lee ed98b4bf4a precompute element matrices of Mform_ in DarcyProblem 2023-09-06 14:42:20 -07:00
Chak Shing Lee 8f11035617 Merge branch 'block-solvers/bramble-pasciak-dev' of https://github.com/mfem/mfem into block-hybridization-dev 2023-09-06 14:21:10 -07:00
Chak Shing Lee e60b446438 remove unused lines 2023-09-06 14:18:30 -07:00
Chak Shing Lee ece621c512 resolve conflicts from merging with block-solvers/bramble-pasciak-dev 2023-09-06 14:16:50 -07:00
Chak Shing Lee 1253fe5b16 Merge branch 'block-hybridization-dev' of https://github.com/mfem/mfem into block-hybridization-dev 2023-09-06 11:54:29 -07:00
Chak Shing Lee 78d869d6fe Merge branch 'csl/bilinearform-vdofs-fix' of https://github.com/mfem/mfem into block-solvers/bramble-pasciak-dev 2023-09-06 11:13:01 -07:00
Chak Shing Lee 2d8d46a208 use M instead of Q to construct the (1,1)-block preconditioner in BramblePasciakSolver. adjust documentation and print 2023-09-05 11:22:24 -07:00
Chak Shing Lee 40abb09c99 resolve conflicts with master 2023-09-01 16:58:24 -07:00
Chak Shing Lee bb681b5172 Merge branch 'master' of https://github.com/mfem/mfem into block-hybridization-dev 2023-09-01 16:43:25 -07:00
Gabriel Esteban Pinochet Soto bf9bdddfdc Restructure of the code.
- Remove overloaded BramblePasciakSolver::Init function
- Move MFEM pre-defined BPSolver setting to the constructor
- Add pointers to solvers in BramblePasciakSolver class
- Simplify options
- Remove redundant option in Parameter structs
- Rename AddOperator to SumOperator
- Wrap *.cpp files into namespace scopes
- Add some documentation
- Make style
2023-09-01 14:15:47 -07:00
Baecker b3851cd284 Corrected ex37 2023-09-01 08:44:31 -07:00
Baecker 8d9d3cba4c Corrected documentation again 2023-09-01 08:18:14 -07:00
Baecker c826ed6f88 Corrected documentation again 2023-09-01 08:14:09 -07:00
Baecker 69c6a75d29 corrected the documentation 2023-09-01 08:04:57 -07:00
Baecker 98e41c1de9 Added documentation. 2023-08-31 15:39:09 -07:00
Baecker dede616db7 Fixed some bugs and imporved performance. Everything should be running.' 2023-08-31 14:27:16 -07:00
Baecker 34842a5c71 Added CutIntRules 2023-08-30 13:15:20 -07:00
adam-sim-dev f238ed6f41 Merge branch 'master' into cxxflags 2023-08-30 17:10:35 +08:00
Gabriel Esteban Pinochet Soto 2b88ef81ae Add serial and parallel refinement flag. 2023-08-28 16:50:53 -07:00
Gabriel Esteban Pinochet Soto 5fc779e128 Reorganize functions
- Move general-purpose functions to block-solvers.cpp
- Reorganize code
- TODO Serial and parallel refinement flags
2023-08-28 14:01:19 -07:00
Sebastian Grimberg 0c4d3e35e3 Thread-safety for MFEM classes and global instances 2023-08-27 14:12:01 -07:00
Sebastian Grimberg 56b3d254a0 Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-08-24 17:38:51 -07:00
adam-sim-dev eb5a77e2e8 Merge branch 'master' into cxxflags 2023-08-25 08:15:51 +08:00
Gabriel Esteban Pinochet Soto 2ca61c74b0 Remove warnings.
- Remove warnings concerning unset/unused operators.
2023-08-22 17:29:46 -07:00
Gabriel Esteban Pinochet Soto 98e2af65da Modify documentation.
- Remove characters.
2023-08-21 10:34:54 -07:00
Gabriel Esteban Pinochet Soto 46a8bca7f5 Add documentation 2023-08-21 10:30:56 -07:00
Gabriel Esteban Pinochet Soto cb95ddc422 Remove draft elasticity. Add documentation.
- Remove draft. Comment CMake files.
- Add some explanation regarding BPCG and BP transform.
- Make style.
2023-08-21 10:12:52 -07:00
Gabriel Esteban Pinochet Soto aae0f2b7f2 Compartmentalization of block-solvers.
- Add bramble_pasciack.xpp, darcy_solver.xpp
- Move solvers to their respective files and headders
- Update makefile and CMakeList.txt
- (WIP) Add draft elasticity solver (similar to darcy_solver)
- (WIP) Add specific classes to handle the elasticity FES
- (WIP) Define basic block structure
2023-08-17 17:55:16 -07:00
Sebastian Grimberg 3059cf06c7 Merge branch 'master' into sjg/stateless-doftrans-threadsafe 2023-08-17 12:20:13 -07:00
Sebastian Grimberg 61f6c8e115 Merge branch 'master' into sjg/strumpack-solver-dev 2023-08-17 12:17:40 -07:00
Gabriel Esteban Pinochet Soto 31b17b2913 Condense Init functions.
- Define operator pointers when required.
- Use OperatorPtr for solver_ in BPSClass.
- Add MFEM Warnings.
- Add H preconditioner.
2023-08-14 14:44:26 -07:00
Gabriel Esteban Pinochet Soto 6f3cf11d58 Indentation fix (make style). 2023-08-10 16:25:23 -07:00
Gabriel Esteban Pinochet Soto 0631cea458 Update BramblePasciakSolver::GetNumIterations. 2023-08-10 16:15:35 -07:00
Gabriel Esteban Pinochet Soto 79f2d77612 Add BPCGSolver. Modify BramblePasciakSolver class.
- Add class BPCGSolver as a derived class of CGSolver.
- Add bool use_bpcg in BramblePasciakSolver.
- Storage main matrices in BramblePasciakSolver.
- Remaining operators stored as pointers.
- Update linalg/operator.hpp (make style).
- TODO Fix bug final_iter.
2023-08-10 15:51:36 -07:00
Will Pazner 9159121ff7 Bug fix in Mesh::RemoveInternalBoundaries 2023-08-09 07:48:10 -07:00
Will Pazner 80916f85a4 Set 1D be_to_face in Mesh::FinalizeTopology 2023-08-09 07:48:10 -07:00
Will Pazner e37314ff51 Remove Mesh::be_to_edge
It cannot just be marked MFEM_DEPRECATED: gcc will complain.
2023-08-09 07:48:10 -07:00
Will Pazner 4d47bb42f3 Set up be_to_face in Mesh::Make1D 2023-08-09 07:48:10 -07:00
Will Pazner eba1824ebb Document that GetBdrElementEdgeIndex is the same as GetBdrFace 2023-08-09 07:48:10 -07:00
Will Pazner 9b4c527442 Deprecate Mesh::be_to_edge
Mesh::be_to_face should be used instead for 1D, 2D and 3D.
2023-08-09 07:48:10 -07:00
Will Pazner 66258d17ba Remove 1D as special case in GenerateBoundaryElements 2023-08-09 07:48:10 -07:00
Will Pazner 5359237ffd Add boundary elements in 1D ParSubMesh 2023-08-09 07:48:10 -07:00
Will Pazner 808a8b1a18 Support Mesh::GenerateBoundaryElements for 1D meshes 2023-08-09 07:48:10 -07:00
Sebastian Grimberg db6d9df56b Style/formatting updates for fespace.cpp 2023-08-08 11:59:26 -07:00
Sebastian Grimberg 55a6d1b25a Thread-safe FiniteElementSpace::GetElementDofs and GetBdrElementDofs variants for DofTransformation, similar to Mesh::GetElementTransformation and GetBdrElementTransformation 2023-08-08 11:59:26 -07:00
Sebastian Grimberg e42c849e49 Refactor DofTransformation classes and use in FiniteElementSpace to exploit statefull/stateless objects 2023-08-08 11:59:26 -07:00
Gabriel Esteban Pinochet Soto 08deeaacd9 Add AddOperator operator. 2023-08-07 10:35:26 -07:00
Gabriel Esteban Pinochet Soto b4a0df6f5c Add parameter control. Add some documentation.
- Add parameter control for the default preconditioner.
- Add brief explanation of the current class.
- Include some relevant citations.
2023-08-07 10:29:28 -07:00
Chak Shing Lee 17271c5d27 fix doc 2023-08-02 18:57:15 -07:00
Chak Shing Lee da5222a860 some minor adjustment, and renaming of variables to match with other DarcySolver 2023-08-02 18:42:47 -07:00
Gabriel Esteban Pinochet Soto b765c24d1c Check style with make style 2023-07-31 15:17:47 -07:00
Gabriel Esteban Pinochet Soto 3056cddd22 Add Bramble-Pasciak solver.
- Modify DarcyProblem class.
- Add Bramble-Pasciak class.
- Define Bramble-Pasciak constructors.
- Define Bramble-Pasciak Mult.
- Update header accordingly.
2023-07-31 15:17:47 -07:00
Sebastian Grimberg 935f060063 Merge branch 'master' into sjg/strumpack-solver-dev 2023-07-30 18:20:01 -07:00
adam-sim-dev 7c7e6fe9d3 Merge branch 'master' into cxxflags 2023-07-26 09:10:00 +08:00
Barry Fadness e83a2b4dfa Split Mult into member functions 2023-07-18 19:03:59 -07:00
Barry Fadness aa6ee1e659 Split constructor into member functions 2023-07-17 23:13:02 -07:00
Jamie Bramwell d2358b36fb Merge branch 'master' into elasticity-amg-fix 2023-07-10 19:50:58 -04:00
Sebastian Grimberg 449df5ceea Merge branch 'master' into sjg/bilinearform-integs-marker 2023-07-07 08:50:28 -07:00
adam-sim-dev 996bfd97bd Merge branch 'master' into cxxflags 2023-07-07 09:47:29 +08:00
Jamie A. Bramwell d0bcf2f903 Turn off the iterative weight refinement for elasticity problems using BoomerAMG. This was causing a seg fault in hypre v2.26.0 in a user problem 2023-07-06 16:08:44 -07:00
Jamie A. Bramwell fbf26241d1 Use the correct ordering in the SetElasticityOptions routine and turn off iterative weight refinement as it was causing a seg-fault in a user application as of Hypre v2.26.0 2023-07-06 15:27:25 -07:00
Sebastian Grimberg f5d0658223 Address PR comments 2023-07-06 08:15:48 -07:00
Sebastian Grimberg c145a0c687 And another attempt to resolve LNK2019 error 2023-07-03 08:48:10 -07:00
Sebastian Grimberg 947cb04ea4 Another attempt to resolve LNK2019 error 2023-07-03 08:24:54 -07:00
Sebastian Grimberg 075c9caea4 Attempt to resolve LNK2019 linker error on Windows 2023-07-03 07:37:15 -07:00
adam-sim-dev 05c4de2e23 Merge branch 'master' into cxxflags 2023-06-30 11:00:48 +08:00
Sebastian Grimberg 77810e3741 Alternative approach to 15934beb to inititalize MPI with MPI_Init_thread and a level of threading which by default is configured based on MFEM's build configuration, but can be overridden at runtime by modifying Mpi::default_thread_required 2023-06-29 15:31:47 -07:00
Veselin Dobrev 15934bebb9 In the singleton class Mpi: added method Mpi::Init_thread that
performs MPI initialization using MPI_Init_thread; added method
Mpi::Init_auto that selects what MPI init mode to use based on
the configured external packages used by MFEM -- currently it
calls Mpi::Init_thread(MPI_THREAD_MULTIPLE) when using STRUMPACK
built with SLATE or PT-Scotch, otherwise it calls Mpi::Init.

In the examples that can use STRUMPACK, use Mpi::Init_auto instead
of Mpi::Init.

Fix a small unrelated issue noticed during testing: in
miniapps/multidomain/multidomain.cpp, do not open GLVis socket
connections when visualization is disabled.
2023-06-27 17:47:22 -07:00
adam-sim-dev 75b5eacbd8 Merge branch 'master' into cxxflags 2023-06-27 13:29:59 +08:00
Sebastian Grimberg a2daad497d Merge branch 'master' into sjg/strumpack-solver-dev 2023-06-26 16:57:20 -07:00
Sebastian Grimberg a357c4fe42 Add warning message to mfem::Mpi::Init when MPI_Init_thread may be required instead of MPI_Init 2023-06-26 10:17:38 -07:00
adam-sim-dev 47ce35a487 Merge branch 'master' into cxxflags 2023-06-25 08:30:26 +08:00
Sebastian Grimberg 1726be86b9 Fix unit test hang for older STRUMPACK versions 2023-06-22 11:40:00 -07:00
Sebastian Grimberg a65ee60983 Merge branch 'master' into sjg/strumpack-solver-dev 2023-06-22 11:35:54 -07:00
Sebastian Grimberg ce47a35740 Merge branch 'master' into sjg/strumpack-solver-dev 2023-06-22 10:38:53 -07:00
Sebastian Grimberg e138f366fe Merge branch 'master' into sjg/strumpack-solver-dev 2023-06-21 12:10:10 -07:00
adam-sim-dev 8390b1b44e Merge branch 'master' into cxxflags 2023-06-18 20:11:11 +08:00
adam-sim-dev bbfb88b7ee Merge branch 'master' into cxxflags 2023-06-14 21:29:12 +08:00
Tzanio Kolev c788c4787c Merge branch 'master' into use-getaddrinfo 2023-06-11 15:19:15 -07:00
topazus 1e642147ae Replace deprecated gethostbyname by getaddrinfo 2023-06-06 17:35:36 +08:00
adam-sim-dev a4457ce492 Merge branch 'master' into cxxflags 2023-05-23 21:23:36 +08:00
Sebastian Grimberg ef6074c420 ex31p with the -ams option in 2D revealed a bug for DiscreteLinearOperator::Assemble 2023-05-17 16:04:31 -07:00
Sebastian Grimberg ec729707e9 Merge branch 'master' into sjg/bilinearform-integs-marker 2023-05-14 17:15:56 -07:00
adam-sim-dev c10f832d2c Merge branch 'master' into cxxflags 2023-05-07 22:32:05 +08:00
adam-sim-dev 89bf320ee0 Add $(MFEM_CXXFLAGS) 2023-05-07 21:59:36 +08:00
Sebastian Grimberg 49ebade007 Minor added simplification missed in 052b5e0c 2023-05-05 11:30:25 -07:00
Sebastian Grimberg 76650a0d1e Merge branch 'master' into sjg/bilinearform-integs-marker 2023-05-05 10:10:48 -07:00
Sebastian Grimberg bdf529b9fe Fix unit test to work with old STRUMPACK versions prior to v7.1.2 2023-05-03 10:33:23 -07:00
Sebastian Grimberg a53acb7ce8 Merge branch 'master' into sjg/strumpack-solver-dev 2023-05-02 17:47:01 -07:00
Sebastian Grimberg 35bd5c84e9 Merge branch 'master' into sjg/bilinearform-integs-marker 2023-05-02 17:46:05 -07:00
Sebastian Grimberg ad21adbf57 Merge branch 'master' into sjg/bilinearform-integs-marker 2023-04-18 11:10:33 -07:00
Sebastian Grimberg ff5238ed5b Merge branch 'master' into sjg/strumpack-solver-dev 2023-04-18 11:09:49 -07:00
Sebastian Grimberg 6ae0a5bb89 Fix STRUMPACK version check bug 2023-04-11 21:56:44 -07:00
Sebastian Grimberg 8dedcb1ee3 Fix test and style updates 2023-04-11 10:25:00 -07:00
Sebastian Grimberg 417837e238 Remove code for unsupported STRUMPACK < v3.0
Fix ReturnCode bug for v6.3.1 as well.
2023-04-11 10:23:49 -07:00
Sebastian Grimberg b7a0ae8f6a Merge branch 'master' into sjg/strumpack-solver-dev 2023-04-11 10:01:40 -07:00
Sebastian Grimberg b9bf7a57c1 Merge branch 'master' into sjg/bilinearform-integs-marker 2023-04-03 10:07:41 -07:00
Ketan Mittal aada43250d initial commit 2023-03-31 11:15:13 -07:00
hughcars 3a1b7ebc51 Merge branch 'master' into sjg/strumpack-solver-dev 2023-03-30 12:44:22 -04:00
Sebastian Grimberg 8edc9eaab0 make style 2023-03-15 16:43:55 -07:00
Sebastian Grimberg 052b5e0cf2 Address PR comments 2023-03-15 16:43:02 -07:00
Sebastian Grimberg 6738a32c03 Add domain integrator markers for MixedBilinearForm, DiscreteLinearOperator, and NonlinearFormclasses 2023-03-01 10:48:18 -08:00
Sebastian Grimberg c2138c03e3 Merge branch 'master' into sjg/strumpack-solver-dev 2023-02-28 16:23:53 -08:00
Barry Fadness 637de53e10 Change default boundary conditions 2023-02-12 18:34:48 -08:00
Barry Fadness f347adafd7 Store and use mixed_dofs array 2023-02-12 18:13:35 -08:00
Barry Fadness 5cb5bdfa47 Make small style changes 2023-02-12 00:58:36 -08:00
Barry Fadness b6b515a5cc Remove unnecessary zero initializations 2023-02-12 00:57:10 -08:00
Barry Fadness 89c9ac4a3e Move test_size init before use 2023-02-11 20:46:39 -08:00
Barry Fadness 2b238b3ccc Reuse Minv_sub_vec vector 2023-02-11 20:42:58 -08:00
Barry Fadness 115cf9cc35 Move vector initialization outside of loops 2023-02-11 20:41:55 -08:00
Barry Fadness 030f6b0adf Utilize offsets arrays 2023-02-11 20:37:40 -08:00
Barry Fadness 6ab54fae6a Remove unnecessary test_dofs array 2023-02-11 20:32:44 -08:00
Barry Fadness 98f8c25102 Use existing function to restrict u hat 2023-02-11 19:51:22 -08:00
Barry Fadness cb3649b0e7 Reuse rhs_r vector 2023-02-11 19:45:23 -08:00
Barry Fadness 8affea4ff7 Delete num_hat_dofs variable 2023-02-11 19:27:06 -08:00
Barry Fadness 52ce79500b Make Ct_local code more consistent 2023-02-11 19:07:42 -08:00
Barry Fadness f7b685a949 Initialize dense matrices outside of loop 2023-02-11 19:04:50 -08:00
Barry Fadness 561f9495c8 Correct the order of the contraint space
If the FE space is RT_p, then GetOrder()
returns p + 1. See fe_coll.hpp L360.
2023-02-03 20:32:37 -08:00
Barry Fadness 640502cd19 Use Last Array class member function 2023-02-03 19:16:08 -08:00
Barry Fadness 1e1524ef0a Store the number of elements in const int 2023-02-03 19:07:52 -08:00
Barry Fadness 60f6b4138f Use test_offsets array 2023-01-30 21:23:16 -08:00
Barry Fadness 8799a5a6c1 Move offsets code closer to Init 2023-01-30 20:37:12 -08:00
Barry Fadness b6a7aa9e7e Make lines more similar to hybridization.cpp 2023-01-29 21:24:46 -08:00
Barry Fadness 873fd364bd Edit whitespace 2023-01-29 20:54:26 -08:00
Barry Fadness 8bdf7a5bde Increase the value of epsilon 2023-01-29 20:52:55 -08:00
Barry Fadness 7586d62bee Move creation of dofs array 2023-01-29 20:51:59 -08:00
Barry Fadness ebafb82533 Remove get calls from for loops 2023-01-29 20:49:56 -08:00
Barry Fadness de77303ca3 Move elimination step so that dofs are correct
The element matrix elimination previously used
the hat_dof_marker array. Now we need adjusted
dofs instead, which are obtained from the signed
dofs.
2023-01-29 17:29:18 -08:00
Barry Fadness ffafd46e06 Remove the unnecessary hat_dof_marker array 2023-01-28 16:51:22 -08:00
Barry Fadness 5ffb1421b3 Move ess_dof_marker creation 2023-01-28 16:48:03 -08:00
Barry Fadness bf0ebd3b4a Remove skip_zeros variable and use default value 2023-01-28 16:44:58 -08:00
Barry Fadness 4483127d46 Remove num_hat_dofs variable in constructor 2023-01-28 16:44:10 -08:00
Sebastian Grimberg 0b8b7d748c Merge branch 'master' into sjg/strumpack-solver-dev 2023-01-27 15:25:45 -08:00
Sebastian Grimberg 53bc105b9b Add option to enable or disable STRUMPACK GPU support 2023-01-27 15:25:41 -08:00
Sebastian Grimberg c7f42bd83c Fix deprecated Vector cast 2023-01-12 10:26:11 -08:00
Sebastian Grimberg e7fc38420d Build process fixes for STRUMPACK 2023-01-11 08:48:43 -08:00
Sebastian Grimberg 5295015a31 Add tests and update examples 2023-01-10 10:55:57 -08:00
Sebastian Grimberg 48750e304b Update STRUMPACK solver: 64-bit index support and multiple RHS
For STRUMPACK > 6.3.1, also support mixed precision solver.
2023-01-10 10:54:18 -08:00
Barry Fadness 1c02f91d61 Fix bug in serial refinement number
Each number in the fraction was an integer. If neither
the numerator nor the denominator is a float, then only
the quotient is returned. As a result the logarithm will
be less than it should be, and the ceiling will not
round up.
2022-12-23 21:14:21 -08:00
Barry Fadness bc8d146070 Add description of block hybridization solver 2022-12-20 13:39:14 -08:00
Barry Fadness d48a9fb683 Add brackets to free array memory in destructor 2022-12-20 13:38:34 -08:00
Barry Fadness 15666ae446 Fix small typo and edit preamble notes 2022-12-05 11:52:16 -08:00
Barry Fadness c234398430 Prevent the mass coefficient from being destroyed
An integrator does not own its coefficient. If a coefficient
is created in a scoped region using stack memory, then it will
expire even though a bilinear form may rely on it.

Make the mass coefficient a unique pointer owned by the Darcy
problem class. Then the coefficient will persist until a Darcy
problem instance reaches the end of the main function.
2022-11-21 00:26:28 -08:00
Barry Fadness 842b8e81a5 Enable the hypre preconditioner again
No error message is encountered for hypre versions < 22100.
2022-11-21 00:12:56 -08:00
Barry Fadness 95131ae6df Fix dof true dof problems
We need to go back and forth between dofs and true dofs.
The offsets_ array should be true dofs, so some code could
be deleted. All array sizes may be okay now.
2022-10-20 17:06:42 -07:00
Barry Fadness 7b7fd1d7d1 Fix essential bc elimination in right-hand side 2022-10-17 01:51:11 -07:00
Barry Fadness 51bf50bd1f Edit comment and remove forgotten line 2022-10-17 01:49:17 -07:00
Barry Fadness ba77f139b2 Simplify setting the right-hand side pressure block 2022-10-17 01:46:08 -07:00
Barry Fadness c0db35f4be Unset preconditioner for now because of seg faults 2022-09-29 13:04:54 -07:00
Barry Fadness fad4206ccb Clean up formatting to be consistent 2022-09-29 12:53:29 -07:00
Barry Fadness 8844cbbd87 Substitute offsets to avoid computing sizes multiple times 2022-09-29 12:31:01 -07:00
Barry Fadness 5da2f32570 Add essential bc elimination - incorrect 2022-09-29 12:23:47 -07:00
Barry Fadness 1d6b812c22 Change order of variable initialization to address warning 2022-09-26 00:34:04 -07:00
Barry Fadness 0c10422f95 Remove polynomial order from parameter list because unnecessary 2022-09-26 00:29:18 -07:00
Barry Fadness 836bc54397 Fix typo in anisotropic boundary file path 2022-09-26 00:06:56 -07:00
Barry Fadness 0fe70454b5 Change array name to know it is a list 2022-09-26 00:00:56 -07:00
Barry Fadness 3d420605fe Allocate the preconditioner on the heap 2022-09-22 00:51:06 -07:00
Barry Fadness f182173df4 Change tolerance value eps and delete print statement 2022-09-21 23:18:03 -07:00
Barry Fadness feba2c4bfe Set preconditioner and then operator (as recommended) 2022-09-21 23:15:18 -07:00
Barry Fadness 25f972fcdb Convert between true dofs and local dofs 2022-09-21 23:09:50 -07:00
Barry Fadness dd1d6f4e26 Fix obtaining the hat dofs for solution recovery 2022-09-21 23:07:57 -07:00
Barry Fadness cd11ddf27a Remove second memory allocation of private members 2022-09-21 22:59:21 -07:00
Barry Fadness 96f79c97b0 Make parallel mesh alias instead of a copy 2022-09-21 22:53:47 -07:00
Barry Fadness d6574909ee Make the constraint FE space a class member
The constraint space owns its action-only prolongation
operator. This operator is used in the Mult() function,
so we must prevent the space from being destroyed after
the constructor is called.
2022-09-21 22:04:54 -07:00
Barry Fadness bed8da810d Remove vector mass coefficient temporarily
The vector mass piecewise constant coefficient created
in the DarcyProblem class constructor is destroyed. It
is needed in the hybridization solver to compute the
element matrices. We will deal with this later.
2022-09-21 21:31:11 -07:00
Barry Fadness 4096ed429d Make changes to match block-solvers and just to compile 2022-09-19 13:47:13 -07:00
Barry Fadness 513dd5914d Add block hybridization solver class 2022-09-19 13:45:20 -07:00
Barry Fadness c72c5f6570 Add block hybridization solver 2022-09-19 13:44:26 -07:00
Barry Fadness b2146af63a Add getter for parallel test FE space 2022-09-19 13:44:03 -07:00
Barry Fadness e5f597a556 Cut and paste right-hand side code
The code to reduce the right-hand side was intertwined
with the construction of the left-hand side. Move the
lines of code from the constructor to the Mult function.
2022-09-18 18:07:11 -07:00
Barry Fadness 1dd16d99f2 Copy and paste block hybridization code 2022-09-18 13:37:31 -07:00
chakshinglee 5f92c58dfe make style 2022-09-12 22:14:29 -07:00
chakshinglee ce8f6bb37d shorter name for the block-diagonally-preconditioned MINRES solver 2022-09-12 21:57:11 -07:00
chakshinglee 26c86d7b8c add the elimination step as an option for DarcySolver 2022-09-12 21:09:50 -07:00
chakshinglee 1fdc4b7dae store both the right hand sides before and after elimination in DarcyProblem; add getter for the bilinear forms for hybridization solver 2022-09-12 18:02:03 -07:00
chakshinglee 3dfa563818 resolve conflicts with master 2022-09-12 16:16:03 -07:00
Lee de57fe137e Adding an access function to the serial constraint matrix (transpose) Ct in the Hybridization class. This will be useful in hybridizing block systems. 2017-06-12 09:50:58 -07:00
Lee 45167598a0 First commit. Adding functions to compute element matrices (only for domain integrators) for MixedBilinearForm. These are needed for forming local block systems. 2017-06-12 09:46:45 -07:00
145 changed files with 10497 additions and 3379 deletions
+8 -1
View File
@@ -128,6 +128,13 @@ examples/amgx/sol.gf
examples/amgx/mesh.*
examples/amgx/sol.*
examples/caliper/ex1
examples/caliper/ex1p
examples/caliper/refined.mesh
examples/caliper/sol.gf
examples/caliper/mesh.*
examples/caliper/sol.*
examples/ginkgo/ex1
examples/ginkgo/refined.mesh
examples/ginkgo/sol.gf
@@ -300,7 +307,7 @@ miniapps/tools/convert-dc
miniapps/tools/lor-transfer
miniapps/tools/plor-transfer
miniapps/tools/get-values
miniapps/tools/check-tmop-metric
miniapps/tools/tmop-check-metric
miniapps/tools/tmop-metric-magnitude
miniapps/tools/nodal-transfer
miniapps/tools/ParaView
+11
View File
@@ -16,10 +16,18 @@ Discretization improvements
- Introduced support for higher order non conformal Nedelec elements on
simplices in ParMesh.
- Added functionality for construction of cut-surface and cut-volume
IntegrationRules through a moment-fitting approach. The cut is specified by
the zero level set of a Coefficient. See fem/intrules_cut.hpp and Example 38.
Miscellaneous
-------------
- The ReadCubit Genesis mesh importer has been rewritten to improve readability.
- Improved thread safety for global variables in the library, for example
IntegrationRules IntRules, RefinedIntRules, GeometryRefiner
GlobGeometryRefiner, and FiniteElement::dof2quad_array.
Version 4.6, released on September 27, 2023
===========================================
@@ -87,12 +95,15 @@ Linear and nonlinear solvers
- Added HIP support to the PETSc and SUNDIALS interfaces.
- Efficient GPU-accelerated LOR assembly now supports surface meshes.
New and updated examples and miniapps
-------------------------------------
- Added a new H(div) solver miniapp demonstrating the use of a matrix-free
saddle-point solver methodology, suitable for high-order discretizations and
for GPU acceleration. Examples illustrating the solution of Darcy and grad-div
problems are included. See miniapps/hdiv-linear-solver.
>>>>>>> master
- Added new Discontinuous Petrov-Galerkin (DPG) miniapp which includes serial
and parallel examples for diffusion, convection-diffusion, acoustics and
+23 -6
View File
@@ -139,10 +139,9 @@ if (MFEM_USE_CUDA)
set(CMAKE_CUDA_HOST_LINK_LAUNCHER ${CMAKE_CXX_COMPILER})
endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDA_FLAGS}")
find_package(CUDAToolkit REQUIRED)
set(CUSPARSE_FOUND TRUE)
set(CUSPARSE_LIBRARIES "cusparse")
set(CUBLAS_FOUND TRUE)
set(CUBLAS_LIBRARIES "cublas")
get_target_property(CUSPARSE_LIBRARIES CUDA::cusparse LOCATION)
endif()
if (XSDK_ENABLE_C)
@@ -531,7 +530,7 @@ find_package(Threads REQUIRED)
set(MFEM_TPLS OPENMP HYPRE LAPACK BLAS SuperLUDist STRUMPACK METIS SuiteSparse
SUNDIALS PETSC SLEPC MUMPS AXOM FMS CONDUIT Ginkgo GNUTLS GSLIB
NETCDF MPFR PUMI HIOP POSIXCLOCKS MFEMBacktrace ZLIB OCCA CEED RAJA UMPIRE
ADIOS2 CUBLAS CUSPARSE MKL_CPARDISO MKL_PARDISO AMGX CALIPER CODIPACK
ADIOS2 CUSPARSE MKL_CPARDISO MKL_PARDISO AMGX CALIPER CODIPACK
BENCHMARK PARELAG MPI_CXX HIP HIPSPARSE MOONOLITH BLITZ ALGOIM ENZYME)
# Add all *_FOUND libraries in the variable TPL_LIBRARIES.
@@ -641,16 +640,34 @@ if (NOT ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}"))
foreach(Header mfem.hpp mfem-performance.hpp)
message(STATUS
"Writing substitute header --> \"${Header}\"")
file(WRITE "${PROJECT_BINARY_DIR}/${Header}"
file(WRITE "${PROJECT_BINARY_DIR}/${Header}.tmp"
"// Auto-generated file.
#define MFEM_CONFIG_FILE \"${PROJECT_BINARY_DIR}/config/_config.hpp\"
#include \"${PROJECT_SOURCE_DIR}/${Header}\"
")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_BINARY_DIR}/${Header}.tmp"
"${PROJECT_BINARY_DIR}/${Header}"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove
"${PROJECT_BINARY_DIR}/${Header}.tmp"
)
# This version will be installed in the top include directory:
file(WRITE "${PROJECT_BINARY_DIR}/InstallHeaders/${Header}"
file(WRITE "${PROJECT_BINARY_DIR}/InstallHeaders/${Header}.tmp"
"// Auto-generated file.
#include \"mfem/${Header}\"
")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_BINARY_DIR}/InstallHeaders/${Header}.tmp"
"${PROJECT_BINARY_DIR}/InstallHeaders/${Header}"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove
"${PROJECT_BINARY_DIR}/InstallHeaders/${Header}.tmp"
)
endforeach()
endif()
+1 -2
View File
@@ -659,8 +659,7 @@ The specific libraries and their options are:
requires the PT-Scotch and Scalapack libraries as well as ParMETIS, which
includes METIS 5 in its distribution. Starting with STRUMPACK v2.2.0, ParMETIS
and PT-Scotch are optional dependencies.
The support for STRUMPACK was added in MFEM v3.3.2 and it requires STRUMPACK
2.0.0 or later.
The support for STRUMPACK was added in MFEM v3.3.2.
URL: http://portal.nersc.gov/project/sparse/strumpack
Options: STRUMPACK_OPT, STRUMPACK_LIB.
Versions: STRUMPACK >= 3.0.0.
+28
View File
@@ -14,9 +14,13 @@
# - HYPRE_LIBRARIES
# - HYPRE_INCLUDE_DIRS
# - HYPRE_VERSION
# - HYPRE_USING_CUDA (internal)
# - HYPRE_USING_HIP (internal)
if (HYPRE_FOUND)
if (HYPRE_USING_CUDA)
find_package(CUDAToolkit REQUIRED)
endif()
if (HYPRE_USING_HIP)
find_package(rocsparse REQUIRED)
find_package(rocrand REQUIRED)
@@ -27,6 +31,20 @@ endif()
include(MfemCmakeUtilities)
mfem_find_package(HYPRE HYPRE HYPRE_DIR "include" "HYPRE.h" "lib" "HYPRE"
"Paths to headers required by HYPRE." "Libraries required by HYPRE."
CHECK_BUILD HYPRE_USING_CUDA FALSE
"
#undef HYPRE_USING_CUDA
#include <HYPRE_config.h>
#ifndef HYPRE_USING_CUDA
#error HYPRE is built without CUDA.
#endif
int main()
{
return 0;
}
"
CHECK_BUILD HYPRE_USING_HIP FALSE
"
#undef HYPRE_USING_HIP
@@ -57,6 +75,16 @@ if (HYPRE_FOUND AND (NOT HYPRE_VERSION))
endif()
endif()
if (HYPRE_FOUND AND HYPRE_USING_CUDA)
find_package(CUDAToolkit REQUIRED)
get_target_property(CUSPARSE_LIBRARIES CUDA::cusparse LOCATION)
get_target_property(CURAND_LIBRARIES CUDA::curand LOCATION)
list(APPEND HYPRE_LIBRARIES ${CUSPARSE_LIBRARIES} ${CURAND_LIBRARIES})
set(HYPRE_LIBRARIES ${HYPRE_LIBRARIES} CACHE STRING
"HYPRE libraries + dependencies." FORCE)
message(STATUS "Updated HYPRE_LIBRARIES: ${HYPRE_LIBRARIES}")
endif()
if (HYPRE_FOUND AND HYPRE_USING_HIP)
find_package(rocsparse REQUIRED)
find_package(rocrand REQUIRED)
+3 -7
View File
@@ -106,12 +106,7 @@ set(HYPRE_DIR "${MFEM_DIR}/../hypre/src/hypre" CACHE PATH
# If hypre was compiled to depend on BLAS and LAPACK:
# set(HYPRE_REQUIRED_PACKAGES "BLAS" "LAPACK" CACHE STRING
# "Packages that HYPRE depends on.")
if (MFEM_USE_CUDA)
# This is only necessary when hypre is built with cuda:
set(HYPRE_REQUIRED_LIBRARIES "-lcusparse" "-lcurand" CACHE STRING
"Libraries that HYPRE depends on.")
endif()
# HIP dependency for HYPRE is handled in FindHYPRE.cmake.
# CUDA and HIP dependencies for HYPRE are handled in FindHYPRE.cmake.
set(METIS_DIR "${MFEM_DIR}/../metis-4.0" CACHE PATH "Path to the METIS library.")
@@ -157,7 +152,8 @@ set(STRUMPACK_DIR "${MFEM_DIR}/../STRUMPACK-build" CACHE PATH
# STRUMPACK may also depend on "OpenMP", depending on how it was compiled.
# Starting with v2.2.0 of STRUMPACK, ParMETIS and Scotch are optional.
set(STRUMPACK_REQUIRED_PACKAGES "MPI" "MPI_Fortran" "ParMETIS" "METIS"
"ScaLAPACK" "Scotch/ptscotch/ptscotcherr/scotch/scotcherr" CACHE STRING
"Scotch/ptscotch/ptscotcherr/scotch/scotcherr"
"ScaLAPACK" "LAPACK" "BLAS" CACHE STRING
"Additional packages required by STRUMPACK.")
# If the MPI package does not find all required Fortran libraries:
# set(STRUMPACK_REQUIRED_LIBRARIES "gfortran" "mpi_mpifh" CACHE STRING
+3 -2
View File
@@ -38,14 +38,14 @@ all: header config-mk
MPI = $(MFEM_USE_MPI:NO=)
GHV_CXX ?= $(MFEM_CXX)
GHV = get_hypre_version
GHV_FLAGS = $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(HYPRE_OPT))
GHV_FLAGS = $(MFEM_CXXFLAGS) $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(HYPRE_OPT))
SMX = $(if $(MFEM_USE_PUMI:NO=),MFEM_USE_SIMMETRIX)
SMX_PATH = $(PUMI_DIR)/include/gmi_sim.h
SMX_FILE = $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(SMX_PATH))
MUMPS = $(MFEM_USE_MUMPS:NO=)
GMV_CXX ?= $(MFEM_CXX)
GMV = get_mumps_version
GMV_FLAGS = $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(MUMPS_OPT))
GMV_FLAGS = $(MFEM_CXXFLAGS) $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(MUMPS_OPT))
$(GHV): $(SRC)$(GHV).cpp
$(call mfem-info, Determining HYPRE version ...)
@@ -110,3 +110,4 @@ config-mk:
clean:
rm -f $(CONFIG_HPP) $(CONFIG_MK) sample-runs-build.log
rm -f $(GHV) $(GHV).out $(GMV) $(GMV).out
+1 -1
View File
@@ -315,7 +315,7 @@ function extract_sample_runs()
sruns=`grep -v "^//.* mpirun .* ${app}" "${src}" |
grep "^//.* ${app}" |
sed -e "s/.* ${app}/${vg_app}/g"`
runs="${sruns}${pruns}"
runs="${sruns}"$'\n'"${pruns}"
if [ "$skip_gen_meshes" == "yes" ]; then
runs=`printf "%s" "$runs" | grep -v ".* -m .*\.gen"`
fi
+1
View File
@@ -112,6 +112,7 @@ namespace mfem {
* - <a class="el" href="ex36p_8cpp_source.html">Example 36p</a>: parallel Proximal Galerkin FEM for the obstacle problem
* - <a class="el" href="ex37_8cpp_source.html">Example 37</a>: Topology optimization
* - <a class="el" href="ex37p_8cpp_source.html">Example 37p</a>: parallel topology optimization
* - <a class="el" href="ex38_8cpp_source.html">Example 38</a>: cut-surface and cut-volume integration
*
* <H4>AmgX Examples</H4>
* - Variants of Examples
+6
View File
@@ -45,6 +45,12 @@ list(APPEND ALL_EXE_SRCS
ex37.cpp
)
if(MFEM_USE_LAPACK)
list(APPEND ALL_EXE_SRCS
ex38.cpp
)
endif()
if (MFEM_USE_MPI)
list(APPEND ALL_EXE_SRCS
ex0p.cpp
+3 -2
View File
@@ -262,12 +262,13 @@ int main(int argc, char *argv[])
#ifdef MFEM_USE_STRUMPACK
if (sp_solver)
{
STRUMPACKSolver * strumpack = new STRUMPACKSolver(argc, argv, MPI_COMM_WORLD);
STRUMPACKSolver * strumpack = new STRUMPACKSolver(MPI_COMM_WORLD, argc, argv);
strumpack->SetPrintFactorStatistics(true);
strumpack->SetPrintSolveStatistics(false);
strumpack->SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
strumpack->SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
strumpack->DisableMatching();
strumpack->SetMatching(strumpack::MatchingJob::NONE);
strumpack->SetCompression(strumpack::CompressionType::NONE);
strumpack->SetOperator(*Arow);
strumpack->SetFromCommandLine();
precond = strumpack;
+5 -6
View File
@@ -26,13 +26,12 @@
using namespace std;
using namespace mfem;
/** After spatial discretization, the conduction model can be written as:
/** After spatial discretization, the wave model can be written as:
*
* d^2u/dt^2 = M^{-1}(-Ku)
*
* where u is the vector representing the temperature, M is the mass matrix,
* and K is the diffusion operator with diffusivity depending on u:
* (\kappa + \alpha u).
* where u is the vector representing the temperature, M is the mass,
* and K is the stiffness matrix.
*
* Class WaveOperator represents the right-hand side of the above ODE.
*/
@@ -301,7 +300,7 @@ int main(int argc, char *argv[])
Vector dudt;
dudt_gf.GetTrueDofs(dudt);
// 7. Initialize the conduction operator and the visualization.
// 7. Initialize the wave operator and the visualization.
Array<int> ess_bdr;
if (mesh->bdr_attributes.Size())
{
@@ -356,7 +355,7 @@ int main(int argc, char *argv[])
else
{
sout.precision(precision);
sout << "solution\n" << *mesh << dudt_gf;
sout << "solution\n" << *mesh << u_gf;
sout << "pause\n";
sout << flush;
cout << "GLVis visualization paused."
+29 -4
View File
@@ -170,6 +170,7 @@ int main(int argc, char *argv[])
bool herm_conv = true;
bool slu_solver = false;
bool mumps_solver = false;
bool strumpack_solver = false;
bool visualization = 1;
bool pa = false;
const char *device_config = "cpu";
@@ -200,6 +201,11 @@ int main(int argc, char *argv[])
#ifdef MFEM_USE_MUMPS
args.AddOption(&mumps_solver, "-mumps", "--mumps-solver", "-no-mumps",
"--no-mumps-solver", "Use the MUMPS Solver.");
#endif
#ifdef MFEM_USE_STRUMPACK
args.AddOption(&strumpack_solver, "-strumpack", "--strumpack-solver",
"-no-strumpack", "--no-strumpack-solver",
"Use the STRUMPACK Solver.");
#endif
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
"--no-visualization",
@@ -209,13 +215,14 @@ int main(int argc, char *argv[])
args.AddOption(&device_config, "-d", "--device",
"Device configuration string, see Device::Configure().");
args.Parse();
if (slu_solver && mumps_solver)
if (slu_solver + mumps_solver + strumpack_solver > 1)
{
if (myid == 0)
cout << "WARNING: Both SuperLU and MUMPS have been selected,"
<< " please choose either one." << endl
cout << "WARNING: More than one of SuperLU, MUMPS, and STRUMPACK have"
<< " been selected, please choose only one." << endl
<< " Defaulting to SuperLU." << endl;
mumps_solver = false;
strumpack_solver = false;
}
if (iprob > 4) { iprob = 4; }
@@ -474,6 +481,24 @@ int main(int argc, char *argv[])
delete A;
}
#endif
#ifdef MFEM_USE_STRUMPACK
if (!pa && strumpack_solver)
{
HypreParMatrix *A = Ah.As<ComplexHypreParMatrix>()->GetSystemMatrix();
STRUMPACKRowLocMatrix SA(*A);
STRUMPACKSolver strumpack(MPI_COMM_WORLD, argc, argv);
strumpack.SetPrintFactorStatistics(false);
strumpack.SetPrintSolveStatistics(false);
strumpack.SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
strumpack.SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
strumpack.SetMatching(strumpack::MatchingJob::NONE);
strumpack.SetCompression(strumpack::CompressionType::NONE);
strumpack.SetFromCommandLine();
strumpack.SetOperator(SA);
strumpack.Mult(B, X);
delete A;
}
#endif
#ifdef MFEM_USE_MUMPS
if (!pa && mumps_solver)
{
@@ -493,7 +518,7 @@ int main(int argc, char *argv[])
//
// In PML: 1/mu (abs(1/det(J) J^T J) Curl E, Curl F)
// + omega^2 * epsilon (abs(det(J) * (J^T J)^-1) * E, F)
if (pa || (!slu_solver && !mumps_solver))
if (pa || (!slu_solver && !mumps_solver && !strumpack_solver))
{
ConstantCoefficient absomeg(pow(omega, 2) * epsilon);
RestrictedCoefficient restr_absomeg(absomeg,attr);
+696
View File
@@ -0,0 +1,696 @@
// MFEM Example 38
//
// Compile with: make ex38
//
// Sample runs:
// (since all sample runs require LAPACK, the * symbol is used to exclude them
// from the automatically generated internal MFEM tests).
// * ex38
// * ex38 -i volumetric1d
// * ex38 -i surface2d
// * ex38 -i surface2d -o 4 -r 5
// * ex38 -i volumetric2d
// * ex38 -i volumetric2d -o 4 -r 5
// * ex38 -i surface3d
// * ex38 -i surface3d -o 4 -r 5
// * ex38 -i volumetric3d
// * ex38 -i volumetric3d -o 4 -r 5
//
// Description: This example code demonstrates the use of MFEM to integrate
// functions over implicit interfaces and subdomains bounded by
// implicit interfaces.
//
// The quadrature rules are constructed by means of moment-fitting.
// The interface is given by the zero isoline of a level-set
// function ϕ and the subdomain is given as the domain where ϕ>0
// holds. The algorithm for construction of the quadrature rules
// was introduced by Mueller, Kummer and Oberlack [1].
//
// This example also showcases how to set up integrators using the
// integration rules on implicit surfaces and subdomains.
//
// [1] Mueller, B., Kummer, F. and Oberlack, M. (2013) Highly accurate surface
// and volume integration on implicit domains by means of moment-fitting.
// Int. J. Numer. Meth. Engr. (96) 512-528. DOI:10.1002/nme.4569
#include "mfem.hpp"
#include <iostream>
using namespace std;
using namespace mfem;
/// @brief Integration rule the example should demonstrate
enum class IntegrationType { Volumetric1D, Surface2D, Volumetric2D,
Surface3D, Volumetric3D
};
IntegrationType itype;
/// @brief Level-set function defining the implicit interface
double lvlset(const Vector& X)
{
switch (itype)
{
case IntegrationType::Volumetric1D:
return .55 - X(0);
case IntegrationType::Surface2D:
return 1. - (pow(X(0), 2.) + pow(X(1), 2.));
case IntegrationType::Volumetric2D:
return 1. - (pow(X(0) / 1.5, 2.) + pow(X(1) / .75, 2.));
case IntegrationType::Surface3D:
return 1. - (pow(X(0), 2.) + pow(X(1), 2.) + pow(X(2), 2.));
case IntegrationType::Volumetric3D:
return 1. - (pow(X(0) / 1.5, 2.) + pow(X(1) / .75, 2.) + pow(X(2) / .5, 2.));
default:
return 1.;
}
}
/// @brief Function that should be integrated
double integrand(const Vector& X)
{
switch (itype)
{
case IntegrationType::Volumetric1D:
return 1.;
case IntegrationType::Surface2D:
return 3. * pow(X(0), 2.) - pow(X(1), 2.);
case IntegrationType::Volumetric2D:
return 1.;
case IntegrationType::Surface3D:
return 4. - 3. * pow(X(0), 2.) + 2. * pow(X(1), 2.) - pow(X(2), 2.);
case IntegrationType::Volumetric3D:
return 1.;
default:
return 0.;
}
}
/// @brief Analytic surface integral
double Surface()
{
switch (itype)
{
case IntegrationType::Volumetric1D:
return 1.;
case IntegrationType::Surface2D:
return 2. * M_PI;
case IntegrationType::Volumetric2D:
return 7.26633616541076;
case IntegrationType::Surface3D:
return 40. / 3. * M_PI;
case IntegrationType::Volumetric3D:
return 9.90182151329315;
default:
return 0.;
}
}
/// @brief Analytic volume integral over subdomain with positive level-set
double Volume()
{
switch (itype)
{
case IntegrationType::Volumetric1D:
return .55;
case IntegrationType::Surface2D:
return NAN;
case IntegrationType::Volumetric2D:
return 9. / 8. * M_PI;
case IntegrationType::Surface3D:
return NAN;
case IntegrationType::Volumetric3D:
return 3. / 4. * M_PI;
default:
return 0.;
}
}
#ifdef MFEM_USE_LAPACK
/**
@brief Class for surface IntegrationRule
This class demonstrates how IntegrationRules computed as CutIntegrationRules
can be saved to reduce the impact by computing them from scratch each time.
*/
class SIntegrationRule : public IntegrationRule
{
protected:
/// @brief Space Dimension of the IntegrationRule
int dim;
/// @brief Column-wise matrix of the quadtrature weights
DenseMatrix Weights;
/// @brief Column-wise matrix of the transformation weights of the normal
DenseMatrix SurfaceWeights;
public:
/**
@brief Constructor of SIntegrationRule
The surface integrationRules are computed and saved in the constructor.
@param [in] Order Order of the IntegrationRule
@param [in] LvlSet Level-set defining the implicit interface
@param [in] lsOrder Polynomial degree for approx of level-set function
@param [in] mesh Pointer to the mesh that is used
*/
SIntegrationRule(int Order, Coefficient& LvlSet, int lsOrder, Mesh* mesh)
{
dim = mesh->Dimension();
IsoparametricTransformation Tr;
MomentFittingIntRules MFIRs(Order, LvlSet, lsOrder);
mesh->GetElementTransformation(0, &Tr);
IntegrationRule ir;
MFIRs.GetSurfaceIntegrationRule(Tr, ir);
if (dim >1)
{
Weights.SetSize(ir.GetNPoints(), mesh->GetNE());
}
else
{
Weights.SetSize(2, mesh->GetNE());
}
SurfaceWeights.SetSize(ir.GetNPoints(), mesh->GetNE());
Vector w;
MFIRs.GetSurfaceWeights(Tr, ir, w);
SurfaceWeights.SetCol(0, w);
SetSize(ir.GetNPoints());
for (int ip = 0; ip < GetNPoints(); ip++)
{
IntPoint(ip).index = ip;
IntegrationPoint &intp = IntPoint(ip);
intp.x = ir.IntPoint(ip).x;
intp.y = ir.IntPoint(ip).y;
intp.z = ir.IntPoint(ip).z;
if (dim > 1)
{
Weights(ip, 0) = ir.IntPoint(ip).weight;
}
else
{
Weights(0, 0) = ir.IntPoint(ip).x;
Weights(1, 0) = ir.IntPoint(ip).weight;
}
}
for (int elem = 1; elem < mesh->GetNE(); elem++)
{
mesh->GetElementTransformation(elem, &Tr);
MFIRs.GetSurfaceIntegrationRule(Tr, ir);
Vector w;
MFIRs.GetSurfaceWeights(Tr, ir, w);
SurfaceWeights.SetCol(elem, w);
for (int ip = 0; ip < GetNPoints(); ip++)
{
if (dim > 1)
{
Weights(ip, elem) = ir.IntPoint(ip).weight;
}
else
{
Weights(0, elem) = ir.IntPoint(ip).x;
Weights(1, elem) = ir.IntPoint(ip).weight;
}
}
}
}
/**
@brief Set the weights for the given element and multiply them with the
transformation of the interface
*/
void SetElementinclSurfaceWeight(int Element)
{
if (dim == 1)
{
IntegrationPoint &intp = IntPoint(0);
intp.x = Weights(0, Element);
intp.weight = Weights(1, Element);
cout << intp.x << " " << Element << endl;
}
else
for (int ip = 0; ip < GetNPoints(); ip++)
{
IntegrationPoint &intp = IntPoint(ip);
intp.weight = Weights(ip, Element) * SurfaceWeights(ip, Element);
}
}
/// @brief Set the weights for the given element
void SetElement(int Element)
{
if (dim == 1)
{
IntegrationPoint &intp = IntPoint(0);
intp.x = Weights(0, Element);
intp.weight = Weights(1, Element);
}
else
for (int ip = 0; ip < GetNPoints(); ip++)
{
IntegrationPoint &intp = IntPoint(ip);
intp.weight = Weights(ip, Element);
}
}
/// @brief Destructor of SIntegrationRule
~SIntegrationRule() {}
};
/**
@brief Class for volume IntegrationRule
This class demonstrates how IntegrationRules computed as CutIntegrationRules
can be saved to reduce the impact by computing them from scratch each time.
*/
class CIntegrationRule : public IntegrationRule
{
protected:
/// @brief Space Dimension of the IntegrationRule
int dim;
/// @brief Column-wise matrix of the quadtrature weights
DenseMatrix Weights;
public:
/**
@brief Constructor of CIntegrationRule
The volume integrationRules are computed and saved in the constructor.
@param [in] Order Order of the IntegrationRule
@param [in] LvlSet Level-set defining the implicit interface
@param [in] lsOrder Polynomial degree for approx of level-set function
@param [in] mesh Pointer to the mesh that is used
*/
CIntegrationRule(int Order, Coefficient& LvlSet, int lsOrder, Mesh* mesh)
{
dim = mesh->Dimension();
IsoparametricTransformation Tr;
MomentFittingIntRules MFIRs(Order, LvlSet, lsOrder);
mesh->GetElementTransformation(0, &Tr);
IntegrationRule ir;
MFIRs.GetVolumeIntegrationRule(Tr, ir);
if (dim > 1)
{
Weights.SetSize(ir.GetNPoints(), mesh->GetNE());
}
else
{
Weights.SetSize(2 * ir.GetNPoints(), mesh->GetNE());
}
SetSize(ir.GetNPoints());
for (int ip = 0; ip < GetNPoints(); ip++)
{
IntPoint(ip).index = ip;
IntegrationPoint &intp = IntPoint(ip);
intp.x = ir.IntPoint(ip).x;
intp.y = ir.IntPoint(ip).y;
intp.z = ir.IntPoint(ip).z;
if (dim > 1)
{
Weights(ip, 0) = ir.IntPoint(ip).weight;
}
else
{
Weights(2 * ip, 0) = ir.IntPoint(ip).x;
Weights(2 * ip + 1, 0) = ir.IntPoint(ip).weight;
}
}
for (int elem = 1; elem < mesh->GetNE(); elem++)
{
mesh->GetElementTransformation(elem, &Tr);
MFIRs.GetVolumeIntegrationRule(Tr, ir);
for (int ip = 0; ip < GetNPoints(); ip++)
{
if (dim > 1)
{
Weights(ip, elem) = ir.IntPoint(ip).weight;
}
else
{
Weights(2 * ip, elem) = ir.IntPoint(ip).x;
Weights(2 * ip + 1, elem) = ir.IntPoint(ip).weight;
}
}
}
}
/// @brief Set the weights for the given element
void SetElement(int Element)
{
if (dim == 1)
for (int ip = 0; ip < GetNPoints(); ip++)
{
IntegrationPoint &intp = IntPoint(ip);
intp.x = Weights(2 * ip, Element);
intp.weight = Weights(2 * ip + 1, Element);
}
else
for (int ip = 0; ip < GetNPoints(); ip++)
{
IntegrationPoint &intp = IntPoint(ip);
intp.weight = Weights(ip, Element);
}
}
/// @brief Destructor of CIntegrationRule
~CIntegrationRule() {}
};
/**
@brief Class for surface linearform integrator
Integrator to demonstrate the use of the surface integration rule on an
implicit surface defined by a level-set.
*/
class SurfaceLFIntegrator : public LinearFormIntegrator
{
protected:
/// @brief vector to evaluate the basis functions
Vector shape;
/// @brief surface integration rule
SIntegrationRule* SIntRule;
/// @brief coefficient representing the level-set defining the interface
Coefficient &LevelSet;
/// @brief coefficient representing the integrand
Coefficient &Q;
public:
/**
@brief Constructor for the surface linear form integrator
Constructor for the surface linear form integrator to demonstrate the use
of the surface integration rule by means of moment-fitting.
@param [in] q coefficient representing the inegrand
@param [in] levelset level-set defining the implicit interfac
@param [in] ir surface integrtion rule to be used
*/
SurfaceLFIntegrator(Coefficient &q, Coefficient &levelset,
SIntegrationRule* ir)
: LinearFormIntegrator(), SIntRule(ir), LevelSet(levelset), Q(q) { }
/**
@brief Assembly of the element vector
Assemble the element vector of for the right hand side on the element given
by the FiniteElement and ElementTransformation.
@param [in] el finite Element the vector belongs to
@param [in] Tr transformation of finite element
@param [out] elvect vector containing the
*/
virtual void AssembleRHSElementVect(const FiniteElement &el,
ElementTransformation &Tr,
Vector &elvect) override
{
int dof = el.GetDof();
shape.SetSize(dof);
elvect.SetSize(dof);
elvect = 0.;
// Update the surface integration rule for the current element
SIntRule->SetElementinclSurfaceWeight(Tr.ElementNo);
for (int ip = 0; ip < SIntRule->GetNPoints(); ip++)
{
Tr.SetIntPoint((&(SIntRule->IntPoint(ip))));
double val = Tr.Weight() * Q.Eval(Tr, SIntRule->IntPoint(ip));
el.CalcShape(SIntRule->IntPoint(ip), shape);
add(elvect, SIntRule->IntPoint(ip).weight * val, shape, elvect);
}
}
};
/**
@brief Class for subdomain linearform integrator
Integrator to demonstrate the use of the subdomain integration rule within
an area defined by an implicit surface defined by a level-set.
*/
class SubdomainLFIntegrator : public LinearFormIntegrator
{
protected:
/// @brief vector to evaluate the basis functions
Vector shape;
/// @brief surface integration rule
CIntegrationRule* CIntRule;
/// @brief coefficient representing the level-set defining the interface
Coefficient &LevelSet;
/// @brief coefficient representing the integrand
Coefficient &Q;
public:
/**
@brief Constructor for the volumetric subdomain linear form integrator
Constructor for the subdomain linear form integrator to demonstrate the use
of the volumetric subdomain integration rule by means of moment-fitting.
@param [in] q coefficient representing the inegrand
@param [in] levelset level-set defining the implicit interfac
@param [in] ir subdomain integrtion rule to be used
*/
SubdomainLFIntegrator(Coefficient &q, Coefficient &levelset,
CIntegrationRule* ir)
: LinearFormIntegrator(), CIntRule(ir), LevelSet(levelset), Q(q) { }
/**
@brief Assembly of the element vector
Assemble the element vector of for the right hand side on the element given
by the FiniteElement and ElementTransformation.
@param [in] el finite Element the vector belongs to
@param [in] Tr transformation of finite element
@param [out] elvect vector containing the
*/
virtual void AssembleRHSElementVect(const FiniteElement &el,
ElementTransformation &Tr,
Vector &elvect) override
{
int dof = el.GetDof();
shape.SetSize(dof);
elvect.SetSize(dof);
elvect = 0.;
// Update the subdomain integration rule
CIntRule->SetElement(Tr.ElementNo);
for (int ip = 0; ip < CIntRule->GetNPoints(); ip++)
{
Tr.SetIntPoint((&(CIntRule->IntPoint(ip))));
double val = Tr.Weight()
* Q.Eval(Tr, CIntRule->IntPoint(ip));
el.CalcPhysShape(Tr, shape);
add(elvect, CIntRule->IntPoint(ip).weight * val, shape, elvect);
}
}
};
#endif // MFEM_USE_LAPACK
int main(int argc, char *argv[])
{
#ifndef MFEM_USE_LAPACK
cout << "MFEM must be build with LAPACK for this example." << endl;
return EXIT_FAILURE;
#else
// 1. Parse he command-line options.
int ref_levels = 3;
int order = 2;
const char *inttype = "surface2d";
bool visualization = true;
itype = IntegrationType::Surface2D;
OptionsParser args(argc, argv);
args.AddOption(&order, "-o", "--order", "Order of quadrature rule");
args.AddOption(&ref_levels, "-r", "--refine", "Number of meh refinements");
args.AddOption(&inttype, "-i", "--integrationtype",
"IntegrationType to demonstrate");
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
"--no-visualization",
"Enable or disable GLVis visualization.");
args.ParseCheck();
if (strcmp(inttype, "volumetric1d") == 0
|| strcmp(inttype, "Volumetric1D") == 0)
{
itype = IntegrationType::Volumetric1D;
}
else if (strcmp(inttype, "surface2d") == 0
|| strcmp(inttype, "Surface2D") == 0)
{
itype = IntegrationType::Surface2D;
}
else if (strcmp(inttype, "volumetric2d") == 0
|| strcmp(inttype, "Volumetric2D") == 0)
{
itype = IntegrationType::Volumetric2D;
}
else if (strcmp(inttype, "surface3d") == 0
|| strcmp(inttype, "Surface3d") == 0)
{
itype = IntegrationType::Surface3D;
}
else if (strcmp(inttype, "volumetric3d") == 0
|| strcmp(inttype, "Volumetric3d") == 0)
{
itype = IntegrationType::Volumetric3D;
}
// 2. Construct and refine the mesh.
Mesh *mesh;
if (itype == IntegrationType::Volumetric1D)
{
mesh = new Mesh("../data/inline-segment.mesh");
}
if (itype == IntegrationType::Surface2D
|| itype == IntegrationType::Volumetric2D)
{
mesh = new Mesh(2, 4, 1, 0, 2);
mesh->AddVertex(-1.6,-1.6);
mesh->AddVertex(1.6,-1.6);
mesh->AddVertex(1.6,1.6);
mesh->AddVertex(-1.6,1.6);
mesh->AddQuad(0,1,2,3);
mesh->FinalizeQuadMesh(1, 0, 1);
}
else if (itype == IntegrationType::Surface3D
|| itype == IntegrationType::Volumetric3D)
{
mesh = new Mesh(3, 8, 1, 0, 3);
mesh->AddVertex(-1.6,-1.6,-1.6);
mesh->AddVertex(1.6,-1.6,-1.6);
mesh->AddVertex(1.6,1.6,-1.6);
mesh->AddVertex(-1.6,1.6,-1.6);
mesh->AddVertex(-1.6,-1.6,1.6);
mesh->AddVertex(1.6,-1.6,1.6);
mesh->AddVertex(1.6,1.6,1.6);
mesh->AddVertex(-1.6,1.6,1.6);
mesh->AddHex(0,1,2,3,4,5,6,7);
mesh->FinalizeHexMesh(1, 0, 1);
}
for (int lev = 0; lev < ref_levels; lev++)
{
mesh->UniformRefinement();
}
// 3. Define the necessary finite element space on the mesh.
H1_FECollection fe_coll(1, mesh->Dimension());
FiniteElementSpace *fespace = new FiniteElementSpace(mesh, &fe_coll);
// 4. Construction Coefficients for the level set and the integrand.
FunctionCoefficient levelset(lvlset);
FunctionCoefficient u(integrand);
// 5. Define the necessary Integration rules on element 0.
IsoparametricTransformation Tr;
mesh->GetElementTransformation(0, &Tr);
SIntegrationRule* sir = new SIntegrationRule(order, levelset, 2, mesh);
CIntegrationRule* cir = NULL;
if (itype == IntegrationType::Volumetric1D
|| itype == IntegrationType::Volumetric2D
|| itype == IntegrationType::Volumetric3D)
{
cir = new CIntegrationRule(order, levelset, 2, mesh);
}
// 6. Define and assemble the linear forms on the finite element space.
LinearForm surface(fespace);
LinearForm volume(fespace);
surface.AddDomainIntegrator(new SurfaceLFIntegrator(u, levelset, sir));
surface.Assemble();
if (itype == IntegrationType::Volumetric1D
|| itype == IntegrationType::Volumetric2D
|| itype == IntegrationType::Volumetric3D)
{
volume.AddDomainIntegrator(new SubdomainLFIntegrator(u, levelset, cir));
volume.Assemble();
}
// 7. Print information, computed values and errors to the console.
int qorder = 0;
int nbasis = 2 * (order + 1) + (int)(order * (order + 1) / 2);
IntegrationRules irs(0, Quadrature1D::GaussLegendre);
IntegrationRule ir = irs.Get(Geometry::SQUARE, qorder);
for (; ir.GetNPoints() <= nbasis; qorder++)
{
ir = irs.Get(Geometry::SQUARE, qorder);
}
cout << "============================================" << endl;
cout << "Mesh size dx: ";
if (itype != IntegrationType::Volumetric1D)
{
cout << 3.2 / pow(2., (double)ref_levels) << endl;
}
else
{
cout << .25 / pow(2., (double)ref_levels) << endl;
}
if (itype == IntegrationType::Surface2D
|| itype == IntegrationType::Volumetric2D)
{
cout << "Number of div free basis functions: " << nbasis << endl;
cout << "Number of quadrature points: " << ir.GetNPoints() << endl;
}
cout << scientific << setprecision(2);
cout << "============================================" << endl;
cout << "Computed value of surface integral: " << surface.Sum() << endl;
cout << "True value of surface integral: " << Surface() << endl;
cout << "Absolut Error (Surface): ";
cout << abs(surface.Sum() - Surface()) << endl;
cout << "Relative Error (Surface): ";
cout << abs(surface.Sum() - Surface()) / Surface() << endl;
if (itype == IntegrationType::Volumetric1D
|| itype == IntegrationType::Volumetric2D
|| itype == IntegrationType::Volumetric3D)
{
cout << "--------------------------------------------" << endl;
cout << "Computed value of volume integral: " << volume.Sum() << endl;
cout << "True value of volume integral: " << Volume() << endl;
cout << "Absolut Error (Volume): ";
cout << abs(volume.Sum() - Volume()) << endl;
cout << "Relative Error (Volume): ";
cout << abs(volume.Sum() - Volume()) / Volume() << endl;
}
cout << "============================================" << endl;
// 8. Plot the level-set function on a high order finite element space.
if (visualization)
{
H1_FECollection fe_coll2(5, mesh->Dimension());
FiniteElementSpace fespace2(mesh, &fe_coll2);
FunctionCoefficient levelset_coeff(levelset);
GridFunction lgf(&fespace2);
lgf.ProjectCoefficient(levelset_coeff);
char vishost[] = "localhost";
int visport = 19916;
socketstream sol_sock(vishost, visport);
sol_sock.precision(8);
sol_sock << "solution\n" << *mesh << lgf << flush;
sol_sock << "keys pppppppppppppppppppppppppppcmmlRj\n";
sol_sock << "levellines " << 0. << " " << 0. << " " << 1 << "\n" << flush;
}
delete sir;
delete cir;
delete fespace;
delete mesh;
return EXIT_SUCCESS;
#endif //MFEM_USE_LAPACK
}
+23 -23
View File
@@ -3,28 +3,28 @@
//
// Compile with: make ex1
//
// Sample runs: ex1 -m ../data/square-disc.mesh
// ex1 -m ../data/star.mesh
// ex1 -m ../data/star-mixed.mesh
// ex1 -m ../data/escher.mesh
// ex1 -m ../data/fichera.mesh
// ex1 -m ../data/fichera-mixed.mesh
// ex1 -m ../data/toroid-wedge.mesh
// ex1 -m ../data/square-disc-p2.vtk -o 2
// ex1 -m ../data/square-disc-p3.mesh -o 3
// ex1 -m ../data/square-disc-nurbs.mesh -o -1
// ex1 -m ../data/star-mixed-p2.mesh -o 2
// ex1 -m ../data/disc-nurbs.mesh -o -1
// ex1 -m ../data/pipe-nurbs.mesh -o -1
// ex1 -m ../data/fichera-mixed-p2.mesh -o 2
// ex1 -m ../data/star-surf.mesh
// ex1 -m ../data/square-disc-surf.mesh
// ex1 -m ../data/inline-segment.mesh
// ex1 -m ../data/amr-quad.mesh
// ex1 -m ../data/amr-hex.mesh
// ex1 -m ../data/fichera-amr.mesh
// ex1 -m ../data/mobius-strip.mesh
// ex1 -m ../data/mobius-strip.mesh -o -1 -sc
// Sample runs: ex1 -m ../../data/square-disc.mesh
// ex1 -m ../../data/star.mesh
// ex1 -m ../../data/star-mixed.mesh
// ex1 -m ../../data/escher.mesh
// ex1 -m ../../data/fichera.mesh
// ex1 -m ../../data/fichera-mixed.mesh
// ex1 -m ../../data/toroid-wedge.mesh
// ex1 -m ../../data/square-disc-p2.vtk -o 2
// ex1 -m ../../data/square-disc-p3.mesh -o 3
// ex1 -m ../../data/square-disc-nurbs.mesh -o -1
// ex1 -m ../../data/star-mixed-p2.mesh -o 2
// ex1 -m ../../data/disc-nurbs.mesh -o -1
// ex1 -m ../../data/pipe-nurbs.mesh -o -1
// ex1 -m ../../data/fichera-mixed-p2.mesh -o 2
// ex1 -m ../../data/star-surf.mesh
// ex1 -m ../../data/square-disc-surf.mesh
// ex1 -m ../../data/inline-segment.mesh
// ex1 -m ../../data/amr-quad.mesh
// ex1 -m ../../data/amr-hex.mesh
// ex1 -m ../../data/fichera-amr.mesh
// ex1 -m ../../data/mobius-strip.mesh
// ex1 -m ../../data/mobius-strip.mesh -o -1 -sc
//
// Device sample runs:
// ex1 -pa -d cuda
@@ -32,7 +32,7 @@
// ex1 -pa -d occa-cuda
// ex1 -pa -d raja-omp
// ex1 -pa -d occa-omp
// ex1 -m ../data/beam-hex.mesh -pa -d cuda
// ex1 -m ../../data/beam-hex.mesh -pa -d cuda
//
// Description: This example code demonstrates the use of MFEM to define a
// simple finite element discretization of the Laplace problem
+10 -6
View File
@@ -22,15 +22,19 @@ MFEM_LIB_FILE = mfem_is_not_built
-include $(CONFIG_MK)
SEQ_EXAMPLES = ex0 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex14 ex15 ex16 \
ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 ex28 ex29 ex30 \
ex31 ex33 ex34 ex36 ex37
ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 ex28 ex29 ex30 \
ex31 ex33 ex34 ex36 ex37
PAR_EXAMPLES = ex0p ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex8p ex9p ex10p ex11p \
ex12p ex13p ex14p ex15p ex16p ex17p ex18p ex19p ex20p ex21p ex22p ex24p \
ex25p ex26p ex27p ex28p ex29p ex30p ex31p ex32p ex33p ex34p ex35p ex36p \
ex37p
ex12p ex13p ex14p ex15p ex16p ex17p ex18p ex19p ex20p ex21p ex22p ex24p \
ex25p ex26p ex27p ex28p ex29p ex30p ex31p ex32p ex33p ex34p ex35p ex36p \
ex37p
SEQ_DEVICE_EXAMPLES = ex1 ex3 ex4 ex5 ex6 ex9 ex22 ex24 ex25 ex26 ex34
PAR_DEVICE_EXAMPLES = ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex9p ex13p ex22p \
ex24p ex25p ex26p ex34p ex35p
ex24p ex25p ex26p ex34p ex35p
ifeq ($(MFEM_USE_LAPACK),YES)
SEQ_EXAMPLES += ex38
endif
ifeq ($(MFEM_USE_MPI),NO)
EXAMPLES = $(SEQ_EXAMPLES)
+3 -2
View File
@@ -273,12 +273,13 @@ int main(int argc, char *argv[])
#ifdef MFEM_USE_STRUMPACK
if (sp_solver)
{
STRUMPACKSolver * strumpack = new STRUMPACKSolver(argc, argv, MPI_COMM_WORLD);
STRUMPACKSolver * strumpack = new STRUMPACKSolver(MPI_COMM_WORLD, argc, argv);
strumpack->SetPrintFactorStatistics(true);
strumpack->SetPrintSolveStatistics(false);
strumpack->SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
strumpack->SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
strumpack->DisableMatching();
strumpack->SetMatching(strumpack::MatchingJob::NONE);
strumpack->SetCompression(strumpack::CompressionType::NONE);
strumpack->SetOperator(*Arow);
strumpack->SetFromCommandLine();
precond = strumpack;
+2 -3
View File
@@ -77,6 +77,7 @@ set(SRCS
gridfunc.cpp
hybridization.cpp
intrules.cpp
intrules_cut.cpp
ceed/interface/basis.cpp
ceed/interface/restriction.cpp
ceed/interface/operator.cpp
@@ -96,9 +97,6 @@ set(SRCS
lor/lor_ads.cpp
lor/lor_ams.cpp
lor/lor_batched.cpp
lor/lor_h1.cpp
lor/lor_nd.cpp
lor/lor_rt.cpp
multigrid.cpp
nonlinearform.cpp
nonlinearform_ext.cpp
@@ -186,6 +184,7 @@ set(HDRS
gridfunc.hpp
hybridization.hpp
intrules.hpp
intrules_cut.hpp
ceed/interface/basis.hpp
ceed/interface/integrator.hpp
ceed/interface/interface.hpp
+203 -84
View File
@@ -101,6 +101,7 @@ BilinearForm::BilinearForm (FiniteElementSpace * f, BilinearForm * bf, int ps)
// Copy the pointers to the integrators
domain_integs = bf->domain_integs;
domain_integs_marker = bf->domain_integs_marker;
boundary_integs = bf->boundary_integs;
boundary_integs_marker = bf->boundary_integs_marker;
@@ -393,8 +394,8 @@ void BilinearForm::Assemble(int skip_zeros)
}
ElementTransformation *eltrans;
DofTransformation * doftrans;
Mesh *mesh = fes -> GetMesh();
DofTransformation *doftrans;
Mesh *mesh = fes->GetMesh();
DenseMatrix elmat, *elmat_p;
if (mat == NULL)
@@ -431,7 +432,7 @@ void BilinearForm::Assemble(int skip_zeros)
}
// Element-wise integration
for (int i = 0; i < fes -> GetNE(); i++)
for (int i = 0; i < fes->GetNE(); i++)
{
doftrans = fes->GetElementVDofs(i, vdofs);
if (element_matrices)
@@ -441,6 +442,7 @@ void BilinearForm::Assemble(int skip_zeros)
else
{
const int elem_attr = fes->GetMesh()->GetAttribute(i);
eltrans = fes->GetElementTransformation(i);
elmat.SetSize(0);
for (int k = 0; k < domain_integs.Size(); k++)
{
@@ -448,9 +450,8 @@ void BilinearForm::Assemble(int skip_zeros)
(*(domain_integs_marker[k]))[elem_attr-1] == 1)
&& !domain_integs[k]->Patchwise())
{
const FiniteElement &fe = *fes->GetFE(i);
eltrans = fes->GetElementTransformation(i);
domain_integs[k]->AssembleElementMatrix(fe, *eltrans, elemmat);
domain_integs[k]->AssembleElementMatrix(*fes->GetFE(i),
*eltrans, elemmat);
if (elmat.Size() == 0)
{
elmat = elemmat;
@@ -492,7 +493,7 @@ void BilinearForm::Assemble(int skip_zeros)
// Patch-wise integration
if (fes->GetNURBSext())
{
for (int p=0; p<mesh->NURBSext->GetNP(); ++p)
for (int p = 0; p < mesh->NURBSext->GetNP(); ++p)
{
bool vdofsSet = false;
for (int k = 0; k < domain_integs.Size(); k++)
@@ -505,15 +506,15 @@ void BilinearForm::Assemble(int skip_zeros)
vdofsSet = true;
}
SparseMatrix* spmat = nullptr;
SparseMatrix *spmat = nullptr;
domain_integs[k]->AssemblePatchMatrix(p, *fes, spmat);
Array<int> cols;
Vector srow;
for (int r=0; r<spmat->Height(); ++r)
for (int r = 0; r < spmat->Height(); ++r)
{
spmat->GetRow(r, cols, srow);
for (int i=0; i<cols.Size(); ++i)
for (int i = 0; i < cols.Size(); ++i)
{
cols[i] = vdofs[cols[i]];
}
@@ -550,14 +551,14 @@ void BilinearForm::Assemble(int skip_zeros)
}
}
for (int i = 0; i < fes -> GetNBE(); i++)
for (int i = 0; i < fes->GetNBE(); i++)
{
const int bdr_attr = mesh->GetBdrAttribute(i);
if (bdr_attr_marker[bdr_attr-1] == 0) { continue; }
const FiniteElement &be = *fes->GetBE(i);
doftrans = fes -> GetBdrElementVDofs (i, vdofs);
eltrans = fes -> GetBdrElementTransformation (i);
doftrans = fes->GetBdrElementVDofs(i, vdofs);
eltrans = fes->GetBdrElementTransformation(i);
int k = 0;
for (; k < boundary_integs.Size(); k++)
{
@@ -604,11 +605,11 @@ void BilinearForm::Assemble(int skip_zeros)
int nfaces = mesh->GetNumFaces();
for (int i = 0; i < nfaces; i++)
{
tr = mesh -> GetInteriorFaceTransformations (i);
tr = mesh->GetInteriorFaceTransformations(i);
if (tr != NULL)
{
fes -> GetElementVDofs (tr -> Elem1No, vdofs);
fes -> GetElementVDofs (tr -> Elem2No, vdofs2);
fes->GetElementVDofs(tr->Elem1No, vdofs);
fes->GetElementVDofs(tr->Elem2No, vdofs2);
vdofs.Append (vdofs2);
for (int k = 0; k < interior_face_integs.Size(); k++)
{
@@ -616,7 +617,7 @@ void BilinearForm::Assemble(int skip_zeros)
AssembleFaceMatrix(*fes->GetFE(tr->Elem1No),
*fes->GetFE(tr->Elem2No),
*tr, elemmat);
mat -> AddSubMatrix (vdofs, vdofs, elemmat, skip_zeros);
mat->AddSubMatrix(vdofs, vdofs, elemmat, skip_zeros);
}
}
}
@@ -648,16 +649,16 @@ void BilinearForm::Assemble(int skip_zeros)
}
}
for (int i = 0; i < fes -> GetNBE(); i++)
for (int i = 0; i < fes->GetNBE(); i++)
{
const int bdr_attr = mesh->GetBdrAttribute(i);
if (bdr_attr_marker[bdr_attr-1] == 0) { continue; }
tr = mesh -> GetBdrFaceTransformations (i);
tr = mesh->GetBdrFaceTransformations(i);
if (tr != NULL)
{
fes -> GetElementVDofs (tr -> Elem1No, vdofs);
fe1 = fes -> GetFE (tr -> Elem1No);
fes->GetElementVDofs(tr->Elem1No, vdofs);
fe1 = fes->GetFE(tr->Elem1No);
// The fe2 object is really a dummy and not used on the boundaries,
// but we can't dereference a NULL pointer, and we don't want to
// actually make a fake element.
@@ -668,9 +669,9 @@ void BilinearForm::Assemble(int skip_zeros)
(*boundary_face_integs_marker[k])[bdr_attr-1] == 0)
{ continue; }
boundary_face_integs[k] -> AssembleFaceMatrix (*fe1, *fe2, *tr,
elemmat);
mat -> AddSubMatrix (vdofs, vdofs, elemmat, skip_zeros);
boundary_face_integs[k]->AssembleFaceMatrix(*fe1, *fe2, *tr,
elemmat);
mat->AddSubMatrix(vdofs, vdofs, elemmat, skip_zeros);
}
}
}
@@ -1204,6 +1205,7 @@ MixedBilinearForm::MixedBilinearForm (FiniteElementSpace *tr_fes,
mat = NULL;
mat_e = NULL;
extern_bfs = 0;
element_matrices = NULL;
assembly = AssemblyLevel::LEGACY;
ext = NULL;
}
@@ -1218,15 +1220,19 @@ MixedBilinearForm::MixedBilinearForm (FiniteElementSpace *tr_fes,
mat = NULL;
mat_e = NULL;
extern_bfs = 1;
element_matrices = NULL;
ext = NULL;
// Copy the pointers to the integrators
domain_integs = mbf->domain_integs;
boundary_integs = mbf->boundary_integs;
trace_face_integs = mbf->trace_face_integs;
boundary_trace_face_integs = mbf->boundary_trace_face_integs;
domain_integs_marker = mbf->domain_integs_marker;
boundary_integs = mbf->boundary_integs;
boundary_integs_marker = mbf->boundary_integs_marker;
trace_face_integs = mbf->trace_face_integs;
boundary_trace_face_integs = mbf->boundary_trace_face_integs;
boundary_trace_face_integs_marker = mbf->boundary_trace_face_integs_marker;
assembly = AssemblyLevel::LEGACY;
@@ -1349,6 +1355,14 @@ void MixedBilinearForm::GetBlocks(Array2D<SparseMatrix *> &blocks) const
void MixedBilinearForm::AddDomainIntegrator (BilinearFormIntegrator * bfi)
{
domain_integs.Append (bfi);
domain_integs_marker.Append(NULL); // NULL marker means apply everywhere
}
void MixedBilinearForm::AddDomainIntegrator (BilinearFormIntegrator * bfi,
Array<int> &elem_marker)
{
domain_integs.Append (bfi);
domain_integs_marker.Append(&elem_marker);
}
void MixedBilinearForm::AddBoundaryIntegrator (BilinearFormIntegrator * bfi)
@@ -1383,7 +1397,7 @@ void MixedBilinearForm::AddBdrTraceFaceIntegrator(BilinearFormIntegrator *bfi,
boundary_trace_face_integs_marker.Append(&bdr_marker);
}
void MixedBilinearForm::Assemble (int skip_zeros)
void MixedBilinearForm::Assemble(int skip_zeros)
{
if (ext)
{
@@ -1392,39 +1406,71 @@ void MixedBilinearForm::Assemble (int skip_zeros)
}
ElementTransformation *eltrans;
DofTransformation * dom_dof_trans;
DofTransformation * ran_dof_trans;
DenseMatrix elmat;
DofTransformation *dom_dof_trans;
DofTransformation *ran_dof_trans;
DenseMatrix elmat, *elmat_p;
Mesh *mesh = test_fes -> GetMesh();
Mesh *mesh = test_fes->GetMesh();
if (mat == NULL)
{
mat = new SparseMatrix(height, width);
}
#ifdef MFEM_USE_LEGACY_OPENMP
int free_element_matrices = 0;
if (!element_matrices)
{
ComputeElementMatrices();
free_element_matrices = 1;
}
#endif
if (domain_integs.Size())
{
for (int i = 0; i < test_fes -> GetNE(); i++)
for (int k = 0; k < domain_integs.Size(); k++)
{
dom_dof_trans = trial_fes -> GetElementVDofs (i, trial_vdofs);
ran_dof_trans = test_fes -> GetElementVDofs (i, test_vdofs);
eltrans = test_fes -> GetElementTransformation (i);
if (domain_integs_marker[k] != NULL)
{
MFEM_VERIFY(domain_integs_marker[k]->Size() ==
(mesh->attributes.Size() ? mesh->attributes.Max() : 0),
"invalid element marker for domain integrator #"
<< k << ", counting from zero");
}
}
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
elmat = 0.0;
for (int k = 0; k < domain_integs.Size(); k++)
for (int i = 0; i < test_fes->GetNE(); i++)
{
const int elem_attr = mesh->GetAttribute(i);
dom_dof_trans = trial_fes->GetElementVDofs(i, trial_vdofs);
ran_dof_trans = test_fes->GetElementVDofs(i, test_vdofs);
if (element_matrices)
{
domain_integs[k] -> AssembleElementMatrix2 (*trial_fes -> GetFE(i),
*test_fes -> GetFE(i),
*eltrans, elemmat);
elmat += elemmat;
elmat_p = &(*element_matrices)(i);
}
if (ran_dof_trans || dom_dof_trans)
else
{
TransformDual(ran_dof_trans, dom_dof_trans, elmat);
eltrans = test_fes->GetElementTransformation(i);
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
elmat = 0.0;
for (int k = 0; k < domain_integs.Size(); k++)
{
if (domain_integs_marker[k] == NULL ||
(*(domain_integs_marker[k]))[elem_attr-1] == 1)
{
domain_integs[k]->AssembleElementMatrix2(*trial_fes->GetFE(i),
*test_fes->GetFE(i),
*eltrans, elemmat);
elmat += elemmat;
}
}
if (ran_dof_trans || dom_dof_trans)
{
TransformDual(ran_dof_trans, dom_dof_trans, elmat);
}
elmat_p = &elmat;
}
mat -> AddSubMatrix (test_vdofs, trial_vdofs, elmat, skip_zeros);
mat->AddSubMatrix(test_vdofs, trial_vdofs, *elmat_p, skip_zeros);
}
}
@@ -1451,14 +1497,14 @@ void MixedBilinearForm::Assemble (int skip_zeros)
}
}
for (int i = 0; i < test_fes -> GetNBE(); i++)
for (int i = 0; i < test_fes->GetNBE(); i++)
{
const int bdr_attr = mesh->GetBdrAttribute(i);
if (bdr_attr_marker[bdr_attr-1] == 0) { continue; }
dom_dof_trans = trial_fes -> GetBdrElementVDofs (i, trial_vdofs);
ran_dof_trans = test_fes -> GetBdrElementVDofs (i, test_vdofs);
eltrans = test_fes -> GetBdrElementTransformation (i);
dom_dof_trans = trial_fes->GetBdrElementVDofs(i, trial_vdofs);
ran_dof_trans = test_fes->GetBdrElementVDofs(i, test_vdofs);
eltrans = test_fes->GetBdrElementTransformation(i);
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
elmat = 0.0;
@@ -1467,16 +1513,17 @@ void MixedBilinearForm::Assemble (int skip_zeros)
if (boundary_integs_marker[k] &&
(*boundary_integs_marker[k])[bdr_attr-1] == 0) { continue; }
boundary_integs[k]->AssembleElementMatrix2 (*trial_fes -> GetBE(i),
*test_fes -> GetBE(i),
*eltrans, elemmat);
boundary_integs[k]->AssembleElementMatrix2(*trial_fes->GetBE(i),
*test_fes->GetBE(i),
*eltrans, elemmat);
elmat += elemmat;
}
if (ran_dof_trans || dom_dof_trans)
{
TransformDual(ran_dof_trans, dom_dof_trans, elmat);
}
mat -> AddSubMatrix (test_vdofs, trial_vdofs, elmat, skip_zeros);
elmat_p = &elmat;
mat->AddSubMatrix(test_vdofs, trial_vdofs, *elmat_p, skip_zeros);
}
}
@@ -1574,6 +1621,13 @@ void MixedBilinearForm::Assemble (int skip_zeros)
}
}
}
#ifdef MFEM_USE_LEGACY_OPENMP
if (free_element_matrices)
{
FreeElementMatrices();
}
#endif
}
void MixedBilinearForm::AssembleDiagonal_ADAt(const Vector &D,
@@ -1659,6 +1713,13 @@ void MixedBilinearForm::ConformingAssemble()
void MixedBilinearForm::ComputeElementMatrix(int i, DenseMatrix &elmat)
{
if (element_matrices)
{
elmat.SetSize(element_matrices->SizeI(), element_matrices->SizeJ());
elmat = element_matrices->GetData(i);
return;
}
if (domain_integs.Size())
{
const FiniteElement &trial_fe = *trial_fes->GetFE(i);
@@ -1745,6 +1806,50 @@ void MixedBilinearForm::AssembleBdrElementMatrix(
mat->AddSubMatrix(test_vdofs_, trial_vdofs_, elmat, skip_zeros);
}
void MixedBilinearForm::ComputeElementMatrices()
{
if (element_matrices || domain_integs.Size() == 0 || trial_fes->GetNE() == 0)
{
return;
}
int num_elements = trial_fes->GetNE();
int trial_dofs_per_el = trial_fes->GetFE(0)->GetDof() * trial_fes->GetVDim();
int test_dofs_per_el = test_fes->GetFE(0)->GetDof() * test_fes->GetVDim();
element_matrices = new DenseTensor(test_dofs_per_el, trial_dofs_per_el,
num_elements);
DenseMatrix tmp;
IsoparametricTransformation eltrans;
#ifdef MFEM_USE_LEGACY_OPENMP
#pragma omp parallel for private(tmp,eltrans)
#endif
for (int i = 0; i < num_elements; i++)
{
DenseMatrix elmat(element_matrices->GetData(i),
test_dofs_per_el, trial_dofs_per_el);
const FiniteElement &trial_fe = *trial_fes->GetFE(i);
const FiniteElement &test_fe = *test_fes->GetFE(i);
#ifdef MFEM_DEBUG
if (trial_dofs_per_el != trial_fe.GetDof() * trial_fes->GetVDim())
mfem_error("MixedBilinearForm::ComputeElementMatrices:"
" all elements must have same number of dofs");
#endif
test_fes->GetElementTransformation(i, &eltrans);
domain_integs[0]->AssembleElementMatrix2(trial_fe, test_fe, eltrans,
elmat);
for (int k = 1; k < domain_integs.Size(); k++)
{
// note: some integrators may not be thread-safe
domain_integs[k]->AssembleElementMatrix2(trial_fe, test_fe, eltrans,
tmp);
elmat += tmp;
}
elmat.ClearExternalData();
}
}
void MixedBilinearForm::EliminateTrialDofs (
const Array<int> &bdr_attr_is_ess, const Vector &sol, Vector &rhs )
{
@@ -1941,41 +2046,56 @@ void DiscreteLinearOperator::Assemble(int skip_zeros)
return;
}
Array<int> dom_vdofs, ran_vdofs;
ElementTransformation *T;
ElementTransformation *eltrans;
DofTransformation * dom_dof_trans;
DofTransformation * ran_dof_trans;
const FiniteElement *dom_fe, *ran_fe;
DenseMatrix totelmat, elmat;
DenseMatrix elmat;
Mesh *mesh = test_fes->GetMesh();
if (mat == NULL)
{
mat = new SparseMatrix(height, width);
}
if (domain_integs.Size() > 0)
if (domain_integs.Size())
{
for (int k = 0; k < domain_integs.Size(); k++)
{
if (domain_integs_marker[k] != NULL)
{
MFEM_VERIFY(domain_integs_marker[k]->Size() ==
(mesh->attributes.Size() ? mesh->attributes.Max() : 0),
"invalid element marker for domain integrator #"
<< k << ", counting from zero");
}
}
for (int i = 0; i < test_fes->GetNE(); i++)
{
dom_dof_trans = trial_fes->GetElementVDofs(i, dom_vdofs);
ran_dof_trans = test_fes->GetElementVDofs(i, ran_vdofs);
T = test_fes->GetElementTransformation(i);
dom_fe = trial_fes->GetFE(i);
ran_fe = test_fes->GetFE(i);
const int elem_attr = mesh->GetAttribute(i);
dom_dof_trans = trial_fes->GetElementVDofs(i, trial_vdofs);
ran_dof_trans = test_fes->GetElementVDofs(i, test_vdofs);
eltrans = test_fes->GetElementTransformation(i);
domain_integs[0]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
totelmat);
for (int j = 1; j < domain_integs.Size(); j++)
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
elmat = 0.0;
for (int k = 0; k < domain_integs.Size(); k++)
{
domain_integs[j]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
elmat);
totelmat += elmat;
if (domain_integs_marker[k] == NULL ||
(*(domain_integs_marker[k]))[elem_attr-1] == 1)
{
domain_integs[k]->AssembleElementMatrix2(*trial_fes->GetFE(i),
*test_fes->GetFE(i),
*eltrans, elemmat);
elmat += elemmat;
}
}
if (ran_dof_trans || dom_dof_trans)
{
TransformPrimal(ran_dof_trans, dom_dof_trans, totelmat);
TransformPrimal(ran_dof_trans, dom_dof_trans, elemmat);
}
mat->SetSubMatrix(ran_vdofs, dom_vdofs, totelmat, skip_zeros);
mat->SetSubMatrix(test_vdofs, trial_vdofs, elemmat, skip_zeros);
}
}
@@ -1984,21 +2104,20 @@ void DiscreteLinearOperator::Assemble(int skip_zeros)
const int nfaces = test_fes->GetMesh()->GetNumFaces();
for (int i = 0; i < nfaces; i++)
{
trial_fes->GetFaceVDofs(i, dom_vdofs);
test_fes->GetFaceVDofs(i, ran_vdofs);
T = test_fes->GetMesh()->GetFaceTransformation(i);
dom_fe = trial_fes->GetFaceElement(i);
ran_fe = test_fes->GetFaceElement(i);
trial_fes->GetFaceVDofs(i, trial_vdofs);
test_fes->GetFaceVDofs(i, test_vdofs);
eltrans = test_fes->GetMesh()->GetFaceTransformation(i);
trace_face_integs[0]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
totelmat);
for (int j = 1; j < trace_face_integs.Size(); j++)
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
elmat = 0.0;
for (int k = 0; k < trace_face_integs.Size(); k++)
{
trace_face_integs[j]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
elmat);
totelmat += elmat;
trace_face_integs[k]->AssembleElementMatrix2(*trial_fes->GetFaceElement(i),
*test_fes->GetFaceElement(i),
*eltrans, elemmat);
elmat += elemmat;
}
mat->SetSubMatrix(ran_vdofs, dom_vdofs, totelmat, skip_zeros);
mat->SetSubMatrix(test_vdofs, trial_vdofs, elmat, skip_zeros);
}
}
}
+34 -7
View File
@@ -100,7 +100,7 @@ protected:
/// Includes all by default.
/// 0 - ignore attribute
/// 1 - include attribute
Array<Array<int>*> domain_integs_marker;
Array<Array<int>*> domain_integs_marker; ///< Entries are not owned.
/// Set of Boundary Integrators to be applied.
Array<BilinearFormIntegrator*> boundary_integs;
@@ -722,10 +722,13 @@ protected:
/// Domain integrators.
Array<BilinearFormIntegrator*> domain_integs;
/// Entries are not owned.
Array<Array<int>*> domain_integs_marker;
/// Boundary integrators.
Array<BilinearFormIntegrator*> boundary_integs;
Array<Array<int>*> boundary_integs_marker; ///< Entries are not owned.
/// Entries are not owned.
Array<Array<int>*> boundary_integs_marker;
/// Trace face (skeleton) integrators.
Array<BilinearFormIntegrator*> trace_face_integs;
@@ -736,6 +739,7 @@ protected:
Array<Array<int>*> boundary_trace_face_integs_marker;
DenseMatrix elemmat;
DenseTensor *element_matrices; ///< Owned.
Array<int> trial_vdofs, test_vdofs;
private:
@@ -805,12 +809,16 @@ public:
/// Adds a domain integrator. Assumes ownership of @a bfi.
void AddDomainIntegrator(BilinearFormIntegrator *bfi);
/// Adds a domain integrator. Assumes ownership of @a bfi.
void AddDomainIntegrator(BilinearFormIntegrator *bfi,
Array<int> &elem_marker);
/// Adds a boundary integrator. Assumes ownership of @a bfi.
void AddBoundaryIntegrator(BilinearFormIntegrator *bfi);
/// Adds a boundary integrator. Assumes ownership of @a bfi.
void AddBoundaryIntegrator (BilinearFormIntegrator * bfi,
Array<int> &bdr_marker);
void AddBoundaryIntegrator(BilinearFormIntegrator * bfi,
Array<int> &bdr_marker);
/** @brief Add a trace face integrator. Assumes ownership of @a bfi.
@@ -820,14 +828,18 @@ public:
void AddTraceFaceIntegrator(BilinearFormIntegrator *bfi);
/// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
void AddBdrTraceFaceIntegrator (BilinearFormIntegrator * bfi);
void AddBdrTraceFaceIntegrator(BilinearFormIntegrator * bfi);
/// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
void AddBdrTraceFaceIntegrator (BilinearFormIntegrator * bfi,
Array<int> &bdr_marker);
void AddBdrTraceFaceIntegrator(BilinearFormIntegrator * bfi,
Array<int> &bdr_marker);
/// Access all integrators added with AddDomainIntegrator().
Array<BilinearFormIntegrator*> *GetDBFI() { return &domain_integs; }
/** @brief Access all domain markers added with AddDomainIntegrator().
If no marker was specified when the integrator was added, the
corresponding pointer (to Array<int>) will be NULL. */
Array<Array<int>*> *GetDBFI_Marker() { return &domain_integs_marker; }
/// Access all integrators added with AddBoundaryIntegrator().
Array<BilinearFormIntegrator*> *GetBBFI() { return &boundary_integs; }
@@ -884,7 +896,18 @@ public:
MixedBilinearForm becomes an operator on the conforming FE spaces. */
void ConformingAssemble();
/// Compute and store internally all element matrices.
void ComputeElementMatrices();
/// Free the memory used by the element matrices.
void FreeElementMatrices()
{ delete element_matrices; element_matrices = NULL; }
/// Compute the element matrix of the given element
/** The element matrix is computed by calling the domain integrators
or the one stored internally by a prior call of ComputeElementMatrices()
is returned when available.
*/
void ComputeElementMatrix(int i, DenseMatrix &elmat);
/// Compute the boundary element matrix of the given boundary element
@@ -1065,6 +1088,9 @@ public:
/// Adds a domain interpolator. Assumes ownership of @a di.
void AddDomainInterpolator(DiscreteInterpolator *di)
{ AddDomainIntegrator(di); }
void AddDomainInterpolator(DiscreteInterpolator *di,
Array<int> &elem_marker)
{ AddDomainIntegrator(di, elem_marker); }
/// Adds a trace face interpolator. Assumes ownership of @a di.
void AddTraceFaceInterpolator(DiscreteInterpolator *di)
@@ -1072,6 +1098,7 @@ public:
/// Access all interpolators added with AddDomainInterpolator().
Array<BilinearFormIntegrator*> *GetDI() { return &domain_integs; }
Array<Array<int>*> *GetDI_Marker() { return &domain_integs_marker; }
/// Set the desired assembly level. The default is AssemblyLevel::FULL.
/** This method must be called before assembly. */
+1 -1
View File
@@ -303,7 +303,7 @@ void PABilinearFormExtension::SetupRestrictionOperators(const L2FaceValues m)
std::unordered_map<int,int> f_to_be;
for (int i = 0; i < mesh.GetNBE(); ++i)
{
const int f = mesh.GetBdrElementEdgeIndex(i);
const int f = mesh.GetBdrElementFaceIndex(i);
f_to_be[f] = i;
}
const int nf_bdr = trial_fes->GetNFbyType(FaceType::Boundary);
+4 -3
View File
@@ -1340,10 +1340,11 @@ void MassIntegrator::AssembleElementMatrix2(
for (int i = 0; i < ir->GetNPoints(); i++)
{
const IntegrationPoint &ip = ir->IntPoint(i);
trial_fe.CalcShape(ip, shape);
test_fe.CalcShape(ip, te_shape);
Trans.SetIntPoint (&ip);
trial_fe.CalcPhysShape(Trans, shape);
test_fe.CalcPhysShape(Trans, te_shape);
w = Trans.Weight() * ip.weight;
if (Q)
{
+169 -172
View File
@@ -14,175 +14,166 @@
namespace mfem
{
void DofTransformation::TransformPrimal(double *v) const
{
MFEM_ASSERT(dof_trans_,
"DofTransformation has no local transformation, call "
"SetDofTransformation first!");
int size = dof_trans_->Size();
if (vdim_ == 1 || (Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
dof_trans_->TransformPrimal(Fo_, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
dof_trans_->TransformPrimal(Fo_, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void DofTransformation::InvTransformPrimal(double *v) const
{
MFEM_ASSERT(dof_trans_,
"DofTransformation has no local transformation, call "
"SetDofTransformation first!");
int size = dof_trans_->Height();
if (vdim_ == 1 || (Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
dof_trans_->InvTransformPrimal(Fo_, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
dof_trans_->InvTransformPrimal(Fo_, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void DofTransformation::TransformDual(double *v) const
{
MFEM_ASSERT(dof_trans_,
"DofTransformation has no local transformation, call "
"SetDofTransformation first!");
int size = dof_trans_->Size();
if (vdim_ == 1 || (Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
dof_trans_->TransformDual(Fo_, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
dof_trans_->TransformDual(Fo_, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void DofTransformation::InvTransformDual(double *v) const
{
MFEM_ASSERT(dof_trans_,
"DofTransformation has no local transformation, call "
"SetDofTransformation first!");
int size = dof_trans_->Size();
if (vdim_ == 1 || (Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
dof_trans_->InvTransformDual(Fo_, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
dof_trans_->InvTransformDual(Fo_, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void TransformPrimal(const DofTransformation *ran_dof_trans,
const DofTransformation *dom_dof_trans,
DenseMatrix &elmat)
{
if (ran_dof_trans && dom_dof_trans)
{
ran_dof_trans->TransformPrimalCols(elmat);
dom_dof_trans->TransformDualRows(elmat);
}
else if (ran_dof_trans)
// No action if both transformations are NULL
if (ran_dof_trans)
{
ran_dof_trans->TransformPrimalCols(elmat);
}
else if (dom_dof_trans)
if (dom_dof_trans)
{
dom_dof_trans->TransformDualRows(elmat);
}
else
{
// If both transformations are NULL this function should not be called
}
}
void TransformDual(const DofTransformation *ran_dof_trans,
const DofTransformation *dom_dof_trans,
DenseMatrix &elmat)
{
if (ran_dof_trans && dom_dof_trans)
{
ran_dof_trans->TransformDualCols(elmat);
dom_dof_trans->TransformDualRows(elmat);
}
else if (ran_dof_trans)
// No action if both transformations are NULL
if (ran_dof_trans)
{
ran_dof_trans->TransformDualCols(elmat);
}
else if (dom_dof_trans)
if (dom_dof_trans)
{
dom_dof_trans->TransformDualRows(elmat);
}
else
{
// If both transformations are NULL this function should not be called
}
}
void StatelessVDofTransformation::TransformPrimal(const Array<int> & face_ori,
double *v) const
{
int size = sdoftrans_->Size();
if ((Ordering::Type)ordering_ == Ordering::byNODES || vdim_ == 1)
{
for (int i=0; i<vdim_; i++)
{
sdoftrans_->TransformPrimal(face_ori, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
sdoftrans_->TransformPrimal(face_ori, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void StatelessVDofTransformation::InvTransformPrimal(
const Array<int> & face_ori,
double *v) const
{
int size = sdoftrans_->Height();
if ((Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
sdoftrans_->InvTransformPrimal(face_ori, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
sdoftrans_->InvTransformPrimal(face_ori, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void StatelessVDofTransformation::TransformDual(const Array<int> & face_ori,
double *v) const
{
int size = sdoftrans_->Size();
if ((Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
sdoftrans_->TransformDual(face_ori, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
sdoftrans_->TransformDual(face_ori, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
void StatelessVDofTransformation::InvTransformDual(const Array<int> & face_ori,
double *v) const
{
int size = sdoftrans_->Size();
if ((Ordering::Type)ordering_ == Ordering::byNODES)
{
for (int i=0; i<vdim_; i++)
{
sdoftrans_->InvTransformDual(face_ori, &v[i*size]);
}
}
else
{
Vector vec(size);
for (int i=0; i<vdim_; i++)
{
for (int j=0; j<size; j++)
{
vec(j) = v[j*vdim_+i];
}
sdoftrans_->InvTransformDual(face_ori, vec);
for (int j=0; j<size; j++)
{
v[j*vdim_+i] = vec(j);
}
}
}
}
// ordering (i0j0, i1j0, i0j1, i1j1), each row is a column major matrix
const double ND_StatelessDofTransformation::T_data[24] =
const double ND_DofTransformation::T_data[24] =
{
1.0, 0.0, 0.0, 1.0,
-1.0, -1.0, 0.0, 1.0,
@@ -192,11 +183,11 @@ const double ND_StatelessDofTransformation::T_data[24] =
0.0, 1.0, 1.0, 0.0
};
const DenseTensor ND_StatelessDofTransformation
::T(const_cast<double*>(ND_StatelessDofTransformation::T_data), 2, 2, 6);
const DenseTensor ND_DofTransformation
::T(const_cast<double *>(ND_DofTransformation::T_data), 2, 2, 6);
// ordering (i0j0, i1j0, i0j1, i1j1), each row is a column major matrix
const double ND_StatelessDofTransformation::TInv_data[24] =
const double ND_DofTransformation::TInv_data[24] =
{
1.0, 0.0, 0.0, 1.0,
-1.0, -1.0, 0.0, 1.0,
@@ -206,12 +197,11 @@ const double ND_StatelessDofTransformation::TInv_data[24] =
0.0, 1.0, 1.0, 0.0
};
const DenseTensor ND_StatelessDofTransformation
::TInv(const_cast<double*>(TInv_data), 2, 2, 6);
const DenseTensor ND_DofTransformation
::TInv(const_cast<double *>(TInv_data), 2, 2, 6);
ND_StatelessDofTransformation::ND_StatelessDofTransformation(int size, int p,
int num_edges,
int num_tri_faces)
ND_DofTransformation::ND_DofTransformation(int size, int p, int num_edges,
int num_tri_faces)
: StatelessDofTransformation(size)
, order(p)
, nedofs(p)
@@ -221,18 +211,19 @@ ND_StatelessDofTransformation::ND_StatelessDofTransformation(int size, int p,
{
}
void ND_StatelessDofTransformation::TransformPrimal(const Array<int> & Fo,
double *v) const
void ND_DofTransformation::TransformPrimal(const Array<int> & Fo,
double *v) const
{
// Return immediately when no face DoFs are present
if (nfdofs < 2) { return; }
if (IsIdentity()) { return; }
MFEM_VERIFY(Fo.Size() >= nfaces,
"Face orientation array is shorter than the number of faces in "
"ND_StatelessDofTransformation");
"ND_DofTransformation");
double data[2];
Vector v2(data, 2);
DenseMatrix T2;
// Transform face DoFs
for (int f=0; f<nfaces; f++)
@@ -240,23 +231,25 @@ void ND_StatelessDofTransformation::TransformPrimal(const Array<int> & Fo,
for (int i=0; i<nfdofs/2; i++)
{
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
T(Fo[f]).Mult(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
T2.UseExternalData(const_cast<double *>(T.GetData(Fo[f])), 2, 2);
T2.Mult(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
}
}
}
void ND_StatelessDofTransformation::InvTransformPrimal(const Array<int> & Fo,
double *v) const
void ND_DofTransformation::InvTransformPrimal(const Array<int> & Fo,
double *v) const
{
// Return immediately when no face DoFs are present
if (nfdofs < 2) { return; }
if (IsIdentity()) { return; }
MFEM_VERIFY(Fo.Size() >= nfaces,
"Face orientation array is shorter than the number of faces in "
"ND_StatelessDofTransformation");
"ND_DofTransformation");
double data[2];
Vector v2(data, 2);
DenseMatrix T2Inv;
// Transform face DoFs
for (int f=0; f<nfaces; f++)
@@ -264,23 +257,24 @@ void ND_StatelessDofTransformation::InvTransformPrimal(const Array<int> & Fo,
for (int i=0; i<nfdofs/2; i++)
{
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
TInv(Fo[f]).Mult(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
T2Inv.UseExternalData(const_cast<double *>(TInv.GetData(Fo[f])), 2, 2);
T2Inv.Mult(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
}
}
}
void ND_StatelessDofTransformation::TransformDual(const Array<int> & Fo,
double *v) const
void ND_DofTransformation::TransformDual(const Array<int> & Fo, double *v) const
{
// Return immediately when no face DoFs are present
if (nfdofs < 2) { return; }
if (IsIdentity()) { return; }
MFEM_VERIFY(Fo.Size() >= nfaces,
"Face orientation array is shorter than the number of faces in "
"ND_StatelessDofTransformation");
"ND_DofTransformation");
double data[2];
Vector v2(data, 2);
DenseMatrix T2Inv;
// Transform face DoFs
for (int f=0; f<nfaces; f++)
@@ -288,23 +282,25 @@ void ND_StatelessDofTransformation::TransformDual(const Array<int> & Fo,
for (int i=0; i<nfdofs/2; i++)
{
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
TInv(Fo[f]).MultTranspose(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
T2Inv.UseExternalData(const_cast<double *>(TInv.GetData(Fo[f])), 2, 2);
T2Inv.MultTranspose(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
}
}
}
void ND_StatelessDofTransformation::InvTransformDual(const Array<int> & Fo,
double *v) const
void ND_DofTransformation::InvTransformDual(const Array<int> & Fo,
double *v) const
{
// Return immediately when no face DoFs are present
if (nfdofs < 2) { return; }
if (IsIdentity()) { return; }
MFEM_VERIFY(Fo.Size() >= nfaces,
"Face orientation array is shorter than the number of faces in "
"ND_StatelessDofTransformation");
"ND_DofTransformation");
double data[2];
Vector v2(data, 2);
DenseMatrix T2;
// Transform face DoFs
for (int f=0; f<nfaces; f++)
@@ -312,7 +308,8 @@ void ND_StatelessDofTransformation::InvTransformDual(const Array<int> & Fo,
for (int i=0; i<nfdofs/2; i++)
{
v2 = &v[nedges*nedofs + f*nfdofs + 2*i];
T(Fo[f]).MultTranspose(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
T2.UseExternalData(const_cast<double *>(T.GetData(Fo[f])), 2, 2);
T2.MultTranspose(v2, &v[nedges*nedofs + f*nfdofs + 2*i]);
}
}
}
+77 -251
View File
@@ -80,6 +80,9 @@ public:
inline int Width() const { return size_; }
inline int NumCols() const { return size_; }
/// If the DofTransformation performs no transformation
virtual bool IsIdentity() const = 0;
/** Transform local DoFs to align with the global DoFs. For example, this
transformation can be used to map the local vector computed by
FiniteElement::Project() to the transformed vector stored within a
@@ -115,6 +118,8 @@ public:
inline void InvTransformDual(const Array<int> & face_orientation,
Vector &v) const
{ InvTransformDual(face_orientation, v.GetData()); }
virtual ~StatelessDofTransformation() = default;
};
/** The DofTransformation class is an extension of the
@@ -133,35 +138,76 @@ public:
transferring finite element degrees of freedom between different meshes.
For examples of its use see the TransferMap used by the SubMesh class.
*/
class DofTransformation : virtual public StatelessDofTransformation
class DofTransformation
{
protected:
Array<int> Fo;
DofTransformation(int size)
: StatelessDofTransformation(size) {}
Array<int> Fo_;
const StatelessDofTransformation * dof_trans_;
int vdim_;
int ordering_;
public:
/** @brief Default constructor which requires that SetDofTransformation be
called before use. */
DofTransformation(int vdim = 1, int ordering = 0)
: dof_trans_(NULL)
, vdim_(vdim)
, ordering_(ordering)
{}
/// Constructor with a known StatelessDofTransformation
DofTransformation(const StatelessDofTransformation & dof_trans,
int vdim = 1, int ordering = 0)
: dof_trans_(&dof_trans)
, vdim_(vdim)
, ordering_(ordering)
{}
/** @brief Configure the transformation using face orientations for the
current element. */
/// The face_orientation array can be obtained from Mesh::GetElementFaces.
inline void SetFaceOrientations(const Array<int> & face_orientation)
{ Fo = face_orientation; }
inline void SetFaceOrientations(const Array<int> & Fo)
{ Fo_ = Fo; }
inline const Array<int> & GetFaceOrientations() const { return Fo; }
/// Return the face orientations for the current element
inline const Array<int> & GetFaceOrientations() const { return Fo_; }
using StatelessDofTransformation::TransformPrimal;
using StatelessDofTransformation::InvTransformPrimal;
using StatelessDofTransformation::TransformDual;
using StatelessDofTransformation::InvTransformDual;
/// Set or change the nested StatelessDofTransformation object
inline void SetDofTransformation(const StatelessDofTransformation & dof_trans)
{
dof_trans_ = &dof_trans;
}
inline void SetDofTransformation(const StatelessDofTransformation * dof_trans)
{
dof_trans_ = dof_trans;
}
/// Return the nested StatelessDofTransformation object
inline const StatelessDofTransformation * GetDofTransformation() const
{ return dof_trans_; }
/// Set or change the vdim and ordering parameter
inline void SetVDim(int vdim = 1, int ordering = 0)
{
vdim_ = vdim;
ordering_ = ordering;
}
/// Return the current vdim value
inline int GetVDim() const { return vdim_; }
inline int Size() const { return dof_trans_->Size(); }
inline int Height() const { return dof_trans_->Height(); }
inline int NumRows() const { return dof_trans_->NumRows(); }
inline int Width() const { return dof_trans_->Width(); }
inline int NumCols() const { return dof_trans_->NumCols(); }
inline bool IsIdentity() const { return dof_trans_->IsIdentity(); }
/** Transform local DoFs to align with the global DoFs. For example, this
transformation can be used to map the local vector computed by
FiniteElement::Project() to the transformed vector stored within a
GridFunction object. */
inline void TransformPrimal(double *v) const
{ TransformPrimal(Fo, v); }
void TransformPrimal(double *v) const;
inline void TransformPrimal(Vector &v) const
{ TransformPrimal(v.GetData()); }
@@ -179,21 +225,18 @@ public:
transform the vector obtained using GridFunction::GetSubVector before it
can be used to compute a local interpolation.
*/
inline void InvTransformPrimal(double *v) const
{ InvTransformPrimal(Fo, v); }
void InvTransformPrimal(double *v) const;
inline void InvTransformPrimal(Vector &v) const
{ InvTransformPrimal(v.GetData()); }
/** Transform dual DoFs as computed by a LinearFormIntegrator before summing
into a LinearForm object. */
inline void TransformDual(double *v) const
{ TransformDual(Fo, v); }
void TransformDual(double *v) const;
inline void TransformDual(Vector &v) const
{ TransformDual(v.GetData()); }
/** Inverse Transform dual DoFs */
inline void InvTransformDual(double *v) const
{ InvTransformDual(Fo, v); }
void InvTransformDual(double *v) const;
inline void InvTransformDual(Vector &v) const
{ InvTransformDual(v.GetData()); }
@@ -225,8 +268,6 @@ public:
TransformDual(V.GetColumn(c));
}
}
virtual ~DofTransformation() = default;
};
/** Transform a matrix of DoFs entries from different finite element spaces as
@@ -245,145 +286,6 @@ void TransformDual(const DofTransformation *ran_dof_trans,
const DofTransformation *dom_dof_trans,
DenseMatrix &elmat);
/** The StatelessVDofTransformation class implements a nested transformation
where an arbitrary StatelessDofTransformation is replicated with a
vdim >= 1.
*/
class StatelessVDofTransformation : virtual public StatelessDofTransformation
{
protected:
int vdim_;
int ordering_;
StatelessDofTransformation * sdoftrans_;
public:
/** @brief Default constructor which requires that SetDofTransformation be
called before use. */
StatelessVDofTransformation(int vdim = 1, int ordering = 0)
: StatelessDofTransformation(0)
, vdim_(vdim)
, ordering_(ordering)
, sdoftrans_(NULL)
{}
/// Constructor with a known StatelessDofTransformation
StatelessVDofTransformation(StatelessDofTransformation & doftrans,
int vdim = 1,
int ordering = 0)
: StatelessDofTransformation(vdim * doftrans.Size())
, vdim_(vdim)
, ordering_(ordering)
, sdoftrans_(&doftrans)
{}
/// Set or change the vdim parameter
inline void SetVDim(int vdim)
{
vdim_ = vdim;
if (sdoftrans_)
{
size_ = vdim_ * sdoftrans_->Size();
}
}
/// Return the current vdim value
inline int GetVDim() const { return vdim_; }
/// Set or change the nested StatelessDofTransformation object
inline void SetDofTransformation(StatelessDofTransformation & doftrans)
{
size_ = vdim_ * doftrans.Size();
sdoftrans_ = &doftrans;
}
/// Return the nested StatelessDofTransformation object
inline StatelessDofTransformation * GetDofTransformation() const
{ return sdoftrans_; }
using StatelessDofTransformation::TransformPrimal;
using StatelessDofTransformation::InvTransformPrimal;
using StatelessDofTransformation::TransformDual;
using StatelessDofTransformation::InvTransformDual;
/** Specializations of these base class methods which account for the vdim
and ordering of the full set of DoFs.
*/
void TransformPrimal(const Array<int> & face_ori, double *v) const;
void InvTransformPrimal(const Array<int> & face_ori, double *v) const;
void TransformDual(const Array<int> & face_ori, double *v) const;
void InvTransformDual(const Array<int> & face_ori, double *v) const;
};
/** The VDofTransformation class implements a nested transformation where an
arbitrary DofTransformation is replicated with a vdim >= 1.
*/
class VDofTransformation : public StatelessVDofTransformation,
public DofTransformation
{
protected:
DofTransformation * doftrans_;
public:
/** @brief Default constructor which requires that SetDofTransformation be
called before use. */
VDofTransformation(int vdim = 1, int ordering = 0)
: StatelessDofTransformation(0)
, StatelessVDofTransformation(vdim, ordering)
, DofTransformation(0)
, doftrans_(NULL)
{}
/// Constructor with a known DofTransformation
/// @note The face orientations in @a doftrans will be copied into the
/// new VDofTransformation object.
VDofTransformation(DofTransformation & doftrans, int vdim = 1,
int ordering = 0)
: StatelessDofTransformation(vdim * doftrans.Size())
, StatelessVDofTransformation(doftrans, vdim, ordering)
, DofTransformation(vdim * doftrans.Size())
, doftrans_(&doftrans)
{
DofTransformation::SetFaceOrientations(doftrans.GetFaceOrientations());
}
using StatelessVDofTransformation::SetDofTransformation;
/// Set or change the nested DofTransformation object
/// @note The face orientations in @a doftrans will be copied into the
/// VDofTransformation object.
void SetDofTransformation(DofTransformation & doftrans)
{
doftrans_ = &doftrans;
StatelessVDofTransformation::SetDofTransformation(doftrans);
DofTransformation::SetFaceOrientations(doftrans.GetFaceOrientations());
}
/// Return the nested DofTransformation object
inline DofTransformation * GetDofTransformation() const { return doftrans_; }
/// Set new face orientations in both the VDofTransformation and the
/// DofTransformation contained within (if there is one).
inline void SetFaceOrientations(const Array<int> & face_orientation)
{
DofTransformation::SetFaceOrientations(face_orientation);
if (doftrans_) { doftrans_->SetFaceOrientations(face_orientation); }
}
using DofTransformation::TransformPrimal;
using DofTransformation::InvTransformPrimal;
using DofTransformation::TransformDual;
using DofTransformation::InvTransformDual;
inline void TransformPrimal(double *v) const
{ TransformPrimal(Fo, v); }
inline void InvTransformPrimal(double *v) const
{ InvTransformPrimal(Fo, v); }
inline void TransformDual(double *v) const
{ TransformDual(Fo, v); }
inline void InvTransformDual(double *v) const
{ InvTransformDual(Fo, v); }
};
/** Abstract base class for high-order Nedelec spaces on elements with
triangular faces.
@@ -396,7 +298,7 @@ public:
be accessed as DenseMatrices using the GetFaceTransform() and
GetFaceInverseTransform() methods.
*/
class ND_StatelessDofTransformation : virtual public StatelessDofTransformation
class ND_DofTransformation : public StatelessDofTransformation
{
private:
static const double T_data[24];
@@ -410,8 +312,7 @@ protected:
const int nedges; // number of edges per element
const int nfaces; // number of triangular faces per element
ND_StatelessDofTransformation(int size, int order,
int num_edges, int num_tri_faces);
ND_DofTransformation(int size, int order, int num_edges, int num_tri_faces);
public:
// Return the 2x2 transformation operator for the given face orientation
@@ -421,116 +322,41 @@ public:
static const DenseMatrix & GetFaceInverseTransform(int ori)
{ return TInv(ori); }
void TransformPrimal(const Array<int> & face_orientation,
double *v) const;
bool IsIdentity() const override { return nfdofs < 2; }
void InvTransformPrimal(const Array<int> & face_orientation,
double *v) const;
void TransformDual(const Array<int> & face_orientation,
double *v) const;
void InvTransformDual(const Array<int> & face_orientation,
double *v) const;
void TransformPrimal(const Array<int> & Fo, double *v) const override;
void InvTransformPrimal(const Array<int> & Fo, double *v) const override;
void TransformDual(const Array<int> & Fo, double *v) const override;
void InvTransformDual(const Array<int> & Fo, double *v) const override;
};
/// Stateless DoF transformation implementation for the Nedelec basis on
/// triangles
class ND_TriStatelessDofTransformation : public ND_StatelessDofTransformation
{
public:
ND_TriStatelessDofTransformation(int order)
: StatelessDofTransformation(order*(order + 2))
, ND_StatelessDofTransformation(order*(order + 2), order, 3, 1)
{}
};
/// DoF transformation implementation for the Nedelec basis on triangles
class ND_TriDofTransformation : public DofTransformation,
public ND_TriStatelessDofTransformation
class ND_TriDofTransformation : public ND_DofTransformation
{
public:
ND_TriDofTransformation(int order)
: StatelessDofTransformation(order*(order + 2))
, DofTransformation(order*(order + 2))
, ND_TriStatelessDofTransformation(order)
{}
using DofTransformation::TransformPrimal;
using DofTransformation::InvTransformPrimal;
using DofTransformation::TransformDual;
using DofTransformation::InvTransformDual;
using ND_TriStatelessDofTransformation::TransformPrimal;
using ND_TriStatelessDofTransformation::InvTransformPrimal;
using ND_TriStatelessDofTransformation::TransformDual;
using ND_TriStatelessDofTransformation::InvTransformDual;
};
/// DoF transformation implementation for the Nedelec basis on tetrahedra
class ND_TetStatelessDofTransformation : public ND_StatelessDofTransformation
{
public:
ND_TetStatelessDofTransformation(int order)
: StatelessDofTransformation(order*(order + 2)*(order + 3)/2)
, ND_StatelessDofTransformation(order*(order + 2)*(order + 3)/2, order,
6, 4)
: ND_DofTransformation(order*(order + 2), order, 3, 1)
{}
};
/// DoF transformation implementation for the Nedelec basis on tetrahedra
class ND_TetDofTransformation : public DofTransformation,
public ND_TetStatelessDofTransformation
class ND_TetDofTransformation : public ND_DofTransformation
{
public:
ND_TetDofTransformation(int order)
: StatelessDofTransformation(order*(order + 2)*(order + 3)/2)
, DofTransformation(order*(order + 2)*(order + 3)/2)
, ND_TetStatelessDofTransformation(order)
{}
using DofTransformation::TransformPrimal;
using DofTransformation::InvTransformPrimal;
using DofTransformation::TransformDual;
using DofTransformation::InvTransformDual;
using ND_TetStatelessDofTransformation::TransformPrimal;
using ND_TetStatelessDofTransformation::InvTransformPrimal;
using ND_TetStatelessDofTransformation::TransformDual;
using ND_TetStatelessDofTransformation::InvTransformDual;
};
/// DoF transformation implementation for the Nedelec basis on wedge elements
class ND_WedgeStatelessDofTransformation : public ND_StatelessDofTransformation
{
public:
ND_WedgeStatelessDofTransformation(int order)
: StatelessDofTransformation(3 * order * ((order + 1) * (order + 2))/2)
, ND_StatelessDofTransformation(3 * order * ((order + 1) * (order + 2))/2,
order, 9, 2)
: ND_DofTransformation(order*(order + 2)*(order + 3)/2, order, 6, 4)
{}
};
/// DoF transformation implementation for the Nedelec basis on wedge elements
class ND_WedgeDofTransformation : public DofTransformation,
public ND_WedgeStatelessDofTransformation
class ND_WedgeDofTransformation : public ND_DofTransformation
{
public:
ND_WedgeDofTransformation(int order)
: StatelessDofTransformation(3 * order * ((order + 1) * (order + 2))/2)
, DofTransformation(3 * order * ((order + 1) * (order + 2))/2)
, ND_WedgeStatelessDofTransformation(order)
: ND_DofTransformation(3 * order * ((order + 1) * (order + 2))/2,
order, 9, 2)
{}
using DofTransformation::TransformPrimal;
using DofTransformation::InvTransformPrimal;
using DofTransformation::TransformDual;
using DofTransformation::InvTransformDual;
using ND_WedgeStatelessDofTransformation::TransformPrimal;
using ND_WedgeStatelessDofTransformation::InvTransformPrimal;
using ND_WedgeStatelessDofTransformation::TransformDual;
using ND_WedgeStatelessDofTransformation::InvTransformDual;
};
} // namespace mfem
+1 -5
View File
@@ -355,15 +355,11 @@ int InverseElementTransformation::Transform(const Vector &pt,
}
else
{
const int old_type = GlobGeometryRefiner.GetType();
GlobGeometryRefiner.SetType(qpts_type);
RefinedGeometry &RefG =
*GlobGeometryRefiner.Refine(T->GetGeometryType(), order);
RefinedGeometry &RefG = *refiner.Refine(T->GetGeometryType(), order);
int closest_idx = (init_guess_type == ClosestPhysNode) ?
FindClosestPhysPoint(pt, RefG.RefPts) :
FindClosestRefPoint(pt, RefG.RefPts);
ip0 = &RefG.RefPts.IntPoint(closest_idx);
GlobGeometryRefiner.SetType(old_type);
}
break;
}
+4 -4
View File
@@ -233,7 +233,7 @@ protected:
// Parameters of the inversion algorithms:
const IntegrationPoint *ip0;
int init_guess_type; // algorithm to use
int qpts_type; // Quadrature1D type for the initial guess type
GeometryRefiner refiner; // geometry refiner for initial guess
int rel_qpts_order; // num_1D_qpts = max(trans_order+rel_qpts_order,0)+1
int solver_type; // solution strategy to use
int max_iter; // max. number of Newton iterations
@@ -276,7 +276,7 @@ public:
: T(Trans),
ip0(NULL),
init_guess_type(Center),
qpts_type(Quadrature1D::OpenHalfUniform),
refiner(Quadrature1D::OpenHalfUniform),
rel_qpts_order(-1),
solver_type(NewtonElementProject),
max_iter(16),
@@ -301,7 +301,7 @@ public:
{ ip0 = &init_ip; SetInitialGuessType(GivenPoint); }
/// Set the Quadrature1D type used for the `Closest*` initial guess types.
void SetInitGuessPointsType(int q_type) { qpts_type = q_type; }
void SetInitGuessPointsType(int q_type) { refiner.SetType(q_type); }
/// Set the relative order used for the `Closest*` initial guess types.
/** The number of points in each spatial direction is given by the formula
@@ -361,7 +361,7 @@ public:
class IsoparametricTransformation : public ElementTransformation
{
private:
DenseMatrix dshape,d2shape;
DenseMatrix dshape, d2shape;
Vector shape;
const FiniteElement *FElem;
+207 -165
View File
@@ -359,135 +359,148 @@ void FiniteElement::CalcPhysHessian(ElementTransformation &Trans,
// Hessian in physical coords
lhm.Invert();
Mult( hess, lhm, Hessian);
Mult(hess, lhm, Hessian);
}
const DofToQuad &FiniteElement::GetDofToQuad(const IntegrationRule &ir,
DofToQuad::Mode mode) const
{
DofToQuad *d2q = nullptr;
MFEM_VERIFY(mode == DofToQuad::FULL, "invalid mode requested");
for (int i = 0; i < dof2quad_array.Size(); i++)
{
const DofToQuad &d2q = *dof2quad_array[i];
if (d2q.IntRule == &ir && d2q.mode == mode) { return d2q; }
}
#ifdef MFEM_THREAD_SAFE
DenseMatrix vshape(dof, dim);
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
#pragma omp critical (DofToQuad)
#endif
DofToQuad *d2q = new DofToQuad;
const int nqpt = ir.GetNPoints();
d2q->FE = this;
d2q->IntRule = &ir;
d2q->mode = mode;
d2q->ndof = dof;
d2q->nqpt = nqpt;
if (range_type == SCALAR)
{
d2q->B.SetSize(nqpt*dof);
d2q->Bt.SetSize(dof*nqpt);
Vector shape;
vshape.GetColumnReference(0, shape);
for (int i = 0; i < nqpt; i++)
for (int i = 0; i < dof2quad_array.Size(); i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcShape(ip, shape);
for (int j = 0; j < dof; j++)
{
d2q->B[i+nqpt*j] = d2q->Bt[j+dof*i] = shape(j);
}
d2q = dof2quad_array[i];
if (d2q->IntRule != &ir || d2q->mode != mode) { d2q = nullptr; }
}
}
else if (range_type == VECTOR)
{
d2q->B.SetSize(nqpt*dim*dof);
d2q->Bt.SetSize(dof*nqpt*dim);
for (int i = 0; i < nqpt; i++)
if (!d2q)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcVShape(ip, vshape);
for (int d = 0; d < dim; d++)
#ifdef MFEM_THREAD_SAFE
DenseMatrix vshape(dof, dim);
#endif
d2q = new DofToQuad;
const int nqpt = ir.GetNPoints();
d2q->FE = this;
d2q->IntRule = &ir;
d2q->mode = mode;
d2q->ndof = dof;
d2q->nqpt = nqpt;
switch (range_type)
{
for (int j = 0; j < dof; j++)
case SCALAR:
{
d2q->B[i+nqpt*(d+dim*j)] = d2q->Bt[j+dof*(i+nqpt*d)] = vshape(j, d);
}
}
}
}
else
{
// Skip B and Bt for unknown range type
}
switch (deriv_type)
{
case GRAD:
{
d2q->G.SetSize(nqpt*dim*dof);
d2q->Gt.SetSize(dof*nqpt*dim);
d2q->B.SetSize(nqpt*dof);
d2q->Bt.SetSize(dof*nqpt);
for (int i = 0; i < nqpt; i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcDShape(ip, vshape);
for (int d = 0; d < dim; d++)
{
for (int j = 0; j < dof; j++)
Vector shape;
vshape.GetColumnReference(0, shape);
for (int i = 0; i < nqpt; i++)
{
d2q->G[i+nqpt*(d+dim*j)] = d2q->Gt[j+dof*(i+nqpt*d)] = vshape(j, d);
const IntegrationPoint &ip = ir.IntPoint(i);
CalcShape(ip, shape);
for (int j = 0; j < dof; j++)
{
d2q->B[i+nqpt*j] = d2q->Bt[j+dof*i] = shape(j);
}
}
break;
}
}
break;
}
case DIV:
{
d2q->G.SetSize(nqpt*dof);
d2q->Gt.SetSize(dof*nqpt);
Vector divshape;
vshape.GetColumnReference(0, divshape);
for (int i = 0; i < nqpt; i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcDivShape(ip, divshape);
for (int j = 0; j < dof; j++)
case VECTOR:
{
d2q->G[i+nqpt*j] = d2q->Gt[j+dof*i] = divshape(j);
}
}
break;
}
case CURL:
{
d2q->G.SetSize(nqpt*cdim*dof);
d2q->Gt.SetSize(dof*nqpt*cdim);
d2q->B.SetSize(nqpt*dim*dof);
d2q->Bt.SetSize(dof*nqpt*dim);
DenseMatrix curlshape(vshape.GetData(), dof, cdim); // cdim <= dim
for (int i = 0; i < nqpt; i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcCurlShape(ip, curlshape);
for (int d = 0; d < cdim; d++)
{
for (int j = 0; j < dof; j++)
for (int i = 0; i < nqpt; i++)
{
d2q->G[i+nqpt*(d+cdim*j)] = d2q->Gt[j+dof*(i+nqpt*d)] = curlshape(j, d);
const IntegrationPoint &ip = ir.IntPoint(i);
CalcVShape(ip, vshape);
for (int d = 0; d < dim; d++)
{
for (int j = 0; j < dof; j++)
{
d2q->B[i+nqpt*(d+dim*j)] =
d2q->Bt[j+dof*(i+nqpt*d)] = vshape(j, d);
}
}
}
break;
}
case UNKNOWN_RANGE_TYPE:
// Skip B and Bt for unknown range type
break;
}
break;
switch (deriv_type)
{
case GRAD:
{
d2q->G.SetSize(nqpt*dim*dof);
d2q->Gt.SetSize(dof*nqpt*dim);
for (int i = 0; i < nqpt; i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcDShape(ip, vshape);
for (int d = 0; d < dim; d++)
{
for (int j = 0; j < dof; j++)
{
d2q->G[i+nqpt*(d+dim*j)] =
d2q->Gt[j+dof*(i+nqpt*d)] = vshape(j, d);
}
}
}
break;
}
case DIV:
{
d2q->G.SetSize(nqpt*dof);
d2q->Gt.SetSize(dof*nqpt);
Vector divshape;
vshape.GetColumnReference(0, divshape);
for (int i = 0; i < nqpt; i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcDivShape(ip, divshape);
for (int j = 0; j < dof; j++)
{
d2q->G[i+nqpt*j] = d2q->Gt[j+dof*i] = divshape(j);
}
}
break;
}
case CURL:
{
d2q->G.SetSize(nqpt*cdim*dof);
d2q->Gt.SetSize(dof*nqpt*cdim);
DenseMatrix curlshape(vshape.GetData(), dof, cdim); // cdim <= dim
for (int i = 0; i < nqpt; i++)
{
const IntegrationPoint &ip = ir.IntPoint(i);
CalcCurlShape(ip, curlshape);
for (int d = 0; d < cdim; d++)
{
for (int j = 0; j < dof; j++)
{
d2q->G[i+nqpt*(d+cdim*j)] =
d2q->Gt[j+dof*(i+nqpt*d)] = curlshape(j, d);
}
}
}
break;
}
case NONE:
// Skip G and Gt for unknown derivative type
break;
}
dof2quad_array.Append(d2q);
}
case NONE:
default:
// Skip G and Gt for unknown derivative type
break;
}
dof2quad_array.Append(d2q);
return *d2q;
}
@@ -904,14 +917,14 @@ VectorFiniteElement::VectorFiniteElement(int D, Geometry::Type G,
}
void VectorFiniteElement::CalcShape(
const IntegrationPoint &ip, Vector &shape ) const
const IntegrationPoint &ip, Vector &shape) const
{
mfem_error("Error: Cannot use scalar CalcShape(...) function with\n"
" VectorFiniteElements!");
}
void VectorFiniteElement::CalcDShape(
const IntegrationPoint &ip, DenseMatrix &dshape ) const
const IntegrationPoint &ip, DenseMatrix &dshape) const
{
mfem_error("Error: Cannot use scalar CalcDShape(...) function with\n"
" VectorFiniteElements!");
@@ -2183,51 +2196,72 @@ void Poly_1D::CalcChebyshev(const int p, const double x, double *u, double *d,
const double *Poly_1D::GetPoints(const int p, const int btype)
{
Array<double*> *pts;
BasisType::Check(btype);
const int qtype = BasisType::GetQuadrature1D(btype);
if (qtype == Quadrature1D::Invalid) { return NULL; }
if (points_container.find(btype) == points_container.end())
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
#pragma omp critical (Poly1DGetPoints)
#endif
{
points_container[btype] = new Array<double*>(h_mt);
auto it = points_container.find(btype);
if (it != points_container.end())
{
pts = it->second;
}
else
{
pts = new Array<double*>(h_mt);
points_container[btype] = pts;
}
if (pts->Size() <= p)
{
pts->SetSize(p + 1, NULL);
}
if ((*pts)[p] == NULL)
{
(*pts)[p] = new double[p + 1];
quad_func.GivePolyPoints(p + 1, (*pts)[p], qtype);
}
}
Array<double*> &pts = *points_container[btype];
if (pts.Size() <= p)
{
pts.SetSize(p + 1, NULL);
}
if (pts[p] == NULL)
{
pts[p] = new double[p + 1];
quad_func.GivePolyPoints(p+1, pts[p], qtype);
}
return pts[p];
return (*pts)[p];
}
Poly_1D::Basis &Poly_1D::GetBasis(const int p, const int btype)
{
Array<Basis*> *bases;
BasisType::Check(btype);
if ( bases_container.find(btype) == bases_container.end() )
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
#pragma omp critical (Poly1DGetBasis)
#endif
{
// we haven't been asked for basis or points of this type yet
bases_container[btype] = new Array<Basis*>(h_mt);
auto it = bases_container.find(btype);
if (it != bases_container.end())
{
bases = it->second;
}
else
{
// we haven't been asked for basis or points of this type yet
bases = new Array<Basis*>(h_mt);
bases_container[btype] = bases;
}
if (bases->Size() <= p)
{
bases->SetSize(p + 1, NULL);
}
if ((*bases)[p] == NULL)
{
EvalType etype;
if (btype == BasisType::Positive) { etype = Positive; }
else if (btype == BasisType::IntegratedGLL) { etype = Integrated; }
else { etype = Barycentric; }
(*bases)[p] = new Basis(p, GetPoints(p, btype), etype);
}
}
Array<Basis*> &bases = *bases_container[btype];
if (bases.Size() <= p)
{
bases.SetSize(p + 1, NULL);
}
if (bases[p] == NULL)
{
EvalType etype;
if (btype == BasisType::Positive) { etype = Positive; }
else if (btype == BasisType::IntegratedGLL) { etype = Integrated; }
else { etype = Barycentric; }
bases[p] = new Basis(p, GetPoints(p, btype), etype);
}
return *bases[p];
return *(*bases)[p];
}
Poly_1D::~Poly_1D()
@@ -2236,7 +2270,7 @@ Poly_1D::~Poly_1D()
it != points_container.end() ; ++it)
{
Array<double*>& pts = *it->second;
for ( int i = 0 ; i < pts.Size() ; ++i )
for (int i = 0; i < pts.Size(); ++i)
{
delete [] pts[i];
}
@@ -2247,7 +2281,7 @@ Poly_1D::~Poly_1D()
it != bases_container.end() ; ++it)
{
Array<Basis*>& bases = *it->second;
for ( int i = 0 ; i < bases.Size() ; ++i )
for (int i = 0; i < bases.Size(); ++i)
{
delete bases[i];
}
@@ -2461,39 +2495,47 @@ const DofToQuad &TensorBasisElement::GetTensorDofToQuad(
DofToQuad::Mode mode, const Poly_1D::Basis &basis, bool closed,
Array<DofToQuad*> &dof2quad_array)
{
DofToQuad *d2q = nullptr;
MFEM_VERIFY(mode == DofToQuad::TENSOR, "invalid mode requested");
for (int i = 0; i < dof2quad_array.Size(); i++)
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
#pragma omp critical (DofToQuad)
#endif
{
const DofToQuad &d2q = *dof2quad_array[i];
if (d2q.IntRule == &ir && d2q.mode == mode) { return d2q; }
}
DofToQuad *d2q = new DofToQuad;
const int ndof = closed ? fe.GetOrder() + 1 : fe.GetOrder();
const int nqpt = (int)floor(pow(ir.GetNPoints(), 1.0/fe.GetDim()) + 0.5);
d2q->FE = &fe;
d2q->IntRule = &ir;
d2q->mode = mode;
d2q->ndof = ndof;
d2q->nqpt = nqpt;
d2q->B.SetSize(nqpt*ndof);
d2q->Bt.SetSize(ndof*nqpt);
d2q->G.SetSize(nqpt*ndof);
d2q->Gt.SetSize(ndof*nqpt);
Vector val(ndof), grad(ndof);
for (int i = 0; i < nqpt; i++)
{
// The first 'nqpt' points in 'ir' have the same x-coordinates as those
// of the 1D rule.
basis.Eval(ir.IntPoint(i).x, val, grad);
for (int j = 0; j < ndof; j++)
for (int i = 0; i < dof2quad_array.Size(); i++)
{
d2q->B[i+nqpt*j] = d2q->Bt[j+ndof*i] = val(j);
d2q->G[i+nqpt*j] = d2q->Gt[j+ndof*i] = grad(j);
d2q = dof2quad_array[i];
if (d2q->IntRule != &ir || d2q->mode != mode) { d2q = nullptr; }
}
if (!d2q)
{
d2q = new DofToQuad;
const int ndof = closed ? fe.GetOrder() + 1 : fe.GetOrder();
const int nqpt = (int)floor(pow(ir.GetNPoints(), 1.0/fe.GetDim()) + 0.5);
d2q->FE = &fe;
d2q->IntRule = &ir;
d2q->mode = mode;
d2q->ndof = ndof;
d2q->nqpt = nqpt;
d2q->B.SetSize(nqpt*ndof);
d2q->Bt.SetSize(ndof*nqpt);
d2q->G.SetSize(nqpt*ndof);
d2q->Gt.SetSize(ndof*nqpt);
Vector val(ndof), grad(ndof);
for (int i = 0; i < nqpt; i++)
{
// The first 'nqpt' points in 'ir' have the same x-coordinates as those
// of the 1D rule.
basis.Eval(ir.IntPoint(i).x, val, grad);
for (int j = 0; j < ndof; j++)
{
d2q->B[i+nqpt*j] = d2q->Bt[j+ndof*i] = val(j);
d2q->G[i+nqpt*j] = d2q->Gt[j+ndof*i] = grad(j);
}
}
dof2quad_array.Append(d2q);
}
}
dof2quad_array.Append(d2q);
return *d2q;
}
+4 -4
View File
@@ -250,7 +250,7 @@ protected:
/// Container for all DofToQuad objects created by the FiniteElement.
/** Multiple DofToQuad objects may be needed when different quadrature rules
or different DofToQuad::Mode are used. */
mutable Array<DofToQuad*> dof2quad_array;
mutable Array<DofToQuad *> dof2quad_array;
public:
/// Enumeration for range_type and deriv_range_type
@@ -596,7 +596,7 @@ public:
/** @brief Return a DoF transformation object for this particular type of
basis.
*/
virtual StatelessDofTransformation * GetDofTransformation() const
virtual const StatelessDofTransformation *GetDofTransformation() const
{ return NULL; }
/// Deconstruct the FiniteElement
@@ -1026,8 +1026,8 @@ public:
};
private:
typedef std::map< int, Array<double*>* > PointsMap;
typedef std::map< int, Array<Basis*>* > BasisMap;
typedef std::map<int, Array<double*>*> PointsMap;
typedef std::map<int, Array<Basis*>*> BasisMap;
MemoryType h_mt;
PointsMap points_container;
+1 -1
View File
@@ -6031,7 +6031,7 @@ void RT0PyrFiniteElement::CalcVShape(const IntegrationPoint &ip,
shape(1,2) = z;
shape(2,0) = x * (2.0 - z) * ozi;
shape(2,1) = - y * z * ozi;;
shape(2,1) = - y * z * ozi;
shape(2,2) = z;
shape(3,0) = - x * z * ozi;
+6 -6
View File
@@ -179,7 +179,7 @@ class ND_TetrahedronElement : public VectorFiniteElement
Array<int> dof2tk;
DenseMatrixInverse Ti;
mutable ND_TetStatelessDofTransformation doftrans;
ND_TetDofTransformation doftrans;
public:
/// Construct the ND_TetrahedronElement of order @a p
@@ -201,7 +201,7 @@ public:
ElementTransformation &Trans,
DenseMatrix &I) const
{ LocalInterpolation_ND(CheckVectorFE(fe), tk, dof2tk, Trans, I); }
virtual StatelessDofTransformation * GetDofTransformation() const
virtual const StatelessDofTransformation *GetDofTransformation() const
{ return &doftrans; }
using FiniteElement::Project;
virtual void Project(VectorCoefficient &vc,
@@ -242,7 +242,7 @@ class ND_TriangleElement : public VectorFiniteElement
Array<int> dof2tk;
DenseMatrixInverse Ti;
mutable ND_TriStatelessDofTransformation doftrans;
ND_TriDofTransformation doftrans;
public:
/// Construct the ND_TriangleElement of order @a p
@@ -264,7 +264,7 @@ public:
ElementTransformation &Trans,
DenseMatrix &I) const
{ LocalInterpolation_ND(CheckVectorFE(fe), tk, dof2tk, Trans, I); }
virtual StatelessDofTransformation * GetDofTransformation() const
virtual const StatelessDofTransformation *GetDofTransformation() const
{ return &doftrans; }
using FiniteElement::Project;
virtual void Project(VectorCoefficient &vc,
@@ -346,7 +346,7 @@ private:
#endif
Array<int> dof2tk, t_dof, s_dof;
mutable ND_WedgeStatelessDofTransformation doftrans;
ND_WedgeDofTransformation doftrans;
H1_TriangleElement H1TriangleFE;
ND_TriangleElement NDTriangleFE;
@@ -379,7 +379,7 @@ public:
DenseMatrix &I) const
{ LocalInterpolation_ND(CheckVectorFE(fe), tk, dof2tk, Trans, I); }
virtual StatelessDofTransformation * GetDofTransformation() const
virtual const StatelessDofTransformation *GetDofTransformation() const
{ return &doftrans; }
using FiniteElement::Project;
+6 -10
View File
@@ -59,7 +59,7 @@ void H1Ser_QuadrilateralElement::CalcShape(const IntegrationPoint &ip,
int p = (this)->GetOrder();
double x = ip.x, y = ip.y;
Poly_1D::Basis edgeNodalBasis(poly1d.GetBasis(p, BasisType::GaussLobatto));
Poly_1D::Basis &edgeNodalBasis = poly1d.GetBasis(p, BasisType::GaussLobatto);
Vector nodalX(p+1);
Vector nodalY(p+1);
@@ -113,10 +113,9 @@ void H1Ser_QuadrilateralElement::CalcShape(const IntegrationPoint &ip,
{
double *legX = new double[p-1];
double *legY = new double[p-1];
Poly_1D *storeLegendre = new Poly_1D();
storeLegendre->CalcLegendre(p-2, x, legX);
storeLegendre->CalcLegendre(p-2, y, legY);
Poly_1D::CalcLegendre(p-2, x, legX);
Poly_1D::CalcLegendre(p-2, y, legY);
int interior_total = 0;
for (int j = 4; j < p + 1; j++)
@@ -131,7 +130,6 @@ void H1Ser_QuadrilateralElement::CalcShape(const IntegrationPoint &ip,
delete[] legX;
delete[] legY;
delete storeLegendre;
}
}
@@ -141,7 +139,7 @@ void H1Ser_QuadrilateralElement::CalcDShape(const IntegrationPoint &ip,
int p = (this)->GetOrder();
double x = ip.x, y = ip.y;
Poly_1D::Basis edgeNodalBasis(poly1d.GetBasis(p, BasisType::GaussLobatto));
Poly_1D::Basis &edgeNodalBasis = poly1d.GetBasis(p, BasisType::GaussLobatto);
Vector nodalX(p+1);
Vector DnodalX(p+1);
Vector nodalY(p+1);
@@ -203,10 +201,9 @@ void H1Ser_QuadrilateralElement::CalcDShape(const IntegrationPoint &ip,
double *legY = new double[p-1];
double *DlegX = new double[p-1];
double *DlegY = new double[p-1];
Poly_1D *storeLegendre = new Poly_1D();
storeLegendre->CalcLegendre(p-2, x, legX, DlegX);
storeLegendre->CalcLegendre(p-2, y, legY, DlegY);
Poly_1D::CalcLegendre(p-2, x, legX, DlegX);
Poly_1D::CalcLegendre(p-2, y, legY, DlegY);
int interior_total = 0;
for (int j = 4; j < p + 1; j++)
@@ -224,7 +221,6 @@ void H1Ser_QuadrilateralElement::CalcDShape(const IntegrationPoint &ip,
delete[] legY;
delete[] DlegX;
delete[] DlegY;
delete storeLegendre;
}
}
+1 -1
View File
@@ -2896,7 +2896,7 @@ ND_FECollection::FiniteElementForGeometry(Geometry::Type GeomType) const
}
}
StatelessDofTransformation *
const StatelessDofTransformation *
ND_FECollection::DofTransformationForGeometry(Geometry::Type GeomType) const
{
if (!Geometry::IsTensorProduct(GeomType) && this->GetOrder() > 1)
+2 -2
View File
@@ -63,7 +63,7 @@ public:
/** @brief Returns a DoF transformation object compatible with this basis
and geometry type.
*/
virtual StatelessDofTransformation *
virtual const StatelessDofTransformation *
DofTransformationForGeometry(Geometry::Type GeomType) const
{ return NULL; }
@@ -483,7 +483,7 @@ public:
int DofForGeometry(Geometry::Type GeomType) const override
{ return ND_dof[GeomType]; }
StatelessDofTransformation *
const StatelessDofTransformation *
DofTransformationForGeometry(Geometry::Type GeomType) const override;
const int *DofOrderForOrientation(Geometry::Type GeomType,
+1
View File
@@ -13,6 +13,7 @@
#define MFEM_FEM_HPP
#include "intrules.hpp"
#include "intrules_cut.hpp"
#include "geom.hpp"
#include "fe.hpp"
#include "fe_coll.hpp"
+187 -195
View File
@@ -63,7 +63,6 @@ FiniteElementSpace::FiniteElementSpace()
elem_dof(NULL), elem_fos(NULL), bdr_elem_dof(NULL), bdr_elem_fos(NULL),
face_dof(NULL),
NURBSext(NULL), own_ext(false),
DoFTrans(0), VDoFTrans(vdim, ordering),
cP_is_set(false),
Th(Operator::ANY_TYPE),
sequence(0), mesh_sequence(0), orders_changed(false), relaxed_hp(false)
@@ -72,7 +71,6 @@ FiniteElementSpace::FiniteElementSpace()
FiniteElementSpace::FiniteElementSpace(const FiniteElementSpace &orig,
Mesh *mesh_,
const FiniteElementCollection *fec_)
: VDoFTrans(orig.vdim, orig.ordering)
{
mesh_ = mesh_ ? mesh_ : orig.mesh;
fec_ = fec_ ? fec_ : orig.fec;
@@ -212,7 +210,7 @@ void FiniteElementSpace::GetVDofs(int vd, Array<int>& dofs, int ndofs_) const
}
}
void FiniteElementSpace::DofsToVDofs (Array<int> &dofs, int ndofs_) const
void FiniteElementSpace::DofsToVDofs(Array<int> &dofs, int ndofs_) const
{
if (vdim == 1) { return; }
if (ndofs_ < 0) { ndofs_ = this->ndofs; }
@@ -264,7 +262,7 @@ int FiniteElementSpace::DofToVDof(int dof, int vd, int ndofs_) const
}
// static function
void FiniteElementSpace::AdjustVDofs (Array<int> &vdofs)
void FiniteElementSpace::AdjustVDofs(Array<int> &vdofs)
{
int n = vdofs.Size(), *vdof = vdofs;
for (int i = 0; i < n; i++)
@@ -277,36 +275,36 @@ void FiniteElementSpace::AdjustVDofs (Array<int> &vdofs)
}
}
void FiniteElementSpace::GetElementVDofs(int i, Array<int> &vdofs,
DofTransformation &doftrans) const
{
GetElementDofs(i, vdofs, doftrans);
DofsToVDofs(vdofs);
doftrans.SetVDim(vdim, ordering);
}
DofTransformation *
FiniteElementSpace::GetElementVDofs(int i, Array<int> &vdofs) const
{
DofTransformation * doftrans = GetElementDofs(i, vdofs);
DoFTrans.SetDofTransformation(NULL);
GetElementVDofs(i, vdofs, DoFTrans);
return DoFTrans.GetDofTransformation() ? &DoFTrans : NULL;
}
void FiniteElementSpace::GetBdrElementVDofs(int i, Array<int> &vdofs,
DofTransformation &doftrans) const
{
GetBdrElementDofs(i, vdofs, doftrans);
DofsToVDofs(vdofs);
if (vdim == 1 || doftrans == NULL)
{
return doftrans;
}
else
{
VDoFTrans.SetDofTransformation(*doftrans);
return &VDoFTrans;
}
doftrans.SetVDim(vdim, ordering);
}
DofTransformation *
FiniteElementSpace::GetBdrElementVDofs(int i, Array<int> &vdofs) const
{
DofTransformation * doftrans = GetBdrElementDofs(i, vdofs);
DofsToVDofs(vdofs);
if (vdim == 1 || doftrans == NULL)
{
return doftrans;
}
else
{
VDoFTrans.SetDofTransformation(*doftrans);
return &VDoFTrans;
}
DoFTrans.SetDofTransformation(NULL);
GetBdrElementVDofs(i, vdofs, DoFTrans);
return DoFTrans.GetDofTransformation() ? &DoFTrans : NULL;
}
void FiniteElementSpace::GetPatchVDofs(int i, Array<int> &vdofs) const
@@ -777,9 +775,9 @@ FiniteElementSpace::H2L_GlobalRestrictionMatrix (FiniteElementSpace *lfes)
return R;
}
void FiniteElementSpace
::AddDependencies(SparseMatrix& deps, Array<int>& master_dofs,
Array<int>& slave_dofs, DenseMatrix& I, int skipfirst)
void FiniteElementSpace::AddDependencies(
SparseMatrix& deps, Array<int>& master_dofs, Array<int>& slave_dofs,
DenseMatrix& I, int skipfirst)
{
for (int i = skipfirst; i < slave_dofs.Size(); i++)
{
@@ -802,11 +800,9 @@ void FiniteElementSpace
}
}
void FiniteElementSpace
::AddEdgeFaceDependencies(SparseMatrix &deps, Array<int> &master_dofs,
const FiniteElement *master_fe,
Array<int> &slave_dofs, int slave_face,
const DenseMatrix *pm) const
void FiniteElementSpace::AddEdgeFaceDependencies(
SparseMatrix &deps, Array<int> &master_dofs, const FiniteElement *master_fe,
Array<int> &slave_dofs, int slave_face, const DenseMatrix *pm) const
{
// In variable-order spaces in 3D, we need to only constrain interior face
// DOFs (this is done one level up), since edge dependencies can be more
@@ -1533,12 +1529,12 @@ SparseMatrix* FiniteElementSpace::RefinementMatrix(int old_ndofs,
localP);
}
FiniteElementSpace::RefinementOperator::RefinementOperator
(const FiniteElementSpace* fespace, Table* old_elem_dof, Table* old_elem_fos,
int old_ndofs)
: fespace(fespace)
, old_elem_dof(old_elem_dof)
, old_elem_fos(old_elem_fos)
FiniteElementSpace::RefinementOperator::RefinementOperator(
const FiniteElementSpace* fespace, Table* old_elem_dof, Table* old_elem_fos,
int old_ndofs)
: fespace(fespace),
old_elem_dof(old_elem_dof),
old_elem_fos(old_elem_fos)
{
MFEM_VERIFY(fespace->GetNE() >= old_elem_dof->Size(),
"Previous mesh is not coarser.");
@@ -1553,7 +1549,7 @@ FiniteElementSpace::RefinementOperator::RefinementOperator
fespace->GetLocalRefinementMatrices(elem_geoms[i], localP[elem_geoms[i]]);
}
ConstructDoFTrans();
ConstructDoFTransArray();
}
FiniteElementSpace::RefinementOperator::RefinementOperator(
@@ -1578,59 +1574,58 @@ FiniteElementSpace::RefinementOperator::RefinementOperator(
old_elem_fos = new Table(*coarse_fes->GetElementToFaceOrientationTable());
}
ConstructDoFTrans();
ConstructDoFTransArray();
}
FiniteElementSpace::RefinementOperator::~RefinementOperator()
{
delete old_elem_dof;
delete old_elem_fos;
for (int i=0; i<old_DoFTrans.Size(); i++)
for (int i=0; i<old_DoFTransArray.Size(); i++)
{
delete old_DoFTrans[i];
delete old_DoFTransArray[i];
}
}
void FiniteElementSpace::RefinementOperator
::ConstructDoFTrans()
void FiniteElementSpace::RefinementOperator::ConstructDoFTransArray()
{
old_DoFTrans.SetSize(Geometry::NUM_GEOMETRIES);
for (int i=0; i<old_DoFTrans.Size(); i++)
old_DoFTransArray.SetSize(Geometry::NUM_GEOMETRIES);
for (int i=0; i<old_DoFTransArray.Size(); i++)
{
old_DoFTrans[i] = NULL;
old_DoFTransArray[i] = NULL;
}
const FiniteElementCollection *fec_ref = fespace->FEColl();
if (dynamic_cast<const ND_FECollection*>(fec_ref))
{
const FiniteElement * nd_tri =
const FiniteElement *nd_tri =
fec_ref->FiniteElementForGeometry(Geometry::TRIANGLE);
if (nd_tri)
{
old_DoFTrans[Geometry::TRIANGLE] =
old_DoFTransArray[Geometry::TRIANGLE] =
new ND_TriDofTransformation(nd_tri->GetOrder());
}
const FiniteElement * nd_tet =
const FiniteElement *nd_tet =
fec_ref->FiniteElementForGeometry(Geometry::TETRAHEDRON);
if (nd_tet)
{
old_DoFTrans[Geometry::TETRAHEDRON] =
old_DoFTransArray[Geometry::TETRAHEDRON] =
new ND_TetDofTransformation(nd_tet->GetOrder());
}
const FiniteElement * nd_pri =
const FiniteElement *nd_pri =
fec_ref->FiniteElementForGeometry(Geometry::PRISM);
if (nd_pri)
{
old_DoFTrans[Geometry::PRISM] =
old_DoFTransArray[Geometry::PRISM] =
new ND_WedgeDofTransformation(nd_pri->GetOrder());
}
}
}
void FiniteElementSpace::RefinementOperator
::Mult(const Vector &x, Vector &y) const
void FiniteElementSpace::RefinementOperator::Mult(const Vector &x,
Vector &y) const
{
Mesh* mesh_ref = fespace->GetMesh();
const CoarseFineTransformations &trans_ref =
@@ -1662,6 +1657,7 @@ void FiniteElementSpace::RefinementOperator
fespace->DofsToVDofs(vd, vdofs);
old_dofs.Copy(old_vdofs);
fespace->DofsToVDofs(vd, old_vdofs, old_ndofs);
x.GetSubVector(old_vdofs, subX);
lP.Mult(subX, subY);
y.SetSubVector(vdofs, subY);
@@ -1670,40 +1666,30 @@ void FiniteElementSpace::RefinementOperator
else
{
old_elem_fos->GetRow(emb.parent, old_Fo);
old_DoFTrans[geom]->SetFaceOrientations(old_Fo);
DofTransformation *new_doftrans = NULL;
VDofTransformation *vdoftrans =
dynamic_cast<VDofTransformation*>(doftrans);
if (vdoftrans)
{
new_doftrans = doftrans;
doftrans = vdoftrans->GetDofTransformation();
}
old_DoFTrans.SetDofTransformation(*old_DoFTransArray[geom]);
old_DoFTrans.SetFaceOrientations(old_Fo);
doftrans->SetVDim();
for (int vd = 0; vd < rvdim; vd++)
{
dofs.Copy(vdofs);
fespace->DofsToVDofs(vd, vdofs);
old_dofs.Copy(old_vdofs);
fespace->DofsToVDofs(vd, old_vdofs, old_ndofs);
x.GetSubVector(old_vdofs, subX);
old_DoFTrans[geom]->InvTransformPrimal(subX);
old_DoFTrans.InvTransformPrimal(subX);
lP.Mult(subX, subY);
doftrans->TransformPrimal(subY);
y.SetSubVector(vdofs, subY);
}
if (vdoftrans)
{
doftrans = new_doftrans;
}
doftrans->SetVDim(rvdim, fespace->GetOrdering());
}
}
}
void FiniteElementSpace::RefinementOperator
::MultTranspose(const Vector &x, Vector &y) const
void FiniteElementSpace::RefinementOperator::MultTranspose(const Vector &x,
Vector &y) const
{
y = 0.0;
@@ -1727,7 +1713,7 @@ void FiniteElementSpace::RefinementOperator
const Geometry::Type geom = mesh_ref->GetElementBaseGeometry(k);
const DenseMatrix &lP = localP[geom](emb.matrix);
DofTransformation * doftrans = fespace->GetElementDofs(k, f_dofs);
DofTransformation *doftrans = fespace->GetElementDofs(k, f_dofs);
old_elem_dof->GetRow(emb.parent, c_dofs);
if (!doftrans)
@@ -1742,7 +1728,6 @@ void FiniteElementSpace::RefinementOperator
fespace->DofsToVDofs(vd, c_vdofs, old_ndofs);
x.GetSubVector(f_vdofs, subX);
for (int p = 0; p < f_dofs.Size(); ++p)
{
if (processed[DecodeDof(f_dofs[p])])
@@ -1750,7 +1735,6 @@ void FiniteElementSpace::RefinementOperator
subX[p] = 0.0;
}
}
lP.MultTranspose(subX, subY);
y.AddElementVector(c_vdofs, subY);
}
@@ -1760,17 +1744,10 @@ void FiniteElementSpace::RefinementOperator
subYt.SetSize(lP.Width());
old_elem_fos->GetRow(emb.parent, old_Fo);
old_DoFTrans[geom]->SetFaceOrientations(old_Fo);
DofTransformation *new_doftrans = NULL;
VDofTransformation *vdoftrans =
dynamic_cast<VDofTransformation*>(doftrans);
if (vdoftrans)
{
new_doftrans = doftrans;
doftrans = vdoftrans->GetDofTransformation();
}
old_DoFTrans.SetDofTransformation(*old_DoFTransArray[geom]);
old_DoFTrans.SetFaceOrientations(old_Fo);
doftrans->SetVDim();
for (int vd = 0; vd < rvdim; vd++)
{
f_dofs.Copy(f_vdofs);
@@ -1787,16 +1764,11 @@ void FiniteElementSpace::RefinementOperator
subX[p] = 0.0;
}
}
lP.MultTranspose(subX, subYt);
old_DoFTrans[geom]->TransformDual(subYt);
old_DoFTrans.TransformDual(subYt);
y.AddElementVector(c_vdofs, subYt);
}
if (vdoftrans)
{
doftrans = new_doftrans;
}
doftrans->SetVDim(rvdim, fespace->GetOrdering());
}
for (int p = 0; p < f_dofs.Size(); ++p)
@@ -2024,8 +1996,8 @@ FiniteElementSpace::DerefinementOperator::~DerefinementOperator()
delete coarse_elem_dof;
}
void FiniteElementSpace::DerefinementOperator
::Mult(const Vector &x, Vector &y) const
void FiniteElementSpace::DerefinementOperator::Mult(const Vector &x,
Vector &y) const
{
Array<int> c_vdofs, f_vdofs;
Vector loc_x, loc_y;
@@ -2227,7 +2199,7 @@ void FiniteElementSpace::Constructor(Mesh *mesh_, NURBSExtension *NURBSext_,
R_transpose.reset();
cP_is_set = false;
ConstructDoFTrans();
ConstructDoFTransArray();
}
else
{
@@ -2239,40 +2211,39 @@ void FiniteElementSpace::Constructor(Mesh *mesh_, NURBSExtension *NURBSext_,
BuildElementToDofTable();
}
void FiniteElementSpace::ConstructDoFTrans()
void FiniteElementSpace::ConstructDoFTransArray()
{
DestroyDoFTrans();
DestroyDoFTransArray();
VDoFTrans.SetVDim(vdim);
DoFTrans.SetSize(Geometry::NUM_GEOMETRIES);
for (int i=0; i<DoFTrans.Size(); i++)
DoFTransArray.SetSize(Geometry::NUM_GEOMETRIES);
for (int i=0; i<DoFTransArray.Size(); i++)
{
DoFTrans[i] = NULL;
DoFTransArray[i] = NULL;
}
if (mesh->Dimension() < 3) { return; }
if (dynamic_cast<const ND_FECollection*>(fec))
{
const FiniteElement * nd_tri =
const FiniteElement *nd_tri =
fec->FiniteElementForGeometry(Geometry::TRIANGLE);
if (nd_tri)
{
DoFTrans[Geometry::TRIANGLE] =
DoFTransArray[Geometry::TRIANGLE] =
new ND_TriDofTransformation(nd_tri->GetOrder());
}
const FiniteElement * nd_tet =
const FiniteElement *nd_tet =
fec->FiniteElementForGeometry(Geometry::TETRAHEDRON);
if (nd_tet)
{
DoFTrans[Geometry::TETRAHEDRON] =
DoFTransArray[Geometry::TETRAHEDRON] =
new ND_TetDofTransformation(nd_tet->GetOrder());
}
const FiniteElement * nd_pri =
const FiniteElement *nd_pri =
fec->FiniteElementForGeometry(Geometry::PRISM);
if (nd_pri)
{
DoFTrans[Geometry::PRISM] =
DoFTransArray[Geometry::PRISM] =
new ND_WedgeDofTransformation(nd_pri->GetOrder());
}
}
@@ -2324,7 +2295,7 @@ void FiniteElementSpace::BuildNURBSFaceToDofTable() const
face_to_be = -1;
for (int b = 0; b < GetNBE(); b++)
{
int f = mesh->GetBdrElementEdgeIndex(b);
int f = mesh->GetBdrElementFaceIndex(b);
face_to_be[f] = b;
}
@@ -2476,7 +2447,7 @@ void FiniteElementSpace::Construct()
ndofs = nvdofs + nedofs + nfdofs + nbdofs;
ConstructDoFTrans();
ConstructDoFTransArray();
// record the current mesh sequence number to detect refinement etc.
mesh_sequence = mesh->GetSequence();
@@ -2501,9 +2472,8 @@ int FiniteElementSpace::MinOrder(VarOrderBits bits)
return 0;
}
void FiniteElementSpace
::CalcEdgeFaceVarOrders(Array<VarOrderBits> &edge_orders,
Array<VarOrderBits> &face_orders) const
void FiniteElementSpace::CalcEdgeFaceVarOrders(
Array<VarOrderBits> &edge_orders, Array<VarOrderBits> &face_orders) const
{
MFEM_ASSERT(IsVariableOrder(), "");
MFEM_ASSERT(Nonconforming(), "");
@@ -2727,8 +2697,8 @@ int FiniteElementSpace::GetNVariants(int entity, int index) const
static const char* msg_orders_changed =
"Element orders changed, you need to Update() the space first.";
DofTransformation *
FiniteElementSpace::GetElementDofs(int elem, Array<int> &dofs) const
void FiniteElementSpace::GetElementDofs(int elem, Array<int> &dofs,
DofTransformation &doftrans) const
{
MFEM_VERIFY(!orders_changed, msg_orders_changed);
@@ -2736,13 +2706,16 @@ FiniteElementSpace::GetElementDofs(int elem, Array<int> &dofs) const
{
elem_dof->GetRow(elem, dofs);
if (DoFTrans[mesh->GetElementBaseGeometry(elem)])
if (DoFTransArray[mesh->GetElementBaseGeometry(elem)])
{
Array<int> Fo;
elem_fos -> GetRow (elem, Fo);
DoFTrans[mesh->GetElementBaseGeometry(elem)]->SetFaceOrientations(Fo);
doftrans.SetDofTransformation(
*DoFTransArray[mesh->GetElementBaseGeometry(elem)]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim();
}
return DoFTrans[mesh->GetElementBaseGeometry(elem)];
return;
}
Array<int> V, E, Eo, F, Fo; // TODO: LocalArray
@@ -2766,10 +2739,12 @@ FiniteElementSpace::GetElementDofs(int elem, Array<int> &dofs) const
{
nfd += fec->GetNumDof(mesh->GetFaceGeometry(F[i]), order);
}
if (DoFTrans[mesh->GetElementBaseGeometry(elem)])
if (DoFTransArray[mesh->GetElementBaseGeometry(elem)])
{
DoFTrans[mesh->GetElementBaseGeometry(elem)]
-> SetFaceOrientations(Fo);
doftrans.SetDofTransformation(
*DoFTransArray[mesh->GetElementBaseGeometry(elem)]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim();
}
}
@@ -2828,54 +2803,18 @@ FiniteElementSpace::GetElementDofs(int elem, Array<int> &dofs) const
dofs.Append(bbase + j);
}
}
return DoFTrans[mesh->GetElementBaseGeometry(elem)];
}
void FiniteElementSpace::GetPatchDofs(int patch, Array<int> &dofs) const
DofTransformation *FiniteElementSpace::GetElementDofs(int elem,
Array<int> &dofs) const
{
MFEM_ASSERT(NURBSext,
"FiniteElementSpace::GetPatchDofs needs a NURBSExtension");
NURBSext->GetPatchDofs(patch, dofs);
DoFTrans.SetDofTransformation(NULL);
GetElementDofs(elem, dofs, DoFTrans);
return DoFTrans.GetDofTransformation() ? &DoFTrans : NULL;
}
const FiniteElement *FiniteElementSpace::GetFE(int i) const
{
if (i < 0 || i >= mesh->GetNE())
{
if (mesh->GetNE() == 0)
{
MFEM_ABORT("Empty MPI partitions are not permitted!");
}
MFEM_ABORT("Invalid element id:" << i << "; minimum allowed:" << 0 <<
", maximum allowed:" << mesh->GetNE()-1);
}
const FiniteElement *FE =
fec->GetFE(mesh->GetElementGeometry(i), GetElementOrderImpl(i));
if (NURBSext)
{
NURBSext->LoadFE(i, FE);
}
else
{
#ifdef MFEM_DEBUG
// consistency check: fec->GetOrder() and FE->GetOrder() should return
// the same value (for standard, constant-order spaces)
if (!IsVariableOrder() && FE->GetDim() > 0)
{
MFEM_ASSERT(FE->GetOrder() == fec->GetOrder(),
"internal error: " <<
FE->GetOrder() << " != " << fec->GetOrder());
}
#endif
}
return FE;
}
DofTransformation *
FiniteElementSpace::GetBdrElementDofs(int bel, Array<int> &dofs) const
void FiniteElementSpace::GetBdrElementDofs(int bel, Array<int> &dofs,
DofTransformation &doftrans) const
{
MFEM_VERIFY(!orders_changed, msg_orders_changed);
@@ -2883,17 +2822,19 @@ FiniteElementSpace::GetBdrElementDofs(int bel, Array<int> &dofs) const
{
bdr_elem_dof->GetRow(bel, dofs);
if (DoFTrans[mesh->GetBdrElementBaseGeometry(bel)])
if (DoFTransArray[mesh->GetBdrElementBaseGeometry(bel)])
{
Array<int> Fo;
bdr_elem_fos -> GetRow (bel, Fo);
DoFTrans[mesh->GetBdrElementBaseGeometry(bel)]->
SetFaceOrientations(Fo);
doftrans.SetDofTransformation(
*DoFTransArray[mesh->GetBdrElementBaseGeometry(bel)]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim();
}
return DoFTrans[mesh->GetBdrElementBaseGeometry(bel)];
return;
}
Array<int> V, E, Eo, Fo; // TODO: LocalArray
Array<int> V, E, Eo; // TODO: LocalArray
int F, oF;
int dim = mesh->Dimension();
@@ -2917,11 +2858,14 @@ FiniteElementSpace::GetBdrElementDofs(int bel, Array<int> &dofs) const
{
mesh->GetBdrElementFace(bel, &F, &oF);
if (DoFTrans[mesh->GetBdrElementBaseGeometry(bel)])
if (DoFTransArray[mesh->GetBdrElementBaseGeometry(bel)])
{
Fo.Append(oF);
DoFTrans[mesh->GetBdrElementBaseGeometry(bel)]->
SetFaceOrientations(Fo);
mfem::Array<int> Fo(1);
Fo[0] = oF;
doftrans.SetDofTransformation(
*DoFTransArray[mesh->GetBdrElementBaseGeometry(bel)]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim();
}
}
@@ -2963,8 +2907,14 @@ FiniteElementSpace::GetBdrElementDofs(int bel, Array<int> &dofs) const
dofs.Append(EncodeDof(nvdofs + nedofs + fbase, ind[j]));
}
}
}
return DoFTrans[mesh->GetBdrElementBaseGeometry(bel)];
DofTransformation *FiniteElementSpace::GetBdrElementDofs(int bel,
Array<int> &dofs) const
{
DoFTrans.SetDofTransformation(NULL);
GetBdrElementDofs(bel, dofs, DoFTrans);
return DoFTrans.GetDofTransformation() ? &DoFTrans : NULL;
}
int FiniteElementSpace::GetFaceDofs(int face, Array<int> &dofs,
@@ -3134,18 +3084,6 @@ int FiniteElementSpace::GetNumElementInteriorDofs(int i) const
GetElementOrderImpl(i));
}
void FiniteElementSpace::GetEdgeInteriorDofs(int i, Array<int> &dofs) const
{
MFEM_VERIFY(!IsVariableOrder(), "not implemented");
int ne = fec->DofForGeometry(Geometry::SEGMENT);
dofs.SetSize (ne);
for (int j = 0, k = nvdofs+i*ne; j < ne; j++, k++)
{
dofs[j] = k;
}
}
void FiniteElementSpace::GetFaceInteriorDofs(int i, Array<int> &dofs) const
{
MFEM_VERIFY(!IsVariableOrder(), "not implemented");
@@ -3170,6 +3108,61 @@ void FiniteElementSpace::GetFaceInteriorDofs(int i, Array<int> &dofs) const
}
}
void FiniteElementSpace::GetEdgeInteriorDofs(int i, Array<int> &dofs) const
{
MFEM_VERIFY(!IsVariableOrder(), "not implemented");
int ne = fec->DofForGeometry(Geometry::SEGMENT);
dofs.SetSize (ne);
for (int j = 0, k = nvdofs+i*ne; j < ne; j++, k++)
{
dofs[j] = k;
}
}
void FiniteElementSpace::GetPatchDofs(int patch, Array<int> &dofs) const
{
MFEM_ASSERT(NURBSext,
"FiniteElementSpace::GetPatchDofs needs a NURBSExtension");
NURBSext->GetPatchDofs(patch, dofs);
}
const FiniteElement *FiniteElementSpace::GetFE(int i) const
{
if (i < 0 || i >= mesh->GetNE())
{
if (mesh->GetNE() == 0)
{
MFEM_ABORT("Empty MPI partitions are not permitted!");
}
MFEM_ABORT("Invalid element id:" << i << "; minimum allowed:" << 0 <<
", maximum allowed:" << mesh->GetNE()-1);
}
const FiniteElement *FE =
fec->GetFE(mesh->GetElementGeometry(i), GetElementOrderImpl(i));
if (NURBSext)
{
NURBSext->LoadFE(i, FE);
}
else
{
#ifdef MFEM_DEBUG
// consistency check: fec->GetOrder() and FE->GetOrder() should return
// the same value (for standard, constant-order spaces)
if (!IsVariableOrder() && FE->GetDim() > 0)
{
MFEM_ASSERT(FE->GetOrder() == fec->GetOrder(),
"internal error: " <<
FE->GetOrder() << " != " << fec->GetOrder());
}
#endif
}
return FE;
}
const FiniteElement *FiniteElementSpace::GetBE(int i) const
{
int order = fec->GetOrder();
@@ -3242,8 +3235,8 @@ const FiniteElement *FiniteElementSpace::GetEdgeElement(int i,
return fec->GetFE(Geometry::SEGMENT, eo);
}
const FiniteElement *FiniteElementSpace
::GetTraceElement(int i, Geometry::Type geom_type) const
const FiniteElement *FiniteElementSpace::GetTraceElement(
int i, Geometry::Type geom_type) const
{
return fec->TraceFiniteElementForGeometry(geom_type);
}
@@ -3283,7 +3276,7 @@ void FiniteElementSpace::Destroy()
}
E2BFQ_array.SetSize(0);
DestroyDoFTrans();
DestroyDoFTransArray();
dof_elem_array.DeleteAll();
dof_ldof_array.DeleteAll();
@@ -3301,19 +3294,18 @@ void FiniteElementSpace::Destroy()
delete bdr_elem_dof;
delete bdr_elem_fos;
delete face_dof;
delete [] bdofs;
}
ceed::RemoveBasisAndRestriction(this);
}
void FiniteElementSpace::DestroyDoFTrans()
void FiniteElementSpace::DestroyDoFTransArray()
{
for (int i = 0; i < DoFTrans.Size(); i++)
for (int i = 0; i < DoFTransArray.Size(); i++)
{
delete DoFTrans[i];
delete DoFTransArray[i];
}
DoFTrans.SetSize(0);
DoFTransArray.SetSize(0);
}
void FiniteElementSpace::GetTransferOperator(
+56 -21
View File
@@ -271,8 +271,8 @@ protected:
int own_ext;
mutable Array<int> face_to_be; // NURBS FE space only
Array<DofTransformation*> DoFTrans;
mutable VDofTransformation VDoFTrans;
Array<StatelessDofTransformation *> DoFTransArray;
mutable DofTransformation DoFTrans;
/** Matrix representing the prolongation from the global conforming dofs to
a set of intermediate partially conforming dofs, e.g. the dofs associated
@@ -328,8 +328,8 @@ protected:
void Construct();
void Destroy();
void ConstructDoFTrans();
void DestroyDoFTrans();
void ConstructDoFTransArray();
void DestroyDoFTransArray();
void BuildElementToDofTable() const;
void BuildBdrElementToDofTable() const;
@@ -416,10 +416,10 @@ protected:
Table* old_elem_dof; // Owned.
Table* old_elem_fos; // Owned.
Array<DofTransformation*> old_DoFTrans;
mutable VDofTransformation old_VDoFTrans;
Array<StatelessDofTransformation*> old_DoFTransArray;
mutable DofTransformation old_DoFTrans;
void ConstructDoFTrans();
void ConstructDoFTransArray();
public:
/** Construct the operator based on the elem_dof table of the original
@@ -803,7 +803,16 @@ public:
/// with triangular faces.
///
/// @note The returned object should NOT be deleted by the caller.
virtual DofTransformation *GetElementDofs(int elem, Array<int> &dofs) const;
DofTransformation *GetElementDofs(int elem, Array<int> &dofs) const;
/// @brief The same as GetElementDofs(), but with a user-allocated
/// DofTransformation object. @a doftrans must be allocated in advance and
/// will be owned by the caller. The user can use the
/// DofTransformation::GetDofTransformation method on the returned
/// @a doftrans object to detect if the DofTransformation should actually be
/// used.
virtual void GetElementDofs(int elem, Array<int> &dofs,
DofTransformation &doftrans) const;
/// @brief Returns indices of degrees of freedom for boundary element 'bel'.
/// The returned indices are offsets into an @ref ldof vector. See also
@@ -817,13 +826,16 @@ public:
/// with triangular faces.
///
/// @note The returned object should NOT be deleted by the caller.
virtual DofTransformation *GetBdrElementDofs(int bel,
Array<int> &dofs) const;
DofTransformation *GetBdrElementDofs(int bel, Array<int> &dofs) const;
/** @brief Returns indices of degrees of freedom for NURBS patch index
@a patch. Cartesian ordering is used, for the tensor-product degrees of
freedom. */
void GetPatchDofs(int patch, Array<int> &dofs) const;
/// @brief The same as GetBdrElementDofs(), but with a user-allocated
/// DofTransformation object. @a doftrans must be allocated in advance and
/// will be owned by the caller. The user can use the
/// DofTransformation::GetDofTransformation method on the returned
/// @a doftrans object to detect if the DofTransformation should actually be
/// used.
virtual void GetBdrElementDofs(int bel, Array<int> &dofs,
DofTransformation &doftrans) const;
/// @brief Returns the indices of the degrees of freedom for the specified
/// face, including the DOFs for the edges and the vertices of the face.
@@ -870,6 +882,13 @@ public:
/// GetElementInteriorVDofs().
void GetElementInteriorDofs(int i, Array<int> &dofs) const;
/// @brief Returns the number of degrees of freedom associated with the
/// interior of the specified element.
///
/// See GetElementInteriorDofs() for more information or to obtain the
/// relevant indices.
int GetNumElementInteriorDofs(int i) const;
/// @brief Returns the indices of the degrees of freedom for the interior
/// of the specified face.
///
@@ -882,13 +901,6 @@ public:
/// GetFaceInteriorVDofs().
void GetFaceInteriorDofs(int i, Array<int> &dofs) const;
/// @brief Returns the number of degrees of freedom associated with the
/// interior of the specified element.
///
/// See GetElementInteriorDofs() for more information or to obtain the
/// relevant indices.
int GetNumElementInteriorDofs(int i) const;
/// @brief Returns the indices of the degrees of freedom for the interior
/// of the specified edge.
///
@@ -897,6 +909,11 @@ public:
void GetEdgeInteriorDofs(int i, Array<int> &dofs) const;
///@}
/** @brief Returns indices of degrees of freedom for NURBS patch index
@a patch. Cartesian ordering is used, for the tensor-product degrees of
freedom. */
void GetPatchDofs(int patch, Array<int> &dofs) const;
/// @anchor dof2vdof @name DoF To VDoF Conversion methods
/// These methods convert between local dof and local vector dof using the
/// appropriate relationship based on the Ordering::Type defined in this
@@ -1023,6 +1040,15 @@ public:
/// @note The returned object should NOT be deleted by the caller.
DofTransformation *GetElementVDofs(int i, Array<int> &vdofs) const;
/// @brief The same as GetElementVDofs(), but with a user-allocated
/// DofTransformation object. @a doftrans must be allocated in advance and
/// will be owned by the caller. The user can use the
/// DofTransformation::GetDofTransformation method on the returned
/// @a doftrans object to detect if the DofTransformation should actually be
/// used.
void GetElementVDofs(int i, Array<int> &vdofs,
DofTransformation &doftrans) const;
/// @brief Returns indices of degrees of freedom for @a i'th boundary
/// element.
/// The returned indices are offsets into an @ref ldof vector with @b vdim
@@ -1038,6 +1064,15 @@ public:
/// @note The returned object should NOT be deleted by the caller.
DofTransformation *GetBdrElementVDofs(int i, Array<int> &vdofs) const;
/// @brief The same as GetBdrElementVDofs(), but with a user-allocated
/// DofTransformation object. @a doftrans must be allocated in advance and
/// will be owned by the caller. The user can use the
/// DofTransformation::GetDofTransformation method on the returned
/// @a doftrans object to detect if the DofTransformation should actually be
/// used.
void GetBdrElementVDofs(int i, Array<int> &vdofs,
DofTransformation &doftrans) const;
/// Returns indices of degrees of freedom in @a vdofs for NURBS patch @a i.
void GetPatchVDofs(int i, Array<int> &vdofs) const;
+9 -9
View File
@@ -31,13 +31,13 @@ FmsBasisTypeToMfemBasis(FmsBasisType b)
switch (b)
{
case FMS_NODAL_GAUSS_OPEN:
retval = mfem::BasisType::GaussLegendre;;
retval = mfem::BasisType::GaussLegendre;
break;
case FMS_NODAL_GAUSS_CLOSED:
retval = mfem::BasisType::GaussLobatto;;
retval = mfem::BasisType::GaussLobatto;
break;
case FMS_POSITIVE:
retval = mfem::BasisType::Positive;;
retval = mfem::BasisType::Positive;
break;
case FMS_NODAL_UNIFORM_OPEN:
retval = mfem::BasisType::OpenUniform;
@@ -1812,22 +1812,22 @@ MeshToFmsMesh(const Mesh *mmesh, FmsMesh *fmesh, FmsComponent *volume)
switch (betype)
{
case Element::POINT:
bdr_eles[FMS_VERTEX].push_back(mmesh->GetBdrElementEdgeIndex(i));
bdr_eles[FMS_VERTEX].push_back(mmesh->GetBdrElementFaceIndex(i));
break;
case Element::SEGMENT:
bdr_eles[FMS_EDGE].push_back(mmesh->GetBdrElementEdgeIndex(i));
bdr_eles[FMS_EDGE].push_back(mmesh->GetBdrElementFaceIndex(i));
break;
case Element::TRIANGLE:
bdr_eles[FMS_TRIANGLE].push_back(mmesh->GetBdrElementEdgeIndex(i));
bdr_eles[FMS_TRIANGLE].push_back(mmesh->GetBdrElementFaceIndex(i));
break;
case Element::QUADRILATERAL:
bdr_eles[FMS_QUADRILATERAL].push_back(mmesh->GetBdrElementEdgeIndex(i));
bdr_eles[FMS_QUADRILATERAL].push_back(mmesh->GetBdrElementFaceIndex(i));
break;
case Element::TETRAHEDRON:
bdr_eles[FMS_TETRAHEDRON].push_back(mmesh->GetBdrElementEdgeIndex(i));
bdr_eles[FMS_TETRAHEDRON].push_back(mmesh->GetBdrElementFaceIndex(i));
break;
case Element::HEXAHEDRON:
bdr_eles[FMS_HEXAHEDRON].push_back(mmesh->GetBdrElementEdgeIndex(i));
bdr_eles[FMS_HEXAHEDRON].push_back(mmesh->GetBdrElementFaceIndex(i));
break;
default:
MFEM_WARNING("Unsupported boundary element " << betype << " at boundary index "
+596 -508
View File
File diff suppressed because it is too large Load Diff
+15 -15
View File
@@ -65,10 +65,10 @@ public:
/** @brief Return an IntegrationRule consisting of all vertices of the given
Geometry::Type, @a GeomType. */
const IntegrationRule *GetVertices(int GeomType);
const IntegrationRule *GetVertices(int GeomType) const;
/// Return the center of the given Geometry::Type, @a GeomType.
const IntegrationPoint &GetCenter(int GeomType)
const IntegrationPoint &GetCenter(int GeomType) const
{ return GeomCenter[GeomType]; }
/// Get a random point in the reference element specified by @a GeomType.
@@ -97,9 +97,9 @@ public:
const DenseMatrix &GetGeomToPerfGeomJac(int GeomType) const
{ return *GeomToPerfGeomJac[GeomType]; }
DenseMatrix *GetPerfGeomToGeomJac(int GeomType)
const DenseMatrix *GetPerfGeomToGeomJac(int GeomType) const
{ return PerfGeomToGeomJac[GeomType]; }
void GetPerfPointMat(int GeomType, DenseMatrix &pm);
void GetPerfPointMat(int GeomType, DenseMatrix &pm) const;
void JacToPerfJac(int GeomType, const DenseMatrix &J,
DenseMatrix &PJ) const;
@@ -123,7 +123,7 @@ public:
}
/// Return the number of boundary "faces" of a given Geometry::Type.
int NumBdr(int GeomType) { return NumBdrArray[GeomType]; }
int NumBdr(int GeomType) const { return NumBdrArray[GeomType]; }
};
template <> struct
@@ -317,27 +317,27 @@ public:
int Type;
RefinedGeometry(int NPts, int NRefG, int NRefE, int NBdrE = 0) :
RefPts(NPts), RefGeoms(NRefG), RefEdges(NRefE), NumBdrEdges(NBdrE) { }
RefPts(NPts), RefGeoms(NRefG), RefEdges(NRefE), NumBdrEdges(NBdrE) {}
};
class GeometryRefiner
{
private:
int type; // Quadrature1D type (ClosedUniform is default)
int Type; // Quadrature1D type (ClosedUniform is default)
Array<RefinedGeometry *> RGeom[Geometry::NumGeom];
Array<IntegrationRule *> IntPts[Geometry::NumGeom];
RefinedGeometry *FindInRGeom(Geometry::Type Geom, int Times, int ETimes,
int Type);
IntegrationRule *FindInIntPts(Geometry::Type Geom, int NPts);
RefinedGeometry *FindInRGeom(Geometry::Type Geom, int Times,
int ETimes) const;
IntegrationRule *FindInIntPts(Geometry::Type Geom, int NPts) const;
public:
GeometryRefiner();
GeometryRefiner(int t = Quadrature1D::ClosedUniform) : Type(t) {}
/// Set the Quadrature1D type of points to use for subdivision.
void SetType(const int t) { type = t; }
void SetType(int t) { Type = t; }
/// Get the Quadrature1D type of points used for subdivision.
int GetType() const { return type; }
int GetType() const { return Type; }
RefinedGeometry *Refine(Geometry::Type Geom, int Times, int ETimes = 1);
@@ -345,10 +345,10 @@ public:
const IntegrationRule *RefineInterior(Geometry::Type Geom, int Times);
/// Get the Refinement level based on number of points
virtual int GetRefinementLevelFromPoints(Geometry::Type Geom, int Npts);
static int GetRefinementLevelFromPoints(Geometry::Type Geom, int Npts);
/// Get the Refinement level based on number of elements
virtual int GetRefinementLevelFromElems(Geometry::Type geom, int Npts);
static int GetRefinementLevelFromElems(Geometry::Type geom, int Npts);
~GeometryRefiner();
};
+4
View File
@@ -120,6 +120,10 @@ public:
/// Return the serial hybridized matrix.
SparseMatrix &GetMatrix() { return *H; }
/// Return the transpose of the serial constraint matrix.
SparseMatrix &GetConstraintMatrixTranspose()
{ if (!Ct) mfem_error("Ct has not been constructed!"); return *Ct; }
#ifdef MFEM_USE_MPI
/// Return the parallel hybridized matrix.
HypreParMatrix &GetParallelMatrix() { return *pH.Is<HypreParMatrix>(); }
+73 -48
View File
@@ -737,7 +737,7 @@ void QuadratureFunctions1D::GivePolyPoints(const int np, double *pts,
ClosedGL(np, &ir);
break;
}
default:
case Quadrature1D::Invalid:
{
MFEM_ABORT("Asking for an unknown type of 1D Quadrature points, "
"type = " << type);
@@ -831,7 +831,10 @@ void QuadratureFunctions1D::CalculateUniformWeights(IntegrationRule *ir,
hinv = p+1;
ihoffset = 1;
break;
default:
case Quadrature1D::GaussLegendre:
case Quadrature1D::GaussLobatto:
case Quadrature1D::ClosedGL:
case Quadrature1D::Invalid:
MFEM_ABORT("invalid Quadrature1D type: " << type);
}
// set w0 = (-1)^p*(p!)/(hinv^p)
@@ -940,10 +943,10 @@ IntegrationRules IntRules(0, Quadrature1D::GaussLegendre);
IntegrationRules RefinedIntRules(1, Quadrature1D::GaussLegendre);
IntegrationRules::IntegrationRules(int Ref, int type_):
quad_type(type_)
IntegrationRules::IntegrationRules(int ref, int type)
: quad_type(type)
{
refined = Ref;
refined = ref;
if (refined < 0) { own_rules = 0; return; }
@@ -975,11 +978,19 @@ IntegrationRules::IntegrationRules(int Ref, int type_):
CubeIntRules.SetSize(32, h_mt);
CubeIntRules = NULL;
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
IntRuleLocks.SetSize(Geometry::NUM_GEOMETRIES, h_mt);
for (int i = 0; i < Geometry::NUM_GEOMETRIES; i++)
{
omp_init_lock(&IntRuleLocks[i]);
}
#endif
}
const IntegrationRule &IntegrationRules::Get(int GeomType, int Order)
{
Array<IntegrationRule *> *ir_array;
Array<IntegrationRule *> *ir_array = NULL;
switch (GeomType)
{
@@ -991,9 +1002,9 @@ const IntegrationRule &IntegrationRules::Get(int GeomType, int Order)
case Geometry::CUBE: ir_array = &CubeIntRules; break;
case Geometry::PRISM: ir_array = &PrismIntRules; break;
case Geometry::PYRAMID: ir_array = &PyramidIntRules; break;
default:
mfem_error("IntegrationRules::Get(...) : Unknown geometry type!");
ir_array = NULL;
case Geometry::INVALID:
case Geometry::NUM_GEOMETRIES:
MFEM_ABORT("Unknown type of reference element!");
}
if (Order < 0)
@@ -1001,36 +1012,35 @@ const IntegrationRule &IntegrationRules::Get(int GeomType, int Order)
Order = 0;
}
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
omp_set_lock(&IntRuleLocks[GeomType]);
#endif
if (!HaveIntRule(*ir_array, Order))
{
#ifdef MFEM_USE_LEGACY_OPENMP
#pragma omp critical
#endif
{
if (!HaveIntRule(*ir_array, Order))
{
IntegrationRule *ir = GenerateIntegrationRule(GeomType, Order);
IntegrationRule *ir = GenerateIntegrationRule(GeomType, Order);
#ifdef MFEM_DEBUG
int RealOrder = Order;
while (RealOrder+1 < ir_array->Size() &&
(*ir_array)[RealOrder+1] == ir)
{
RealOrder++;
}
MFEM_VERIFY(RealOrder == ir->GetOrder(), "internal error");
#else
MFEM_CONTRACT_VAR(ir);
#endif
}
int RealOrder = Order;
while (RealOrder+1 < ir_array->Size() && (*ir_array)[RealOrder+1] == ir)
{
RealOrder++;
}
MFEM_VERIFY(RealOrder == ir->GetOrder(), "internal error");
#else
MFEM_CONTRACT_VAR(ir);
#endif
}
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
omp_unset_lock(&IntRuleLocks[GeomType]);
#endif
return *(*ir_array)[Order];
}
void IntegrationRules::Set(int GeomType, int Order, IntegrationRule &IntRule)
{
Array<IntegrationRule *> *ir_array;
Array<IntegrationRule *> *ir_array = NULL;
switch (GeomType)
{
@@ -1042,11 +1052,15 @@ void IntegrationRules::Set(int GeomType, int Order, IntegrationRule &IntRule)
case Geometry::CUBE: ir_array = &CubeIntRules; break;
case Geometry::PRISM: ir_array = &PrismIntRules; break;
case Geometry::PYRAMID: ir_array = &PyramidIntRules; break;
default:
mfem_error("IntegrationRules::Set(...) : Unknown geometry type!");
ir_array = NULL;
case Geometry::INVALID:
case Geometry::NUM_GEOMETRIES:
MFEM_ABORT("Unknown type of reference element!");
}
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
omp_set_lock(&IntRuleLocks[GeomType]);
#endif
if (HaveIntRule(*ir_array, Order))
{
MFEM_ABORT("Overwriting set rules is not supported!");
@@ -1055,16 +1069,19 @@ void IntegrationRules::Set(int GeomType, int Order, IntegrationRule &IntRule)
AllocIntRule(*ir_array, Order);
(*ir_array)[Order] = &IntRule;
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
omp_unset_lock(&IntRuleLocks[GeomType]);
#endif
}
void IntegrationRules::DeleteIntRuleArray(Array<IntegrationRule *> &ir_array)
void IntegrationRules::DeleteIntRuleArray(
Array<IntegrationRule *> &ir_array) const
{
int i;
IntegrationRule *ir = NULL;
// Many of the intrules have multiple contiguous copies in the ir_array
// so we have to be careful to not delete them twice.
for (i = 0; i < ir_array.Size(); i++)
IntegrationRule *ir = NULL;
for (int i = 0; i < ir_array.Size(); i++)
{
if (ir_array[i] != NULL && ir_array[i] != ir)
{
@@ -1076,6 +1093,13 @@ void IntegrationRules::DeleteIntRuleArray(Array<IntegrationRule *> &ir_array)
IntegrationRules::~IntegrationRules()
{
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
for (int i = 0; i < Geometry::NUM_GEOMETRIES; i++)
{
omp_destroy_lock(&IntRuleLocks[i]);
}
#endif
if (!own_rules) { return; }
DeleteIntRuleArray(PointIntRules);
@@ -1110,10 +1134,11 @@ IntegrationRule *IntegrationRules::GenerateIntegrationRule(int GeomType,
return PrismIntegrationRule(Order);
case Geometry::PYRAMID:
return PyramidIntegrationRule(Order);
default:
mfem_error("IntegrationRules::Set(...) : Unknown geometry type!");
return NULL;
case Geometry::INVALID:
case Geometry::NUM_GEOMETRIES:
MFEM_ABORT("Unknown type of reference element!");
}
return NULL;
}
@@ -1122,7 +1147,7 @@ IntegrationRule *IntegrationRules::PointIntegrationRule(int Order)
{
if (Order > 1)
{
mfem_error("Point Integration Rule of Order > 1 not defined");
MFEM_ABORT("Point Integration Rule of Order > 1 not defined");
return NULL;
}
@@ -1185,7 +1210,7 @@ IntegrationRule *IntegrationRules::SegmentIntegrationRule(int Order)
QuadratureFunctions1D::OpenHalfUniform(n, ir);
break;
}
default:
case Quadrature1D::Invalid:
{
MFEM_ABORT("unknown Quadrature1D type: " << quad_type);
}
@@ -1762,8 +1787,8 @@ IntegrationRule *IntegrationRules::PyramidIntegrationRule(int Order)
for (int k=0; k<npts; k++)
{
const IntegrationPoint & ipc = irc.IntPoint(k);
IntegrationPoint & ipp = PyramidIntRules[Order]->IntPoint(k);
const IntegrationPoint &ipc = irc.IntPoint(k);
IntegrationPoint &ipp = PyramidIntRules[Order]->IntPoint(k);
ipp.x = ipc.x * (1.0 - ipc.z);
ipp.y = ipc.y * (1.0 - ipc.z);
ipp.z = ipc.z;
@@ -1775,8 +1800,8 @@ IntegrationRule *IntegrationRules::PyramidIntegrationRule(int Order)
// Integration rules for reference prism
IntegrationRule *IntegrationRules::PrismIntegrationRule(int Order)
{
const IntegrationRule & irt = Get(Geometry::TRIANGLE, Order);
const IntegrationRule & irs = Get(Geometry::SEGMENT, Order);
const IntegrationRule &irt = Get(Geometry::TRIANGLE, Order);
const IntegrationRule &irs = Get(Geometry::SEGMENT, Order);
int nt = irt.GetNPoints();
int ns = irs.GetNPoints();
AllocIntRule(PrismIntRules, Order);
@@ -1790,12 +1815,12 @@ IntegrationRule *IntegrationRules::PrismIntegrationRule(int Order)
for (int ks=0; ks<ns; ks++)
{
const IntegrationPoint & ips = irs.IntPoint(ks);
const IntegrationPoint &ips = irs.IntPoint(ks);
for (int kt=0; kt<nt; kt++)
{
int kp = ks * nt + kt;
const IntegrationPoint & ipt = irt.IntPoint(kt);
IntegrationPoint & ipp = PrismIntRules[Order]->IntPoint(kp);
const IntegrationPoint &ipt = irt.IntPoint(kt);
IntegrationPoint &ipp = PrismIntRules[Order]->IntPoint(kp);
ipp.x = ipt.x;
ipp.y = ipt.y;
ipp.z = ips.x;
+11 -5
View File
@@ -14,6 +14,9 @@
#include "../config/config.hpp"
#include "../general/array.hpp"
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
#include <omp.h>
#endif
#include <vector>
#include <map>
@@ -428,14 +431,18 @@ private:
Array<IntegrationRule *> PrismIntRules;
Array<IntegrationRule *> CubeIntRules;
void AllocIntRule(Array<IntegrationRule *> &ir_array, int Order)
#if defined(MFEM_THREAD_SAFE) && defined(MFEM_USE_OPENMP)
Array<omp_lock_t> IntRuleLocks;
#endif
void AllocIntRule(Array<IntegrationRule *> &ir_array, int Order) const
{
if (ir_array.Size() <= Order)
{
ir_array.SetSize(Order + 1, NULL);
}
}
bool HaveIntRule(Array<IntegrationRule *> &ir_array, int Order)
bool HaveIntRule(Array<IntegrationRule *> &ir_array, int Order) const
{
return (ir_array.Size() > Order && ir_array[Order] != NULL);
}
@@ -443,6 +450,7 @@ private:
{
return Order | 1; // valid for all quad_type's
}
void DeleteIntRuleArray(Array<IntegrationRule *> &ir_array) const;
/// The following methods allocate new IntegrationRule objects without
/// checking if they already exist. To avoid memory leaks use
@@ -457,12 +465,10 @@ private:
IntegrationRule *PrismIntegrationRule(int Order);
IntegrationRule *CubeIntegrationRule(int Order);
void DeleteIntRuleArray(Array<IntegrationRule *> &ir_array);
public:
/// Sets initial sizes for the integration rule arrays, but rules
/// are defined the first time they are requested with the Get method.
explicit IntegrationRules(int Ref = 0,
explicit IntegrationRules(int ref = 0,
int type = Quadrature1D::GaussLegendre);
/// Returns an integration rule for given GeomType and Order.
+1597
View File
File diff suppressed because it is too large Load Diff
+1936
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -137,7 +137,7 @@ bool LinearForm::SupportsDevice() const
// Make sure every boundary element corresponds to a boundary face
for (int be = 0; be < fes->GetNBE(); ++be)
{
const int f = mesh.GetBdrElementEdgeIndex(be);
const int f = mesh.GetBdrElementFaceIndex(be);
const auto face_info = mesh.GetFaceInformation(f);
if (!face_info.IsBoundary())
{
+1 -1
View File
@@ -148,7 +148,7 @@ void LinearFormExtension::Update()
std::unordered_map<int,int> f_to_be;
for (int i = 0; i < mesh.GetNBE(); ++i)
{
const int f = mesh.GetBdrElementEdgeIndex(i);
const int f = mesh.GetBdrElementFaceIndex(i);
f_to_be[f] = i;
}
MFEM_VERIFY(size_t(nf_bdr) == f_to_be.size(), "Incompatible sizes");
+8 -8
View File
@@ -257,13 +257,13 @@ void BatchedLOR_AMS::FormCoordinateVectors(const Vector &X_vert)
// vertices of the LOR mesh. The vertex coordinates are already computed in
// E-vector format and passed in in X_vert.
//
// In this function, we need to convert X_vert (which has the shape (dim,
// In this function, we need to convert X_vert (which has the shape (sdim,
// ndof_per_el, nel_ho)) to T-DOF format.
//
// We place the results in the vector xyz_tvec, which has shape (ntdofs, dim)
// We place the results in the vector xyz_tvec, which has shape (ntdofs, sdim)
// and then make the hypre vectors x, y, and z point to subvectors.
//
// In 2D, z is NULL.
// When the space dimension is 2, z is NULL.
// Create the H1 vertex space and get the element restriction
ElementDofOrdering ordering = ElementDofOrdering::LEXICOGRAPHIC;
@@ -275,17 +275,17 @@ void BatchedLOR_AMS::FormCoordinateVectors(const Vector &X_vert)
const int nel_ho = vert_fes.GetNE();
const int ndp1 = order + 1;
const int ndof_per_el = static_cast<int>(pow(ndp1, dim));
const int sdim = dim;
const int sdim = vert_fes.GetMesh()->SpaceDimension();
const int ntdofs = R->Height();
const MemoryClass mc = GetHypreMemoryClass();
bool dev = (mc == MemoryClass::DEVICE);
xyz_tvec = new Vector(ntdofs*dim);
xyz_tvec = new Vector(ntdofs*sdim);
auto xyz_tv = Reshape(HypreWrite(xyz_tvec->GetMemory()), ntdofs, dim);
auto xyz_tv = Reshape(HypreWrite(xyz_tvec->GetMemory()), ntdofs, sdim);
const auto xyz_e =
Reshape(HypreRead(X_vert.GetMemory()), dim, ndof_per_el, nel_ho);
Reshape(HypreRead(X_vert.GetMemory()), sdim, ndof_per_el, nel_ho);
const auto d_offsets = HypreRead(el_restr->Offsets().GetMemory());
const auto d_indices = HypreRead(el_restr->Indices().GetMemory());
const auto ltdof_ldof = HypreRead(R->GetMemoryJ());
@@ -309,7 +309,7 @@ void BatchedLOR_AMS::FormCoordinateVectors(const Vector &X_vert)
x = new HypreParVector(vert_fes.GetComm(), glob_size, d_x_ptr, cols, dev);
double *d_y_ptr = xyz_tv + 1*ntdofs;
y = new HypreParVector(vert_fes.GetComm(), glob_size, d_y_ptr, cols, dev);
if (dim == 3)
if (sdim == 3)
{
double *d_z_ptr = xyz_tv + 2*ntdofs;
z = new HypreParVector(vert_fes.GetComm(), glob_size, d_z_ptr, cols, dev);
+37 -31
View File
@@ -77,6 +77,7 @@ void BatchedLORAssembly::FormLORVertexCoordinates(FiniteElementSpace &fes_ho,
// Get nodal points at the LOR vertices
const int dim = mesh_ho.Dimension();
const int sdim = mesh_ho.SpaceDimension();
const int nel_ho = mesh_ho.GetNE();
const int order = fes_ho.GetMaxElementOrder();
const int nd1d = order + 1;
@@ -94,7 +95,7 @@ void BatchedLORAssembly::FormLORVertexCoordinates(FiniteElementSpace &fes_ho,
IntegrationRule ir = GetCollocatedIntRule(fes_ho);
// Map from nodal E-vector to Q-vector at the LOR vertex points
X_vert.SetSize(dim*ndof_per_el*nel_ho);
X_vert.SetSize(sdim*ndof_per_el*nel_ho);
const QuadratureInterpolator *quad_interp =
nodal_fes->GetQuadratureInterpolator(ir);
quad_interp->SetOutputLayout(QVectorLayout::byVDIM);
@@ -380,44 +381,49 @@ void BatchedLORAssembly::SparseIJToCSR(OperatorHandle &A) const
FillJAndData(*A_mat);
}
template <int ORDER, int SDIM, typename LOR_KERNEL>
static void Assemble_(LOR_KERNEL &kernel, int dim)
{
if (dim == 2) { kernel.template Assemble2D<ORDER,SDIM>(); }
else if (dim == 3) { kernel.template Assemble3D<ORDER>(); }
else { MFEM_ABORT("Unsupported dimension"); }
}
template <int ORDER, typename LOR_KERNEL>
static void Assemble_(LOR_KERNEL &kernel, int dim, int sdim)
{
if (sdim == 2) { Assemble_<ORDER,2>(kernel, dim); }
else if (sdim == 3) { Assemble_<ORDER,3>(kernel, dim); }
else { MFEM_ABORT("Unsupported space dimension."); }
}
template <typename LOR_KERNEL>
static void Assemble_(LOR_KERNEL &kernel, int dim, int sdim, int order)
{
switch (order)
{
case 1: Assemble_<1>(kernel, dim, sdim); break;
case 2: Assemble_<2>(kernel, dim, sdim); break;
case 3: Assemble_<3>(kernel, dim, sdim); break;
case 4: Assemble_<4>(kernel, dim, sdim); break;
case 5: Assemble_<5>(kernel, dim, sdim); break;
case 6: Assemble_<6>(kernel, dim, sdim); break;
case 7: Assemble_<7>(kernel, dim, sdim); break;
case 8: Assemble_<8>(kernel, dim, sdim); break;
default: MFEM_ABORT("No kernel order " << order << "!");
}
}
template <typename LOR_KERNEL>
void BatchedLORAssembly::AssemblyKernel(BilinearForm &a)
{
LOR_KERNEL kernel(a, fes_ho, X_vert, sparse_ij, sparse_mapping);
const int dim = fes_ho.GetMesh()->Dimension();
const int sdim = fes_ho.GetMesh()->SpaceDimension();
const int order = fes_ho.GetMaxElementOrder();
if (dim == 2)
{
switch (order)
{
case 1: kernel.template Assemble2D<1>(); break;
case 2: kernel.template Assemble2D<2>(); break;
case 3: kernel.template Assemble2D<3>(); break;
case 4: kernel.template Assemble2D<4>(); break;
case 5: kernel.template Assemble2D<5>(); break;
case 6: kernel.template Assemble2D<6>(); break;
case 7: kernel.template Assemble2D<7>(); break;
case 8: kernel.template Assemble2D<8>(); break;
default: MFEM_ABORT("No kernel order " << order << "!");
}
}
else if (dim == 3)
{
switch (order)
{
case 1: kernel.template Assemble3D<1>(); break;
case 2: kernel.template Assemble3D<2>(); break;
case 3: kernel.template Assemble3D<3>(); break;
case 4: kernel.template Assemble3D<4>(); break;
case 5: kernel.template Assemble3D<5>(); break;
case 6: kernel.template Assemble3D<6>(); break;
case 7: kernel.template Assemble3D<7>(); break;
case 8: kernel.template Assemble3D<8>(); break;
default: MFEM_ABORT("No kernel order " << order << "!");
}
}
Assemble_(kernel, dim, sdim, order);
}
void BatchedLORAssembly::AssembleWithoutBC(BilinearForm &a, OperatorHandle &A)
+9 -2
View File
@@ -22,15 +22,22 @@ namespace mfem
class BatchedLOR_H1 : BatchedLORKernel
{
public:
template <int ORDER> void Assemble2D();
template <int ORDER, int SDIM> void Assemble2D();
template <int ORDER> void Assemble3D();
BatchedLOR_H1(BilinearForm &a,
FiniteElementSpace &fes_ho_,
Vector &X_vert_,
Vector &sparse_ij_,
Array<int> &sparse_mapping_);
Array<int> &sparse_mapping_)
: BatchedLORKernel(fes_ho_, X_vert_, sparse_ij_, sparse_mapping_)
{
ProjectLORCoefficient<MassIntegrator>(a, c1);
ProjectLORCoefficient<DiffusionIntegrator>(a, c2);
}
};
}
#include "lor_h1_impl.hpp"
#endif
+2 -56
View File
@@ -9,7 +9,6 @@
// terms of the BSD-3 license. We welcome feedback and contributions, see file
// CONTRIBUTING.md for details.
#include "lor_h1.hpp"
#include "lor_util.hpp"
#include "../../linalg/dtensor.hpp"
#include "../../general/forall.hpp"
@@ -17,7 +16,7 @@
namespace mfem
{
template <int ORDER>
template <int ORDER, int SDIM>
void BatchedLOR_H1::Assemble2D()
{
const int nel_ho = fes_ho.GetNE();
@@ -74,31 +73,8 @@ void BatchedLOR_H1::Assemble2D()
for (int i=0; i<sz_local_mat; ++i) { local_mat[i] = 0.0; }
double vx[4], vy[4];
LORVertexCoordinates2D<ORDER>(X, iel_ho, kx, ky, vx, vy);
SetupLORQuadData2D<ORDER,SDIM,false,false>(X, iel_ho, kx, ky, Q, false);
for (int iqy=0; iqy<2; ++iqy)
{
for (int iqx=0; iqx<2; ++iqx)
{
const double x = iqx;
const double y = iqy;
const double w = 1.0/4.0;
double J_[2*2];
DeviceTensor<2> J(J_, 2, 2);
Jacobian2D(x, y, vx, vy, J);
const double detJ = Det2D(J);
const double w_detJ = w/detJ;
Q(0,iqy,iqx) = w_detJ * (J(0,1)*J(0,1) + J(1,1)*J(1,1)); // 1,1
Q(1,iqy,iqx) = -w_detJ * (J(0,1)*J(0,0) + J(1,1)*J(1,0)); // 1,2
Q(2,iqy,iqx) = w_detJ * (J(0,0)*J(0,0) + J(1,0)*J(1,0)); // 2,2
Q(3,iqy,iqx) = w*detJ;
}
}
for (int iqx=0; iqx<2; ++iqx)
{
for (int iqy=0; iqy<2; ++iqy)
@@ -519,34 +495,4 @@ void BatchedLOR_H1::Assemble3D()
}
}
// Explicit template instantiations
template void BatchedLOR_H1::Assemble2D<1>();
template void BatchedLOR_H1::Assemble2D<2>();
template void BatchedLOR_H1::Assemble2D<3>();
template void BatchedLOR_H1::Assemble2D<4>();
template void BatchedLOR_H1::Assemble2D<5>();
template void BatchedLOR_H1::Assemble2D<6>();
template void BatchedLOR_H1::Assemble2D<7>();
template void BatchedLOR_H1::Assemble2D<8>();
template void BatchedLOR_H1::Assemble3D<1>();
template void BatchedLOR_H1::Assemble3D<2>();
template void BatchedLOR_H1::Assemble3D<3>();
template void BatchedLOR_H1::Assemble3D<4>();
template void BatchedLOR_H1::Assemble3D<5>();
template void BatchedLOR_H1::Assemble3D<6>();
template void BatchedLOR_H1::Assemble3D<7>();
template void BatchedLOR_H1::Assemble3D<8>();
BatchedLOR_H1::BatchedLOR_H1(BilinearForm &a,
FiniteElementSpace &fes_ho_,
Vector &X_vert_,
Vector &sparse_ij_,
Array<int> &sparse_mapping_)
: BatchedLORKernel(fes_ho_, X_vert_, sparse_ij_, sparse_mapping_)
{
ProjectLORCoefficient<MassIntegrator>(a, c1);
ProjectLORCoefficient<DiffusionIntegrator>(a, c2);
}
} // namespace mfem
+9 -2
View File
@@ -22,15 +22,22 @@ namespace mfem
class BatchedLOR_ND : BatchedLORKernel
{
public:
template <int ORDER> void Assemble2D();
template <int ORDER, int SDIM> void Assemble2D();
template <int ORDER> void Assemble3D();
BatchedLOR_ND(BilinearForm &a,
FiniteElementSpace &fes_ho_,
Vector &X_vert_,
Vector &sparse_ij_,
Array<int> &sparse_mapping_);
Array<int> &sparse_mapping_)
: BatchedLORKernel(fes_ho_, X_vert_, sparse_ij_, sparse_mapping_)
{
ProjectLORCoefficient<VectorFEMassIntegrator>(a, c1);
ProjectLORCoefficient<CurlCurlIntegrator>(a, c2);
}
};
}
#include "lor_nd_impl.hpp"
#endif
+2 -56
View File
@@ -9,7 +9,6 @@
// terms of the BSD-3 license. We welcome feedback and contributions, see file
// CONTRIBUTING.md for details.
#include "lor_nd.hpp"
#include "lor_util.hpp"
#include "../../linalg/dtensor.hpp"
#include "../../general/forall.hpp"
@@ -17,7 +16,7 @@
namespace mfem
{
template <int ORDER>
template <int ORDER, int SDIM>
void BatchedLOR_ND::Assemble2D()
{
const int nel_ho = fes_ho.GetNE();
@@ -83,31 +82,8 @@ void BatchedLOR_ND::Assemble2D()
// local_mat is the local (dense) stiffness matrix
for (int i=0; i<sz_local_mat; ++i) { local_mat[i] = 0.0; }
double vx[4], vy[4];
LORVertexCoordinates2D<ORDER>(X, iel_ho, kx, ky, vx, vy);
SetupLORQuadData2D<ORDER,SDIM,false,true>(X, iel_ho, kx, ky, Q, true);
for (int iqx=0; iqx<2; ++iqx)
{
for (int iqy=0; iqy<2; ++iqy)
{
const double x = iqx;
const double y = iqy;
const double w = 1.0/4.0;
double J_[2*2];
DeviceTensor<2> J(J_, 2, 2);
Jacobian2D(x, y, vx, vy, J);
const double detJ = Det2D(J);
const double w_detJ = w/detJ;
Q(0,iqy,iqx) = w_detJ * (J(0,1)*J(0,1) + J(1,1)*J(1,1)); // 1,1
Q(1,iqy,iqx) = -w_detJ * (J(0,1)*J(0,0) + J(1,1)*J(1,0)); // 1,2
Q(2,iqy,iqx) = w_detJ * (J(0,0)*J(0,0) + J(1,0)*J(1,0)); // 2,2
Q(3,iqy,iqx) = w_detJ;
}
}
for (int iqx=0; iqx<2; ++iqx)
{
for (int iqy=0; iqy<2; ++iqy)
@@ -563,34 +539,4 @@ void BatchedLOR_ND::Assemble3D()
}
}
// Explicit template instantiations
template void BatchedLOR_ND::Assemble2D<1>();
template void BatchedLOR_ND::Assemble2D<2>();
template void BatchedLOR_ND::Assemble2D<3>();
template void BatchedLOR_ND::Assemble2D<4>();
template void BatchedLOR_ND::Assemble2D<5>();
template void BatchedLOR_ND::Assemble2D<6>();
template void BatchedLOR_ND::Assemble2D<7>();
template void BatchedLOR_ND::Assemble2D<8>();
template void BatchedLOR_ND::Assemble3D<1>();
template void BatchedLOR_ND::Assemble3D<2>();
template void BatchedLOR_ND::Assemble3D<3>();
template void BatchedLOR_ND::Assemble3D<4>();
template void BatchedLOR_ND::Assemble3D<5>();
template void BatchedLOR_ND::Assemble3D<6>();
template void BatchedLOR_ND::Assemble3D<7>();
template void BatchedLOR_ND::Assemble3D<8>();
BatchedLOR_ND::BatchedLOR_ND(BilinearForm &a,
FiniteElementSpace &fes_ho_,
Vector &X_vert_,
Vector &sparse_ij_,
Array<int> &sparse_mapping_)
: BatchedLORKernel(fes_ho_, X_vert_, sparse_ij_, sparse_mapping_)
{
ProjectLORCoefficient<VectorFEMassIntegrator>(a, c1);
ProjectLORCoefficient<CurlCurlIntegrator>(a, c2);
}
} // namespace mfem
+9 -2
View File
@@ -22,15 +22,22 @@ namespace mfem
class BatchedLOR_RT : BatchedLORKernel
{
public:
template <int ORDER> void Assemble2D();
template <int ORDER, int SDIM> void Assemble2D();
template <int ORDER> void Assemble3D();
BatchedLOR_RT(BilinearForm &a,
FiniteElementSpace &fes_ho_,
Vector &X_vert_,
Vector &sparse_ij_,
Array<int> &sparse_mapping_);
Array<int> &sparse_mapping_)
: BatchedLORKernel(fes_ho_, X_vert_, sparse_ij_, sparse_mapping_)
{
ProjectLORCoefficient<VectorFEMassIntegrator>(a, c1);
ProjectLORCoefficient<DivDivIntegrator>(a, c2);
}
};
}
#include "lor_rt_impl.hpp"
#endif
+2 -56
View File
@@ -9,7 +9,6 @@
// terms of the BSD-3 license. We welcome feedback and contributions, see file
// CONTRIBUTING.md for details.
#include "lor_rt.hpp"
#include "lor_util.hpp"
#include "../../linalg/dtensor.hpp"
#include "../../general/forall.hpp"
@@ -17,7 +16,7 @@
namespace mfem
{
template <int ORDER>
template <int ORDER, int SDIM>
void BatchedLOR_RT::Assemble2D()
{
const int nel_ho = fes_ho.GetNE();
@@ -79,31 +78,8 @@ void BatchedLOR_RT::Assemble2D()
// local_mat is the local (dense) stiffness matrix
for (int i=0; i<sz_local_mat; ++i) { local_mat[i] = 0.0; }
double vx[4], vy[4];
LORVertexCoordinates2D<ORDER>(X, iel_ho, kx, ky, vx, vy);
SetupLORQuadData2D<ORDER,SDIM,true,false>(X, iel_ho, kx, ky, Q, true);
for (int iqx=0; iqx<2; ++iqx)
{
for (int iqy=0; iqy<2; ++iqy)
{
const double x = iqx;
const double y = iqy;
const double w = 1.0/4.0;
double J_[2*2];
DeviceTensor<2> J(J_, 2, 2);
Jacobian2D(x, y, vx, vy, J);
const double detJ = Det2D(J);
const double w_detJ = w/detJ;
Q(0,iqy,iqx) = w_detJ * (J(0,0)*J(0,0) + J(1,0)*J(1,0)); // 1,1
Q(1,iqy,iqx) = w_detJ * (J(0,0)*J(0,1) + J(1,0)*J(1,1)); // 1,2
Q(2,iqy,iqx) = w_detJ * (J(0,1)*J(0,1) + J(1,1)*J(1,1)); // 2,2
Q(3,iqy,iqx) = w_detJ;
}
}
for (int iqx=0; iqx<2; ++iqx)
{
for (int iqy=0; iqy<2; ++iqy)
@@ -547,34 +523,4 @@ void BatchedLOR_RT::Assemble3D()
}
}
// Explicit template instantiations
template void BatchedLOR_RT::Assemble2D<1>();
template void BatchedLOR_RT::Assemble2D<2>();
template void BatchedLOR_RT::Assemble2D<3>();
template void BatchedLOR_RT::Assemble2D<4>();
template void BatchedLOR_RT::Assemble2D<5>();
template void BatchedLOR_RT::Assemble2D<6>();
template void BatchedLOR_RT::Assemble2D<7>();
template void BatchedLOR_RT::Assemble2D<8>();
template void BatchedLOR_RT::Assemble3D<1>();
template void BatchedLOR_RT::Assemble3D<2>();
template void BatchedLOR_RT::Assemble3D<3>();
template void BatchedLOR_RT::Assemble3D<4>();
template void BatchedLOR_RT::Assemble3D<5>();
template void BatchedLOR_RT::Assemble3D<6>();
template void BatchedLOR_RT::Assemble3D<7>();
template void BatchedLOR_RT::Assemble3D<8>();
BatchedLOR_RT::BatchedLOR_RT(BilinearForm &a,
FiniteElementSpace &fes_ho_,
Vector &X_vert_,
Vector &sparse_ij_,
Array<int> &sparse_mapping_)
: BatchedLORKernel(fes_ho_, X_vert_, sparse_ij_, sparse_mapping_)
{
ProjectLORCoefficient<VectorFEMassIntegrator>(a, c1);
ProjectLORCoefficient<DivDivIntegrator>(a, c2);
}
} // namespace mfem
+107 -35
View File
@@ -20,11 +20,22 @@
namespace mfem
{
template <int ORDER>
MFEM_HOST_DEVICE inline void LORVertexCoordinates2D(
const double *X, int iel_ho, int kx, int ky, double vx[4], double vy[4])
MFEM_HOST_DEVICE inline double Det2D(DeviceMatrix &J)
{
return J(0,0)*J(1,1) - J(1,0)*J(0,1);
}
MFEM_HOST_DEVICE inline double Det3D(DeviceMatrix &J)
{
return J(0,0) * (J(1,1) * J(2,2) - J(2,1) * J(1,2)) -
J(1,0) * (J(0,1) * J(2,2) - J(2,1) * J(0,2)) +
J(2,0) * (J(0,1) * J(1,2) - J(1,1) * J(0,2));
}
template <int ORDER, int SDIM=2>
MFEM_HOST_DEVICE inline void LORVertexCoordinates2D(
const double *X, int iel_ho, int kx, int ky, double **v)
{
const int dim = 2;
const int nd1d = ORDER + 1;
const int nvert_per_el = nd1d*nd1d;
@@ -33,23 +44,31 @@ MFEM_HOST_DEVICE inline void LORVertexCoordinates2D(
const int v2 = kx + 1 + nd1d*(ky + 1);
const int v3 = kx + nd1d*(ky + 1);
const int e0 = dim*(v0 + nvert_per_el*iel_ho);
const int e1 = dim*(v1 + nvert_per_el*iel_ho);
const int e2 = dim*(v2 + nvert_per_el*iel_ho);
const int e3 = dim*(v3 + nvert_per_el*iel_ho);
const int e0 = SDIM*(v0 + nvert_per_el*iel_ho);
const int e1 = SDIM*(v1 + nvert_per_el*iel_ho);
const int e2 = SDIM*(v2 + nvert_per_el*iel_ho);
const int e3 = SDIM*(v3 + nvert_per_el*iel_ho);
// Vertex coordinates
vx[0] = X[e0 + 0];
vy[0] = X[e0 + 1];
v[0][0] = X[e0 + 0];
v[1][0] = X[e0 + 1];
vx[1] = X[e1 + 0];
vy[1] = X[e1 + 1];
v[0][1] = X[e1 + 0];
v[1][1] = X[e1 + 1];
vx[2] = X[e2 + 0];
vy[2] = X[e2 + 1];
v[0][2] = X[e2 + 0];
v[1][2] = X[e2 + 1];
vx[3] = X[e3 + 0];
vy[3] = X[e3 + 1];
v[0][3] = X[e3 + 0];
v[1][3] = X[e3 + 1];
if (SDIM == 3)
{
v[2][0] = X[e0 + 2];
v[2][1] = X[e1 + 2];
v[2][2] = X[e2 + 2];
v[2][3] = X[e3 + 2];
}
}
template <int ORDER>
@@ -112,15 +131,80 @@ MFEM_HOST_DEVICE inline void LORVertexCoordinates3D(
vz[7] = X[e7 + 2];
}
template <int SDIM=2>
MFEM_HOST_DEVICE inline void Jacobian2D(
const double x, const double y, const double vx[4], const double vy[4],
DeviceMatrix &J)
{
J(0,0) = -(1-y)*vx[0] + (1-y)*vx[1] + y*vx[2] - y*vx[3];
J(0,1) = -(1-x)*vx[0] - x*vx[1] + x*vx[2] + (1-x)*vx[3];
const double x, const double y, double **v, DeviceMatrix &J);
J(1,0) = -(1-y)*vy[0] + (1-y)*vy[1] + y*vy[2] - y*vy[3];
J(1,1) = -(1-x)*vy[0] - x*vy[1] + x*vy[2] + (1-x)*vy[3];
template <> MFEM_HOST_DEVICE inline void Jacobian2D<2>(
const double x, const double y, double **v, DeviceMatrix &J)
{
J(0,0) = -(1-y)*v[0][0] + (1-y)*v[0][1] + y*v[0][2] - y*v[0][3];
J(0,1) = -(1-x)*v[0][0] - x*v[0][1] + x*v[0][2] + (1-x)*v[0][3];
J(1,0) = -(1-y)*v[1][0] + (1-y)*v[1][1] + y*v[1][2] - y*v[1][3];
J(1,1) = -(1-x)*v[1][0] - x*v[1][1] + x*v[1][2] + (1-x)*v[1][3];
}
template <> MFEM_HOST_DEVICE inline void Jacobian2D<3>(
const double x, const double y, double **v, DeviceMatrix &J)
{
J(0,0) = -(1-y)*v[0][0] + (1-y)*v[0][1] + y*v[0][2] - y*v[0][3];
J(0,1) = -(1-x)*v[0][0] - x*v[0][1] + x*v[0][2] + (1-x)*v[0][3];
J(1,0) = -(1-y)*v[1][0] + (1-y)*v[1][1] + y*v[1][2] - y*v[1][3];
J(1,1) = -(1-x)*v[1][0] - x*v[1][1] + x*v[1][2] + (1-x)*v[1][3];
J(2,0) = -(1-y)*v[2][0] + (1-y)*v[2][1] + y*v[2][2] - y*v[2][3];
J(2,1) = -(1-x)*v[2][0] - x*v[2][1] + x*v[2][2] + (1-x)*v[2][3];
}
template <int ORDER, int SDIM, bool RT, bool ND>
MFEM_HOST_DEVICE inline void SetupLORQuadData2D(
const double *X, int iel_ho, int kx, int ky, DeviceTensor<3> &Q, bool piola)
{
double vx[4], vy[4], vz[4];
double *v[] = {vx, vy, vz};
LORVertexCoordinates2D<ORDER,SDIM>(X, iel_ho, kx, ky, v);
for (int iqy=0; iqy<2; ++iqy)
{
for (int iqx=0; iqx<2; ++iqx)
{
const double x = iqx;
const double y = iqy;
const double w = 1.0/4.0;
double J_[SDIM*2];
DeviceTensor<2> J(J_, SDIM, 2);
Jacobian2D<SDIM>(x, y, v, J);
if (SDIM == 2)
{
const double detJ = Det2D(J);
const double w_detJ = w/detJ;
const double E = J(0,0)*J(0,0) + J(1,0)*J(1,0);
const double F = J(0,0)*J(0,1) + J(1,0)*J(1,1);
const double G = J(0,1)*J(0,1) + J(1,1)*J(1,1);
Q(0,iqy,iqx) = w_detJ * (RT ? E : G); // 1,1
Q(1,iqy,iqx) = w_detJ * (RT ? F : -F); // 1,2
Q(2,iqy,iqx) = w_detJ * (RT ? G : E); // 2,2
Q(3,iqy,iqx) = (ND || RT) ? w_detJ : w*detJ;
}
else
{
const double E = J(0,0)*J(0,0) + J(1,0)*J(1,0) + J(2,0)*J(2,0);
const double F = J(0,0)*J(0,1) + J(1,0)*J(1,1) + J(2,0)*J(2,1);
const double G = J(0,1)*J(0,1) + J(1,1)*J(1,1) + J(2,1)*J(2,1);
const double detJ = sqrt(E*G - F*F);
const double w_detJ = w/detJ;
Q(0,iqy,iqx) = w_detJ * (RT ? E : G); // 1,1
Q(1,iqy,iqx) = w_detJ * (RT ? F : -F); // 1,2
Q(2,iqy,iqx) = w_detJ * (RT ? G : E); // 2,2
Q(3,iqy,iqx) = (ND || RT) ? w_detJ : w*detJ;
}
}
}
}
MFEM_HOST_DEVICE inline void Jacobian3D(
@@ -180,18 +264,6 @@ MFEM_HOST_DEVICE inline void Adjugate3D(const DeviceMatrix &J, DeviceMatrix &A)
A(2,2) = (J(0,0) * J(1,1)) - (J(0,1) * J(1,0));
}
MFEM_HOST_DEVICE inline double Det2D(DeviceMatrix &J)
{
return J(0,0)*J(1,1) - J(1,0)*J(0,1);
}
MFEM_HOST_DEVICE inline double Det3D(DeviceMatrix &J)
{
return J(0,0) * (J(1,1) * J(2,2) - J(2,1) * J(1,2)) -
J(1,0) * (J(0,1) * J(2,2) - J(2,1) * J(0,2)) +
J(2,0) * (J(0,1) * J(1,2) - J(1,1) * J(0,2));
}
}
#endif
+169 -11
View File
@@ -97,12 +97,37 @@ double NonlinearForm::GetGridFunctionEnergy(const Vector &x) const
const FiniteElement *fe;
ElementTransformation *T;
DofTransformation *doftrans;
Mesh *mesh = fes->GetMesh();
double energy = 0.0;
if (dnfi.Size())
{
// Which attributes need to be processed?
Array<int> attr_marker(mesh->attributes.Size() ?
mesh->attributes.Max() : 0);
attr_marker = 0;
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] == NULL)
{
attr_marker = 1;
break;
}
Array<int> &marker = *dnfi_marker[k];
MFEM_ASSERT(marker.Size() == attr_marker.Size(),
"invalid marker for domain integrator #"
<< k << ", counting from zero");
for (int i = 0; i < attr_marker.Size(); i++)
{
attr_marker[i] |= marker[i];
}
}
for (int i = 0; i < fes->GetNE(); i++)
{
const int attr = mesh->GetAttribute(i);
if (attr_marker[attr-1] == 0) { continue; }
fe = fes->GetFE(i);
doftrans = fes->GetElementVDofs(i, vdofs);
T = fes->GetElementTransformation(i);
@@ -110,6 +135,9 @@ double NonlinearForm::GetGridFunctionEnergy(const Vector &x) const
if (doftrans) {doftrans->InvTransformPrimal(el_x); }
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] &&
(*dnfi_marker[k])[attr-1] == 0) { continue; }
energy += dnfi[k]->GetElementEnergy(*fe, *T, el_x);
}
}
@@ -175,8 +203,32 @@ void NonlinearForm::Mult(const Vector &x, Vector &y) const
if (dnfi.Size())
{
// Which attributes need to be processed?
Array<int> attr_marker(mesh->attributes.Size() ?
mesh->attributes.Max() : 0);
attr_marker = 0;
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] == NULL)
{
attr_marker = 1;
break;
}
Array<int> &marker = *dnfi_marker[k];
MFEM_ASSERT(marker.Size() == attr_marker.Size(),
"invalid marker for domain integrator #"
<< k << ", counting from zero");
for (int i = 0; i < attr_marker.Size(); i++)
{
attr_marker[i] |= marker[i];
}
}
for (int i = 0; i < fes->GetNE(); i++)
{
const int attr = mesh->GetAttribute(i);
if (attr_marker[attr-1] == 0) { continue; }
fe = fes->GetFE(i);
doftrans = fes->GetElementVDofs(i, vdofs);
T = fes->GetElementTransformation(i);
@@ -184,6 +236,9 @@ void NonlinearForm::Mult(const Vector &x, Vector &y) const
if (doftrans) {doftrans->InvTransformPrimal(el_x); }
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] &&
(*dnfi_marker[k])[attr-1] == 0) { continue; }
dnfi[k]->AssembleElementVector(*fe, *T, el_x, el_y);
if (doftrans) {doftrans->TransformDual(el_y); }
py.AddElementVector(vdofs, el_y);
@@ -322,8 +377,32 @@ Operator &NonlinearForm::GetGradient(const Vector &x) const
if (dnfi.Size())
{
// Which attributes need to be processed?
Array<int> attr_marker(mesh->attributes.Size() ?
mesh->attributes.Max() : 0);
attr_marker = 0;
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] == NULL)
{
attr_marker = 1;
break;
}
Array<int> &marker = *dnfi_marker[k];
MFEM_ASSERT(marker.Size() == attr_marker.Size(),
"invalid marker for domain integrator #"
<< k << ", counting from zero");
for (int i = 0; i < attr_marker.Size(); i++)
{
attr_marker[i] |= marker[i];
}
}
for (int i = 0; i < fes->GetNE(); i++)
{
const int attr = mesh->GetAttribute(i);
if (attr_marker[attr-1] == 0) { continue; }
fe = fes->GetFE(i);
doftrans = fes->GetElementVDofs(i, vdofs);
T = fes->GetElementTransformation(i);
@@ -331,6 +410,9 @@ Operator &NonlinearForm::GetGradient(const Vector &x) const
if (doftrans) {doftrans->InvTransformPrimal(el_x); }
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] &&
(*dnfi_marker[k])[attr-1] == 0) { continue; }
dnfi[k]->AssembleElementGrad(*fe, *T, el_x, elmat);
if (doftrans) { doftrans->TransformDual(elmat); }
Grad->AddSubMatrix(vdofs, vdofs, elmat, skip_zeros);
@@ -561,13 +643,6 @@ BlockNonlinearForm::BlockNonlinearForm(Array<FiniteElementSpace *> &f) :
SetSpaces(f);
}
void BlockNonlinearForm::AddBdrFaceIntegrator(BlockNonlinearFormIntegrator *nfi,
Array<int> &bdr_attr_marker)
{
bfnfi.Append(nfi);
bfnfi_marker.Append(&bdr_attr_marker);
}
void BlockNonlinearForm::SetEssentialBC(
const Array<Array<int> *> &bdr_attr_is_ess, Array<Vector *> &rhs)
{
@@ -592,6 +667,7 @@ double BlockNonlinearForm::GetEnergyBlocked(const BlockVector &bx) const
Array<const FiniteElement *> fe(fes.Size());
ElementTransformation *T;
DofTransformation *doftrans;
Mesh *mesh = fes[0]->GetMesh();
double energy = 0.0;
for (int i=0; i<fes.Size(); ++i)
@@ -601,8 +677,33 @@ double BlockNonlinearForm::GetEnergyBlocked(const BlockVector &bx) const
}
if (dnfi.Size())
{
// Which attributes need to be processed?
Array<int> attr_marker(mesh->attributes.Size() ?
mesh->attributes.Max() : 0);
attr_marker = 0;
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] == NULL)
{
attr_marker = 1;
break;
}
Array<int> &marker = *dnfi_marker[k];
MFEM_ASSERT(marker.Size() == attr_marker.Size(),
"invalid marker for domain integrator #"
<< k << ", counting from zero");
for (int i = 0; i < attr_marker.Size(); i++)
{
attr_marker[i] |= marker[i];
}
}
for (int i = 0; i < fes[0]->GetNE(); ++i)
{
const int attr = mesh->GetAttribute(i);
if (attr_marker[attr-1] == 0) { continue; }
T = fes[0]->GetElementTransformation(i);
for (int s=0; s<fes.Size(); ++s)
{
@@ -614,9 +715,13 @@ double BlockNonlinearForm::GetEnergyBlocked(const BlockVector &bx) const
for (int k = 0; k < dnfi.Size(); ++k)
{
if (dnfi_marker[k] &&
(*dnfi_marker[k])[attr-1] == 0) { continue; }
energy += dnfi[k]->GetElementEnergy(fe, *T, el_x_const);
}
}
}
// free the allocated memory
for (int i = 0; i < fes.Size(); ++i)
@@ -656,6 +761,7 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
Array<const FiniteElement *> fe2(fes.Size());
ElementTransformation *T;
Array<DofTransformation *> doftrans(fes.Size()); doftrans = nullptr;
Mesh *mesh = fes[0]->GetMesh();
by.UseDevice(true);
by = 0.0;
@@ -670,8 +776,32 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
if (dnfi.Size())
{
// Which attributes need to be processed?
Array<int> attr_marker(mesh->attributes.Size() ?
mesh->attributes.Max() : 0);
attr_marker = 0;
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] == NULL)
{
attr_marker = 1;
break;
}
Array<int> &marker = *dnfi_marker[k];
MFEM_ASSERT(marker.Size() == attr_marker.Size(),
"invalid marker for domain integrator #"
<< k << ", counting from zero");
for (int i = 0; i < attr_marker.Size(); i++)
{
attr_marker[i] |= marker[i];
}
}
for (int i = 0; i < fes[0]->GetNE(); ++i)
{
const int attr = mesh->GetAttribute(i);
if (attr_marker[attr-1] == 0) { continue; }
T = fes[0]->GetElementTransformation(i);
for (int s = 0; s < fes.Size(); ++s)
{
@@ -683,6 +813,9 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
for (int k = 0; k < dnfi.Size(); ++k)
{
if (dnfi_marker[k] &&
(*dnfi_marker[k])[attr-1] == 0) { continue; }
dnfi[k]->AssembleElementVector(fe, *T,
el_x_const, el_y);
@@ -698,7 +831,6 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
if (fnfi.Size())
{
Mesh *mesh = fes[0]->GetMesh();
FaceElementTransformations *tr;
for (int i = 0; i < mesh->GetNumFaces(); ++i)
@@ -736,8 +868,8 @@ void BlockNonlinearForm::MultBlocked(const BlockVector &bx,
if (bfnfi.Size())
{
Mesh *mesh = fes[0]->GetMesh();
FaceElementTransformations *tr;
// Which boundary attributes need to be processed?
Array<int> bdr_attr_marker(mesh->bdr_attributes.Size() ?
mesh->bdr_attributes.Max() : 0);
@@ -858,6 +990,7 @@ void BlockNonlinearForm::ComputeGradientBlocked(const BlockVector &bx) const
Array<const FiniteElement *>fe2(fes.Size());
ElementTransformation * T;
Array<DofTransformation *> doftrans(fes.Size()); doftrans = nullptr;
Mesh *mesh = fes[0]->GetMesh();
for (int i=0; i<fes.Size(); ++i)
{
@@ -888,8 +1021,32 @@ void BlockNonlinearForm::ComputeGradientBlocked(const BlockVector &bx) const
if (dnfi.Size())
{
// Which attributes need to be processed?
Array<int> attr_marker(mesh->attributes.Size() ?
mesh->attributes.Max() : 0);
attr_marker = 0;
for (int k = 0; k < dnfi.Size(); k++)
{
if (dnfi_marker[k] == NULL)
{
attr_marker = 1;
break;
}
Array<int> &marker = *dnfi_marker[k];
MFEM_ASSERT(marker.Size() == attr_marker.Size(),
"invalid marker for domain integrator #"
<< k << ", counting from zero");
for (int i = 0; i < attr_marker.Size(); i++)
{
attr_marker[i] |= marker[i];
}
}
for (int i = 0; i < fes[0]->GetNE(); ++i)
{
const int attr = mesh->GetAttribute(i);
if (attr_marker[attr-1] == 0) { continue; }
T = fes[0]->GetElementTransformation(i);
for (int s = 0; s < fes.Size(); ++s)
{
@@ -901,6 +1058,9 @@ void BlockNonlinearForm::ComputeGradientBlocked(const BlockVector &bx) const
for (int k = 0; k < dnfi.Size(); ++k)
{
if (dnfi_marker[k] &&
(*dnfi_marker[k])[attr-1] == 0) { continue; }
dnfi[k]->AssembleElementGrad(fe, *T, el_x_const, elmats);
for (int j=0; j<fes.Size(); ++j)
@@ -923,7 +1083,6 @@ void BlockNonlinearForm::ComputeGradientBlocked(const BlockVector &bx) const
if (fnfi.Size())
{
FaceElementTransformations *tr;
Mesh *mesh = fes[0]->GetMesh();
for (int i = 0; i < mesh->GetNumFaces(); ++i)
{
@@ -960,7 +1119,6 @@ void BlockNonlinearForm::ComputeGradientBlocked(const BlockVector &bx) const
if (bfnfi.Size())
{
FaceElementTransformations *tr;
Mesh *mesh = fes[0]->GetMesh();
// Which boundary attributes need to be processed?
Array<int> bdr_attr_marker(mesh->bdr_attributes.Size() ?
+17 -4
View File
@@ -37,6 +37,7 @@ protected:
/// Set of Domain Integrators to be assembled (added).
Array<NonlinearFormIntegrator*> dnfi; // owned
Array<Array<int>*> dnfi_marker; // not owned
/// Set of interior face Integrators to be assembled (added).
Array<NonlinearFormIntegrator*> fnfi; // owned
@@ -108,7 +109,12 @@ public:
/// Adds new Domain Integrator.
void AddDomainIntegrator(NonlinearFormIntegrator *nlfi)
{ dnfi.Append(nlfi); }
{ dnfi.Append(nlfi); dnfi_marker.Append(NULL); }
/// Adds new Domain Integrator, restricted to specific attributes.
void AddDomainIntegrator(NonlinearFormIntegrator *nlfi,
Array<int> &elem_marker)
{ dnfi.Append(nlfi); dnfi_marker.Append(&elem_marker); }
/// Access all integrators added with AddDomainIntegrator().
Array<NonlinearFormIntegrator*> *GetDNFI() { return &dnfi; }
@@ -227,13 +233,14 @@ protected:
/// Set of Domain Integrators to be assembled (added).
Array<BlockNonlinearFormIntegrator*> dnfi;
Array<Array<int>*> dnfi_marker;
/// Set of interior face Integrators to be assembled (added).
Array<BlockNonlinearFormIntegrator*> fnfi;
/// Set of Boundary Face Integrators to be assembled (added).
Array<BlockNonlinearFormIntegrator*> bfnfi;
Array<Array<int>*> bfnfi_marker;
Array<Array<int>*> bfnfi_marker;
/** Auxiliary block-vectors for wrapping input and output vectors or holding
GridFunction-like block-vector data (e.g. in parallel). */
@@ -298,7 +305,12 @@ public:
/// Adds new Domain Integrator.
void AddDomainIntegrator(BlockNonlinearFormIntegrator *nlfi)
{ dnfi.Append(nlfi); }
{ dnfi.Append(nlfi); dnfi_marker.Append(NULL); }
/// Adds new Domain Integrator, restricted to specific attributes.
void AddDomainIntegrator(BlockNonlinearFormIntegrator *nlfi,
Array<int> &elem_marker)
{ dnfi.Append(nlfi); dnfi_marker.Append(&elem_marker); }
/// Adds new Interior Face Integrator.
void AddInteriorFaceIntegrator(BlockNonlinearFormIntegrator *nlfi)
@@ -311,7 +323,8 @@ public:
/** @brief Adds new Boundary Face Integrator, restricted to specific boundary
attributes. */
void AddBdrFaceIntegrator(BlockNonlinearFormIntegrator *nlfi,
Array<int> &bdr_marker);
Array<int> &bdr_marker)
{ bfnfi.Append(nlfi); bfnfi_marker.Append(&bdr_marker); }
virtual void SetEssentialBC(const Array<Array<int> *>&bdr_attr_is_ess,
Array<Vector *> &rhs);
+3
View File
@@ -266,6 +266,9 @@ public:
test_pfes = test_fes;
}
/// Return the test parallel FE space associated with the ParMixedBilinearForm.
ParFiniteElementSpace *TestParFESpace() const { return test_pfes; }
/// Returns the matrix assembled on the true dofs, i.e. P_test^t A P_trial.
HypreParMatrix *ParallelAssemble();
+78 -48
View File
@@ -466,53 +466,54 @@ void ParFiniteElementSpace::ApplyLDofSigns(Table &el_dof) const
ApplyLDofSigns(all_dofs);
}
DofTransformation *
ParFiniteElementSpace::GetElementDofs(int i, Array<int> &dofs) const
void ParFiniteElementSpace::GetElementDofs(int i, Array<int> &dofs,
DofTransformation &doftrans) const
{
if (elem_dof)
{
elem_dof->GetRow(i, dofs);
if (DoFTrans[mesh->GetElementBaseGeometry(i)])
if (DoFTransArray[mesh->GetElementBaseGeometry(i)])
{
Array<int> Fo;
elem_fos->GetRow(i, Fo);
DoFTrans[mesh->GetElementBaseGeometry(i)]->SetFaceOrientations(Fo);
return DoFTrans[mesh->GetElementBaseGeometry(i)];
doftrans.SetDofTransformation(
*DoFTransArray[mesh->GetElementBaseGeometry(i)]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim();
}
return NULL;
return;
}
DofTransformation * doftrans = FiniteElementSpace::GetElementDofs(i, dofs);
FiniteElementSpace::GetElementDofs(i, dofs, doftrans);
if (Conforming())
{
ApplyLDofSigns(dofs);
}
return doftrans;
}
DofTransformation *
ParFiniteElementSpace::GetBdrElementDofs(int i, Array<int> &dofs) const
void ParFiniteElementSpace::GetBdrElementDofs(int i, Array<int> &dofs,
DofTransformation &doftrans) const
{
if (bdr_elem_dof)
{
bdr_elem_dof->GetRow(i, dofs);
if (DoFTrans[mesh->GetBdrElementBaseGeometry(i)])
if (DoFTransArray[mesh->GetBdrElementBaseGeometry(i)])
{
Array<int> Fo;
bdr_elem_fos -> GetRow (i, Fo);
DoFTrans[mesh->GetBdrElementBaseGeometry(i)]->SetFaceOrientations(Fo);
return DoFTrans[mesh->GetBdrElementBaseGeometry(i)];
bdr_elem_fos->GetRow(i, Fo);
doftrans.SetDofTransformation(
*DoFTransArray[mesh->GetBdrElementBaseGeometry(i)]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim();
}
return NULL;
return;
}
DofTransformation * doftrans =
FiniteElementSpace::GetBdrElementDofs(i, dofs);
FiniteElementSpace::GetBdrElementDofs(i, dofs, doftrans);
if (Conforming())
{
ApplyLDofSigns(dofs);
}
return doftrans;
}
int ParFiniteElementSpace::GetFaceDofs(int i, Array<int> &dofs,
@@ -743,6 +744,8 @@ void ParFiniteElementSpace::Build_Dof_TrueDof_Matrix() const // matrix P
// Safe to assume 1-1 correspondence between shared dofs
int ldof = GetVSize();
int ltdof = TrueVSize();
std::cout << MyRank << " (ldof, ltdof) = ("
<< ldof << "," << ltdof << ")" << std::endl;
HYPRE_Int *i_diag = Memory<HYPRE_Int>(ldof+1);
HYPRE_Int *j_diag = Memory<HYPRE_Int>(ltdof);
@@ -755,7 +758,11 @@ void ParFiniteElementSpace::Build_Dof_TrueDof_Matrix() const // matrix P
HYPRE_BigInt *cmap = Memory<HYPRE_BigInt>(ldof-ltdof);
HYPRE_BigInt *col_starts = GetTrueDofOffsets();
std::cout << MyRank << " col_starts: [" << col_starts[0]
<< "," << col_starts[1] << "]" << std::endl;
HYPRE_BigInt *row_starts = GetDofOffsets();
std::cout << MyRank << " row_starts: [" << row_starts[0]
<< "," << row_starts[1] << "]" << std::endl;
Array<Pair<HYPRE_BigInt, int> > cmap_j_offd(ldof-ltdof);
@@ -777,6 +784,18 @@ void ParFiniteElementSpace::Build_Dof_TrueDof_Matrix() const // matrix P
i_diag[i+1] = diag_counter;
i_offd[i+1] = offd_counter;
}
std::cout << MyRank << " i_diag: ";
for (int i = 0; i < ldof+1; ++i)
{
std::cout << i_diag[i] << " ";
}
std::cout << std::endl;
std::cout << MyRank << " j_diag: ";
for (int i = 0; i < ltdof; ++i)
{
std::cout << j_diag[i] << " ";
}
std::cout << std::endl;
SortPairs<HYPRE_BigInt, int>(cmap_j_offd, offd_counter);
@@ -785,6 +804,24 @@ void ParFiniteElementSpace::Build_Dof_TrueDof_Matrix() const // matrix P
cmap[i] = cmap_j_offd[i].one;
j_offd[cmap_j_offd[i].two] = i;
}
std::cout << MyRank << " i_offd: ";
for (int i = 0; i < ldof+1; ++i)
{
std::cout << i_offd[i] << " ";
}
std::cout << std::endl;
std::cout << MyRank << " j_offd: ";
for (int i = 0; i < ldof-ltdof; ++i)
{
std::cout << j_offd[i] << " ";
}
std::cout << std::endl;
std::cout << MyRank << " cmap: ";
for (int i = 0; i < ldof-ltdof; ++i)
{
std::cout << cmap[i] << " ";
}
std::cout << std::endl;
P = new HypreParMatrix(MyComm, MyRank, NRanks, row_starts, col_starts,
i_diag, j_diag, i_offd, j_offd,
@@ -939,8 +976,8 @@ void ParFiniteElementSpace::Build_Dof_TrueDof_Matrix() const // matrix P
}
else if (i_offd[i+1] == i_offd[i] + 2)
{
const double * T = ND_StatelessDofTransformation
::GetFaceTransform(ltori[i]).GetData();
const double *T =
ND_DofTransformation::GetFaceTransform(ltori[i]).GetData();
j_offd[i_offd[i] + 1] = j_offd[i_offd[i]] + 1;
d_offd[i_offd[i]] = T[0]; d_offd[i_offd[i] + 1] = T[2];
i++;
@@ -1454,31 +1491,30 @@ void ParFiniteElementSpace::ExchangeFaceNbrData()
delete [] requests;
}
DofTransformation *ParFiniteElementSpace::GetFaceNbrElementVDofs(
int i, Array<int> &vdofs) const
void ParFiniteElementSpace::GetFaceNbrElementVDofs(
int i, Array<int> &vdofs, DofTransformation &doftrans) const
{
face_nbr_element_dof.GetRow(i, vdofs);
DofTransformation *doftrans = NULL;
Geometry::Type geom = GetFaceNbrFE(i)->GetGeomType();
if (DoFTrans[geom])
if (DoFTransArray[GetFaceNbrFE(i)->GetGeomType()])
{
Array<int> F, Fo;
pmesh->GetFaceNbrElementFaces(pmesh->GetNE() + i, F, Fo);
doftrans = DoFTrans[geom];
doftrans->SetFaceOrientations(Fo);
}
if (vdim == 1 || doftrans == NULL)
{
return doftrans;
}
else
{
VDoFTrans.SetDofTransformation(*doftrans);
return &VDoFTrans;
doftrans.SetDofTransformation(
*DoFTransArray[GetFaceNbrFE(i)->GetGeomType()]);
doftrans.SetFaceOrientations(Fo);
doftrans.SetVDim(vdim, ordering);
}
}
DofTransformation *ParFiniteElementSpace::GetFaceNbrElementVDofs(
int i, Array<int> &vdofs) const
{
DoFTrans.SetDofTransformation(NULL);
GetFaceNbrElementVDofs(i, vdofs, DoFTrans);
return DoFTrans.GetDofTransformation() ? &DoFTrans : NULL;
}
void ParFiniteElementSpace::GetFaceNbrFaceVDofs(int i, Array<int> &vdofs) const
{
// Works for NC mesh where 'i' is an index returned by
@@ -2235,19 +2271,13 @@ void NeighborRowMessage::Decode(int rank)
// This is the second "fundamental unit" used in the transformation.
const auto initial_second_row = second_row;
const double *T =
ND_DofTransformation::GetFaceTransform(fo).GetData();
const auto T = [&fo]()
{
auto T = ND_StatelessDofTransformation::GetFaceTransform(fo);
T(0,0) -= 1;
T(1,1) -= 1;
return T;
}();
first_row.AddRow(initial_first_row, T(0,0));
first_row.AddRow(initial_second_row, T(0,1));
second_row.AddRow(initial_first_row, T(1,0));
second_row.AddRow(initial_second_row, T(1,1));
first_row.AddRow(initial_first_row, T[0] - 1.0);
first_row.AddRow(initial_second_row, T[2]);
second_row.AddRow(initial_first_row, T[1]);
second_row.AddRow(initial_second_row, T[3] - 1.0);
first_row.Collapse();
second_row.Collapse();
+17 -5
View File
@@ -248,7 +248,11 @@ public:
If the FiniteElementCollection, @a f, is NULL (default), the FE
collection used by @a global_fes will be reused. If @a f is not NULL, it
must be the same as, or a copy of, the FE collection used by
@a global_fes. */
@a global_fes.
@note Currently the @a partitioning array is not used by this
constructor, it is required for general parallel variable-order support.
*/
ParFiniteElementSpace(ParMesh *pm, const FiniteElementSpace *global_fes,
const int *partitioning,
const FiniteElementCollection *f = NULL);
@@ -284,11 +288,17 @@ public:
/// Return the number of local vector true dofs.
int GetTrueVSize() const override { return ltdof_size; }
/// Returns indexes of degrees of freedom in array dofs for i'th element.
DofTransformation *GetElementDofs(int i, Array<int> &dofs) const override;
/// Returns indexes of degrees of freedom in array dofs for i'th element and
/// returns the DofTransformation data in a user-provided object.
using FiniteElementSpace::GetElementDofs;
void GetElementDofs(int i, Array<int> &dofs,
DofTransformation &doftrans) const override;
/// Returns indexes of degrees of freedom for i'th boundary element.
DofTransformation *GetBdrElementDofs(int i, Array<int> &dofs) const override;
/// Returns indexes of degrees of freedom for i'th boundary element and
/// returns the DofTransformation data in a user-provided object.
using FiniteElementSpace::GetBdrElementDofs;
void GetBdrElementDofs(int i, Array<int> &dofs,
DofTransformation &doftrans) const override;
/** Returns the indexes of the degrees of freedom for i'th face
including the dofs for the edges and the vertices of the face. */
@@ -382,6 +392,8 @@ public:
// Face-neighbor functions
void ExchangeFaceNbrData();
int GetFaceNbrVSize() const { return num_face_nbr_dofs; }
void GetFaceNbrElementVDofs(int i, Array<int> &vdofs,
DofTransformation &doftrans) const;
DofTransformation *GetFaceNbrElementVDofs(int i, Array<int> &vdofs) const;
void GetFaceNbrFaceVDofs(int i, Array<int> &vdofs) const;
const FiniteElement *GetFaceNbrFE(int i) const;
+17 -1
View File
@@ -693,7 +693,23 @@ void ParGridFunction::ProjectBdrCoefficient(
#ifdef MFEM_DEBUG
Array<int> ess_vdofs_marker;
pfes->GetEssentialVDofs(attr, ess_vdofs_marker);
if (vcoeff) { pfes->GetEssentialVDofs(attr, ess_vdofs_marker); }
else
{
ess_vdofs_marker.SetSize(Size());
ess_vdofs_marker = 0;
for (int i = 0; i < fes->GetVDim(); i++)
{
if (!coeff[i]) { continue; }
Array<int> component_dof_marker;
pfes->GetEssentialVDofs(attr, component_dof_marker,i);
for (int j = 0; j<Size(); j++)
{
ess_vdofs_marker[j] = bool(ess_vdofs_marker[j]) ||
bool(component_dof_marker[j]);
}
}
}
for (int i = 0; i < values_counter.Size(); i++)
{
MFEM_ASSERT(pfes->GetLocalTDofNumber(i) == -1 ||
+1 -1
View File
@@ -177,7 +177,7 @@ int FaceQuadratureSpace::GetEntityIndex(const ElementTransformation &T) const
return get_face_index(T.ElementNo);
case ElementTransformation::BDR_ELEMENT:
case ElementTransformation::BDR_FACE:
return get_face_index(mesh.GetBdrElementEdgeIndex(T.ElementNo));
return get_face_index(mesh.GetBdrElementFaceIndex(T.ElementNo));
default:
MFEM_ABORT("Invalid element type.");
return -1;
+43 -10
View File
@@ -462,21 +462,52 @@ void TMOP_Metric_009::AssembleH(const DenseMatrix &Jpt,
ie.Assemble_ddI1b(weight, A.GetData());
}
// mu_14 = |T-I|^2
double TMOP_Metric_014::EvalWMatrixForm(const DenseMatrix &Jpt) const
{
// mu_14 = |J - I|^2.
DenseMatrix Mat(Jpt);
Mat(0,0) -= 1.0;
Mat(1,1) -= 1.0;
return Mat.FNorm2();
}
double TMOP_Metric_014::EvalW(const DenseMatrix &Jpt) const
{
MFEM_VERIFY(Jtr != NULL,
"Requires a target Jacobian, use SetTargetJacobian().");
// mu_14 = |J - I|^2 = I1[J-I].
DenseMatrix Mat(Jpt);
Mat(0,0) -= 1.0;
Mat(1,1) -= 1.0;
DenseMatrix Id(2,2);
ie.SetJacobian(Mat.GetData());
return ie.Get_I1();
}
Id(0,0) = 1; Id(0,1) = 0;
Id(1,0) = 0; Id(1,1) = 1;
void TMOP_Metric_014::EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
{
// P = dI1[J-I] d/dJ[J-I] = dI1[J-I].
DenseMatrix JptMinusId = Jpt;
for (int i = 0; i < Jpt.Size(); i++)
{
JptMinusId(i, i) -= 1.0;
}
ie.SetJacobian(JptMinusId.GetData());
P = ie.Get_dI1();
}
DenseMatrix Mat(2,2);
Mat = Jpt;
Mat.Add(-1,Id);
return Mat.FNorm2();
void TMOP_Metric_014::AssembleH(const DenseMatrix &Jpt,
const DenseMatrix &DS,
const double weight,
DenseMatrix &A) const
{
// dP = ddI1[J-I].
DenseMatrix JptMinusId = Jpt;
for (int i = 0; i < Jpt.Size(); i++)
{
JptMinusId(i, i) -= 1.0;
}
ie.SetJacobian(JptMinusId.GetData());
ie.SetDerivativeMatrix(DS.Height(), DS.GetData());
ie.Assemble_ddI1(weight, A.GetData());
}
double TMOP_Metric_022::EvalW(const DenseMatrix &Jpt) const
@@ -4347,6 +4378,8 @@ UpdateAfterMeshPositionChange(const Vector &x_new,
{
if (discr_tc) { PA.Jtr_needs_update = true; }
if (PA.enabled) { UpdateCoefficientsPA(x_new); }
Ordering::Type ordering = x_fes.GetOrdering();
// Update the finite difference delta if FD are used.
+26 -9
View File
@@ -373,16 +373,20 @@ public:
/// 2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
class TMOP_Metric_014 : public TMOP_QualityMetric
{
protected:
mutable InvariantsEvaluator2D<double> ie;
public:
// W = |T-I|^2.
// W = |J - I|^2.
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
// W = I1[J-I].
virtual double EvalW(const DenseMatrix &Jpt) const;
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
{ MFEM_ABORT("Not implemented"); }
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
const double weight, DenseMatrix &A) const
{ MFEM_ABORT("Not implemented"); }
const double weight, DenseMatrix &A) const;
};
/// 2D Shifted barrier form of shape metric (mu_2).
@@ -1817,17 +1821,27 @@ protected:
// PA extension
// ------------
// Jtr: all ref->target Jacobians, (dim x dim) Q-Vector as DenseTensor.
// updated when needed, based on Jtr_needs_update.
//
// E: Q-vector for TMOP-energy
// Used as temporary storage when the total energy is computed.
// O: Q-Vector of 1.0, used to compute sums using the dot product kernel.
// X0: E-vector for initial nodal coordinates used for limiting.
// Does not change during the TMOP iteration.
// H: Q-Vector for Hessian associated with the metric term.
// Updated by every call to PANonlinearFormExtension::GetGradient().
// C0: Q-Vector for spatial weight used for the limiting term.
// Updated when the mesh nodes change.
// LD: E-Vector constructed using limiting distance grid function (delta).
// Does not change during the TMOP iteration.
// H0: Q-Vector for Hessian associated with the limiting term.
// Updated by every call to PANonlinearFormExtension::GetGradient().
// MC: Q-Vector for the metric Coefficient.
// Updated when the mesh nodes change.
//
// maps: Dof2Quad map for fespace associate with nodal coordinates.
// maps_lim: Dof2Quad map for fespace associated with the limiting distance
// grid function.
// maps: Dof2Quad map for fes associated with the nodal coordinates.
// maps_lim: Dof2Quad map for fes associated with the limiting dist GridFunc.
//
// Jtr_debug_grad
// We keep track if Jtr was set by AssembleGradPA() in Jtr_debug_grad: it
@@ -1846,7 +1860,7 @@ protected:
mutable DenseTensor Jtr;
mutable bool Jtr_needs_update;
mutable bool Jtr_debug_grad;
mutable Vector E, O, X0, H, C0, LD, H0;
mutable Vector E, O, X0, H, C0, LD, H0, MC;
const DofToQuad *maps;
const DofToQuad *maps_lim = nullptr;
const GeometricFactors *geom;
@@ -1960,6 +1974,9 @@ protected:
void AssemblePA_Limiting();
void ComputeAllElementTargets(const Vector &xe = Vector()) const;
// Updates the Q-vectors for the metric_coeff and lim_coeff, based on the
// new physical positions of the quadrature points.
void UpdateCoefficientsPA(const Vector &x_loc);
// Compute Min(Det(Jpt)) in the mesh, does not reduce over MPI.
double ComputeMinDetT(const Vector &x, const FiniteElementSpace &fes);
+65
View File
@@ -176,6 +176,42 @@ void TMOP_Integrator::ComputeAllElementTargets(const Vector &xe) const
targetC->ComputeAllElementTargets(*fes, ir, xe, PA.Jtr);
}
void TMOP_Integrator::UpdateCoefficientsPA(const Vector &x_loc)
{
// Both are constant or not specified.
if (PA.MC.Size() == 1 && PA.C0.Size() == 1) { return; }
// Coefficients are always evaluated on the CPU for now.
PA.MC.HostWrite();
PA.C0.HostWrite();
const IntegrationRule &ir = *PA.ir;
auto T = new IsoparametricTransformation;
for (int e = 0; e < PA.ne; ++e)
{
// Uses the node positions in x_loc.
PA.fes->GetMesh()->GetElementTransformation(e, x_loc, T);
if (PA.MC.Size() > 1)
{
for (int q = 0; q < PA.nq; ++q)
{
PA.MC(q + e * PA.nq) = metric_coeff->Eval(*T, ir.IntPoint(q));
}
}
if (PA.C0.Size() > 1)
{
for (int q = 0; q < PA.nq; ++q)
{
PA.C0(q + e * PA.nq) = lim_coeff->Eval(*T, ir.IntPoint(q));
}
}
}
delete T;
}
void TMOP_Integrator::AssemblePA(const FiniteElementSpace &fes)
{
const MemoryType mt = (pa_mt == MemoryType::DEFAULT) ?
@@ -213,6 +249,35 @@ void TMOP_Integrator::AssemblePA(const FiniteElementSpace &fes)
PA.O.SetSize(ne*nq, Device::GetDeviceMemoryType());
PA.O = 1.0;
if (metric_coeff)
{
if (auto cc = dynamic_cast<ConstantCoefficient *>(metric_coeff))
{
PA.MC.SetSize(1, Device::GetMemoryType());
PA.MC.HostWrite();
PA.MC(0) = cc->constant;
}
else
{
PA.MC.SetSize(PA.nq * PA.ne, Device::GetMemoryType());
auto M0 = Reshape(PA.MC.HostWrite(), PA.nq, PA.ne);
for (int e = 0; e < PA.ne; ++e)
{
ElementTransformation& T = *PA.fes->GetElementTransformation(e);
for (int q = 0; q < ir.GetNPoints(); ++q)
{
M0(q,e) = metric_coeff->Eval(T, ir.IntPoint(q));
}
}
}
}
else
{
PA.MC.SetSize(1, Device::GetMemoryType());
PA.MC.HostWrite();
PA.MC(0) = 1.0;
}
// Setup ref->target Jacobians, PA.Jtr, (dim x dim) Q-vector, DenseTensor
PA.Jtr.SetSize(dim, dim, PA.ne*PA.nq, mt);
PA.Jtr_needs_update = true;
+10 -2
View File
@@ -258,6 +258,7 @@ void EvalH_094(const int e, const int qx, const int qy,
MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_2D,
const Vector &x_,
const double metric_normal,
const Vector &mc_,
const Array<double> &metric_param,
const int mid,
const int NE,
@@ -273,11 +274,16 @@ MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_2D,
|| mid == 80 || mid == 94,
"2D metric not yet implemented!");
const bool const_m0 = mc_.Size() == 1;
constexpr int DIM = 2;
constexpr int NBZ = 1;
const int D1D = T_D1D ? T_D1D : d1d;
const int Q1D = T_Q1D ? T_Q1D : q1d;
const auto MC = const_m0 ?
Reshape(mc_.Read(), 1, 1, 1) :
Reshape(mc_.Read(), Q1D, Q1D, NE);
const auto W = Reshape(w_.Read(), Q1D, Q1D);
const auto b = Reshape(b_.Read(), Q1D, D1D);
const auto g = Reshape(g_.Read(), Q1D, D1D);
@@ -312,7 +318,8 @@ MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_2D,
{
const double *Jtr = &J(0,0,qx,qy,e);
const double detJtr = kernels::Det<2>(Jtr);
const double weight = metric_normal * W(qx,qy) * detJtr;
const double m_coef = const_m0 ? MC(0,0,0) : MC(qx,qy,e);
const double weight = metric_normal * m_coef * W(qx,qy) * detJtr;
// Jrt = Jtr^{-1}
double Jrt[4];
@@ -347,6 +354,7 @@ void TMOP_Integrator::AssembleGradPA_2D(const Vector &X) const
const int Q1D = PA.maps->nqpt;
const int id = (D1D << 4 ) | Q1D;
const double mn = metric_normal;
const Vector &MC = PA.MC;
const DenseTensor &J = PA.Jtr;
const Array<double> &W = PA.ir->GetWeights();
const Array<double> &B = PA.maps->B;
@@ -359,7 +367,7 @@ void TMOP_Integrator::AssembleGradPA_2D(const Vector &X) const
m->GetWeights(mp);
}
MFEM_LAUNCH_TMOP_KERNEL(SetupGradPA_2D,id,X,mn,mp,M,N,W,B,G,J,H);
MFEM_LAUNCH_TMOP_KERNEL(SetupGradPA_2D,id,X,mn,MC,mp,M,N,W,B,G,J,H);
}
} // namespace mfem
+11 -2
View File
@@ -312,6 +312,7 @@ void EvalH_338(const int e, const int qx, const int qy, const int qz,
MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_3D,
const double metric_normal,
const Vector &mc_,
const Array<double> &metric_param,
const int mid,
const Vector &x_,
@@ -328,10 +329,15 @@ MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_3D,
mid == 321 || mid == 332 || mid == 338,
"3D metric not yet implemented!");
const bool const_m0 = mc_.Size() == 1;
constexpr int DIM = 3;
const int D1D = T_D1D ? T_D1D : d1d;
const int Q1D = T_Q1D ? T_Q1D : q1d;
const auto MC = const_m0 ?
Reshape(mc_.Read(), 1, 1, 1, 1) :
Reshape(mc_.Read(), Q1D, Q1D, Q1D, NE);
const auto b = Reshape(b_.Read(), Q1D, D1D);
const auto g = Reshape(g_.Read(), Q1D, D1D);
const auto W = Reshape(w_.Read(), Q1D, Q1D, Q1D);
@@ -369,7 +375,9 @@ MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_3D,
{
const double *Jtr = &J(0,0,qx,qy,qz,e);
const double detJtr = kernels::Det<3>(Jtr);
const double weight = metric_normal * W(qx,qy,qz) * detJtr;
const double m_coef = const_m0 ? MC(0,0,0,0) : MC(qx,qy,qz,e);
const double weight = metric_normal * m_coef *
W(qx,qy,qz) * detJtr;
// Jrt = Jtr^{-1}
double Jrt[9];
@@ -438,6 +446,7 @@ void TMOP_Integrator::AssembleGradPA_3D(const Vector &X) const
const int M = metric->Id();
const int id = (D1D << 4 ) | Q1D;
const double mn = metric_normal;
const Vector &MC = PA.MC;
const DenseTensor &J = PA.Jtr;
const Array<double> &W = PA.ir->GetWeights();
const Array<double> &B = PA.maps->B;
@@ -450,7 +459,7 @@ void TMOP_Integrator::AssembleGradPA_3D(const Vector &X) const
m->GetWeights(mp);
}
MFEM_LAUNCH_TMOP_KERNEL(SetupGradPA_3D,id,mn,mp,M,X,N,W,B,G,J,H);
MFEM_LAUNCH_TMOP_KERNEL(SetupGradPA_3D,id,mn,MC,mp,M,X,N,W,B,G,J,H);
}
} // namespace mfem
+11 -2
View File
@@ -98,6 +98,7 @@ void EvalP_094(const double *Jpt, const double *w, double *P)
MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_2D,
const double metric_normal,
const Vector &mc_,
const Array<double> &metric_param,
const int mid,
const int NE,
@@ -114,12 +115,17 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_2D,
|| mid == 80 || mid == 94,
"2D metric not yet implemented!");
const bool const_m0 = mc_.Size() == 1;
constexpr int DIM = 2;
constexpr int NBZ = 1;
const int D1D = T_D1D ? T_D1D : d1d;
const int Q1D = T_Q1D ? T_Q1D : q1d;
const auto MC = const_m0 ?
Reshape(mc_.Read(), 1, 1, 1) :
Reshape(mc_.Read(), Q1D, Q1D, NE);
const auto J = Reshape(j_.Read(), DIM, DIM, Q1D, Q1D, NE);
const auto W = Reshape(w_.Read(), Q1D, Q1D);
const auto b = Reshape(b_.Read(), Q1D, D1D);
@@ -154,7 +160,9 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_2D,
{
const double *Jtr = &J(0,0,qx,qy,e);
const double detJtr = kernels::Det<2>(Jtr);
const double weight = metric_normal * W(qx,qy) * detJtr;
const double m_coef = const_m0 ? MC(0,0,0) : MC(qx,qy,e);
const double weight = metric_normal * m_coef *
W(qx,qy) * detJtr;
// Jrt = Jtr^{-1}
double Jrt[4];
@@ -204,6 +212,7 @@ void TMOP_Integrator::AddMultPA_2D(const Vector &X, Vector &Y) const
const Array<double> &B = PA.maps->B;
const Array<double> &G = PA.maps->G;
const double mn = metric_normal;
const Vector &MC = PA.MC;
Array<double> mp;
if (auto m = dynamic_cast<TMOP_Combo_QualityMetric *>(metric))
@@ -211,7 +220,7 @@ void TMOP_Integrator::AddMultPA_2D(const Vector &X, Vector &Y) const
m->GetWeights(mp);
}
MFEM_LAUNCH_TMOP_KERNEL(AddMultPA_Kernel_2D,id,mn,mp,M,N,J,W,B,G,X,Y);
MFEM_LAUNCH_TMOP_KERNEL(AddMultPA_Kernel_2D,id,mn,MC,mp,M,N,J,W,B,G,X,Y);
}
} // namespace mfem
+11 -2
View File
@@ -131,6 +131,7 @@ void EvalP_338(const double *J, const double *w, double *P)
MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_3D,
const double metric_normal,
const Vector &mc_,
const Array<double> &metric_param,
const int mid,
const int NE,
@@ -147,10 +148,15 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_3D,
mid == 321 || mid == 332 || mid == 338,
"3D metric not yet implemented!");
const bool const_m0 = mc_.Size() == 1;
constexpr int DIM = 3;
const int D1D = T_D1D ? T_D1D : d1d;
const int Q1D = T_Q1D ? T_Q1D : q1d;
const auto MC = const_m0 ?
Reshape(mc_.Read(), 1, 1, 1, 1) :
Reshape(mc_.Read(), Q1D, Q1D, Q1D, NE);
const auto J = Reshape(j_.Read(), DIM, DIM, Q1D, Q1D, Q1D, NE);
const auto W = Reshape(w_.Read(), Q1D, Q1D, Q1D);
const auto b = Reshape(b_.Read(), Q1D, D1D);
@@ -188,7 +194,9 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_3D,
{
const double *Jtr = &J(0,0,qx,qy,qz,e);
const double detJtr = kernels::Det<3>(Jtr);
const double weight = metric_normal * W(qx,qy,qz) * detJtr;
const double m_coef = const_m0 ? MC(0,0,0,0) : MC(qx,qy,qz,e);
const double weight = metric_normal * m_coef *
W(qx,qy,qz) * detJtr;
// Jrt = Jtr^{-1}
double Jrt[9];
@@ -240,6 +248,7 @@ void TMOP_Integrator::AddMultPA_3D(const Vector &X, Vector &Y) const
const Array<double> &B = PA.maps->B;
const Array<double> &G = PA.maps->G;
const double mn = metric_normal;
const Vector &MC = PA.MC;
Array<double> mp;
if (auto m = dynamic_cast<TMOP_Combo_QualityMetric *>(metric))
@@ -247,7 +256,7 @@ void TMOP_Integrator::AddMultPA_3D(const Vector &X, Vector &Y) const
m->GetWeights(mp);
}
MFEM_LAUNCH_TMOP_KERNEL(AddMultPA_Kernel_3D,id,mn,mp,M,N,J,W,B,G,X,Y);
MFEM_LAUNCH_TMOP_KERNEL(AddMultPA_Kernel_3D,id,mn,MC,mp,M,N,J,W,B,G,X,Y);
}
} // namespace mfem
+10 -2
View File
@@ -73,6 +73,7 @@ double EvalW_094(const double *Jpt, const double *w)
MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_2D,
const double metric_normal,
const Vector &mc_,
const Array<double> &metric_param,
const int mid,
const int NE,
@@ -90,12 +91,17 @@ MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_2D,
|| mid == 80 || mid == 94,
"2D metric not yet implemented!");
const bool const_m0 = mc_.Size() == 1;
constexpr int DIM = 2;
constexpr int NBZ = 1;
const int D1D = T_D1D ? T_D1D : d1d;
const int Q1D = T_Q1D ? T_Q1D : q1d;
const auto MC = const_m0 ?
Reshape(mc_.Read(), 1, 1, 1) :
Reshape(mc_.Read(), Q1D, Q1D, NE);
const auto J = Reshape(j_.Read(), DIM, DIM, Q1D, Q1D, NE);
const auto b = Reshape(b_.Read(), Q1D, D1D);
const auto g = Reshape(g_.Read(), Q1D, D1D);
@@ -131,7 +137,8 @@ MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_2D,
{
const double *Jtr = &J(0,0,qx,qy,e);
const double detJtr = kernels::Det<2>(Jtr);
const double weight = metric_normal * W(qx,qy) * detJtr;
const double m_coef = const_m0 ? MC(0,0,0) : MC(qx,qy,e);
const double weight = metric_normal * m_coef * W(qx,qy) * detJtr;
// Jrt = Jtr^{-1}
double Jrt[4];
@@ -169,6 +176,7 @@ double TMOP_Integrator::GetLocalStateEnergyPA_2D(const Vector &X) const
const int Q1D = PA.maps->nqpt;
const int id = (D1D << 4 ) | Q1D;
const double mn = metric_normal;
const Vector &MC = PA.MC;
const DenseTensor &J = PA.Jtr;
const Array<double> &W = PA.ir->GetWeights();
const Array<double> &B = PA.maps->B;
@@ -182,7 +190,7 @@ double TMOP_Integrator::GetLocalStateEnergyPA_2D(const Vector &X) const
m->GetWeights(mp);
}
MFEM_LAUNCH_TMOP_KERNEL(EnergyPA_2D,id,mn,mp,M,N,J,W,B,G,X,O,E);
MFEM_LAUNCH_TMOP_KERNEL(EnergyPA_2D,id,mn,MC,mp,M,N,J,W,B,G,X,O,E);
}
} // namespace mfem
+11 -2
View File
@@ -82,6 +82,7 @@ double EvalW_338(const double *J, const double *w)
MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_3D,
const double metric_normal,
const Vector &mc_,
const Array<double> &metric_param,
const int mid,
const int NE,
@@ -99,10 +100,15 @@ MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_3D,
mid == 321 || mid == 332 || mid == 338,
"3D metric not yet implemented!");
const bool const_m0 = mc_.Size() == 1;
constexpr int DIM = 3;
const int D1D = T_D1D ? T_D1D : d1d;
const int Q1D = T_Q1D ? T_Q1D : q1d;
const auto MC = const_m0 ?
Reshape(mc_.Read(), 1, 1, 1, 1) :
Reshape(mc_.Read(), Q1D, Q1D, Q1D, NE);
const auto J = Reshape(j_.Read(), DIM, DIM, Q1D, Q1D, Q1D, NE);
const auto b = Reshape(b_.Read(), Q1D, D1D);
const auto g = Reshape(g_.Read(), Q1D, D1D);
@@ -141,7 +147,9 @@ MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_3D,
{
const double *Jtr = &J(0,0,qx,qy,qz,e);
const double detJtr = kernels::Det<3>(Jtr);
const double weight = metric_normal * W(qx,qy,qz) * detJtr;
const double m_coef = const_m0 ? MC(0,0,0,0) : MC(qx,qy,qz,e);
const double weight = metric_normal * m_coef *
W(qx,qy,qz) * detJtr;
// Jrt = Jtr^{-1}
double Jrt[9];
@@ -181,6 +189,7 @@ double TMOP_Integrator::GetLocalStateEnergyPA_3D(const Vector &X) const
const int Q1D = PA.maps->nqpt;
const int id = (D1D << 4 ) | Q1D;
const double mn = metric_normal;
const Vector &MC = PA.MC;
const DenseTensor &J = PA.Jtr;
const Array<double> &W = PA.ir->GetWeights();
const Array<double> &B = PA.maps->B;
@@ -194,7 +203,7 @@ double TMOP_Integrator::GetLocalStateEnergyPA_3D(const Vector &X) const
m->GetWeights(mp);
}
MFEM_LAUNCH_TMOP_KERNEL(EnergyPA_3D,id,mn,mp,M,N,J,W,B,G,O,X,E);
MFEM_LAUNCH_TMOP_KERNEL(EnergyPA_3D,id,mn,MC,mp,M,N,J,W,B,G,O,X,E);
}
} // namespace mfem
+7 -1
View File
@@ -781,7 +781,13 @@ std::unique_ptr<SparseMatrix>>
int ndof_lor = fes_lor.GetNDofs();
// If the local mesh is empty, skip all computations
if (nel_ho == 0) { return {nullptr, nullptr}; }
if (nel_ho == 0)
{
return std::make_pair(
std::unique_ptr<SparseMatrix>(new SparseMatrix),
std::unique_ptr<SparseMatrix>(new SparseMatrix)
);
}
const CoarseFineTransformations& cf_tr = mesh_lor->GetRefinementTransforms();
+12
View File
@@ -26,6 +26,10 @@
#include "sort_pairs.hpp"
#include "globals.hpp"
#ifdef MFEM_USE_STRUMPACK
#include <StrumpackConfig.hpp> // STRUMPACK_USE_PTSCOTCH, etc.
#endif
#include <iostream>
#include <map>
@@ -34,6 +38,14 @@ using namespace std;
namespace mfem
{
#if defined(MFEM_USE_STRUMPACK) && \
(defined(STRUMPACK_USE_PTSCOTCH) || defined(STRUMPACK_USE_SLATE_SCALAPACK))
int Mpi::default_thread_required = MPI_THREAD_MULTIPLE;
#else
int Mpi::default_thread_required = MPI_THREAD_SINGLE;
#endif
GroupTopology::GroupTopology(const GroupTopology &gt)
: MyComm(gt.MyComm),
group_lproc(gt.group_lproc)
+36 -14
View File
@@ -22,7 +22,6 @@
#include "globals.hpp"
#include <mpi.h>
namespace mfem
{
@@ -32,10 +31,34 @@ namespace mfem
class Mpi
{
public:
/// Singleton creation with Mpi::Init();
static void Init() { Init_(NULL, NULL); }
/// Singleton creation with Mpi::Init(argc,argv);
static void Init(int &argc, char **&argv) { Init_(&argc, &argv); }
/// Singleton creation with Mpi::Init(argc, argv).
static void Init(int &argc, char **&argv,
int required = default_thread_required,
int *provided = nullptr)
{ Init(&argc, &argv, required, provided); }
/// Singleton creation with Mpi::Init().
static void Init(int *argc = nullptr, char ***argv = nullptr,
int required = default_thread_required,
int *provided = nullptr)
{
MFEM_VERIFY(!IsInitialized(), "MPI already initialized!");
if (required == MPI_THREAD_SINGLE)
{
int mpi_err = MPI_Init(argc, argv);
MFEM_VERIFY(!mpi_err, "error in MPI_Init()!");
if (provided) { *provided = MPI_THREAD_SINGLE; }
}
else
{
int mpi_provided;
int mpi_err = MPI_Init_thread(argc, argv, required, &mpi_provided);
MFEM_VERIFY(!mpi_err, "error in MPI_Init()!");
if (provided) { *provided = mpi_provided; }
}
// The Mpi singleton object below needs to be created after MPI_Init() for
// some MPI implementations.
Singleton();
}
/// Finalize MPI (if it has been initialized and not yet already finalized).
static void Finalize()
{
@@ -71,20 +94,19 @@ public:
}
/// Return true if the rank in MPI_COMM_WORLD is zero.
static bool Root() { return WorldRank() == 0; }
/// Default level of thread support for MPI_Init_thread.
static MFEM_EXPORT int default_thread_required;
private:
/// Initialize MPI
static void Init_(int *argc, char ***argv)
/// Initialize the Mpi singleton.
static Mpi &Singleton()
{
MFEM_VERIFY(!IsInitialized(), "MPI already initialized!")
MPI_Init(argc, argv);
// The "mpi" object below needs to be created after MPI_Init() for some
// MPI implementations
static Mpi mpi;
return mpi;
}
/// Finalize MPI
/// Finalize MPI.
~Mpi() { Finalize(); }
/// Prevent direct construction of objects of this class
Mpi() { }
/// Prevent direct construction of objects of this class.
Mpi() {}
};
/** @brief A simple convenience class based on the Mpi singleton class above.
+1 -1
View File
@@ -56,7 +56,7 @@ void mfem_backtrace(int mode = 0, int depth = -1);
/** @brief Function called when an error is encountered. Used by the macros
MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY. */
void mfem_error(const char *msg = NULL);
[[noreturn]] void mfem_error(const char *msg = NULL);
/// Function called by the macro MFEM_WARNING.
void mfem_warning(const char *msg = NULL);
+50 -31
View File
@@ -16,13 +16,13 @@
#include <cstdlib>
#include <errno.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#else
#include <winsock.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#ifdef _MSC_VER
typedef int ssize_t;
// Link with ws2_32.lib
@@ -51,47 +51,66 @@ int isockstream::establish()
{
// char myname[129];
char myname[] = "localhost";
int port;
struct sockaddr_in sa;
struct hostent *hp;
int sfd;
struct addrinfo hints, *res, *rp;
memset(&sa, 0, sizeof(struct sockaddr_in));
// gethostname(myname, 128);
hp= gethostbyname(myname);
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
if (hp == NULL)
int s = getaddrinfo(myname, NULL, &hints, &res);
if (s != 0)
{
mfem::err << "isockstream::establish(): gethostbyname() failed!\n"
<< "isockstream::establish(): gethostname() returned: '"
mfem::err << "isockstream::establish(): getaddrinfo() failed!\n"
<< "isockstream::establish(): getaddrinfo() returned: '"
<< myname << "'" << endl;
error = 1;
return (-1);
}
sa.sin_family= hp->h_addrtype;
sa.sin_port= htons(portnum);
if ((port = socket(AF_INET, SOCK_STREAM, 0)) < 0)
// loop the list of address structures returned by getaddrinfo()
for (rp = res; rp != NULL; rp = rp->ai_next)
{
mfem::err << "isockstream::establish(): socket() failed!" << endl;
error = 2;
if ((sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol)) < 0)
{
mfem::err << "isockstream::establish(): socket() failed!" << endl;
error = 2;
return (-1);
}
int on = 1;
if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
{
mfem::err << "isockstream::establish(): setsockopt() failed!" << endl;
return (-1);
}
#if defined(__APPLE__)
if (bind(sfd, (const struct sockaddr *)rp->ai_addr, rp->ai_addrlen) < 0)
#else
if (bind(sfd, rp->ai_addr, rp->ai_addrlen) < 0)
#endif
{
mfem::err << "isockstream::establish(): bind() failed!" << endl;
close(sfd);
error = 3;
continue;
}
break;
}
// No address succeeded
if (rp == NULL)
{
mfem::err << "Could not bind\n";
return (-1);
}
int on=1;
setsockopt(port, SOL_SOCKET, SO_REUSEADDR, (char *)(&on), sizeof(on));
if (bind(port,(const sockaddr*)&sa,(socklen_t)sizeof(struct sockaddr_in)) < 0)
{
mfem::err << "isockstream::establish(): bind() failed!" << endl;
close(port);
error = 3;
return (-1);
}
listen(port, 4);
error = 0;
return (port);
freeaddrinfo(res);
listen(sfd, 4);
return (sfd);
}
int isockstream::read_data(int s, char *buf, int n)
+38 -31
View File
@@ -19,15 +19,15 @@
#include <cstring> // memset, memcpy, strerror
#include <cerrno> // errno
#ifndef _WIN32
#include <netdb.h> // gethostbyname
#include <netdb.h> // getaddrinfo
#include <arpa/inet.h> // htons
#include <sys/types.h> // socket, setsockopt, connect, recv, send
#include <sys/socket.h> // socket, setsockopt, connect, recv, send
#include <unistd.h> // close
#include <netinet/in.h> // sockaddr_in
#define closesocket (::close)
#else
#include <winsock.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#ifdef _MSC_VER
typedef int ssize_t;
// Link with ws2_32.lib
@@ -93,8 +93,7 @@ int socketbuf::attach(int sd)
int socketbuf::open(const char hostname[], int port)
{
struct sockaddr_in sa;
struct hostent *hp;
struct addrinfo hints, *res, *rp;
if (!wsInit_.Initialized())
{
@@ -105,42 +104,50 @@ int socketbuf::open(const char hostname[], int port)
setg(NULL, NULL, NULL);
setp(obuf, obuf + buflen);
hp = gethostbyname(hostname);
if (hp == NULL)
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = 0;
hints.ai_protocol = 0;
std::string portStr = std::to_string(port);
int s = getaddrinfo(hostname, portStr.c_str(), &hints, &res);
if (s != 0)
{
socket_descriptor = -3;
return -1;
}
memset(&sa, 0, sizeof(sa));
memcpy((char *)&sa.sin_addr, hp->h_addr, hp->h_length);
sa.sin_family = hp->h_addrtype;
sa.sin_port = htons(port);
socket_descriptor = socket(hp->h_addrtype, SOCK_STREAM, 0);
if (socket_descriptor < 0)
for (rp = res; rp != NULL; rp = rp->ai_next)
{
return -1;
}
socket_descriptor = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (socket_descriptor < 0)
{
continue;
}
#if defined __APPLE__
// OS X does not support the MSG_NOSIGNAL option of send().
// Instead we can use the SO_NOSIGPIPE socket option.
int on = 1;
if (setsockopt(socket_descriptor, SOL_SOCKET, SO_NOSIGPIPE,
(char *)(&on), sizeof(on)) < 0)
{
closesocket(socket_descriptor);
socket_descriptor = -2;
return -1;
}
// OS X does not support the MSG_NOSIGNAL option of send().
// Instead we can use the SO_NOSIGPIPE socket option.
int on = 1;
if (setsockopt(socket_descriptor, SOL_SOCKET, SO_NOSIGPIPE,
&on, sizeof(on)) < 0)
{
closesocket(socket_descriptor);
socket_descriptor = -2;
return -1;
}
#endif
if (connect(socket_descriptor,
(const struct sockaddr *)&sa, sizeof(sa)) < 0)
{
closesocket(socket_descriptor);
socket_descriptor = -2;
return -1;
if (connect(socket_descriptor, rp->ai_addr, rp->ai_addrlen) < 0)
{
closesocket(socket_descriptor);
socket_descriptor = -2;
continue;
}
break;
}
freeaddrinfo(res);
return 0;
}
+50 -6
View File
@@ -937,11 +937,14 @@ GMRESSolver::GMRESSolver(GinkgoExecutor &exec,
void GMRESSolver::SetKDim(int dim)
{
m = dim;
using gmres_type = gko::solver::Gmres<double>;
gko::as<gmres_type::Factory>(solver_gen)->get_parameters().krylov_dim = m;
using gmres = gko::solver::Gmres<double>;
// Create new solver factory with other parameters the same, but new value for krylov_dim
auto current_params = gko::as<gmres::Factory>(solver_gen)->get_parameters();
this->solver_gen = current_params.with_krylov_dim(static_cast<unsigned long>(m))
.on(this->executor);
if (solver)
{
gko::as<gmres_type>(solver)->set_krylov_dim(static_cast<unsigned long>(m));
gko::as<gmres>(solver)->set_krylov_dim(static_cast<unsigned long>(m));
}
}
@@ -1036,11 +1039,14 @@ CBGMRESSolver::CBGMRESSolver(GinkgoExecutor &exec,
void CBGMRESSolver::SetKDim(int dim)
{
m = dim;
using gmres_type = gko::solver::CbGmres<double>;
gko::as<gmres_type::Factory>(solver_gen)->get_parameters().krylov_dim = m;
using gmres = gko::solver::CbGmres<double>;
// Create new solver factory with other parameters the same, but new value for krylov_dim
auto current_params = gko::as<gmres::Factory>(solver_gen)->get_parameters();
this->solver_gen = current_params.with_krylov_dim(static_cast<unsigned long>(m))
.on(this->executor);
if (solver)
{
gko::as<gmres_type>(solver)->set_krylov_dim(static_cast<unsigned long>(m));
gko::as<gmres>(solver)->set_krylov_dim(static_cast<unsigned long>(m));
}
}
@@ -1205,7 +1211,11 @@ IluPreconditioner::IluPreconditioner(
.with_skip_sorting(skip_sort)
.on(executor);
precond_gen = gko::preconditioner::Ilu<>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
#else
.with_factorization(fact_factory)
#endif
.on(executor);
}
else
@@ -1217,7 +1227,11 @@ IluPreconditioner::IluPreconditioner(
.with_skip_sorting(skip_sort)
.on(executor);
precond_gen = gko::preconditioner::Ilu<>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
#else
.with_factorization(fact_factory)
#endif
.on(executor);
}
@@ -1255,9 +1269,15 @@ IluIsaiPreconditioner::IluIsaiPreconditioner(
.on(executor);
precond_gen = gko::preconditioner::Ilu<l_solver_type,
u_solver_type>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
.with_l_solver_factory(l_solver_factory)
.with_u_solver_factory(u_solver_factory)
#else
.with_factorization(fact_factory)
.with_l_solver(l_solver_factory)
.with_u_solver(u_solver_factory)
#endif
.on(executor);
}
@@ -1271,9 +1291,15 @@ IluIsaiPreconditioner::IluIsaiPreconditioner(
.on(executor);
precond_gen = gko::preconditioner::Ilu<l_solver_type,
u_solver_type>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
.with_l_solver_factory(l_solver_factory)
.with_u_solver_factory(u_solver_factory)
#else
.with_factorization(fact_factory)
.with_l_solver(l_solver_factory)
.with_u_solver(u_solver_factory)
#endif
.on(executor);
}
}
@@ -1298,7 +1324,11 @@ IcPreconditioner::IcPreconditioner(
.with_skip_sorting(skip_sort)
.on(executor);
precond_gen = gko::preconditioner::Ic<>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
#else
.with_factorization(fact_factory)
#endif
.on(executor);
}
else
@@ -1311,7 +1341,11 @@ IcPreconditioner::IcPreconditioner(
.with_skip_sorting(skip_sort)
.on(executor);
precond_gen = gko::preconditioner::Ic<>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
#else
.with_factorization(fact_factory)
#endif
.on(executor);
}
}
@@ -1340,8 +1374,13 @@ IcIsaiPreconditioner::IcIsaiPreconditioner(
.with_skip_sorting(skip_sort)
.on(executor);
precond_gen = gko::preconditioner::Ic<l_solver_type>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
.with_l_solver_factory(l_solver_factory)
#else
.with_factorization(fact_factory)
.with_l_solver(l_solver_factory)
#endif
.on(executor);
}
else
@@ -1354,8 +1393,13 @@ IcIsaiPreconditioner::IcIsaiPreconditioner(
.with_skip_sorting(skip_sort)
.on(executor);
precond_gen = gko::preconditioner::Ic<l_solver_type>::build()
#if MFEM_GINKGO_VERSION < 10700
.with_factorization_factory(fact_factory)
.with_l_solver_factory(l_solver_factory)
#else
.with_factorization(fact_factory)
.with_l_solver(l_solver_factory)
#endif
.on(executor);
}
}
+12 -6
View File
@@ -862,8 +862,10 @@ public:
{
rel_tol = rtol;
this->update_stop_factory();
gko::as<typename SolverType::Factory>(solver_gen)->get_parameters().criteria =
{ combined_factory };
auto current_params = gko::as<typename SolverType::Factory>
(solver_gen)->get_parameters();
this->solver_gen = current_params.with_criteria(this->combined_factory)
.on(this->executor);
if (solver)
{
gko::as<SolverType>(solver)->set_stop_criterion_factory(combined_factory);
@@ -874,8 +876,10 @@ public:
{
abs_tol = atol;
this->update_stop_factory();
gko::as<typename SolverType::Factory>(solver_gen)->get_parameters().criteria =
{ combined_factory };
auto current_params = gko::as<typename SolverType::Factory>
(solver_gen)->get_parameters();
this->solver_gen = current_params.with_criteria(this->combined_factory)
.on(this->executor);
if (solver)
{
gko::as<SolverType>(solver)->set_stop_criterion_factory(combined_factory);
@@ -886,8 +890,10 @@ public:
{
max_iter = max_it;
this->update_stop_factory();
gko::as<typename SolverType::Factory>(solver_gen)->get_parameters().criteria =
{ combined_factory };
auto current_params = gko::as<typename SolverType::Factory>
(solver_gen)->get_parameters();
this->solver_gen = current_params.with_criteria(this->combined_factory)
.on(this->executor);
if (solver)
{
gko::as<SolverType>(solver)->set_stop_criterion_factory(combined_factory);
+4 -3
View File
@@ -5075,7 +5075,8 @@ void HypreBoomerAMG::RecomputeRBMs()
}
}
void HypreBoomerAMG::SetElasticityOptions(ParFiniteElementSpace *fespace_)
void HypreBoomerAMG::SetElasticityOptions(ParFiniteElementSpace *fespace_,
bool interp_refine_)
{
#ifdef HYPRE_USING_GPU
MFEM_ABORT("this method is not supported in hypre built with GPU support");
@@ -5086,7 +5087,7 @@ void HypreBoomerAMG::SetElasticityOptions(ParFiniteElementSpace *fespace_)
// Make sure the systems AMG options are set
int dim = fespace_->GetParMesh()->Dimension();
SetSystemsOptions(dim);
SetSystemsOptions(dim, fespace->GetOrdering() == Ordering::byNODES);
// Nodal coarsening options (nodal coarsening is required for this solver)
// See hypre's new_ij driver and the paper for descriptions.
@@ -5101,7 +5102,7 @@ void HypreBoomerAMG::SetElasticityOptions(ParFiniteElementSpace *fespace_)
// Optionally pre-process the interpolation matrix through iterative weight
// refinement (this is generally applicable for any system)
int interp_refine = 1;
int interp_refine = interp_refine_;
HYPRE_BoomerAMGSetNodal(amg_precond, nodal);
HYPRE_BoomerAMGSetNodalDiag(amg_precond, nodal_diag);
+4 -3
View File
@@ -1623,9 +1623,10 @@ public:
geometric rigid body modes and could perform better on some problems, see
"Improving algebraic multigrid interpolation operators for linear
elasticity problems", Baker, Kolev, Yang, NLAA 2009, DOI:10.1002/nla.688.
This solver assumes Ordering::byVDIM in the FiniteElementSpace used to
construct A. */
void SetElasticityOptions(ParFiniteElementSpace *fespace);
The optional argument @ interp_refine is used to enable/disable pre-processing
of the interpolation matrix through iterative weight refinement */
void SetElasticityOptions(ParFiniteElementSpace *fespace,
bool interp_refine = true);
#if MFEM_HYPRE_VERSION >= 21800
/** Hypre parameters to use AIR AMG solve for advection-dominated problems.
+38
View File
@@ -365,6 +365,44 @@ void SecondOrderTimeDependentOperator::ImplicitSolve(const double dt0,
mfem_error("SecondOrderTimeDependentOperator::ImplicitSolve() is not overridden!");
}
SumOperator::SumOperator(const Operator *A, const double alpha,
const Operator *B, const double beta,
bool ownA, bool ownB)
: Operator(A->Height(), A->Width()),
A(A), B(B), alpha(alpha), beta(beta), ownA(ownA), ownB(ownB),
a(A->Width()), b(B->Width())
{
MFEM_VERIFY(A->Width() == B->Width(),
"incompatible Operators: different widths\n"
<< "A->Width() = " << A->Width()
<< ", B->Width() = " << B->Width() );
MFEM_VERIFY(A->Height() == B->Height(),
"incompatible Operators: different heights\n"
<< "A->Height() = " << A->Height()
<< ", B->Height() = " << B->Height() );
{
const Solver* SolverA = dynamic_cast<const Solver*>(A);
const Solver* SolverB = dynamic_cast<const Solver*>(B);
if (SolverA)
{
MFEM_VERIFY(!(SolverA->iterative_mode),
"Operator A of a SumOperator should not be in iterative mode");
}
if (SolverB)
{
MFEM_VERIFY(!(SolverB->iterative_mode),
"Operator B of a SumOperator should not be in iterative mode");
}
}
}
SumOperator::~SumOperator()
{
if (ownA) { delete A; }
if (ownB) { delete B; }
}
ProductOperator::ProductOperator(const Operator *A, const Operator *B,
bool ownA, bool ownB)
+22
View File
@@ -769,6 +769,28 @@ public:
{ A.Mult(x, y); }
};
/// General linear combination operator: x -> a A(x) + b B(x).
class SumOperator : public Operator
{
const Operator *A, *B;
const double alpha, beta;
bool ownA, ownB;
mutable Vector a, b;
public:
SumOperator(
const Operator *A, const double alpha,
const Operator *B, const double beta,
bool ownA, bool ownB);
virtual void Mult(const Vector &x, Vector &y) const
{ A->Mult(x, a); B->Mult(x, b); add(alpha, a, beta, b, y); }
virtual void MultTranspose(const Vector &x, Vector &y) const
{ A->MultTranspose(x, a); B->MultTranspose(x, b); add(alpha, a, beta, b, y); }
virtual ~SumOperator();
};
/// General product operator: x -> (A*B)(x) = A(B(x)).
class ProductOperator : public Operator
+442 -209
View File
@@ -16,238 +16,471 @@
#include "strumpack.hpp"
using namespace std;
using namespace strumpack;
namespace mfem
{
STRUMPACKRowLocMatrix::STRUMPACKRowLocMatrix(MPI_Comm comm,
int num_loc_rows, int first_loc_row,
int glob_nrows, int glob_ncols,
int *I, int *J, double *data)
: comm_(comm), A_(NULL)
int num_loc_rows,
HYPRE_BigInt first_loc_row,
HYPRE_BigInt glob_nrows,
HYPRE_BigInt glob_ncols,
int *I, HYPRE_BigInt *J,
double *data, bool sym_sparse)
{
// Set mfem::Operator member data
height = num_loc_rows;
width = num_loc_rows;
// Allocate STRUMPACK's CSRMatrixMPI
int nprocs, rank;
MPI_Comm_rank(comm_, &rank);
MPI_Comm_size(comm_, &nprocs);
int * dist = new int[nprocs + 1];
dist[rank + 1] = first_loc_row + num_loc_rows;
// Allocate STRUMPACK's CSRMatrixMPI (copies all inputs)
int rank, nprocs;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &nprocs);
Array<HYPRE_BigInt> dist(nprocs + 1);
dist[0] = 0;
MPI_Allgather(MPI_IN_PLACE, 0, MPI_INT, dist + 1, 1, MPI_INT, comm_);
A_ = new CSRMatrixMPI<double,int>(num_loc_rows, I, J, data, dist, comm_, false);
delete[] dist;
}
dist[rank + 1] = first_loc_row + (HYPRE_BigInt)num_loc_rows;
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
dist.GetData() + 1, 1, HYPRE_MPI_BIG_INT, comm);
STRUMPACKRowLocMatrix::STRUMPACKRowLocMatrix(const HypreParMatrix & hypParMat)
: comm_(hypParMat.GetComm()),
A_(NULL)
{
// First cast the parameter to a hypre_ParCSRMatrix
hypre_ParCSRMatrix * parcsr_op =
(hypre_ParCSRMatrix *)const_cast<HypreParMatrix&>(hypParMat);
MFEM_ASSERT(parcsr_op != NULL,"STRUMPACK: const_cast failed in SetOperator");
// Create the CSRMatrixMPI A_ by borrowing the internal data from a
// hypre_CSRMatrix.
hypParMat.HostRead();
hypre_CSRMatrix * csr_op = hypre_MergeDiagAndOffd(parcsr_op);
hypParMat.HypreRead();
hypre_CSRMatrixSetDataOwner(csr_op,0);
#if MFEM_HYPRE_VERSION >= 21600
// For now, this method assumes that HYPRE_Int is int. Also, csr_op->num_cols
// is of type HYPRE_Int, so if we want to check for big indices in
// csr_op->big_j, we'll have to check all entries and that check will only be
// necessary in HYPRE_MIXEDINT mode which is not supported at the moment.
hypre_CSRMatrixBigJtoJ(csr_op);
#endif
height = csr_op->num_rows;
width = csr_op->num_rows;
int nprocs, rank;
MPI_Comm_rank(comm_, &rank);
MPI_Comm_size(comm_, &nprocs);
int * dist = new int[nprocs + 1];
dist[rank + 1] = parcsr_op->first_row_index + csr_op->num_rows;
dist[0] = 0;
MPI_Allgather(MPI_IN_PLACE, 0, MPI_INT, dist + 1, 1, MPI_INT, comm_);
A_ = new CSRMatrixMPI<double,int>(csr_op->num_rows, csr_op->i, csr_op->j,
csr_op->data, dist, comm_, false);
delete[] dist;
// Everything has been copied or abducted so delete the structure
hypre_CSRMatrixDestroy(csr_op);
}
STRUMPACKRowLocMatrix::~STRUMPACKRowLocMatrix()
{
// Delete the struct
if ( A_ != NULL ) { delete A_; }
}
STRUMPACKSolver::STRUMPACKSolver( int argc, char* argv[], MPI_Comm comm )
: comm_(comm),
APtr_(NULL),
solver_(NULL)
{
this->Init(argc, argv);
}
STRUMPACKSolver::STRUMPACKSolver( STRUMPACKRowLocMatrix & A )
: comm_(A.GetComm()),
APtr_(&A),
solver_(NULL)
{
height = A.Height();
width = A.Width();
this->Init(0, NULL);
}
STRUMPACKSolver::~STRUMPACKSolver()
{
if ( solver_ != NULL ) { delete solver_; }
}
void STRUMPACKSolver::Init( int argc, char* argv[] )
{
MPI_Comm_size(comm_, &numProcs_);
MPI_Comm_rank(comm_, &myid_);
factor_verbose_ = false;
solve_verbose_ = false;
solver_ = new StrumpackSparseSolverMPIDist<double,int>(comm_, argc, argv,
false);
}
void STRUMPACKSolver::SetFromCommandLine( )
{
solver_->options().set_from_command_line( );
}
void STRUMPACKSolver::SetPrintFactorStatistics( bool print_stat )
{
factor_verbose_ = print_stat;
}
void STRUMPACKSolver::SetPrintSolveStatistics( bool print_stat )
{
solve_verbose_ = print_stat;
}
void STRUMPACKSolver::SetKrylovSolver( strumpack::KrylovSolver method )
{
solver_->options().set_Krylov_solver( method );
}
void STRUMPACKSolver::SetReorderingStrategy( strumpack::ReorderingStrategy
method )
{
solver_->options().set_reordering_method( method );
}
void STRUMPACKSolver::DisableMatching( )
{
#if STRUMPACK_VERSION_MAJOR >= 3
solver_->options().set_matching( strumpack::MatchingJob::NONE );
#if !(defined(HYPRE_BIGINT) || defined(HYPRE_MIXEDINT))
A_ = new strumpack::CSRMatrixMPI<double, HYPRE_BigInt>(
(HYPRE_BigInt)num_loc_rows, I, J, data, dist.GetData(),
comm, sym_sparse);
#else
solver_->options().set_mc64job( strumpack::MC64Job::NONE );
Array<HYPRE_BigInt> II(num_loc_rows+1);
for (int i = 0; i <= num_loc_rows; i++) { II[i] = (HYPRE_BigInt)I[i]; }
A_ = new strumpack::CSRMatrixMPI<double, HYPRE_BigInt>(
(HYPRE_BigInt)num_loc_rows, II.GetData(), J, data, dist.GetData(),
comm, sym_sparse);
#endif
}
void STRUMPACKSolver::EnableMatching( )
STRUMPACKRowLocMatrix::STRUMPACKRowLocMatrix(const Operator &op,
bool sym_sparse)
{
#if STRUMPACK_VERSION_MAJOR >= 3
solver_->options().set_matching
( strumpack::MatchingJob::MAX_DIAGONAL_PRODUCT_SCALING );
#else
solver_->options().set_mc64job
( strumpack::MC64Job::MAX_DIAGONAL_PRODUCT_SCALING );
#endif
}
#if STRUMPACK_VERSION_MAJOR >= 3
void STRUMPACKSolver::EnableParallelMatching( )
{
solver_->options().set_matching
( strumpack::MatchingJob::COMBBLAS );
}
#endif
void STRUMPACKSolver::SetRelTol( double rtol )
{
solver_->options().set_rel_tol( rtol );
}
void STRUMPACKSolver::SetAbsTol( double atol )
{
solver_->options().set_abs_tol( atol );
}
void STRUMPACKSolver::Mult( const Vector & x, Vector & y ) const
{
MFEM_ASSERT(APtr_ != NULL,
"STRUMPACK Error: The operator must be set before"
" the system can be solved.");
MFEM_ASSERT(x.Size() == Width(), "invalid x.Size() = " << x.Size()
<< ", expected size = " << Width());
MFEM_ASSERT(y.Size() == Height(), "invalid y.Size() = " << y.Size()
<< ", expected size = " << Height());
double* yPtr = y.HostWrite();
const double* xPtr = x.HostRead();
solver_->options().set_verbose( factor_verbose_ );
ReturnCode ret = solver_->factor();
switch (ret)
{
case ReturnCode::SUCCESS: break;
case ReturnCode::MATRIX_NOT_SET:
{
MFEM_ABORT("STRUMPACK: Matrix was not set!");
}
break;
case ReturnCode::REORDERING_ERROR:
{
MFEM_ABORT("STRUMPACK: Matrix reordering failed!");
}
break;
default:
{
MFEM_ABORT("STRUMPACK: 'factor()' error code = " << ret);
}
}
solver_->options().set_verbose( solve_verbose_ );
solver_->solve(xPtr, yPtr);
}
void STRUMPACKSolver::SetOperator( const Operator & op )
{
// Verify that we have a compatible operator
APtr_ = dynamic_cast<const STRUMPACKRowLocMatrix*>(&op);
if ( APtr_ == NULL )
{
mfem_error("STRUMPACKSolver::SetOperator : not STRUMPACKRowLocMatrix!");
}
solver_->set_matrix( *(APtr_->getA()) );
const HypreParMatrix *APtr = dynamic_cast<const HypreParMatrix *>(&op);
MFEM_VERIFY(APtr, "Not a compatible matrix type");
MPI_Comm comm = APtr->GetComm();
// Set mfem::Operator member data
height = op.Height();
width = op.Width();
// First cast the parameter to a hypre_ParCSRMatrix
hypre_ParCSRMatrix *parcsr_op =
(hypre_ParCSRMatrix *)const_cast<HypreParMatrix &>(*APtr);
// Create the CSRMatrixMPI A by taking the internal data from a
// hypre_CSRMatrix
APtr->HostRead();
hypre_CSRMatrix *csr_op = hypre_MergeDiagAndOffd(parcsr_op);
APtr->HypreRead();
HYPRE_Int *Iptr = csr_op->i;
#if MFEM_HYPRE_VERSION >= 21600
HYPRE_BigInt *Jptr = csr_op->big_j;
#else
HYPRE_Int *Jptr = csr_op->j;
#endif
double *data = csr_op->data;
HYPRE_BigInt fst_row = parcsr_op->first_row_index;
HYPRE_Int m_loc = csr_op->num_rows;
// Allocate STRUMPACK's CSRMatrixMPI
int rank, nprocs;
MPI_Comm_rank(comm, &rank);
MPI_Comm_size(comm, &nprocs);
Array<HYPRE_BigInt> dist(nprocs + 1);
dist[0] = 0;
dist[rank + 1] = fst_row + (HYPRE_BigInt)m_loc;
MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
dist.GetData() + 1, 1, HYPRE_MPI_BIG_INT, comm);
#if !defined(HYPRE_MIXEDINT)
A_ = new strumpack::CSRMatrixMPI<double, HYPRE_BigInt>(
(HYPRE_BigInt)m_loc, Iptr, Jptr, data, dist.GetData(),
comm, sym_sparse);
#else
Array<HYPRE_BigInt> II(m_loc+1);
for (int i = 0; i <= m_loc; i++) { II[i] = (HYPRE_BigInt)Iptr[i]; }
A_ = new strumpack::CSRMatrixMPI<double, HYPRE_BigInt>(
(HYPRE_BigInt)m_loc, II.GetData(), Jptr, data, dist.GetData(),
comm, sym_sparse);
#endif
// Everything has been copied so delete the structure
hypre_CSRMatrixDestroy(csr_op);
}
STRUMPACKRowLocMatrix::~STRUMPACKRowLocMatrix()
{
delete A_;
}
template <typename STRUMPACKSolverType>
STRUMPACKSolverBase<STRUMPACKSolverType>::
STRUMPACKSolverBase(MPI_Comm comm, int argc, char *argv[])
: APtr_(NULL),
factor_verbose_(false),
solve_verbose_(false),
reorder_reuse_(false),
nrhs_(-1)
{
solver_ = new STRUMPACKSolverType(comm, argc, argv, false);
}
template <typename STRUMPACKSolverType>
STRUMPACKSolverBase<STRUMPACKSolverType>::
STRUMPACKSolverBase(STRUMPACKRowLocMatrix &A, int argc, char *argv[])
: APtr_(&A),
factor_verbose_(false),
solve_verbose_(false),
reorder_reuse_(false),
nrhs_(-1)
{
solver_ = new STRUMPACKSolverType(A.GetComm(), argc, argv, false);
SetOperator(A);
}
template <typename STRUMPACKSolverType>
STRUMPACKSolverBase<STRUMPACKSolverType>::
~STRUMPACKSolverBase()
{
delete solver_;
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetFromCommandLine()
{
solver_->options().set_from_command_line();
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetPrintFactorStatistics(bool print_stat)
{
factor_verbose_ = print_stat;
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetPrintSolveStatistics(bool print_stat)
{
solve_verbose_ = print_stat;
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>
::SetRelTol(double rtol)
{
solver_->options().set_rel_tol(rtol);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>
::SetAbsTol(double atol)
{
solver_->options().set_abs_tol(atol);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>
::SetMaxIter(int max_it)
{
solver_->options().set_maxit(max_it);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>
::SetReorderingReuse(bool reuse)
{
reorder_reuse_ = reuse;
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>
::EnableGPU()
{
solver_->options().enable_gpu();
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>
::DisableGPU()
{
solver_->options().disable_gpu();
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetKrylovSolver(strumpack::KrylovSolver method)
{
solver_->options().set_Krylov_solver(method);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetReorderingStrategy(strumpack::ReorderingStrategy method)
{
solver_->options().set_reordering_method(method);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetMatching(strumpack::MatchingJob job)
{
solver_->options().set_matching(job);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetCompression(strumpack::CompressionType type)
{
#if STRUMPACK_VERSION_MAJOR >= 5
solver_->options().set_compression(type);
#else
switch (type)
{
case strumpack::NONE:
solver_->options().disable_BLR();
solver_->options().disable_HSS();
break;
case strumpack::BLR:
solver_->options().enable_BLR();
break;
case strumpack::HSS:
solver_->options().enable_HSS();
break;
default:
MFEM_ABORT("Invalid compression type for STRUMPACK version " <<
STRUMPACK_VERSION_MAJOR << "!");
break;
}
#endif
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetCompressionRelTol(double rtol)
{
#if STRUMPACK_VERSION_MAJOR >= 5
solver_->options().set_compression_rel_tol(rtol);
#else
solver_->options().BLR_options().set_rel_tol(rtol);
solver_->options().HSS_options().set_rel_tol(rtol);
#endif
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetCompressionAbsTol(double atol)
{
#if STRUMPACK_VERSION_MAJOR >= 5
solver_->options().set_compression_abs_tol(atol);
#else
solver_->options().BLR_options().set_abs_tol(atol);
solver_->options().HSS_options().set_abs_tol(atol);
#endif
}
#if STRUMPACK_VERSION_MAJOR >= 5
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetCompressionLossyPrecision(int precision)
{
solver_->options().set_lossy_precision(precision);
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetCompressionButterflyLevels(int levels)
{
solver_->options().HODLR_options().set_butterfly_levels(levels);
}
#endif
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
SetOperator(const Operator &op)
{
// Verify that we have a compatible operator
bool first_mat = !APtr_;
APtr_ = dynamic_cast<const STRUMPACKRowLocMatrix *>(&op);
MFEM_VERIFY(APtr_,
"STRUMPACK: Operator is not a STRUMPACKRowLocMatrix!");
// Set mfem::Operator member data
height = op.Height();
width = op.Width();
if (first_mat || !reorder_reuse_)
{
solver_->set_matrix(*(APtr_->GetA()));
}
else
{
solver_->update_matrix_values(*(APtr_->GetA()));
}
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
FactorInternal() const
{
MFEM_ASSERT(APtr_,
"STRUMPACK: Operator must be set before the system can be "
"solved!");
solver_->options().set_verbose(factor_verbose_);
strumpack::ReturnCode ret = solver_->factor();
if (ret != strumpack::ReturnCode::SUCCESS)
{
#if STRUMPACK_VERSION_MAJOR >= 7
MFEM_ABORT("STRUMPACK: Factor failed with return code " << ret << "!");
#else
MFEM_ABORT("STRUMPACK: Factor failed!");
#endif
}
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
Mult(const Vector &x, Vector &y) const
{
MFEM_ASSERT(x.Size() == Width(),
"STRUMPACK: Invalid x.Size() = " << x.Size() <<
", expected size = " << Width() << "!");
MFEM_ASSERT(y.Size() == Height(),
"STRUMPACK: Invalid y.Size() = " << y.Size() <<
", expected size = " << Height() << "!");
const double *xPtr = x.HostRead();
double *yPtr = y.HostReadWrite();
FactorInternal();
solver_->options().set_verbose(solve_verbose_);
strumpack::ReturnCode ret = solver_->solve(xPtr, yPtr, false);
if (ret != strumpack::ReturnCode::SUCCESS)
{
#if STRUMPACK_VERSION_MAJOR >= 7
MFEM_ABORT("STRUMPACK: Solve failed with return code " << ret << "!");
#else
MFEM_ABORT("STRUMPACK: Solve failed!");
#endif
}
}
template <typename STRUMPACKSolverType>
void STRUMPACKSolverBase<STRUMPACKSolverType>::
ArrayMult(const Array<const Vector *> &X, Array<Vector *> &Y) const
{
MFEM_ASSERT(X.Size() == Y.Size(),
"Number of columns mismatch in STRUMPACK solve!");
if (X.Size() == 1)
{
nrhs_ = 1;
MFEM_ASSERT(X[0] && Y[0], "Missing Vector in STRUMPACK solve!");
Mult(*X[0], *Y[0]);
return;
}
// Multiple RHS case
int ldx = Height();
if (nrhs_ != X.Size())
{
rhs_.SetSize(X.Size() * ldx);
sol_.SetSize(X.Size() * ldx);
nrhs_ = X.Size();
}
for (int i = 0; i < nrhs_; i++)
{
MFEM_ASSERT(X[i] && X[i]->Size() == Width(),
"STRUMPACK: Missing or invalid sized RHS Vector in solve!");
Vector s(rhs_, i * ldx, ldx);
s = *X[i];
rhs_.SyncMemory(s); // Update flags for rhs_ if updated on device
}
const double *xPtr = rhs_.HostRead();
double *yPtr = sol_.HostReadWrite();
FactorInternal();
solver_->options().set_verbose(solve_verbose_);
strumpack::ReturnCode ret = solver_->solve(nrhs_, xPtr, ldx, yPtr, ldx,
false);
if (ret != strumpack::ReturnCode::SUCCESS)
{
#if STRUMPACK_VERSION_MAJOR >= 7
MFEM_ABORT("STRUMPACK: Solve failed with return code " << ret << "!");
#else
MFEM_ABORT("STRUMPACK: Solve failed!");
#endif
}
for (int i = 0; i < nrhs_; i++)
{
MFEM_ASSERT(Y[i] && Y[i]->Size() == Width(),
"STRUMPACK: Missing or invalid sized solution Vector in solve!");
Vector s(sol_, i * ldx, ldx);
*Y[i] = s;
}
}
STRUMPACKSolver::
STRUMPACKSolver(MPI_Comm comm)
: STRUMPACKSolverBase<strumpack::
SparseSolverMPIDist<double, HYPRE_BigInt>>
(comm, 0, NULL) {}
STRUMPACKSolver::
STRUMPACKSolver(STRUMPACKRowLocMatrix &A)
: STRUMPACKSolverBase<strumpack::
SparseSolverMPIDist<double, HYPRE_BigInt>>
(A, 0, NULL) {}
STRUMPACKSolver::
STRUMPACKSolver(MPI_Comm comm, int argc, char *argv[])
: STRUMPACKSolverBase<strumpack::
SparseSolverMPIDist<double, HYPRE_BigInt>>
(comm, argc, argv) {}
STRUMPACKSolver::
STRUMPACKSolver(STRUMPACKRowLocMatrix &A, int argc, char *argv[])
: STRUMPACKSolverBase<strumpack::
SparseSolverMPIDist<double, HYPRE_BigInt>>
(A, argc, argv) {}
#if STRUMPACK_VERSION_MAJOR >= 7
STRUMPACKMixedPrecisionSolver::
STRUMPACKMixedPrecisionSolver(MPI_Comm comm)
: STRUMPACKSolverBase<strumpack::
SparseSolverMixedPrecisionMPIDist<float, double, HYPRE_BigInt>>
(comm, 0, NULL) {}
STRUMPACKMixedPrecisionSolver::
STRUMPACKMixedPrecisionSolver(STRUMPACKRowLocMatrix &A)
: STRUMPACKSolverBase<strumpack::
SparseSolverMixedPrecisionMPIDist<float, double, HYPRE_BigInt>>
(A, 0, NULL) {}
STRUMPACKMixedPrecisionSolver::
STRUMPACKMixedPrecisionSolver(MPI_Comm comm, int argc, char *argv[])
: STRUMPACKSolverBase<strumpack::
SparseSolverMixedPrecisionMPIDist<float, double, HYPRE_BigInt>>
(comm, argc, argv) {}
STRUMPACKMixedPrecisionSolver::
STRUMPACKMixedPrecisionSolver(STRUMPACKRowLocMatrix &A, int argc, char *argv[])
: STRUMPACKSolverBase<strumpack::
SparseSolverMixedPrecisionMPIDist<float, double, HYPRE_BigInt>>
(A, argc, argv) {}
#endif
template class STRUMPACKSolverBase<strumpack::
SparseSolverMPIDist<double, HYPRE_BigInt>>;
#if STRUMPACK_VERSION_MAJOR >= 7
template class STRUMPACKSolverBase<strumpack::
SparseSolverMixedPrecisionMPIDist<float, double, HYPRE_BigInt>>;
#endif
} // mfem namespace
#endif // MFEM_USE_MPI
+169 -67
View File
@@ -16,12 +16,14 @@
#ifdef MFEM_USE_STRUMPACK
#ifdef MFEM_USE_MPI
#include "operator.hpp"
#include "hypre.hpp"
#include <mpi.h>
// STRUMPACK headers
#include "StrumpackSparseSolverMPIDist.hpp"
#include "StrumpackSparseSolverMixedPrecisionMPIDist.hpp"
namespace mfem
{
@@ -34,63 +36,80 @@ public:
be of size (local) nrows by (global) glob_ncols. The new parallel matrix
contains copies of all input arrays (so they can be deleted). */
STRUMPACKRowLocMatrix(MPI_Comm comm,
int num_loc_rows, int first_loc_row,
int glob_nrows, int glob_ncols,
int *I, int *J, double *data);
int num_loc_rows, HYPRE_BigInt first_loc_row,
HYPRE_BigInt glob_nrows, HYPRE_BigInt glob_ncols,
int *I, HYPRE_BigInt *J, double *data,
bool sym_sparse = false);
/** Creates a copy of the parallel matrix hypParMat in STRUMPACK's RowLoc
format. All data is copied so the original matrix may be deleted. */
STRUMPACKRowLocMatrix(const HypreParMatrix & hypParMat);
STRUMPACKRowLocMatrix(const Operator &op, bool sym_sparse = false);
~STRUMPACKRowLocMatrix();
void Mult(const Vector &x, Vector &y) const
{
mfem_error("STRUMPACKRowLocMatrix::Mult(...)\n"
" matrix vector products are not supported.");
MFEM_ABORT("STRUMPACKRowLocMatrix::Mult: Matrix vector products are not "
"supported!");
}
MPI_Comm GetComm() const { return comm_; }
MPI_Comm GetComm() const { return A_->comm(); }
strumpack::CSRMatrixMPI<double,int>* getA() const { return A_; }
strumpack::CSRMatrixMPI<double, HYPRE_BigInt> *GetA() const { return A_; }
private:
MPI_Comm comm_;
strumpack::CSRMatrixMPI<double,int>* A_;
}; // mfem::STRUMPACKRowLocMatrix
strumpack::CSRMatrixMPI<double, HYPRE_BigInt> *A_;
};
/** The MFEM STRUMPACK Direct Solver class.
The mfem::STRUMPACKSolver class uses the STRUMPACK library to perform LU
factorization of a parallel sparse matrix. The solver is capable of handling
double precision types. See http://portal.nersc.gov/project/sparse/strumpack
double precision types. See
http://portal.nersc.gov/project/sparse/strumpack/.
*/
class STRUMPACKSolver : public mfem::Solver
template <typename STRUMPACKSolverType>
class STRUMPACKSolverBase : public Solver
{
protected:
// Constructor with MPI_Comm parameter and command line arguments.
STRUMPACKSolverBase(MPI_Comm comm, int argc, char *argv[]);
// Constructor with STRUMPACK matrix object and command line arguments.
STRUMPACKSolverBase(STRUMPACKRowLocMatrix &A, int argc, char *argv[]);
public:
// Constructor with MPI_Comm parameter.
STRUMPACKSolver( int argc, char* argv[], MPI_Comm comm );
// Constructor with STRUMPACK Matrix Object.
STRUMPACKSolver( STRUMPACKRowLocMatrix & A);
// Default destructor.
~STRUMPACKSolver( void );
virtual ~STRUMPACKSolverBase();
// Factor and solve the linear system y = Op^{-1} x.
void Mult( const Vector & x, Vector & y ) const;
void Mult(const Vector &x, Vector &y) const;
void ArrayMult(const Array<const Vector *> &X, Array<Vector *> &Y) const;
// Set the operator.
void SetOperator( const Operator & op );
void SetOperator(const Operator &op);
// Set various solver options. Refer to STRUMPACK documentation for
// details.
void SetFromCommandLine( );
void SetPrintFactorStatistics( bool print_stat );
void SetPrintSolveStatistics( bool print_stat );
void SetRelTol( double rtol );
void SetAbsTol( double atol );
void SetFromCommandLine();
void SetPrintFactorStatistics(bool print_stat);
void SetPrintSolveStatistics(bool print_stat);
// Set tolerances and iterations for iterative solvers. Compression
// tolerance is handled below.
void SetRelTol(double rtol);
void SetAbsTol(double atol);
void SetMaxIter(int max_it);
// Set the flag controlling reuse of the symbolic factorization for multiple
// operators. This method has to be called before repeated calls to
// SetOperator.
void SetReorderingReuse(bool reuse);
// Enable or not GPU off-loading available if STRUMPACK was compiled with CUDA. Note
// that input/output from MFEM to STRUMPACK is all still through host memory.
void EnableGPU();
void DisableGPU();
/**
* STRUMPACK is an (approximate) direct solver. It can be used as a direct
@@ -100,70 +119,153 @@ public:
* used without preconditioner.
*
* Supported values are:
* AUTO: Use iterative refinement if no HSS compression is used,
* otherwise use GMRes.
* DIRECT: No outer iterative solver, just a single application of
* the multifrontal solver.
* REFINE: Iterative refinement.
* PREC_GMRES: Preconditioned GMRes.
* The preconditioner is the (approx) multifrontal solver.
* GMRES: UN-preconditioned GMRes. (for testing mainly)
* PREC_BICGSTAB: Preconditioned BiCGStab.
* The preconditioner is the (approx) multifrontal solver.
* AUTO: Use iterative refinement if no HSS compression is
* used, otherwise use GMRes
* DIRECT: No outer iterative solver, just a single application
* of the multifrontal solver
* REFINE: Iterative refinement
* PREC_GMRES: Preconditioned GMRes
* The preconditioner is the (approx) multifrontal solver
* GMRES: UN-preconditioned GMRes (for testing mainly)
* PREC_BICGSTAB: Preconditioned BiCGStab
* The preconditioner is the (approx) multifrontal solver
* BICGSTAB: UN-preconditioned BiCGStab. (for testing mainly)
*/
void SetKrylovSolver( strumpack::KrylovSolver method );
void SetKrylovSolver(strumpack::KrylovSolver method);
/**
* Supported reorderings are:
* METIS, PARMETIS, SCOTCH, PTSCOTCH, RCM
* NATURAL: Do not reorder the system
* METIS: Use Metis nested-dissection reordering (default)
* PARMETIS: Use ParMetis nested-dissection reordering
* SCOTCH: Use Scotch nested-dissection reordering
* PTSCOTCH: Use PT-Scotch nested-dissection reordering
* RCM: Use RCM reordering
* GEOMETRIC: A simple geometric nested dissection code that
* only works for regular meshes
* AMD: Approximate minimum degree
* MMD: Multiple minimum degree
* AND: Nested dissection
* MLF: Minimum local fill
* SPECTRAL: Spectral nested dissection
*/
void SetReorderingStrategy( strumpack::ReorderingStrategy method );
void SetReorderingStrategy(strumpack::ReorderingStrategy method);
/**
* Disable static pivoting for stability. The static pivoting in strumpack
* Configure static pivoting for stability. The static pivoting in STRUMPACK
* permutes the sparse input matrix in order to get large (nonzero) elements
* on the diagonal. If the input matrix is already diagonally dominant, this
* reordering can be disabled.
*
* Supported matching algorithms are:
* NONE: Don't do anything
* MAX_CARDINALITY: Maximum cardinality
* MAX_SMALLEST_DIAGONAL: Maximum smallest diagonal value
* MAX_SMALLEST_DIAGONAL_2: Same as MAX_SMALLEST_DIAGONAL
* but different algorithm
* MAX_DIAGONAL_SUM: Maximum sum of diagonal values
* MAX_DIAGONAL_PRODUCT_SCALING: Maximum product of diagonal values
* and row and column scaling (default)
* COMBBLAS: Use AWPM from CombBLAS (only with
* version >= 3)
*/
void DisableMatching();
void SetMatching(strumpack::MatchingJob job);
/**
* Enable static pivoting for stability using the MC64 algorithm with
* job=5. Using a matching algorithm, this will permute the sparse input
* matrix in order to get nonzero elements (as large as possible) on the
* diagonal. And will also scale the rows and columns of the matrix.
* Enable support for rank-structured data formats, which can be used
* for compression within the sparse solver.
*
* Supported compression types are:
* NONE: No compression, purely direct solver (default)
* HSS: HSS compression of frontal matrices
* BLR: Block low-rank compression of fronts
* HODLR: Hierarchically Off-diagonal Low-Rank
* compression of frontal matrices
* BLR_HODLR: Block low-rank compression of medium
* fronts and Hierarchically Off-diagonal
* Low-Rank compression of large fronts
* ZFP_BLR_HODLR: ZFP compression for small fronts,
* Block low-rank compression of medium
* fronts and Hierarchically Off-diagonal
* Low-Rank compression of large fronts
* LOSSLESS: Lossless compression
* LOSSY: Lossy compression
*
* For versions of STRUMPACK < 5, we support only NONE, HSS, and BLR.
* BLR_HODLR and ZPR_BLR_HODLR are supported in STRUMPACK >= 6.
*/
void EnableMatching();
#if STRUMPACK_VERSION_MAJOR >= 3
/**
* Use the AWPM (approximate weight perfect matching) algorithm from the
* Combinatorial BLAS library for static pivoting, i.e. getting large
* nonzeros on the diagonal. This requires that strumpack was compiled with
* support for Combinatorial BLAS.
*/
void EnableParallelMatching();
void SetCompression(strumpack::CompressionType type);
void SetCompressionRelTol(double rtol);
void SetCompressionAbsTol(double atol);
#if STRUMPACK_VERSION_MAJOR >= 5
void SetCompressionLossyPrecision(int precision);
void SetCompressionButterflyLevels(int levels);
#endif
private:
void Init( int argc, char* argv[] );
// Helper method for calling the STRUMPACK factoriation routine.
void FactorInternal() const;
protected:
MPI_Comm comm_;
int numProcs_;
int myid_;
const STRUMPACKRowLocMatrix *APtr_;
STRUMPACKSolverType *solver_;
bool factor_verbose_;
bool solve_verbose_;
bool reorder_reuse_;
const STRUMPACKRowLocMatrix * APtr_;
strumpack::StrumpackSparseSolverMPIDist<double,int> * solver_;
mutable Vector rhs_, sol_;
mutable int nrhs_;
};
}; // mfem::STRUMPACKSolver class
class STRUMPACKSolver :
public STRUMPACKSolverBase<strumpack::
SparseSolverMPIDist<double, HYPRE_BigInt>>
{
public:
// Constructor with MPI_Comm parameter.
STRUMPACKSolver(MPI_Comm comm);
} // mfem namespace
// Constructor with STRUMPACK matrix object.
STRUMPACKSolver(STRUMPACKRowLocMatrix &A);
// Constructor with MPI_Comm parameter and command line arguments.
STRUMPACKSolver(MPI_Comm comm, int argc, char *argv[]);
MFEM_DEPRECATED STRUMPACKSolver(int argc, char *argv[], MPI_Comm comm)
: STRUMPACKSolver(comm, argc, argv) {}
// Constructor with STRUMPACK matrix object and command line arguments.
STRUMPACKSolver(STRUMPACKRowLocMatrix &A, int argc, char *argv[]);
// Destructor.
~STRUMPACKSolver() {}
};
#if STRUMPACK_VERSION_MAJOR >= 7
class STRUMPACKMixedPrecisionSolver :
public STRUMPACKSolverBase<strumpack::
SparseSolverMixedPrecisionMPIDist<float, double, HYPRE_BigInt>>
{
public:
// Constructor with MPI_Comm parameter.
STRUMPACKMixedPrecisionSolver(MPI_Comm comm);
// Constructor with STRUMPACK matrix object.
STRUMPACKMixedPrecisionSolver(STRUMPACKRowLocMatrix &A);
// Constructor with MPI_Comm parameter and command line arguments.
STRUMPACKMixedPrecisionSolver(MPI_Comm comm, int argc, char *argv[]);
// Constructor with STRUMPACK matrix object and command line arguments.
STRUMPACKMixedPrecisionSolver(STRUMPACKRowLocMatrix &A,
int argc, char *argv[]);
// Destructor.
~STRUMPACKMixedPrecisionSolver() {}
};
#endif
} // namespace mfem
#endif // MFEM_USE_MPI
#endif // MFEM_USE_STRUMPACK
+1
View File
@@ -650,6 +650,7 @@ void SuperLUSolver::ArrayMult(const Array<const Vector *> &X,
MFEM_ASSERT(X[i], "Missing Vector in SuperLUSolver::Mult!");
Vector s(sol_, i * ldx, ldx);
s = *X[i];
sol_.SyncMemory(s); // Update flags for sol_ if updated on device
}
}
+551 -138
View File
File diff suppressed because it is too large Load Diff
+162 -68
View File
@@ -27,12 +27,11 @@
#include "../general/adios2stream.hpp"
#endif
#include <iostream>
#include <array>
namespace mfem
{
// Data type mesh
class GeometricFactors;
class FaceGeometricFactors;
class KnotVector;
@@ -49,15 +48,15 @@ class ParMesh;
class ParNCMesh;
#endif
/// Mesh data type
class Mesh
{
friend class NCMesh;
friend class NURBSExtension;
#ifdef MFEM_USE_MPI
friend class ParMesh;
friend class ParNCMesh;
#endif
friend class NCMesh;
friend class NURBSExtension;
#ifdef MFEM_USE_ADIOS2
friend class adios2stream;
#endif
@@ -220,9 +219,9 @@ protected:
Table *el_to_edge;
Table *el_to_face;
Table *el_to_el;
Array<int> be_to_edge; // for 2D
Table *bel_to_edge; // for 3D
Array<int> be_to_face;
Array<int> be_to_face; // faces = vertices (1D), edges (2D), faces (3D)
Table *bel_to_edge; // for 3D only
// Note that the following tables are owned by this class and should not be
// deleted by the caller. Of these three tables, only face_edge and
@@ -325,35 +324,8 @@ protected:
/* Note NetCDF (optional library) is used for reading cubit files */
#ifdef MFEM_USE_NETCDF
/// @brief Load a mesh from a Genesis file.
void ReadCubit(const char *filename, int &curved, int &read_gf);
/// @brief The final step in constructing the mesh from a Genesis file. This
/// is only called if the mesh order == 2 (determined internally from the
/// cubit element type).
void FinalizeCubitSecondOrderMesh(const int cubit_element_type,
const int num_element_blocks,
const int num_nodes_per_element,
const int *start_of_block,
const double *coordx,
const double *coordy,
const double *coordz,
const int **element_blocks);
/// @brief Returns a pointer to a new mfem::Element based on the provided
/// cubit element type. This is used internally to create the mesh elements
/// from a Genesis file.
Element *CreateCubitElement(const int cubit_element_type,
const int *vertex_ids,
const int block_id);
/// @brief Returns a pointer to a new mfem::Element based on the provided
/// cubit face type. This is used internally to create the boundary elements
/// from a Genesis file.
Element *CreateCubitBoundaryElement(const int cubit_face_type,
const int *vertex_ids,
const int sideset_id) const;
void ReadCubit(const std::string &filename, int &curved, int &read_gf);
#endif
/// Determine the mesh generator bitmask #meshgen, see MeshGenerator().
@@ -365,8 +337,8 @@ protected:
void MarkForRefinement();
void MarkTriMeshForRefinement();
void GetEdgeOrdering(DSTable &v_to_v, Array<int> &order);
virtual void MarkTetMeshForRefinement(DSTable &v_to_v);
void GetEdgeOrdering(const DSTable &v_to_v, Array<int> &order);
virtual void MarkTetMeshForRefinement(const DSTable &v_to_v);
// Methods used to prepare and apply permutation of the mesh nodes assuming
// that the mesh elements may be rotated (e.g. to mark triangle or tet edges
@@ -533,7 +505,7 @@ protected:
nodes in the elements. For example, if T is the element to edge table
T(i, 0) gives the index of edge in element i that connects vertex 0
to vertex 1, etc. Returns the number of the edges. */
int GetElementToEdgeTable(Table &, Array<int> &);
int GetElementToEdgeTable(Table &);
/// Used in GenerateFaces()
void AddPointFaceElement(int lf, int gf, int el);
@@ -573,24 +545,55 @@ protected:
void Printer(std::ostream &out = mfem::out,
std::string section_delimiter = "") const;
/** Creates mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into
nx*ny*nz hexahedra if type=HEXAHEDRON or into 6*nx*ny*nz tetrahedrons if
type=TETRAHEDRON. The parameter @a sfc_ordering controls how the elements
(when type=HEXAHEDRON) are ordered: true - use space-filling curve
ordering, or false - use lexicographic ordering. */
/// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
/// divided into nx*ny*nz hexahedra if @a type = HEXAHEDRON or into
/// 6*nx*ny*nz tetrahedrons if @a type = TETRAHEDRON.
///
/// The parameter @a sfc_ordering controls how the elements
/// (when @a type = HEXAHEDRON) are ordered: true - use space-filling curve
/// ordering, or false - use lexicographic ordering.
void Make3D(int nx, int ny, int nz, Element::Type type,
double sx, double sy, double sz, bool sfc_ordering);
/** Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
quadrilaterals if type = QUADRILATERAL or into 2*nx*ny triangles if
type = TRIANGLE. If generate_edges = 0 (default) edges are not generated,
if 1 edges are generated. The parameter @a sfc_ordering controls how the
elements (when type=QUADRILATERAL) are ordered: true - use space-filling
curve ordering, or false - use lexicographic ordering. */
/// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
/// divided into nx*ny*nz*24 tetrahedrons.
///
/// The mesh is generated by taking nx*ny*nz hexahedra and splitting each
/// hexahedron into 24 tetrahedrons. Each face of the hexahedron is split
/// into 4 triangles (face edges are connected to a face-centered point),
/// and the triangles are connected to a hex-centered point.
void Make3D24TetsFromHex(int nx, int ny, int nz,
double sx, double sy, double sz);
/// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*4
/// triangles.
///
/// The mesh is generated by taking nx*ny quadrilaterals and splitting each
/// quadrilateral into 4 triangles by connecting the vertices to a
/// quad-centered point.
void Make2D4TrisFromQuad(int nx, int ny, double sx, double sy);
/// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*5
/// quadrilaterals.
///
/// The mesh is generated by taking nx*ny quadrilaterals and splitting
/// each quadrilateral into 5 quadrilaterals. Each quadrilateral is projected
/// inwards and connected to the original quadrilateral.
void Make2D5QuadsFromQuad(int nx, int ny, double sx, double sy);
/// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
/// quadrilaterals if @a type = QUADRILATERAL or into 2*nx*ny triangles if
/// @a type = TRIANGLE.
///
/// If generate_edges = 0 (default) edges are not generated, if 1 edges are
/// generated. The parameter @a sfc_ordering controls how the elements (when
/// @a type = QUADRILATERAL) are ordered: true - use space-filling curve
/// ordering, or false - use lexicographic ordering.
void Make2D(int nx, int ny, Element::Type type, double sx, double sy,
bool generate_edges, bool sfc_ordering);
/// Creates a 1D mesh for the interval [0,sx] divided into n equal intervals.
/// @a brief Creates a 1D mesh for the interval [0,sx] divided into n equal
/// intervals.
void Make1D(int n, double sx = 1.0);
/// Internal function used in Mesh::MakeRefined
@@ -730,27 +733,63 @@ public:
int generate_edges = 0, int refine = 1,
bool fix_orientation = true);
/** Creates 1D mesh , divided into n equal intervals. */
/// Creates 1D mesh , divided into n equal intervals.
static Mesh MakeCartesian1D(int n, double sx = 1.0);
/** Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
quadrilaterals if type = QUADRILATERAL or into 2*nx*ny triangles if
type = TRIANGLE. If generate_edges = 0 (default) edges are not generated,
if 1 edges are generated. If scf_ordering = true (default), elements are
ordered along a space-filling curve, instead of row by row. */
/// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny
/// quadrilaterals if @a type = QUADRILATERAL or into 2*nx*ny triangles if
/// @a type = TRIANGLE.
///
/// If generate_edges = 0 (default) edges are not generated, if 1 edges are
/// generated. The parameter @a sfc_ordering controls how the elements (when
/// @a type = QUADRILATERAL) are ordered: true - use space-filling curve
/// ordering, or false - use lexicographic ordering.
static Mesh MakeCartesian2D(
int nx, int ny, Element::Type type, bool generate_edges = false,
double sx = 1.0, double sy = 1.0, bool sfc_ordering = true);
/** Creates mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz], divided into
nx*ny*nz hexahedra if type=HEXAHEDRON or into 6*nx*ny*nz tetrahedrons if
type=TETRAHEDRON. If sfc_ordering = true (default), elements are ordered
along a space-filling curve, instead of row by row and layer by layer. */
/// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
/// divided into nx*ny*nz hexahedra if @a type = HEXAHEDRON or into
/// 6*nx*ny*nz tetrahedrons if @a type = TETRAHEDRON.
///
/// The parameter @a sfc_ordering controls how the elements
/// (when @a type = HEXAHEDRON) are ordered: true - use space-filling curve
/// ordering, or false - use lexicographic ordering.
static Mesh MakeCartesian3D(
int nx, int ny, int nz, Element::Type type,
double sx = 1.0, double sy = 1.0, double sz = 1.0,
bool sfc_ordering = true);
/// @brief Creates a mesh for the parallelepiped [0,sx]x[0,sy]x[0,sz],
/// divided into nx*ny*nz*24 tetrahedrons.
///
/// The mesh is generated by taking nx*ny*nz hexahedra and splitting each
/// hexahedron into 24 tetrahedrons. Each face of the hexahedron is split
/// into 4 triangles (face edges are connected to a face-centered point),
/// and the triangles are connected to a hex-centered point.
static Mesh MakeCartesian3DWith24TetsPerHex(int nx, int ny, int nz,
double sx = 1.0, double sy = 1.0,
double sz = 1.0);
/// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*4
/// triangles.
///
/// The mesh is generated by taking nx*ny quadrilaterals and splitting each
/// quadrilateral into 4 triangles by connecting the vertices to a
/// quad-centered point.
static Mesh MakeCartesian2DWith4TrisPerQuad(int nx, int ny, double sx = 1.0,
double sy = 1.0);
/// @brief Creates mesh for the rectangle [0,sx]x[0,sy], divided into nx*ny*5
/// quadrilaterals.
///
/// The mesh is generated by taking nx*ny quadrilaterals and splitting
/// each quadrilateral into 5 quadrilaterals. Each quadrilateral is projected
/// inwards and connected to the original quadrilateral.
static Mesh MakeCartesian2DWith5QuadsPerQuad(int nx, int ny, double sx = 1.0,
double sy = 1.0);
/// Create a refined (by any factor) version of @a orig_mesh.
/** @param[in] orig_mesh The starting coarse mesh.
@param[in] ref_factor The refinement factor, an integer > 1.
@@ -818,33 +857,82 @@ public:
int AddVertex(const Vector &coords);
/// Mark vertex @a i as nonconforming, with parent vertices @a p1 and @a p2.
void AddVertexParents(int i, int p1, int p2);
/// Adds a vertex at the mean center of the @a nverts vertex indices given
/// by @a vi.
int AddVertexAtMeanCenter(const int *vi, const int nverts, int dim = 3);
/// Adds a segment to the mesh given by 2 vertices @a v1 and @a v2.
int AddSegment(int v1, int v2, int attr = 1);
/// Adds a segment to the mesh given by 2 vertices @a vi.
int AddSegment(const int *vi, int attr = 1);
/// Adds a triangle to the mesh given by 3 vertices @a v1 through @a v3.
int AddTriangle(int v1, int v2, int v3, int attr = 1);
/// Adds a triangle to the mesh given by 3 vertices @a vi.
int AddTriangle(const int *vi, int attr = 1);
/// Adds a triangle to the mesh given by 3 vertices @a vi.
int AddTri(const int *vi, int attr = 1) { return AddTriangle(vi, attr); }
/// Adds a quadrilateral to the mesh given by 4 vertices @a v1 through @a v4.
int AddQuad(int v1, int v2, int v3, int v4, int attr = 1);
/// Adds a quadrilateral to the mesh given by 4 vertices @a vi.
int AddQuad(const int *vi, int attr = 1);
/// Adds a tetrahedron to the mesh given by 4 vertices @a v1 through @a v4.
int AddTet(int v1, int v2, int v3, int v4, int attr = 1);
/// Adds a tetrahedron to the mesh given by 4 vertices @a vi.
int AddTet(const int *vi, int attr = 1);
/// Adds a wedge to the mesh given by 6 vertices @a v1 through @a v6.
int AddWedge(int v1, int v2, int v3, int v4, int v5, int v6, int attr = 1);
/// Adds a wedge to the mesh given by 6 vertices @a vi.
int AddWedge(const int *vi, int attr = 1);
/// Adds a pyramid to the mesh given by 5 vertices @a v1 through @a v5.
int AddPyramid(int v1, int v2, int v3, int v4, int v5, int attr = 1);
/// Adds a pyramid to the mesh given by 5 vertices @a vi.
int AddPyramid(const int *vi, int attr = 1);
/// Adds a hexahedron to the mesh given by 8 vertices @a v1 through @a v8.
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8,
int attr = 1);
/// Adds a hexahedron to the mesh given by 8 vertices @a vi.
int AddHex(const int *vi, int attr = 1);
/// @brief Adds 6 tetrahedrons to the mesh by splitting a hexahedron given by
/// 8 vertices @a vi.
void AddHexAsTets(const int *vi, int attr = 1);
/// @brief Adds 2 wedges to the mesh by splitting a hexahedron given by
/// 8 vertices @a vi.
void AddHexAsWedges(const int *vi, int attr = 1);
/// @brief Adds 6 pyramids to the mesh by splitting a hexahedron given by
/// 8 vertices @a vi.
void AddHexAsPyramids(const int *vi, int attr = 1);
/// @brief Adds 24 tetrahedrons to the mesh by splitting a hexahedron.
///
/// @a vi are the 8 vertices of the hexahedron, @a hex_face_verts has the
/// map from the 4 vertices of each face of the hexahedron to the index
/// of the point created at the center of the face, and @a attr is the
/// attribute of the new elements. See @a Make3D24TetsFromHex for usage.
void AddHexAs24TetsWithPoints(int *vi,
std::map<std::array<int, 4>, int>
&hex_face_verts,
int attr = 1);
/// @brief Adds 4 triangles to the mesh by splitting a quadrilateral given by
/// 4 vertices @a vi.
///
/// @a attr is the attribute of the new elements. See @a Make2D4TrisFromQuad
/// for usage.
void AddQuadAs4TrisWithPoints(int *vi, int attr = 1);
/// @brief Adds 5 quadrilaterals to the mesh by splitting a quadrilateral
/// given by 4 vertices @a vi.
///
/// @a attr is the attribute of the new elements. See @a Make2D5QuadsFromQuad
/// for usage.
void AddQuadAs5QuadsWithPoints(int *vi, int attr = 1);
/// The parameter @a elem should be allocated using the NewElement() method
/// @note Ownership of @a elem will pass to the Mesh object
int AddElement(Element *elem);
@@ -1367,11 +1455,6 @@ public:
GetElementEdges/GetBdrElementEdges. */
void GetBdrElementFace(int i, int *f, int *o) const;
/** Return the vertex index of boundary element i. (1D)
Return the edge index of boundary element i. (2D)
Return the face index of boundary element i. (3D) */
int GetBdrElementEdgeIndex(int i) const;
/** @brief For the given boundary element, bdr_el, return its adjacent
element and its info, i.e. 64*local_bdr_index+bdr_orientation.
@@ -1392,8 +1475,19 @@ public:
@sa GetBdrElementAdjacentElement() */
void GetBdrElementAdjacentElement2(int bdr_el, int &el, int &info) const;
/// Return the local face index for the given boundary face.
int GetBdrFace(int BdrElemNo) const;
/// @brief Return the local face (codimension-1) index for the given boundary
/// element index.
int GetBdrElementFaceIndex(int be_idx) const { return be_to_face[be_idx]; }
/// Deprecated in favor of GetBdrElementFaceIndex().
MFEM_DEPRECATED int GetBdrFace(int i) const { return GetBdrElementFaceIndex(i); }
/** Return the vertex index of boundary element i. (1D)
Return the edge index of boundary element i. (2D)
Return the face index of boundary element i. (3D)
Deprecated in favor of GetBdrElementFaceIndex(). */
MFEM_DEPRECATED int GetBdrElementEdgeIndex(int i) const { return GetBdrElementFaceIndex(i); }
/// @}
+203 -265
View File
@@ -3037,9 +3037,9 @@ static void ReadCubitDimensions(const int netcdf_descriptor,
static void ReadCubitBoundaries(const int netcdf_descriptor,
const int num_boundaries,
std::vector<size_t> &num_boundary_elements,
int **boundary_elements,
int **boundary_sides)
vector<size_t> &num_boundary_elements,
vector<vector<int>> &boundary_elements,
vector<vector<int>> &boundary_sides)
{
int netcdf_status, variable_id;
@@ -3062,15 +3062,15 @@ static void ReadCubitBoundaries(const int netcdf_descriptor,
num_boundary_elements[iboundary] = num_sides;
// 2. Extract elements and sides on each boundary.
boundary_elements[iboundary] = new int[num_sides]; // (element, face) pairs.
boundary_sides[iboundary] = new int[num_sides];
boundary_elements[iboundary].resize(num_sides); // (element, face) pairs.
boundary_sides[iboundary].resize(num_sides);
//
snprintf(string_buffer, buffer_size, "elem_ss%d", iboundary + 1);
netcdf_status = nc_inq_varid(netcdf_descriptor, string_buffer, &variable_id);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id,
boundary_elements[iboundary]);
boundary_elements[iboundary].data());
if (netcdf_status != NC_NOERR) { break; }
@@ -3079,7 +3079,7 @@ static void ReadCubitBoundaries(const int netcdf_descriptor,
netcdf_status = nc_inq_varid(netcdf_descriptor, string_buffer, &variable_id);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id,
boundary_sides[iboundary]);
boundary_sides[iboundary].data());
if (netcdf_status != NC_NOERR) { break; }
}
@@ -3090,7 +3090,8 @@ static void ReadCubitBoundaries(const int netcdf_descriptor,
static void ReadCubitElementBlocks(const int netcdf_descriptor,
const int num_element_blocks, const int num_nodes_per_element,
const std::vector<std::size_t> & num_elements_for_block, int **block_elements)
const vector<size_t> &num_elements_for_block,
vector<vector<int>> &block_elements)
{
int netcdf_status, variable_id;
@@ -3099,8 +3100,8 @@ static void ReadCubitElementBlocks(const int netcdf_descriptor,
for (int iblock = 0; iblock < num_element_blocks; iblock++)
{
block_elements[iblock] = new int[num_elements_for_block[iblock] *
num_nodes_per_element];
block_elements[iblock].resize(
num_elements_for_block[iblock]*num_nodes_per_element);
// Write variable name to buffer.
snprintf(string_buffer, buffer_size, "connect%d", iblock + 1);
@@ -3108,7 +3109,7 @@ static void ReadCubitElementBlocks(const int netcdf_descriptor,
// Get variable ID and then set all nodes of element in block.
netcdf_status = nc_inq_varid(netcdf_descriptor, string_buffer, &variable_id);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id,
block_elements[iblock]);
block_elements[iblock].data());
if (netcdf_status != NC_NOERR) { break; }
}
@@ -3339,10 +3340,147 @@ static int GetCubitBlockIndexForElement(const int global_element_index,
return iblock;
}
mfem::Element *NewElement(Mesh &mesh, Geometry::Type geom, const int *vertices,
const int attribute)
{
Element *new_element = mesh.NewElement(geom);
new_element->SetVertices(vertices);
new_element->SetAttribute(attribute);
return new_element;
}
/// @brief Returns a pointer to a new mfem::Element based on the provided cubit
/// element type. This is used to create the mesh elements from a Genesis file.
mfem::Element *CreateCubitElement(Mesh &mesh,
const int cubit_element_type,
const int *vertex_ids,
const int block_id)
{
switch (cubit_element_type)
{
case ELEMENT_TRI3:
case ELEMENT_TRI6:
return NewElement(mesh, Geometry::TRIANGLE, vertex_ids, block_id);
case ELEMENT_QUAD4:
case ELEMENT_QUAD9:
return NewElement(mesh, Geometry::SQUARE, vertex_ids, block_id);
case ELEMENT_TET4:
case ELEMENT_TET10:
return NewElement(mesh, Geometry::TETRAHEDRON, vertex_ids, block_id);
case ELEMENT_HEX8:
case ELEMENT_HEX27:
return NewElement(mesh, Geometry::CUBE, vertex_ids, block_id);
default:
MFEM_ABORT("Unsupported cubit element type encountered.");
return nullptr;
}
}
/// @brief Returns a pointer to a new mfem::Element based on the provided cubit
/// face type. This is used to create the boundary elements from a Genesis file.
mfem::Element *CreateCubitBoundaryElement(Mesh &mesh,
const int cubit_face_type,
const int *vertex_ids,
const int sideset_id)
{
switch (cubit_face_type)
{
case FACE_EDGE2:
case FACE_EDGE3:
return NewElement(mesh, Geometry::SEGMENT, vertex_ids, sideset_id);
case FACE_TRI3:
case FACE_TRI6:
return NewElement(mesh, Geometry::TRIANGLE, vertex_ids, sideset_id);
case FACE_QUAD4:
case FACE_QUAD9:
return NewElement(mesh, Geometry::SQUARE, vertex_ids, sideset_id);
default:
MFEM_ABORT("Unsupported cubit face type encountered.");
return nullptr;
}
}
/// @brief The final step in constructing the mesh from a Genesis file. This is
/// only called if the mesh order == 2 (determined internally from the cubit
/// element type).
void FinalizeCubitSecondOrderMesh(Mesh &mesh,
const int cubit_element_type,
const int num_element_blocks,
const int num_nodes_per_element,
const int *start_of_block,
const double *coordx,
const double *coordy,
const double *coordz,
const vector<vector<int>> &element_blocks)
{
int *mfem_to_genesis_map = nullptr;
switch (cubit_element_type)
{
case ELEMENT_TRI6:
mfem_to_genesis_map = (int *) mfem_to_genesis_tri6;
break;
case ELEMENT_QUAD9:
mfem_to_genesis_map = (int *) mfem_to_genesis_quad9;
break;
case ELEMENT_TET10:
mfem_to_genesis_map = (int *) mfem_to_genesis_tet10;
break;
case ELEMENT_HEX27:
mfem_to_genesis_map = (int *) mfem_to_genesis_hex27;
break;
default:
MFEM_ABORT("Something went wrong. Linear elements detected when order is 2.");
}
mesh.FinalizeTopology();
// Define quadratic FE space.
const int Dim = mesh.Dimension();
FiniteElementCollection *fec = new H1_FECollection(2,3);
FiniteElementSpace *fes = new FiniteElementSpace(&mesh, fec, Dim,
Ordering::byVDIM);
GridFunction *Nodes = new GridFunction(fes);
Nodes->MakeOwner(fec); // Nodes will destroy 'fec' and 'fes'
mesh.SetNodalGridFunction(Nodes, true);
for (int ielement = 0; ielement < mesh.GetNE(); ielement++)
{
Array<int> dofs;
fes->GetElementDofs(ielement, dofs);
Array<int> vdofs = dofs; // Deep copy.
fes->DofsToVDofs(vdofs);
// Find block that element is part of.
const int iblock = GetCubitBlockIndexForElement(ielement,
num_element_blocks,
start_of_block);
// Find element offset in block.
const int element_offset = ielement - start_of_block[iblock];
const int node_offset = element_offset * num_nodes_per_element;
for (int jnode = 0; jnode < dofs.Size(); jnode++)
{
const int node_index = element_blocks[iblock][node_offset +
mfem_to_genesis_map[jnode] - 1] - 1;
(*Nodes)(vdofs[jnode]) = coordx[node_index];
(*Nodes)(vdofs[jnode] + 1) = coordy[node_index];
if (Dim == 3)
{
(*Nodes)(vdofs[jnode] + 2) = coordz[node_index];
}
}
}
}
} // namespace cubit.
void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
void Mesh::ReadCubit(const std::string &filename, int &curved, int &read_gf)
{
using namespace cubit;
@@ -3352,14 +3490,10 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
// Setup buffer used to write variable names to.
int variable_id;
const int buffer_size = NC_MAX_NAME + 1; // NB: Add 1 for '\0'.
char variable_name_buffer[buffer_size];
// Open the file.
int netcdf_status, netcdf_descriptor;
netcdf_status = nc_open(filename, NC_NOWRITE, &netcdf_descriptor);
netcdf_status = nc_open(filename.c_str(), NC_NOWRITE, &netcdf_descriptor);
if (netcdf_status != NC_NOERR) { HandleNetCDFError(netcdf_status); }
// Read important dimensions from file.
@@ -3399,58 +3533,61 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
SetCubitFaceInfo(cubit_face_type, num_face_nodes, num_face_linear_nodes);
// Read the (element, corresponding side) on each of the boundaries.
std::vector<size_t> num_boundary_elements(num_boundaries);
vector<size_t> num_boundary_elements(num_boundaries);
int **boundary_elements = new int*[num_boundaries];
int **boundary_sides = new int*[num_boundaries];
vector<vector<int>> boundary_elements(num_boundaries);
vector<vector<int>> boundary_sides(num_boundaries);
ReadCubitBoundaries(netcdf_descriptor, num_boundaries, num_boundary_elements,
boundary_elements, boundary_sides);
// Read the boundary ids.
int *boundary_ids = nullptr;
vector<int> boundary_ids;
if (num_boundaries > 0)
{
boundary_ids = new int[num_boundaries];
boundary_ids.resize(num_boundaries);
netcdf_status = nc_inq_varid(netcdf_descriptor, "ss_prop1", &variable_id);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id, boundary_ids);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id,
boundary_ids.data());
if (netcdf_status != NC_NOERR) { HandleNetCDFError(netcdf_status); }
}
// Read the xyz coordinates for each node.
double *coordx = new double[num_nodes];
double *coordy = new double[num_nodes];
double *coordz = (num_dimensions == 3 ? new double[num_nodes] : nullptr);
vector<double> coordx(num_nodes);
vector<double> coordy(num_nodes);
vector<double> coordz(num_dimensions == 3 ? num_nodes : 0);
ReadCubitNodeCoordinates(netcdf_descriptor, coordx, coordy, coordz);
ReadCubitNodeCoordinates(netcdf_descriptor, coordx.data(), coordy.data(),
coordz.data());
// Read the elements that make-up each block.
int **block_elements = new int*[num_element_blocks];
vector<vector<int>> block_elements(num_element_blocks);
ReadCubitElementBlocks(netcdf_descriptor, num_element_blocks,
num_nodes_per_element, num_elements_for_block,
block_elements);
// Read the block IDs.
int *block_ids = new int[num_element_blocks];
vector<int> block_ids(num_element_blocks);
{
netcdf_status = nc_inq_varid(netcdf_descriptor, "eb_prop1", &variable_id);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id, block_ids);
netcdf_status = nc_get_var_int(netcdf_descriptor, variable_id,
block_ids.data());
if (netcdf_status != NC_NOERR) { HandleNetCDFError(netcdf_status); }
}
// Create an array holding the index of the first element in each block. This
// will allow the determination of the block that each element is in.
int *start_of_block = new int[num_element_blocks + 1];
vector<int> start_of_block(num_element_blocks + 1);
start_of_block[0] = 0;
for (int iblock = 1; iblock < num_element_blocks + 1; iblock++)
for (size_t iblock = 1; iblock < num_element_blocks + 1; iblock++)
{
start_of_block[iblock] = start_of_block[iblock - 1] +
num_elements_for_block[iblock - 1];
@@ -3459,15 +3596,15 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
// Iterate over each boundary. For each boundary, we run through the
// (element, side) pairs and extract the face nodes of each element on the
// corresponding side.
int **boundary_nodes = new int*[num_boundaries];
vector<vector<int>> boundary_nodes(num_boundaries);
// Iterate over boundaries.
for (int iboundary = 0; iboundary < num_boundaries; iboundary++)
for (size_t iboundary = 0; iboundary < num_boundaries; iboundary++)
{
const int num_elements_on_boundary = num_boundary_elements[iboundary];
const int num_nodes_on_boundary = num_elements_on_boundary * num_face_nodes;
boundary_nodes[iboundary] = new int[num_nodes_on_boundary];
boundary_nodes[iboundary].resize(num_nodes_on_boundary);
// Iterate over (element, side) pairs on boundary.
for (int jelement = 0; jelement < num_elements_on_boundary; jelement++)
@@ -3480,7 +3617,7 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
// Determine the block the element is part-of.
const int iblock = GetCubitBlockIndexForElement(element_global_index,
num_element_blocks,
start_of_block);
start_of_block.data());
const int element_block_offset = element_global_index - start_of_block[iblock];
const int node_block_offset = element_block_offset * num_nodes_per_element;
@@ -3546,13 +3683,13 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
}
// We need another node ID mapping since MFEM needs contiguous vertex ids.
std::vector<int> unique_vertex_ids;
vector<int> unique_vertex_ids;
for (int iblock = 0; iblock < num_element_blocks; iblock++)
for (size_t iblock = 0; iblock < num_element_blocks; iblock++)
{
const int *nodes_in_block = block_elements[iblock];
const vector<int> &nodes_in_block = block_elements[iblock];
for (int jelement = 0; jelement < num_elements_for_block[iblock]; jelement++)
for (size_t jelement = 0; jelement < num_elements_for_block[iblock]; jelement++)
{
const int element_block_offset = jelement * num_nodes_per_element;
@@ -3565,9 +3702,8 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
// Sort and only retain unique node IDs.
std::sort(unique_vertex_ids.begin(), unique_vertex_ids.end());
std::vector<int>::iterator new_end;
new_end = std::unique(unique_vertex_ids.begin(), unique_vertex_ids.end());
auto new_end = std::unique(unique_vertex_ids.begin(), unique_vertex_ids.end());
unique_vertex_ids.resize(std::distance(unique_vertex_ids.begin(), new_end));
// unique_vertex_ids now contains a 1-based sorted list of node IDs for each
@@ -3576,7 +3712,7 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
// ie. [1, 4, 5, 8, 9] --> [1, 2, 3, 4, 5].
std::map<int,int> cubit_to_mfem_vertex_map;
for (int ivertex = 0; ivertex < unique_vertex_ids.size(); ivertex++)
for (size_t ivertex = 0; ivertex < unique_vertex_ids.size(); ivertex++)
{
const int key = unique_vertex_ids[ivertex];
const int value = ivertex + 1;
@@ -3609,18 +3745,18 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
NumOfElements = num_elements;
elements.SetSize(num_elements);
int renumbered_vertex_ids[max(num_element_linear_nodes, num_face_linear_nodes)];
std::vector<int> renumbered_vertex_ids(max(num_element_linear_nodes,
num_face_linear_nodes));
int element_counter = 0;
// Iterate over blocks.
for (int iblock = 0; iblock < num_element_blocks; iblock++)
for (size_t iblock = 0; iblock < num_element_blocks; iblock++)
{
const int * nodes_ids_for_block = block_elements[iblock];
const vector<int> &nodes_ids_for_block = block_elements[iblock];
// Iterate over elements in block.
for (int jelement = 0; jelement < num_elements_for_block[iblock];
jelement++)
for (size_t jelement = 0; jelement < num_elements_for_block[iblock]; jelement++)
{
// Iterate over linear nodes in block.
for (int knode = 0; knode < num_element_linear_nodes; knode++)
@@ -3633,8 +3769,8 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
}
// Create element.
elements[element_counter++] = CreateCubitElement(cubit_element_type,
renumbered_vertex_ids,
elements[element_counter++] = CreateCubitElement(*this, cubit_element_type,
renumbered_vertex_ids.data(),
block_ids[iblock]);
}
}
@@ -3643,7 +3779,7 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
// Load up the boundary elements.
//
NumOfBdrElements = 0;
for (int iboundary = 0; iboundary < num_boundaries; iboundary++)
for (size_t iboundary = 0; iboundary < num_boundaries; iboundary++)
{
NumOfBdrElements += num_boundary_elements[iboundary];
}
@@ -3653,12 +3789,13 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
int boundary_counter = 0;
// Iterate over boundaries.
for (int iboundary = 0; iboundary < num_boundaries; iboundary++)
for (size_t iboundary = 0; iboundary < num_boundaries; iboundary++)
{
const int *nodes_on_boundary = boundary_nodes[iboundary];
const vector<int> &nodes_on_boundary = boundary_nodes[iboundary];
// Iterate over elements on boundary.
for (int jelement = 0; jelement < num_boundary_elements[iboundary]; jelement++)
for (size_t jelement = 0; jelement < num_boundary_elements[iboundary];
jelement++)
{
// Iterate over element's face linear nodes.
for (int knode = 0; knode < num_face_linear_nodes; knode++)
@@ -3670,8 +3807,9 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
}
// Create boundary element.
boundary[boundary_counter++] = CreateCubitBoundaryElement(cubit_face_type,
renumbered_vertex_ids,
boundary[boundary_counter++] = CreateCubitBoundaryElement(*this,
cubit_face_type,
renumbered_vertex_ids.data(),
boundary_ids[iboundary]);
}
}
@@ -3683,219 +3821,19 @@ void Mesh::ReadCubit(const char *filename, int &curved, int &read_gf)
{
curved = 1;
FinalizeCubitSecondOrderMesh(cubit_element_type, num_element_blocks,
num_nodes_per_element, start_of_block, coordx, coordy, coordz,
(const int **)block_elements);
FinalizeCubitSecondOrderMesh(*this,
cubit_element_type,
num_element_blocks,
num_nodes_per_element,
start_of_block.data(),
coordx.data(),
coordy.data(),
coordz.data(),
block_elements);
}
// Clean up all netcdf stuff.
nc_close(netcdf_descriptor);
for (int iboundary = 0; iboundary < num_boundaries; iboundary++)
{
delete [] boundary_elements[iboundary];
delete [] boundary_sides[iboundary];
delete [] boundary_nodes[iboundary];
}
delete [] boundary_elements;
delete [] boundary_sides;
delete [] boundary_nodes;
delete [] coordx;
delete [] coordy;
delete [] coordz;
for (int iblock = 0; iblock < num_element_blocks; iblock++)
{
delete [] block_elements[iblock];
}
delete [] block_elements;
delete [] start_of_block;
delete [] block_ids;
delete [] boundary_ids;
}
void Mesh::FinalizeCubitSecondOrderMesh(const int cubit_element_type,
const int num_element_blocks,
const int num_nodes_per_element,
const int *start_of_block,
const double *coordx,
const double *coordy,
const double *coordz,
const int **element_blocks)
{
using namespace cubit;
int *mfem_to_genesis_map = nullptr;
switch (cubit_element_type)
{
case ELEMENT_TRI6:
{
mfem_to_genesis_map = (int *) mfem_to_genesis_tri6;
break;
}
case ELEMENT_QUAD9:
{
mfem_to_genesis_map = (int *) mfem_to_genesis_quad9;
break;
}
case ELEMENT_TET10:
{
mfem_to_genesis_map = (int *) mfem_to_genesis_tet10;
break;
}
case ELEMENT_HEX27:
{
mfem_to_genesis_map = (int *) mfem_to_genesis_hex27;
break;
}
case ELEMENT_TRI3:
case ELEMENT_QUAD4:
case ELEMENT_TET4:
case ELEMENT_HEX8:
default:
{
MFEM_ABORT("Something went wrong. Linear elements detected when order is 2.");
break;
}
}
FinalizeTopology();
// Define quadratic FE space.
FiniteElementCollection *fec = new H1_FECollection(2,3);
FiniteElementSpace *fes = new FiniteElementSpace(this, fec, Dim,
Ordering::byVDIM);
Nodes = new GridFunction(fes);
Nodes->MakeOwner(fec); // Nodes will destroy 'fec' and 'fes'
own_nodes = 1;
for (int ielement = 0; ielement < NumOfElements; ielement++)
{
Array<int> dofs;
fes->GetElementDofs(ielement, dofs);
Array<int> vdofs = dofs; // Deep copy.
fes->DofsToVDofs(vdofs);
// Find block that element is part of.
const int iblock = GetCubitBlockIndexForElement(ielement,
num_element_blocks,
start_of_block);
// Find element offset in block.
const int element_offset = ielement - start_of_block[iblock];
const int node_offset = element_offset * num_nodes_per_element;
for (int jnode = 0; jnode < dofs.Size(); jnode++)
{
const int node_index = element_blocks[iblock][node_offset +
mfem_to_genesis_map[jnode] - 1] - 1;
(*Nodes)(vdofs[jnode]) = coordx[node_index];
(*Nodes)(vdofs[jnode] + 1) = coordy[node_index];
if (Dim == 3)
{
(*Nodes)(vdofs[jnode] + 2) = coordz[node_index];
}
}
}
}
mfem::Element *Mesh::CreateCubitElement(const int cubit_element_type,
const int *vertex_ids,
const int block_id)
{
using namespace cubit;
mfem::Element *new_element = nullptr;
switch (cubit_element_type)
{
case ELEMENT_TRI3:
case ELEMENT_TRI6:
{
new_element = new Triangle(vertex_ids, block_id);
break;
}
case ELEMENT_QUAD4:
case ELEMENT_QUAD9:
{
new_element = new Quadrilateral(vertex_ids, block_id);
break;
}
case ELEMENT_TET4:
case ELEMENT_TET10:
{
#ifdef MFEM_USE_MEMALLOC
new_element = TetMemory.Alloc();
new_element->SetVertices(vertex_ids);
new_element->SetAttribute(block_id);
#else
new_element = new Tetrahedron(vertex_ids, block_id);
#endif
break;
}
case ELEMENT_HEX8:
case ELEMENT_HEX27:
{
new_element = new Hexahedron(vertex_ids, block_id);
break;
}
default:
{
MFEM_ABORT("Unsupported cubit element type encountered.");
break;
}
}
return new_element;
}
mfem::Element *Mesh::CreateCubitBoundaryElement(const int cubit_face_type,
const int *vertex_ids,
const int sideset_id) const
{
using namespace cubit;
mfem::Element *new_element = nullptr;
switch (cubit_face_type)
{
case FACE_EDGE2:
case FACE_EDGE3:
{
new_element = new Segment(vertex_ids, sideset_id);
break;
}
case FACE_TRI3:
case FACE_TRI6:
{
new_element = new Triangle(vertex_ids, sideset_id);
break;
}
case FACE_QUAD4:
case FACE_QUAD9:
{
new_element = new Quadrilateral(vertex_ids, sideset_id);
break;
}
default:
{
MFEM_ABORT("Unsupported cubit face type encountered.");
break;
}
}
return new_element;
}
#endif // #ifdef MFEM_USE_NETCDF
+35 -22
View File
@@ -186,7 +186,7 @@ ParMesh::ParMesh(MPI_Comm comm, Mesh &mesh, int *partitioning_,
if (Dim > 1)
{
el_to_edge = new Table;
NumOfEdges = Mesh::GetElementToEdgeTable(*el_to_edge, be_to_edge);
NumOfEdges = Mesh::GetElementToEdgeTable(*el_to_edge);
}
STable3D *faces_tbl = NULL;
@@ -197,6 +197,19 @@ ParMesh::ParMesh(MPI_Comm comm, Mesh &mesh, int *partitioning_,
GenerateFaces();
// Make sure the be_to_face array is initialized.
// In 2D, it will be set in the above call to Mesh::GetElementToEdgeTable.
// In 3D, it will be set in GetElementToFaceTable.
// In 1D, we need to set it manually.
if (Dim == 1)
{
be_to_face.SetSize(NumOfBdrElements);
for (int i = 0; i < NumOfBdrElements; ++i)
{
be_to_face[i] = boundary[i]->GetVertices()[0];
}
}
ListOfIntegerSets groups;
{
// the first group is the local one
@@ -435,7 +448,7 @@ int ParMesh::BuildLocalBoundary(const Mesh& mesh, const int* partitioning,
for (int i = 0; i < mesh.GetNBE(); i++)
{
int edge = mesh.GetBdrElementEdgeIndex(i);
int edge = mesh.GetBdrElementFaceIndex(i);
int el1 = edge_element->GetRow(edge)[0];
if (partitioning[el1] == MyRank)
{
@@ -451,7 +464,7 @@ int ParMesh::BuildLocalBoundary(const Mesh& mesh, const int* partitioning,
boundary.SetSize(nbdry);
for (int i = 0; i < mesh.GetNBE(); i++)
{
int edge = mesh.GetBdrElementEdgeIndex(i);
int edge = mesh.GetBdrElementFaceIndex(i);
int el1 = edge_element->GetRow(edge)[0];
if (partitioning[el1] == MyRank)
{
@@ -917,7 +930,8 @@ void ParMesh::FinalizeParTopo()
}
}
ParMesh::ParMesh(MPI_Comm comm, istream &input, bool refine)
ParMesh::ParMesh(MPI_Comm comm, istream &input, bool refine, int generate_edges,
bool fix_orientation)
: glob_elem_offset(-1)
, glob_offset_sequence(-1)
, gtopo(comm)
@@ -929,9 +943,7 @@ ParMesh::ParMesh(MPI_Comm comm, istream &input, bool refine)
have_face_nbr_data = false;
pncmesh = NULL;
const int gen_edges = 1;
Load(input, gen_edges, refine, true);
Load(input, generate_edges, refine, fix_orientation);
}
void ParMesh::Load(istream &input, int generate_edges, int refine,
@@ -1725,7 +1737,7 @@ void ParMesh::GetSharedTriCommunicator(int ordering,
stria_comm.Finalize();
}
void ParMesh::MarkTetMeshForRefinement(DSTable &v_to_v)
void ParMesh::MarkTetMeshForRefinement(const DSTable &v_to_v)
{
Array<int> order;
GetEdgeOrdering(v_to_v, order); // local edge ordering
@@ -2050,6 +2062,7 @@ void ParMesh::DeleteFaceNbrData()
void ParMesh::SetCurvature(int order, bool discont, int space_dim, int ordering)
{
DeleteFaceNbrData();
space_dim = (space_dim == -1) ? spaceDim : space_dim;
FiniteElementCollection* nfec;
if (discont)
@@ -2070,6 +2083,7 @@ void ParMesh::SetCurvature(int order, bool discont, int space_dim, int ordering)
void ParMesh::SetNodalFESpace(FiniteElementSpace *nfes)
{
DeleteFaceNbrData();
ParFiniteElementSpace *npfes = dynamic_cast<ParFiniteElementSpace*>(nfes);
if (npfes)
{
@@ -2083,6 +2097,7 @@ void ParMesh::SetNodalFESpace(FiniteElementSpace *nfes)
void ParMesh::SetNodalFESpace(ParFiniteElementSpace *npfes)
{
DeleteFaceNbrData();
ParGridFunction *nodes = new ParGridFunction(npfes);
SetNodalGridFunction(nodes, true);
}
@@ -2091,19 +2106,17 @@ void ParMesh::EnsureParNodes()
{
if (Nodes && dynamic_cast<ParFiniteElementSpace*>(Nodes->FESpace()) == NULL)
{
DeleteFaceNbrData();
ParFiniteElementSpace *pfes =
new ParFiniteElementSpace(*Nodes->FESpace(), *this);
ParGridFunction *new_nodes = new ParGridFunction(pfes);
*new_nodes = *Nodes;
if (Nodes->OwnFEC())
{
new_nodes->MakeOwner(Nodes->OwnFEC());
Nodes->MakeOwner(NULL); // takes away ownership of 'fec' and 'fes'
delete Nodes->FESpace();
}
delete Nodes;
Nodes = new_nodes;
}
@@ -3199,17 +3212,15 @@ void ParMesh::ReorientTetMesh()
// other ranks in the group
Array<int> svert_master_rank(svert_lvert.Size());
Array<int> svert_master_index(svert_lvert);
for (int i = 0; i < group_svert.Size(); i++)
{
for (int i = 0; i < group_svert.Size(); i++)
int rank = gtopo.GetGroupMasterRank(i+1);
for (int j = 0; j < group_svert.RowSize(i); j++)
{
int rank = gtopo.GetGroupMasterRank(i+1);
for (int j = 0; j < group_svert.RowSize(i); j++)
{
svert_master_rank[group_svert.GetRow(i)[j]] = rank;
}
svert_master_rank[group_svert.GetRow(i)[j]] = rank;
}
svert_comm.Bcast(svert_master_index);
}
svert_comm.Bcast(svert_master_index);
// the pairs (master rank, master local index) define a globally consistent
// vertex ordering
@@ -3320,7 +3331,7 @@ void ParMesh::ReorientTetMesh()
GenerateFaces();
if (el_to_edge)
{
NumOfEdges = GetElementToEdgeTable(*el_to_edge, be_to_edge);
NumOfEdges = GetElementToEdgeTable(*el_to_edge);
}
}
else
@@ -3555,7 +3566,7 @@ void ParMesh::LocalRefinement(const Array<int> &marked_el, int type)
// 6. Update element-to-edge relations.
if (el_to_edge != NULL)
{
NumOfEdges = GetElementToEdgeTable(*el_to_edge, be_to_edge);
NumOfEdges = GetElementToEdgeTable(*el_to_edge);
}
} // 'if (Dim == 3)'
@@ -3793,7 +3804,7 @@ void ParMesh::LocalRefinement(const Array<int> &marked_el, int type)
if (el_to_edge != NULL)
{
NumOfEdges = GetElementToEdgeTable(*el_to_edge, be_to_edge);
NumOfEdges = GetElementToEdgeTable(*el_to_edge);
GenerateFaces();
}
} // 'if (Dim == 2)'
@@ -3855,6 +3866,8 @@ void ParMesh::NonconformingRefinement(const Array<Refinement> &refinements,
"serial Mesh)");
}
ResetLazyData();
DeleteFaceNbrData();
// NOTE: no check of !refinements.Size(), in parallel we would have to reduce
@@ -5286,7 +5299,7 @@ Mesh ParMesh::GetSerialMesh(int save_rank) const
for (int e = 0; e < NumOfElements; e++)
{
const int attr = elements[e]->GetAttribute();
const int geom_type = elements[e]->GetGeometryType();;
const int geom_type = elements[e]->GetGeometryType();
ints.Append(attr);
ints.Append(geom_type);
pfespace_linear.GetElementDofs(e, dofs);
+18 -12
View File
@@ -24,6 +24,7 @@
namespace mfem
{
#ifdef MFEM_USE_PUMI
class ParPumiMesh;
#endif
@@ -31,9 +32,16 @@ class ParPumiMesh;
/// Class for parallel meshes
class ParMesh : public Mesh
{
protected:
friend class ParNCMesh;
friend class ParSubMesh;
#ifdef MFEM_USE_PUMI
friend class ParPumiMesh;
#endif
#ifdef MFEM_USE_ADIOS2
friend class adios2stream;
#endif
protected:
MPI_Comm MyComm;
int NRanks, MyRank;
@@ -105,7 +113,7 @@ protected:
// Mark all tets to ensure consistency across MPI tasks; also mark the
// shared and boundary triangle faces using the consistently marked tets.
void MarkTetMeshForRefinement(DSTable &v_to_v) override;
void MarkTetMeshForRefinement(const DSTable &v_to_v) override;
/// Return a number(0-1) identifying how the given edge has been split
int GetEdgeSplittings(Element *edge, const DSTable &v_to_v, int *middle);
@@ -336,8 +344,14 @@ public:
explicit ParMesh(const ParMesh &pmesh, bool copy_nodes = true);
/// Read a parallel mesh, each MPI rank from its own file/stream.
/** The @a refine parameter is passed to the method Mesh::Finalize(). */
ParMesh(MPI_Comm comm, std::istream &input, bool refine = true);
/** The @a generate_edges parameter is passed to Mesh::Loader. The @a refine
and @a fix_orientation parameters are passed to the method
Mesh::Finalize().
@note The order of arguments and their default values are different than
for the Mesh class. */
ParMesh(MPI_Comm comm, std::istream &input, bool refine = true,
int generate_edges = 1, bool fix_orientation = true);
/// Deprecated: see @a ParMesh::MakeRefined
MFEM_DEPRECATED
@@ -694,14 +708,6 @@ public:
void PrintSharedEntities(const std::string &fname_prefix) const;
virtual ~ParMesh();
friend class ParNCMesh;
#ifdef MFEM_USE_PUMI
friend class ParPumiMesh;
#endif
#ifdef MFEM_USE_ADIOS2
friend class adios2stream;
#endif
};
}
-3
View File
@@ -1028,9 +1028,6 @@ void ParPumiMesh::UpdateMesh(const ParMesh* AdaptedpMesh)
bel_to_edge = (AdaptedpMesh->bel_to_edge) ?
new Table(*(AdaptedpMesh->bel_to_edge)) : NULL;
// Copy the boudary-to-edge Array, be_to_edge (2D)
AdaptedpMesh->be_to_edge.Copy(be_to_edge);
// Duplicate the faces and faces_info.
faces.SetSize(AdaptedpMesh->faces.Size());
for (int i = 0; i < faces.Size(); i++)
+15 -9
View File
@@ -235,10 +235,13 @@ ParSubMesh::ParSubMesh(const ParMesh &parent, SubMesh::From from,
// Add boundaries
{
int num_of_faces_or_edges =
(Dim == 3) ? NumOfFaces :
((Dim == 2) ? NumOfEdges : NumOfVertices);
Array<int> &be2face = (Dim == 2) ? be_to_edge : be_to_face;
const int num_codim_1 = [this]()
{
if (Dim == 1) { return NumOfVertices; }
else if (Dim == 2) { return NumOfEdges; }
else if (Dim == 3) { return NumOfFaces; }
else { MFEM_ABORT("Invalid dimension."); return -1; }
}();
if (Dim == 3)
{
@@ -249,7 +252,7 @@ ParSubMesh::ParSubMesh(const ParMesh &parent, SubMesh::From from,
}
NumOfBdrElements = 0;
for (int i = 0; i < num_of_faces_or_edges; i++)
for (int i = 0; i < num_codim_1; i++)
{
if (GetFaceInformation(i).IsBoundary())
{
@@ -258,14 +261,17 @@ ParSubMesh::ParSubMesh(const ParMesh &parent, SubMesh::From from,
}
boundary.SetSize(NumOfBdrElements);
be2face.SetSize(NumOfBdrElements);
be_to_face.SetSize(NumOfBdrElements);
Array<int> parent_face_to_be = parent.GetFaceToBdrElMap();
int max_bdr_attr = parent.bdr_attributes.Max();
for (int i = 0, j = 0; i < num_of_faces_or_edges; i++)
for (int i = 0, j = 0; i < num_codim_1; i++)
{
if (GetFaceInformation(i).IsBoundary())
{
boundary[j] = faces[i]->Duplicate(this);
be_to_face[j] = i;
if (from == SubMesh::From::Domain && Dim >= 2)
{
int pbeid = Dim == 3 ? parent_face_to_be[parent_face_ids_[i]] :
@@ -283,7 +289,7 @@ ParSubMesh::ParSubMesh(const ParMesh &parent, SubMesh::From from,
{
boundary[j]->SetAttribute(SubMesh::GENERATED_ATTRIBUTE);
}
be2face[j++] = i;
++j;
}
}
}
@@ -323,7 +329,7 @@ ParSubMesh::ParSubMesh(const ParMesh &parent, SubMesh::From from,
if (Dim > 1)
{
if (!el_to_edge) { el_to_edge = new Table; }
NumOfEdges = GetElementToEdgeTable(*el_to_edge, be_to_edge);
NumOfEdges = GetElementToEdgeTable(*el_to_edge);
}
SetAttributes();
+7 -12
View File
@@ -317,8 +317,7 @@ ParTransferMap::CorrectFaceOrientations(const ParFiniteElementSpace &fes,
if (parent_face_ori.Size() == 0) { return; }
VDofTransformation vdoftrans(fes.GetVDim(),
fes.GetOrdering());
DofTransformation doftrans(fes.GetVDim(), fes.GetOrdering());
int dim = mesh->Dimension();
bool face = (dim == 3);
@@ -332,17 +331,13 @@ ParTransferMap::CorrectFaceOrientations(const ParFiniteElementSpace &fes,
if (parent_face_ori[i] == 0) { continue; }
Geometry::Type geom = face ? mesh->GetFaceGeometry(i) :
mesh->GetElementGeometry(i);;
mesh->GetElementGeometry(i);
StatelessDofTransformation * doftrans =
fec->DofTransformationForGeometry(geom);
if (doftrans == NULL) { continue; }
vdoftrans.SetDofTransformation(*doftrans);
if (!fec->DofTransformationForGeometry(geom)) { continue; }
doftrans.SetDofTransformation(*fec->DofTransformationForGeometry(geom));
Fo[0] = parent_face_ori[i];
vdoftrans.SetFaceOrientations(Fo);
doftrans.SetFaceOrientations(Fo);
if (face)
{
@@ -356,12 +351,12 @@ ParTransferMap::CorrectFaceOrientations(const ParFiniteElementSpace &fes,
if (sub_to_parent_map)
{
src.GetSubVector(vdofs, face_vector);
vdoftrans.TransformPrimal(face_vector);
doftrans.TransformPrimal(face_vector);
}
else
{
dst.GetSubVector(vdofs, face_vector);
vdoftrans.InvTransformPrimal(face_vector);
doftrans.InvTransformPrimal(face_vector);
}
for (int j = 0; j < vdofs.Size(); j++)
+2 -2
View File
@@ -65,7 +65,7 @@ SubMesh::SubMesh(const Mesh &parent, From from,
for (int i = 0; i < NumOfBdrElements; i++)
{
int pbeid = parent_face_to_be[parent_face_ids_[GetBdrFace(i)]];
int pbeid = parent_face_to_be[parent_face_ids_[GetBdrElementFaceIndex(i)]];
if (pbeid != -1)
{
int attr = parent.GetBdrElement(pbeid)->GetAttribute();
@@ -117,7 +117,7 @@ SubMesh::SubMesh(const Mesh &parent, From from,
for (int i = 0; i < NumOfBdrElements; i++)
{
int pbeid = parent_face_to_be[parent_edge_ids_[GetBdrFace(i)]];
int pbeid = parent_face_to_be[parent_edge_ids_[GetBdrElementFaceIndex(i)]];
if (pbeid != -1)
{
int attr = parent.GetBdrElement(pbeid)->GetAttribute();
+7 -12
View File
@@ -241,8 +241,7 @@ void TransferMap::CorrectFaceOrientations(const FiniteElementSpace &fes,
if (parent_face_ori.Size() == 0) { return; }
VDofTransformation vdoftrans(fes.GetVDim(),
fes.GetOrdering());
DofTransformation doftrans(fes.GetVDim(), fes.GetOrdering());
int dim = mesh->Dimension();
bool face = (dim == 3);
@@ -256,17 +255,13 @@ void TransferMap::CorrectFaceOrientations(const FiniteElementSpace &fes,
if (parent_face_ori[i] == 0) { continue; }
Geometry::Type geom = face ? mesh->GetFaceGeometry(i) :
mesh->GetElementGeometry(i);;
mesh->GetElementGeometry(i);
StatelessDofTransformation * doftrans =
fec->DofTransformationForGeometry(geom);
if (doftrans == NULL) { continue; }
vdoftrans.SetDofTransformation(*doftrans);
if (!fec->DofTransformationForGeometry(geom)) { continue; }
doftrans.SetDofTransformation(*fec->DofTransformationForGeometry(geom));
Fo[0] = parent_face_ori[i];
vdoftrans.SetFaceOrientations(Fo);
doftrans.SetFaceOrientations(Fo);
if (face)
{
@@ -280,12 +275,12 @@ void TransferMap::CorrectFaceOrientations(const FiniteElementSpace &fes,
if (sub_to_parent_map)
{
src.GetSubVector(vdofs, face_vector);
vdoftrans.TransformPrimal(face_vector);
doftrans.TransformPrimal(face_vector);
}
else
{
dst.GetSubVector(vdofs, face_vector);
vdoftrans.InvTransformPrimal(face_vector);
doftrans.InvTransformPrimal(face_vector);
}
for (int j = 0; j < vdofs.Size(); j++)
+1 -1
View File
@@ -1403,7 +1403,7 @@ void maxwell_solution_curlcurl(const Vector & X,
curlcurlE.resize(dim);
for (int i = 0; i < dim; ++i)
{
curlcurlE[i] = 0.0;;
curlcurlE[i] = 0.0;
}
switch (prob)
{
+4
View File
@@ -18,6 +18,10 @@ CONFIG_MK = $(MFEM_BUILD_DIR)/config/config.mk
# MFEM_INSTALL_DIR = ../../mfem
# CONFIG_MK = $(MFEM_INSTALL_DIR)/share/mfem/config.mk
# Include defaults.mk to get XLINKER
DEFAULTS_MK = $(MFEM_DIR)/config/defaults.mk
include $(DEFAULTS_MK)
MFEM_LIB_FILE = mfem_is_not_built
-include $(CONFIG_MK)
@@ -213,24 +213,25 @@ HypreParMatrix *FormDiscreteDivergenceMatrix(ParFiniteElementSpace &fes_rt,
auto J = D_local.WriteJ();
auto V = D_local.WriteData();
const int two_dim = 2*dim;
// Loop over L2 DOFs
MFEM_FORALL(i, n_l2,
MFEM_FORALL(ii, n_l2*2*dim,
{
const int k = ii % (two_dim);
const int i = ii / (two_dim);
const int i_loc = i%nvol_per_el;
const int i_el = i/nvol_per_el;
for (int k = 0; k < 2*dim; ++k)
{
const int sjv_loc = e2f(k, i_loc);
const int jv_loc = (sjv_loc >= 0) ? sjv_loc : -1 - sjv_loc;
const int sgn1 = (sjv_loc >= 0) ? 1 : -1;
const int sj = gather_rt(jv_loc, i_el);
const int j = (sj >= 0) ? sj : -1 - sj;
const int sgn2 = (sj >= 0) ? 1 : -1;
const int sjv_loc = e2f(k, i_loc);
const int jv_loc = (sjv_loc >= 0) ? sjv_loc : -1 - sjv_loc;
const int sgn1 = (sjv_loc >= 0) ? 1 : -1;
const int sj = gather_rt(jv_loc, i_el);
const int j = (sj >= 0) ? sj : -1 - sj;
const int sgn2 = (sj >= 0) ? 1 : -1;
J[k + 2*dim*i] = j;
V[k + 2*dim*i] = sgn1*sgn2;
}
J[k + 2*dim*i] = j;
V[k + 2*dim*i] = sgn1*sgn2;
});
// Create a block diagonal parallel matrix
+1 -1
View File
@@ -278,4 +278,4 @@ void SolveCG(Operator &A, Solver &P, const Vector &B, Vector &X)
cout << "Done.\nIterations: " << cg.GetNumIterations()
<< "\nElapsed: " << tic_toc.RealTime() << endl;
}
};
}

Some files were not shown because too many files have changed in this diff Show More