Compare commits

...
Author SHA1 Message Date
Will Pazner 8b555a7bf8 Generic version of PointMatrixHash::operator() 2024-01-23 12:31:41 -08:00
Dylan Copeland fb0cdbb9f7 Merge PR 3806. 2024-01-23 11:13:34 -08:00
Dylan Copeland a8090e318d Merge branch 'master' of github.com:mfem/mfem into float 2024-01-23 11:07:47 -08:00
Tzanio Kolev 0de295d6e1 Merge pull request #3806 from mfem/full-assembly-elast-dev
Miniapp for block preconditioned elasticity with partial and full assembly on GPUs [full-assembly-elast-dev]
2024-01-23 09:09:20 -08:00
Tzanio Kolev 4ba0c28a6a Merge pull request #4055 from mfem/hughcars/pncmesh-update-fix
Fix for ParNCMesh::Update()
2024-01-21 13:04:48 -08:00
Victor DeCaria 77d409b4c6 added documentation link 2024-01-19 12:45:55 -07:00
Victor DeCaria 238a9da6d9 added to changelog 2024-01-19 12:11:39 -07:00
Tzanio Kolev 15be3d493c Merge pull request #4069 from mfem/error-noreturn-fix
Fix [[noreturn]] for MFEM_ABORT with Intel compilers
2024-01-18 04:38:12 -08:00
dylan-copeland 5896f590e7 Added precision flags to cmake files. Added compile-time checks for double or single being defined, not both. Reverted appveyor.yml. 2024-01-17 16:54:18 -08:00
dylan-copeland cda68d779c Restore parallel build instructions in appveyor.yml. 2024-01-16 16:21:09 -08:00
dylan-copeland d54d2668a2 Restart CI 2024-01-16 15:30:08 -08:00
dylan-copeland 1af666cb9a Restart CI 2024-01-16 14:07:58 -08:00
Dylan Copeland ad87b9cb5f appveyor.yml 2024-01-16 13:23:10 -08:00
Dylan Copeland 1c037bf476 Merge branch 'master' of github.com:mfem/mfem into float 2024-01-16 12:17:04 -08:00
Will Pazner dd83719b58 Merge pull request #4063 from mfem/array-doc
Array documentation improvement
2024-01-16 11:12:01 -08:00
Will Pazner cce2d98fce Merge pull request #3994 from mfem/grad-integr-transpose-pa
PA for `GradientIntegrator` transpose
2024-01-16 11:11:43 -08:00
Tzanio Kolev 7d0c0199d8 Merge pull request #4068 from mfem/const-mesh-fix
Fix compilation errors from const changes in PR #4019
2024-01-16 10:44:08 -08:00
Will Pazner 629bb6a2a7 Fix [[noreturn]] for MFEM_ABORT with Intel compilers 2024-01-12 11:58:01 -08:00
Will Pazner 8a5c5523ee Fix compilation errors from const changes in PR #4019
These errors only show up when compiling with LAPACK support.

Also fix some shadow variable warnings.
2024-01-11 14:54:37 -08:00
Dylan Copeland 47e042245e Merge branch 'master' of github.com:mfem/mfem into float 2024-01-11 14:26:05 -08:00
Will Pazner 2b27d4815f Merge pull request #4019 from mfem/sjg/mesh-const-fix
Const correctness fixes for `Mesh` and `ParMesh`
2024-01-11 13:24:42 -08:00
Will Pazner 9bd2fd3cc3 Minor style changes 2024-01-10 21:09:43 -08:00
stefanhenneking 6095d41779 using enum for fec_type 2024-01-10 16:42:06 -06:00
stefanhenneking 217e644b29 Merging master into feature branch 2024-01-10 15:57:46 -06:00
stefanhenneking c54f0ee11a refactored pa_divergence_transpose_testnd and pa_gradient_testnd 2024-01-10 15:50:24 -06:00
stefanhenneking 4eed7c754e using GENERATE instead of loops in "PA Gradient" 2024-01-10 14:48:39 -06:00
stefanhenneking 90bc29a976 using unique_ptr in pa_gradient_testnd 2024-01-10 14:43:51 -06:00
stefanhenneking 96d516a1a8 using GENERATE instead of loop in "FormRectangular" 2024-01-10 14:39:35 -06:00
stefanhenneking 56fcc5dcef Using unique_ptr 2024-01-10 14:25:18 -06:00
dylan-copeland 9f5b282c7a Minor improvement to documentation. 2024-01-09 17:11:05 -08:00
victor-decaria-nnl 5a34b0f236 Merge branch 'master' into full-assembly-elast-dev 2024-01-08 12:22:59 -05:00
dylan-copeland 4e25b1ba6b Merge branch 'master' of github.com:mfem/mfem into float 2024-01-05 11:37:18 -08:00
Sebastian Grimberg 39add0f7a9 Resolve a breaking interface change 2024-01-05 11:05:12 -08:00
Sebastian Grimberg e26f72da36 Address PR feedback: Change pointers to references and add notes for consistency with other Mesh methods 2024-01-04 17:40:58 -08:00
Sebastian Grimberg cbe12d1419 Address PR feedback: Doxygen style 2024-01-04 17:28:50 -08:00
Tzanio Kolev d5aa18f762 Merge pull request #3746 from mfem/hughcars/ncmesh-interior-boundary-dev
Add internal boundary element support for NCMesh
2024-01-04 16:09:52 -08:00
Hugh Carson 918622a430 Clear entity_conf_group and entity_elem_local on Update() 2024-01-04 17:38:13 -05:00
dylan-copeland 30a8a51e20 Error messages for examples and miniapps that fail in single precision. 2024-01-03 20:32:53 -08:00
dylan-copeland d9ae367705 Reinstate KDTree templates. 2024-01-03 10:41:58 -08:00
dylan-copeland b3a3ad3488 Using real_t in KDTree. 2024-01-03 10:30:39 -08:00
dylan-copeland ceaabce20d More KDTree typedefs. 2024-01-02 18:27:51 -08:00
dylan-copeland 49fe6fc429 Remove use of KDTree typedefs. 2024-01-02 18:18:21 -08:00
dylan-copeland 1c1e8293e1 Remove a double from last merge. 2024-01-02 17:05:57 -08:00
Dylan Copeland bcad115dda Merge branch 'master' of github.com:mfem/mfem into float 2024-01-02 14:41:02 -08:00
Dylan Copeland 7c81683d1b Introducing MFEM_USE_DOUBLE. 2024-01-02 14:40:33 -08:00
Tzanio Kolev 144bc29496 Merge pull request #4027 from mfem/bdr-lf-fast-assembly-fix
Boundary LF Integrators fast assembly bug fix
2024-01-02 13:10:50 -08:00
Tzanio Kolev b732c3ffe8 Merge pull request #3957 from mfem/hip-abort-msg-fix
Workaround for an issue in certain HIP builds
2024-01-02 13:10:31 -08:00
Hugh Carson 5736f3832b Fix bug for segment boundary faces 2024-01-02 15:47:46 +00:00
Hugh Carson 38e9c0951b Merge remote-tracking branch 'origin/master' into hughcars/ncmesh-interior-boundary-dev 2024-01-02 11:13:31 +00:00
Veselin Dobrev 148047f692 Merge pull request #4016 from mfem/periodic-mesh-kdtree
Faster periodic meshes with k-d trees
2023-12-27 13:32:32 -08:00
Dylan Copeland 7d1b07f873 CHANGELOG 2023-12-21 13:46:36 -08:00
Dylan Copeland 80449bbd15 Merge branch 'master' of github.com:mfem/mfem into float 2023-12-21 13:20:38 -08:00
victor-decaria-nnl abb466d2f7 Merge pull request #4043 from mfem/full-assembly-elast-dev-changes
Proposed changes for PR #3806
2023-12-21 15:35:38 -05:00
Will Pazner 79b609872a Merge pull request #4032 from mfem/sjg/ceed-chk-fix
Fix libCEED compilation after `CeedChk` removal
2023-12-21 10:46:03 -08:00
Will Pazner 38c27dfe4c Merge pull request #4037 from mfem/block-operator-offsets-dev
Make `BlockOperator` own the offset arrays
2023-12-21 10:45:47 -08:00
Tzanio Kolev c1871afea4 Merge pull request #3971 from mfem/mesh-file-comments
Input comments for mesh file
2023-12-21 06:26:56 -08:00
Tzanio Kolev a7a7807652 Merge pull request #4025 from mfem/sjg/gslib-leak-fix
Fix memory leak in GSLIB interface
2023-12-21 06:26:21 -08:00
Will Pazner 0ecfcb3633 Fix LOR bug in lor_elast.cpp 2023-12-20 21:49:17 -08:00
Will Pazner a35b5e76b0 Doxygen comment for ElasticityComponentIntegrator 2023-12-20 13:21:57 -08:00
Will Pazner b5ca50d967 Remove unneeded include 2023-12-20 13:19:33 -08:00
Will Pazner cbce58c685 Reorganize elasticity and component integrators for PA 2023-12-20 13:19:28 -08:00
Will Pazner 912c7d24b6 Small changes to lor_elast.cpp 2023-12-20 11:04:36 -08:00
Will Pazner 5cdfd84635 Simplify NodalFiniteElement::CreateLexicographicFullMap 2023-12-20 10:58:45 -08:00
Will Pazner 7c9abd5303 Don't need both virtual and override 2023-12-20 10:00:50 -08:00
dylan-copeland bf4c7ea8c1 Fix examples and miniapps on mac. 2023-12-19 19:29:34 -08:00
dylan-copeland 9beaa836b0 MFEM_USE_FLOAT -> MFEM_USE_SINGLE 2023-12-19 17:51:19 -08:00
Dylan Copeland b5670b4daf Fixed a new example and a new miniapp. 2023-12-19 14:39:20 -08:00
Hugh Carson 6a3a7e4746 Fix parallel synchronization bug that crept in during merge 2023-12-19 16:25:13 -05:00
Hugh Carson 4fe30263e4 Address PR feedback 2023-12-19 14:12:10 -05:00
Hugh Carson 170c520493 Merge remote-tracking branch 'origin/master' into hughcars/ncmesh-interior-boundary-dev 2023-12-19 14:09:19 -05:00
Victor DeCaria aea91bf9dc make block operator own the offsets 2023-12-18 14:50:47 -07:00
dylan-copeland fd44d57e91 Merge branch 'master' of github.com:mfem/mfem into float 2023-12-18 09:39:48 -08:00
Tzanio Kolev 8a4affef5a Merge pull request #4014 from mfem/bugfix/rwa/rebalance-lazy-data
reset lazy data on potential topology changes due to rebalancing
2023-12-17 12:25:47 -08:00
Tzanio Kolev 3f629314d2 Merge pull request #4033 from mfem/bilinearform-vdofs-fix-again
Undo accidental revert of PR #3859
2023-12-17 12:25:27 -08:00
Tzanio Kolev c4c3b4edf9 Merge pull request #3688 from mfem/do/docs-polish
Partial modernization of docs
2023-12-17 12:24:50 -08:00
Will Pazner 89ed97c5e8 Merge pull request #3419 from mfem/nurbs-cmesh-miniapp2
Nurbs C-mesh foil section miniapp [nurbs-cmesh-miniapp2]
2023-12-15 14:25:00 -08:00
Sebastian Grimberg 59fd822fb5 Merge branch 'master' into sjg/ceed-chk-fix 2023-12-15 13:50:06 -08:00
Tzanio Kolev 1f028cd9a8 Merge pull request #3854 from mfem/jeremy/ceed-basis-none
libCEED - update CEED_BASIS_COLLOCATED => CEED_BASIS_NONE
2023-12-15 13:34:56 -08:00
Robert W. Anderson 1717231f32 remove ResetLazyData 2023-12-15 12:40:09 -08:00
Sebastian Grimberg e3201429c0 Minor copy-paste fix in GetSharedFaceTransformationsByLocalIndex 2023-12-15 12:35:32 -08:00
Will Pazner 90c4ab6e17 Add comment explaining placement of GetElementVDofs 2023-12-15 09:44:16 -08:00
Chak Shing Lee d25e7a3877 fix unfilled vdofs in BilinearForm::Assemble when element matrices have been precomputed 2023-12-15 09:04:33 -08:00
Sebastian Grimberg a5f73604b1 Fix include issues for compiler errors 2023-12-14 18:07:15 -08:00
Sebastian Grimberg 5b5356495a CeedChk -> PCeedChk (deprecated internal function to MFEM wrapper) 2023-12-14 18:07:02 -08:00
Robert W. Anderson 9e7f733eac add additional data members to the Mesh::Swap method 2023-12-14 09:41:10 -08:00
dylan-copeland 87504f2e6d Default comment value of empty string. 2023-12-13 16:42:15 -08:00
dylan-copeland 7d15a638be Replace some doubles that somehow snuck in. 2023-12-13 14:59:11 -08:00
Veselin Dobrev b273b7669f Fix shadow typedefs 2023-12-13 14:39:36 -08:00
Tzanio Kolev d983b34924 Renamed ftype -> real_t 2023-12-13 12:51:43 -08:00
Will Pazner 865c343db7 Minor style changes 2023-12-13 11:22:26 -08:00
Will Pazner db41b274c9 Make KnotVector::FindMaxima const 2023-12-13 11:21:23 -08:00
JacobLotz 4610d4d689 Fix DoubleTanhKnotVector 2023-12-13 13:46:54 +01:00
JacobLotz 45de8cdf93 Move to unique pointer 2023-12-13 11:44:24 +01:00
stefanhenneking f916711d36 boundary lf fast assembly bug fix 2023-12-13 00:50:25 -06:00
dylan-copeland 28ee8d30fe One more const 2023-12-12 17:06:50 -08:00
Tzanio Kolev 47ab481aa2 Merge branch 'do/docs-polish' of github.com:mfem/mfem into do/docs-polish 2023-12-12 15:26:58 -08:00
Tzanio Kolev a8b0b35c1d Mention the Doxygen version requirement 2023-12-12 15:26:50 -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
Dylan Copeland 373a3a0099 Merge branch 'master' of github.com:mfem/mfem into float 2023-12-12 12:53:39 -08:00
Dylan Copeland e3ea03baa0 Const changes 2023-12-12 12:25:50 -08:00
Dylan Copeland c1b6fe6506 Merge branch 'master' of github.com:mfem/mfem into mesh-file-comments 2023-12-12 11:32:42 -08:00
Dylan Copeland f7dd1f59a7 Minor 2023-12-12 11:32:30 -08:00
Sebastian Grimberg 8fbfec3829 Fix memory leak from MPI_Comm_dup and missing MPI_Comm_free for GSLIB interface 2023-12-12 09:54:09 -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
JacobLotz 8c12c6d2af Last VisIt typo 2023-12-12 10:22:30 +01:00
JacobLotz 37e3151d6d add mfem 4.6 dependency 2023-12-12 09:49:07 +01:00
JacobLotz af3294b361 fix line width 2023-12-12 09:42:45 +01:00
Will Pazner 185a339db3 Merge remote-tracking branch 'origin/master' into periodic-mesh-kdtree
# Conflicts:
#	mesh/mesh.cpp
2023-12-11 13:33:24 -08:00
Sebastian Grimberg 714a6040f0 Address PR feedback: Clean up doxygen comments 2023-12-11 13:25:23 -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
Jacob Lotz 43d577a4f1 make style 2023-12-09 19:37:53 +01:00
Jacob LotzandDylan Copeland 9d44f3be75 Update miniapps/nurbs/nurbs_naca_cmesh.cpp
Co-authored-by: Dylan Copeland <dylancopeland@gmail.com>
2023-12-09 19:36:32 +01:00
Jacob LotzandDylan Copeland 99df066336 Update miniapps/nurbs/nurbs_naca_cmesh.cpp
Co-authored-by: Dylan Copeland <dylancopeland@gmail.com>
2023-12-09 19:36:15 +01:00
Jacob Lotz ce2462a126 const NACA4 class 2023-12-09 19:31:51 +01:00
Jacob LotzandDylan Copeland 9adc3c5d8b Update miniapps/nurbs/nurbs_naca_cmesh.cpp
Co-authored-by: Dylan Copeland <dylancopeland@gmail.com>
2023-12-09 18:33:59 +01:00
Jacob LotzandDylan Copeland 855fd34471 Update miniapps/nurbs/nurbs_naca_cmesh.cpp
Co-authored-by: Dylan Copeland <dylancopeland@gmail.com>
2023-12-09 18:32:48 +01: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
JacobLotz e3cac5edb3 Textual improvements 2023-12-08 11:42:11 +01: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
Sebastian Grimberg 96e2fa95d8 Add const versions of FaceElementTransformations using user provided FaceElementTransformations and ElementTransformation objects, like for GetElementTransformation
Also improves const-correctness throughout Mesh, ParMesh, and NCMesh classes.
2023-12-07 14:24:46 -08:00
Will Pazner b13d4d6631 Mark mfem_error as [[noreturn]] 2023-12-07 11:46:20 -08:00
Tzanio Kolev 3c7ee44fb7 Merge branch 'master' into do/docs-polish 2023-12-07 11:37:23 -08:00
Tzanio Kolev eb28399c7c Small adjustments to new Doxygen style 2023-12-07 11:36:28 -08:00
Tzanio Kolev 35b28b3552 Updated Doxygen config file to version 1.9.8 2023-12-07 11:32:00 -08:00
Dylan Copeland aa4d4efc04 Merge branch 'master' of github.com:mfem/mfem into float 2023-12-07 10:05:17 -08:00
Sebastian Grimberg 28f48489a6 Minor const correctness fix for Mesh 2023-12-07 08:37:49 -08:00
Jacob Lotz 76171e95a7 Merge branch 'master' into nurbs-cmesh-miniapp2 2023-12-07 10:56:12 +01:00
Will Pazner 22670890ce Use KDTree in Mesh::CreatePeriodicVertexMapping for better efficiency 2023-12-06 21:26:00 -08:00
Will Pazner be5541dba1 Add abstract base class KDTreeBase for derived KDTree class templates 2023-12-06 21:25:44 -08:00
Will Pazner 262f5fff23 const-correctness for KDTree 2023-12-06 21:20:12 -08:00
Tzanio Kolev 90b65160c8 Merge branch 'do/docs-polish' of github.com:mfem/mfem into do/docs-polish 2023-12-06 11:33:43 -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
Dennis Ogiermann 66768c1dd8 Add dark mode toggle. 2023-12-06 09:32:37 +01:00
Robert W. Anderson 02e57a881d reset lazy data on potential topology changes due to rebalancing 2023-12-05 18:31:10 -08:00
Mittal, Ketan 956be1a755 adding brief for doxygen comments 2023-12-05 16:21:08 -08:00
Dylan Copeland e9fbd5057f Merge branch 'master' of github.com:mfem/mfem into float 2023-12-05 13:08:02 -08:00
termi-official a0b1307bc0 Add Will's suggestion. 2023-12-05 21:45:03 +01: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
victor-decaria-nnl 0056b04a43 Merge branch 'master' into full-assembly-elast-dev 2023-12-05 12:42:14 -05:00
Victor DeCaria 92a11125c8 astyle 2023-12-05 10:40:52 -07:00
Victor DeCaria 01bd1a1142 Added checks to make sure compression types of CoefficientVector were supported. Refactored to remove need for PACalled. Made QuadratureFunction a forward declaration in bilininteg instead of an include. 2023-12-05 10:40:12 -07:00
Victor DeCaria 8bdc3b67bb using CoefficientVector 2023-12-05 09:19:51 -07: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
Victor DeCaria a4f7c68ac7 reverting a random newline that was deleted 2023-12-05 07:03:28 -07:00
victor-decaria-nnl 2033b9853c Merge branch 'master' into full-assembly-elast-dev 2023-12-05 08:41:53 -05:00
Victor DeCaria 48935c4a8a reverted the move of ElementDofOrdering 2023-12-05 06:39:59 -07:00
Victor DeCaria 61fc44f5ff removed the overloads for GetDofToQuad. Changed MFEM_VERIFY conditions to reflect adding the new enum value 2023-12-05 06:28:09 -07:00
Jacob Lotz ab203b26f9 Merge branch 'master' into nurbs-cmesh-miniapp2 2023-12-05 11:19:43 +01:00
Victor DeCaria 336236eae8 implemented the LEXICOGRAPHIC_FULL idea 2023-12-04 16:55:50 -07: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
Victor DeCaria 4a38577e3f added same tests from makefile to CmakeLists.txt 2023-12-04 12:45:46 -07:00
Victor DeCaria 0ca7ff4533 added GetEVectorOrdering function 2023-12-04 12:45:46 -07:00
victor-decaria-nnl b8e4945878 Merge branch 'master' into full-assembly-elast-dev 2023-12-04 10:37:49 -05: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
Victor DeCaria c7aa393ba0 got rid of forall macros in kernels 2023-12-01 15:06:04 -07:00
victor-decaria-nnlandWill Pazner d9c60f710e Update fem/integ/bilininteg_elasticity_kernels.hpp
applying suggestion to delete @file doxygen line

Co-authored-by: Will Pazner <11493037+pazner@users.noreply.github.com>
2023-12-01 15:23:32 -05:00
Victor DeCaria 71c4566944 applying some suggestions 2023-12-01 13:01:16 -07: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
victor-decaria-nnl 3fd54f4e91 Merge branch 'master' into full-assembly-elast-dev 2023-12-01 14:01:24 -05: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
dylan-copeland a4aa7d70b9 Generalized PR 3852. 2023-11-30 09:51:09 -08:00
dylan-copeland d96152a08a Merge branch 'master' of github.com:mfem/mfem into float 2023-11-30 09:32:47 -08:00
Tzanio Kolev 4653df940c Merge branch 'master' into do/docs-polish 2023-11-29 16:32:25 -08:00
Tzanio Kolev fdbb8e2757 Small updates to new Doxygen documentation style 2023-11-29 16:31:07 -08:00
stefanhenneking c3a5798463 Fixing minor bug in 3D PA. 2023-11-29 15:23:38 -06:00
victor-decaria-nnl 35254a3e02 Merge branch 'master' into full-assembly-elast-dev 2023-11-29 12:51:45 -05: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
victor-decaria-nnl fcbfba6fa3 Merge branch 'master' into full-assembly-elast-dev 2023-11-29 10:59:15 -05: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
victor-decaria-nnl 13abdfafe0 Merge branch 'master' into full-assembly-elast-dev 2023-11-28 11:46:11 -05: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
Hugh Carson 22b991d9f1 Fixes for PR feedback:
- Moved some CHECK out of hot loops, replaced with bool set with &= checked after
- Changed lambda variable names to be snake case for consistency
- Add missing std headers into mesh test utils: array (std::array), functional (std::function) and memory (std::unique_ptr)
2023-11-27 10:20:08 -05:00
Hugh Carson b17291ba3b Rewrap comments at 80 characters 2023-11-24 15:37:28 -05:00
Hugh Carson f60c93dd19 Address PR feedback:
- Comment fixes
- Refactor to move helper functions to mesh utils
- Align at 80 characters
- Refactor tests to reuse the testing meshes more
- Width fixes, some named arguments, a bit of doxygen commenting
- Remove negative from master face detection methods. Fix up doxygen comments
- Extra const correctness
2023-11-24 15:36:15 -05:00
Hugh Carson e59534b921 Merge remote-tracking branch 'origin/master' into hughcars/ncmesh-interior-boundary-dev 2023-11-24 10:36:13 -05: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
stefanhenneking 627a295eaa remove mem leak in test 2023-11-22 17:32:01 -06:00
stefanhenneking f8e4b83043 unit test init ptr 2023-11-22 17:13:14 -06:00
stefanhenneking 304c94f184 init with nullptr 2023-11-22 17:02:50 -06:00
stefanhenneking be6d3e57e7 removing comments 2023-11-22 16:59:44 -06:00
stefanhenneking 86bbefca08 remove cout print 2023-11-22 16:50:04 -06:00
stefanhenneking ae3443fd1d style 2023-11-22 16:31:21 -06:00
stefanhenneking 514d281475 Add unit tests for GradientIntegrator with L2 test functions. 2023-11-22 16:21:38 -06:00
stefanhenneking 5c0ae17a5b Add PA unit tests for GradientIntegrator. 2023-11-22 16:21:06 -06:00
stefanhenneking 0140fed416 Fix GradientIntegrator to support L2 test functions of INTEGRAL type. 2023-11-22 16:19:53 -06:00
stefanhenneking d07e541f5c Fix VectorDomainLFIntegrator when MapType is INTEGRAL. 2023-11-22 16:12:20 -06:00
stefanhenneking ee335907f7 PA implementation for GradientIntegrator transpose. 2023-11-22 16:10:52 -06:00
stefanhenneking f5d2144e80 minor: fix typos and description. 2023-11-22 16:09:07 -06: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
dylan-copeland ff95fdb3af Merge branch 'master' of github.com:mfem/mfem into mesh-file-comments 2023-11-20 16:22:10 -08:00
dylan-copeland 0e209bbf05 Adjust formatting for NCMesh. 2023-11-20 16:20:23 -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
Dylan Copeland d41b97552c Merge branch 'master' of github.com:mfem/mfem into float 2023-11-16 17:37:34 -08:00
nbeams 4db39d6d4b Update Ginkgo CBGMRES documentation to include fptype of float 2023-11-16 17:16:30 -05: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
Hugh Carson 398ff215f3 Merge remote-tracking branch 'origin/master' into hughcars/ncmesh-interior-boundary-dev 2023-11-16 09:31:11 -05: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
Dylan Copeland b3813ed053 Using fptype in ginkgo interface. 2023-11-13 13:46:19 -08:00
Hugh Carson d49dcc33f9 Introduce support for interior boundary elements within NCMesh
- A boundary element is now either a conformal face (internal or external) or a slave face (internal)
- The dofs of master faces of an internal slave face are discovered to enable adding essential boundaries
- Various small refactorings for loops etc.
2023-11-13 14:17:01 -05:00
Hugh Carson 3aea84aa2c Introduce unit tests for nc interior boundaries, and for general nc hardening 2023-11-13 14:16:57 -05: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
Hugh Carson f46e7d93de Various cleanups/refactors ahead of interior boundary 2023-11-13 11:54:31 -05:00
Hugh Carson cccb23b459 Add variadic max function 2023-11-13 11:51:58 -05:00
Hugh Carson 5d8e9c237a Clean up elements to use override, and fill in various missing methods uncovered by setting override and pure virtual 2023-11-13 11:51:58 -05:00
dylan-copeland b78275e79e Merge branch 'master' of github.com:mfem/mfem into float 2023-11-13 07:41:47 -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
Dylan Copeland a8c34e351e Reverted to fmin and fmax for GPU kernels. Fixed some examples for pcuda build. 2023-11-10 21:30:07 -08:00
Dylan Copeland a3d2036838 MFEM_EXPORT for MPITypeMap. 2023-11-10 17:25:21 -08:00
Dylan Copeland f36873a150 Updating CONTRIBUTING.md with policy about fptype. 2023-11-10 13:35:07 -08:00
Dylan Copeland e617238cc5 Style 2023-11-09 21:56:11 -08:00
Dylan Copeland 47e62a55f9 Merge branch 'master' of github.com:mfem/mfem into float 2023-11-09 21:38:06 -08:00
Dylan Copeland 89f62d04e1 Temporary change to branch-history so CI can pass. 2023-11-09 20:17:18 -08:00
Sebastian Grimberg 83a72b343a Fix cusparse, cublas library dependency linkage for CMake builds with CUDA 2023-11-09 18:02:36 -08:00
Dylan Copeland 686756d73f Generalized the remaining miniapps, except gslib. 2023-11-09 14:39:59 -08:00
Dylan Copeland a3e7080fc1 Generalized more miniapps. 2023-11-09 13:28:59 -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
Dylan Copeland 953a883903 Replaced the option to put comments at beginning of the file with option to write comments within the file (after the first line). 2023-11-08 18:59:28 -08:00
Dylan Copeland 25e95ef38b Change the starting character for comments to %. 2023-11-08 15:54:58 -08:00
Dylan Copeland 901c4b425a Skip comments at beginning of mesh file. 2023-11-08 14:56:07 -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
Dylan Copeland 1911fbc883 Generalized miniapps hdiv and hooke. 2023-11-08 09:34:48 -08:00
Dylan Copeland 36106d6fe4 Generalized miniapps in autodiff and electromagnetics. 2023-11-07 15:11:45 -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
Dylan Copeland eea5e91bb3 Generalized miniapps in dpg and toys. 2023-11-07 14:00:04 -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
Dylan Copeland 9eca33b09d Generalized everything in miniapps/meshing. 2023-11-06 19:06:55 -08:00
Dylan Copeland b89222762d Generalized floating point type for all remaining examples. 2023-11-06 15:34:42 -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
Dylan Copeland 69e4e13185 Merge branch 'float' of github.com:mfem/mfem into float 2023-11-04 19:56:13 -07:00
Dylan Copeland c80fdc6f74 Generalized CUDA for float case, so example device runs succeed with a pcuda build. 2023-11-04 19:55:18 -07:00
Veselin Dobrev 62c0444cbf Fix warnings about extra ';' from GCC with '-pedantic' flag 2023-11-04 18:47:52 -07:00
Veselin Dobrev bada9b86f0 Fix a warning from Apple clang 2023-11-04 18:07:51 -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
Jeremy L Thompson 0e859e6122 ceed - check libCEED v0.12.0 min version 2023-11-02 12:49:52 -06:00
Jeremy L Thompson e61fdb139e ceed - document libCEED v0.12.0 min version 2023-11-02 12:30:19 -06:00
Dylan Copeland d02a90f9f2 Generalized type for PA kernels. 2023-11-01 16:31:49 -07:00
Dylan Copeland 9017b9700d Finished generalizing type in fem directory. 2023-11-01 15:54:41 -07:00
Dylan Copeland 3b4fc3b1df Generalized for MPI and hypre. 2023-10-31 21:12:15 -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
Dylan Copeland ee3a46af24 Added support for LAPACK in single-precision. Changed fmax -> std::max, etc. 2023-10-31 14:30:44 -07:00
Sebastian Grimberg aa8e466e42 Address PR feedback: Rename IsEmpty -> IsIdentity and clarify code comments 2023-10-31 12:26:35 -07:00
Dylan Copeland c64d7858e8 Adding build option for single-precision. 2023-10-31 12:04:38 -07:00
Veselin Dobrev ed655d51bc Workaround by @koning for an issue he noticed in certain HIP builds 2023-10-29 17:53:27 -07:00
Vladimir Z Tomov d9937c5b82 Wrong assert code in ParGF::ProjectBdrCoefficient 2023-10-29 17:26:09 -07:00
Sebastian Grimberg 19e016e5d0 Merge branch 'master' into sjg/global-variables-threadsafe 2023-10-27 11:17:59 -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
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
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
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
Victor DeCaria 21b0b8bcf6 added lexicographic full for the rest of the possible element and derivative configurations 2023-10-10 06:06:04 -06:00
Victor DeCaria 44b34f5e64 reverted changes to operator and blockoperator to simplify pr 2023-10-09 16:14:48 -06:00
Dylan Copeland f106c03dd1 Generalized floating point type. So far, ex1 works for a serial build without lapack. 2023-10-09 14:19:25 -07:00
Victor DeCaria 9d65c08c77 reverting some changes to bilinear form infrastructure 2023-10-09 14:21:59 -06:00
Victor DeCaria 6cb689d6bd make ordering part of the doftoquad map 2023-10-09 13:50:47 -06: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
victor-decaria-nnl 3f4d31473e Merge branch 'master' into full-assembly-elast-dev 2023-10-05 15:28:30 -04: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
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
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
JacobLotz 34741d3d96 fix variable issue 2023-09-06 17:23:21 +02:00
JacobLotz 4bbfec3270 Add glvis visualisation 2023-09-06 16:55:26 +02:00
JacobLotz ace2a34e90 more info on multiress control 2023-09-06 16:20:00 +02:00
JacobLotz 38189de216 style 2023-09-06 16:16:47 +02:00
JacobLotz 26590a1bef remove empty comment lines 2023-09-06 16:13:28 +02:00
JacobLotz 88a5d0ad7d more spell check 2023-09-06 15:27:24 +02:00
JacobLotz 47eebe1841 spelling 2023-09-06 15:20:34 +02:00
Jeremy L Thompson e8268e0357 ceed - update CEED_BASIS_COLLOCATED => CEED_BASIS_NONE 2023-09-05 09:36:55 -06:00
Jacob Lotz 07dc63bfbf Merge branch 'master' into nurbs-cmesh-miniapp2 2023-09-05 16:19:03 +02: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
Jacob Lotz 90fd923c4f update make clean in makefile... 2023-08-30 19:36:17 +02:00
Jacob Lotz 04bccfe0ba fix gitignore 2023-08-30 19:23:07 +02:00
Jacob Lotz 74a32f5cd6 make style 2023-08-30 17:41:36 +02:00
Jacob Lotz 8a56100051 make testing error 2023-08-30 17:29:45 +02:00
Jacob Lotz 9edca06544 prettification of miniapp 2023-08-30 17:28:32 +02:00
Jacob Lotz ebbbf6d031 make style 2023-08-30 17:01:03 +02:00
Jacob Lotz 8a1636c3ee Fix testing in cmake and make 2023-08-30 16:58:59 +02:00
Jacob Lotz 55ecd126ae Fix unwanted differences with master after merge master 2023-08-30 16:25:38 +02:00
Jacob Lotz ef5f65457e Merge branch 'master' into nurbs-cmesh-miniapp2 2023-08-30 16:12:22 +02:00
adam-sim-dev f238ed6f41 Merge branch 'master' into cxxflags 2023-08-30 17:10:35 +08: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
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
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
Victor DeCaria dbb119a4a9 fixing more compiler warnings. Added make test for miniapp 2023-08-03 07:42:35 -06:00
Victor DeCaria 2b4daad324 more warning fixes 2023-08-02 15:13:16 -06:00
Victor DeCaria 9f83408b2e fixing static assert and unused variable 2023-08-02 15:00:52 -06:00
Victor DeCaria fe59ea04a2 remove variable shadowing 2023-08-02 14:49:51 -06:00
Victor DeCaria 0e8461c26b Made buildable for sequential variant. 2023-08-02 13:23:10 -06:00
Victor DeCaria 2932862fe9 Adding capability to do partial assembly and full assembly for components of elasticity on GPUs. Added lor_elast miniapp. 2023-07-31 10:39:45 -06:00
Jacob Lotz 2ce61b5e70 Merge branch 'master' into nurbs-cmesh-miniapp2 2023-07-31 17:01:38 +02: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
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
termi-official 06766e8d05 Apply style. 2023-05-23 23:50:21 +02:00
termi-official a209ed2e17 Widen main area in design. 2023-05-23 23:35:15 +02:00
termi-official c7b7b1082f Polish doc strings. 2023-05-23 23:34:41 +02:00
termi-official cc8b1ec9f1 Add correct file. 2023-05-23 23:15:49 +02:00
termi-official 5d586c5081 Modernize styling via doxygen-awesome. 2023-05-23 19:42:44 +02:00
termi-official 45f8586ac9 Make docs logo background transparent. 2023-05-23 19:41:30 +02: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
JacobLotz 71ab478d05 Merge branch 'nurbs-cmesh-miniapp2' of github.com:mfem/mfem into nurbs-cmesh-miniapp2 2023-02-01 10:44:10 +01:00
JacobLotz 9ccf38570a Fix typos in doc and improve style 2023-02-01 10:43:46 +01:00
Jacob Lotz 58bca5e33a Merge branch 'master' into nurbs-cmesh-miniapp2 2023-01-31 18:33:04 +01:00
JacobLotz d32c8eacaf Trying to fix testing 16 2023-01-31 16:52:48 +01:00
JacobLotz 3b1bbb1913 Trying to fix testing 16 2023-01-31 15:52:40 +01:00
JacobLotz 279395ee43 Trying to fix testing 15: apparantly on windows I cannot use M_PI? 2023-01-31 15:51:28 +01:00
JacobLotz 2dfada007d Trying to fix testing 14 2023-01-31 15:46:18 +01:00
JacobLotz 19f2eba010 Trying to fix testing 13 2023-01-31 15:36:12 +01:00
JacobLotz b49a06424d Trying to fix testing 12 2023-01-31 14:57:01 +01:00
JacobLotz fda714333c Trying to fix testing 11 2023-01-31 14:46:46 +01:00
JacobLotz f9852a2333 Trying to fix testing 10 2023-01-31 13:50:46 +01:00
JacobLotz 1573c8afc6 Trying to fix testing 9 2023-01-31 10:25:28 +01: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
JacobLotz 744d3e7d2c Trying to fix testing 8 2023-01-23 17:03:33 +01:00
JacobLotz 312e58d6fe Trying to fix testing 8 2023-01-23 16:25:10 +01:00
JacobLotz 876360aac9 Trying to fix testing 7 2023-01-23 13:46:01 +01:00
JacobLotz 1dda81269e Trying to fix testing 6 2023-01-23 12:53:16 +01:00
JacobLotz e246398e89 Trying to fix testing 5 2023-01-23 11:58:40 +01:00
JacobLotz 228325f2fd Trying to fix testing 4 2023-01-23 11:24:07 +01:00
JacobLotz 1647ca9118 Trying to fix testing 3 2023-01-23 11:05:55 +01:00
JacobLotz 8fce03b0c4 Trying to fix testing 2 2023-01-23 10:44:30 +01:00
JacobLotz ab97591270 Trying to fix testing 1 2023-01-23 09:59:47 +01:00
JacobLotz aac9ac14e4 Add C-mesh around foil section miniapp 2023-01-16 14:19:59 +01:00
JacobLotz 483dfa7b5c Merge branch 'nurbs-auto-knot2edge-dev' into nurbs-cmesh-miniapp2 2023-01-16 13:00:37 +01:00
JacobLotz c4f6a00467 Merge branch 'nurbs-interp-dev' into nurbs-cmesh-miniapp2 2023-01-16 11:37:10 +01:00
JacobLotz 809af14ddf Merge branch 'fix-kv-difference-dev' into nurbs-cmesh-miniapp2 2023-01-16 10:54:41 +01:00
JacobLotz c04b596a7f Merge branch 'nurbs-2drot' into nurbs-cmesh-miniapp2 2023-01-13 09:38:22 +01: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
542 changed files with 34754 additions and 18921 deletions
+13 -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
@@ -276,6 +283,10 @@ miniapps/nurbs/mode_*
miniapps/nurbs/Example1*
miniapps/nurbs/sin-fit.mesh
miniapps/nurbs/CurveInt
miniapps/nurbs/nurbs_naca_cmesh
miniapps/nurbs/naca-cmesh.mesh
miniapps/nurbs/glvis_naca-cmesh.mesh
miniapps/nurbs/Naca_cmesh
miniapps/performance/ex1
miniapps/performance/ex1p
@@ -300,7 +311,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
@@ -331,6 +342,7 @@ miniapps/toys/mondrian.mesh
miniapps/solvers/block-solvers
miniapps/solvers/lor_solvers
miniapps/solvers/plor_solvers
miniapps/solvers/lor_elast
miniapps/solvers/ParaView
miniapps/solvers/mesh.*
miniapps/solvers/sol.*
+31
View File
@@ -15,11 +15,40 @@ Discretization improvements
---------------------------
- Introduced support for higher order non conformal Nedelec elements on
simplices in ParMesh.
- Introduced support for internal boundary elements in nonconformal adapted
meshes.
- 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.
GPU support
----------------------------
- Added support for full assembly on simplices.
- Added functionality for BilinearFormIntegrators to use kernels that work for both
tensor and unstructured elements.
- Added partial assembly for linear elasticity. Does not use sum factorization for now.
New and updated examples and miniapps
-------------------------------------
- Added miniapp to demonstrate new elasticity integrator and unstructured element GPU support,
and a block diagonal preconditioner using low order refinement. Allows comparison with
currently existing legacy mode integrator. See miniapps/solvers/lor_elast.
Miscellaneous
-------------
- Added support for single and double precision, with corresponding hypre build.
Generalized the floating point type from `double` to `real_t`.
- The ReadCubit Genesis mesh importer has been rewritten to improve readability.
- Updated the Doxygen documentation style, which now requires Doxygen version
1.9.8 or later. See the doc/ directory.
- 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,6 +116,8 @@ 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
+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()
+2
View File
@@ -359,6 +359,8 @@ Before you can start, you need a GitHub account, here are a few suggestions:
conflicted files in the commit message.
- All significant new features and changes should be documented in CHANGELOG.
- New examples and miniapps should have documentation on the MFEM webpage.
- The general floating-point type `real_t` should be used, rather than
`float` or `double`, except in special cases where only one is possible.
### Pull Requests
+2 -3
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.
@@ -797,7 +796,7 @@ The specific libraries and their options are:
URL: https://github.com/CEED/libCEED
https://ceed.exascaleproject.org/libceed
Options: CEED_DIR, CEED_OPT, CEED_LIB.
Versions: libCEED >= 0.10.
Versions: libCEED >= 0.12.
- RAJA (optional), used when MFEM_USE_RAJA = YES.
Beginning with MFEM v4.5.1, only RAJA v2022.10.3+ is supported.
+2
View File
@@ -63,6 +63,8 @@ set(MFEM_USE_ALGOIM @MFEM_USE_ALGOIM@)
set(MFEM_USE_BENCHMARK @MFEM_USE_BENCHMARK@)
set(MFEM_USE_PARELAG @MFEM_USE_PARELAG@)
set(MFEM_USE_ENZYME @MFEM_USE_ENZYME@)
set(MFEM_USE_DOUBLE @MFEM_USE_DOUBLE@)
set(MFEM_USE_SINGLE @MFEM_USE_SINGLE@)
set(MFEM_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
set(MFEM_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
+6
View File
@@ -201,4 +201,10 @@
// Enable Enzyme for AD
#cmakedefine MFEM_USE_ENZYME
// Use double-precision floating point type
#cmakedefine MFEM_USE_DOUBLE
// Use single-precision floating point type
#cmakedefine MFEM_USE_SINGLE
#endif // MFEM_CONFIG_HEADER
+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)
+6
View File
@@ -201,4 +201,10 @@
// Enable the Enzyme LLVM plugin
// #define MFEM_USE_ENZYME
// Use double-precision floating point type
// #define MFEM_USE_DOUBLE
// Use single-precision floating point type
// #define MFEM_USE_SINGLE
#endif // MFEM_CONFIG_HEADER
+2
View File
@@ -64,6 +64,8 @@ MFEM_USE_CODIPACK = @MFEM_USE_CODIPACK@
MFEM_USE_BENCHMARK = @MFEM_USE_BENCHMARK@
MFEM_USE_PARELAG = @MFEM_USE_PARELAG@
MFEM_USE_ENZYME = @MFEM_USE_ENZYME@
MFEM_USE_DOUBLE = @MFEM_USE_DOUBLE@
MFEM_USE_SINGLE = @MFEM_USE_SINGLE@
# Compiler, compile options, and link options
MFEM_CXX = @MFEM_CXX@
+5 -7
View File
@@ -66,6 +66,8 @@ option(MFEM_USE_CODIPACK "Enable automatic differentiation (AD) using CoDiPack"
option(MFEM_USE_BENCHMARK "Enable Google Benchmark" OFF)
option(MFEM_USE_PARELAG "Enable ParELAG" OFF)
option(MFEM_USE_ENZYME "Enable Enzyme" OFF)
option(MFEM_USE_DOUBLE "Double precision" ON)
option(MFEM_USE_SINGLE "Single precision" OFF)
# Optional overrides for autodetected MPIEXEC and MPIEXEC_NUMPROC_FLAG
# set(MFEM_MPIEXEC "mpirun" CACHE STRING "Command for running MPI tests")
@@ -106,12 +108,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 +154,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
+2
View File
@@ -167,6 +167,8 @@ MFEM_USE_CODIPACK = NO
MFEM_USE_BENCHMARK = NO
MFEM_USE_PARELAG = NO
MFEM_USE_ENZYME = NO
MFEM_USE_DOUBLE = YES
MFEM_USE_SINGLE = NO
# MPI library compile and link flags
# These settings are used only when building MFEM with MPI + HIP
+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
File diff suppressed because it is too large Load Diff
+2
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
@@ -215,6 +216,7 @@ namespace mfem {
* - <a class="el" href="generate__random__field_8cpp_source.html">SPDE Solvers</a>: SPDE solver random field generation
* - <a class="el" href="pdiffusion_8cpp_source.html">DPG Diffusion example</a>: DPG formulation for the diffusion problem
* - <a class="el" href="pmaxwell_8cpp_source.html">DPG Maxwell example</a>: DPG formulation for the indefinite Maxwell problem
* - <a class="el" href="lor__elast_8cpp_source.html">LOR Elasticity</a>: solve linear elasticity with LOR preconditioning on GPUs
*
* See also the <a class="el" href="https://mfem.org/examples/">examples documentation</a> online.
*/
+1 -1
View File
@@ -14,7 +14,7 @@ If not already available, Doxygen can be downloaded from
http://www.doxygen.org
We recommend using version 1.8 or later.
We recommend using version 1.9.8 or later.
To build the documentation, simply type "make" in the doc/ directory. This will
create the file CodeDocumentation.html, which can be viewed in any web browser.
+3
View File
@@ -0,0 +1,3 @@
html {
--content-maxwidth: auto;
}
File diff suppressed because it is too large Load Diff
+78
View File
@@ -0,0 +1,78 @@
<!-- HTML header for doxygen 1.9.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="$langISO">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN FULL_SIDEBAR-->
<script type="text/javascript">var page_layout=1;</script>
<!--END FULL_SIDEBAR-->
<!--END DISABLE_INDEX-->
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
$darkmode
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
<script type="text/javascript" src="$relpath^doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
</head>
<body>
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN FULL_SIDEBAR-->
<div id="side-nav" class="ui-resizable side-nav-resizable"><!-- do not remove this div, it is closed by doxygen! -->
<!--END FULL_SIDEBAR-->
<!--END DISABLE_INDEX-->
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<!--BEGIN PROJECT_NAME-->
<td id="projectalign">
<div id="projectname">$projectname<!--BEGIN PROJECT_NUMBER--><span id="projectnumber">&#160;$projectnumber</span><!--END PROJECT_NUMBER-->
</div>
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
</td>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td>
<div id="projectbrief">$projectbrief</div>
</td>
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN SEARCHENGINE-->
<!--BEGIN !FULL_SIDEBAR-->
<td>$searchbox</td>
<!--END !FULL_SIDEBAR-->
<!--END SEARCHENGINE-->
<!--END DISABLE_INDEX-->
</tr>
<!--BEGIN SEARCHENGINE-->
<!--BEGIN FULL_SIDEBAR-->
<tr><td colspan="2">$searchbox</td></tr>
<!--END FULL_SIDEBAR-->
<!--END SEARCHENGINE-->
</tbody>
</table>
</div>
<!--END TITLEAREA-->
<!-- end header part -->
+157
View File
@@ -0,0 +1,157 @@
/**
Doxygen Awesome
https://github.com/jothepro/doxygen-awesome-css
MIT License
Copyright (c) 2021 - 2023 jothepro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
class DoxygenAwesomeDarkModeToggle extends HTMLElement {
// SVG icons from https://fonts.google.com/icons
// Licensed under the Apache 2.0 license:
// https://www.apache.org/licenses/LICENSE-2.0.html
static lightModeIcon = `<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#FCBF00"><rect fill="none" height="24" width="24"/><circle cx="12" cy="12" opacity=".3" r="3"/><path d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"/></svg>`
static darkModeIcon = `<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#FE9700"><rect fill="none" height="24" width="24"/><path d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27 C17.45,17.19,14.93,19,12,19c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z" opacity=".3"/><path d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"/></svg>`
static title = "Toggle Light/Dark Mode"
static prefersLightModeInDarkModeKey = "prefers-light-mode-in-dark-mode"
static prefersDarkModeInLightModeKey = "prefers-dark-mode-in-light-mode"
static _staticConstructor = function() {
DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.userPreference)
// Update the color scheme when the browsers preference changes
// without user interaction on the website.
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()
})
// Update the color scheme when the tab is made visible again.
// It is possible that the appearance was changed in another tab
// while this tab was in the background.
document.addEventListener("visibilitychange", visibilityState => {
if (document.visibilityState === 'visible') {
DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()
}
});
}()
static init() {
$(function() {
$(document).ready(function() {
const toggleButton = document.createElement('doxygen-awesome-dark-mode-toggle')
toggleButton.title = DoxygenAwesomeDarkModeToggle.title
toggleButton.updateIcon()
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
toggleButton.updateIcon()
})
document.addEventListener("visibilitychange", visibilityState => {
if (document.visibilityState === 'visible') {
toggleButton.updateIcon()
}
});
$(document).ready(function(){
document.getElementById("MSearchBox").parentNode.appendChild(toggleButton)
})
$(window).resize(function(){
document.getElementById("MSearchBox").parentNode.appendChild(toggleButton)
})
})
})
}
constructor() {
super();
this.onclick=this.toggleDarkMode
}
/**
* @returns `true` for dark-mode, `false` for light-mode system preference
*/
static get systemPreference() {
return window.matchMedia('(prefers-color-scheme: dark)').matches
}
/**
* @returns `true` for dark-mode, `false` for light-mode user preference
*/
static get userPreference() {
return (!DoxygenAwesomeDarkModeToggle.systemPreference && localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)) ||
(DoxygenAwesomeDarkModeToggle.systemPreference && !localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey))
}
static set userPreference(userPreference) {
DoxygenAwesomeDarkModeToggle.darkModeEnabled = userPreference
if(!userPreference) {
if(DoxygenAwesomeDarkModeToggle.systemPreference) {
localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey, true)
} else {
localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)
}
} else {
if(!DoxygenAwesomeDarkModeToggle.systemPreference) {
localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey, true)
} else {
localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey)
}
}
DoxygenAwesomeDarkModeToggle.onUserPreferenceChanged()
}
static enableDarkMode(enable) {
if(enable) {
DoxygenAwesomeDarkModeToggle.darkModeEnabled = true
document.documentElement.classList.add("dark-mode")
document.documentElement.classList.remove("light-mode")
} else {
DoxygenAwesomeDarkModeToggle.darkModeEnabled = false
document.documentElement.classList.remove("dark-mode")
document.documentElement.classList.add("light-mode")
}
}
static onSystemPreferenceChanged() {
DoxygenAwesomeDarkModeToggle.darkModeEnabled = DoxygenAwesomeDarkModeToggle.userPreference
DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)
}
static onUserPreferenceChanged() {
DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)
}
toggleDarkMode() {
DoxygenAwesomeDarkModeToggle.userPreference = !DoxygenAwesomeDarkModeToggle.userPreference
this.updateIcon()
}
updateIcon() {
if(DoxygenAwesomeDarkModeToggle.darkModeEnabled) {
this.innerHTML = DoxygenAwesomeDarkModeToggle.darkModeIcon
} else {
this.innerHTML = DoxygenAwesomeDarkModeToggle.lightModeIcon
}
}
}
customElements.define("doxygen-awesome-dark-mode-toggle", DoxygenAwesomeDarkModeToggle);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 17 KiB

+1 -1
View File
@@ -16,7 +16,7 @@ DOXYGEN_CONF = CodeDocumentation.conf
# doxygen uses: graphviz, latex
html: $(DOXYGEN_CONF)
@# Generate the html documentation
@( cat $(DOXYGEN_CONF) ; echo "$(MFEM_DOXYGEN_FLAGS)" ) | doxygen -
@( cat $(DOXYGEN_CONF) ; printf "$(MFEM_DOXYGEN_FLAGS)\n" ) | doxygen -
@echo "<meta http-equiv=\"REFRESH\" content=\"0;URL=CodeDocumentation/html/index.html\">" > CodeDocumentation.html
@cat warnings.log 1>&2
@# Generate the log of undocumented methods
+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
+34 -30
View File
@@ -62,7 +62,7 @@ protected:
BilinearForm M, S;
NonlinearForm H;
double viscosity;
real_t viscosity;
HyperelasticModel *model;
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
@@ -84,16 +84,16 @@ protected:
public:
HyperelasticOperator(FiniteElementSpace &f, Array<int> &ess_bdr,
double visc, double mu, double K);
real_t visc, real_t mu, real_t K);
/// Compute the right-hand side of the ODE system.
virtual void Mult(const Vector &vx, Vector &dvx_dt) const;
/** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
This is the only requirement for high-order SDIRK implicit integration.*/
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
double ElasticEnergy(const Vector &x) const;
double KineticEnergy(const Vector &v) const;
real_t ElasticEnergy(const Vector &x) const;
real_t KineticEnergy(const Vector &v) const;
void GetElasticEnergyDensity(const GridFunction &x, GridFunction &w) const;
virtual ~HyperelasticOperator();
@@ -109,7 +109,7 @@ private:
BilinearForm *M, *S;
NonlinearForm *H;
mutable SparseMatrix *Jacobian;
double dt;
real_t dt;
const Vector *v, *x;
mutable Vector w, z;
@@ -117,7 +117,7 @@ public:
ReducedSystemOperator(BilinearForm *M_, BilinearForm *S_, NonlinearForm *H_);
/// Set current dt, v, x values - needed to compute action and Jacobian.
void SetParameters(double dt_, const Vector *v_, const Vector *x_);
void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
/// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
virtual void Mult(const Vector &k, Vector &y) const;
@@ -141,7 +141,7 @@ private:
public:
ElasticEnergyCoefficient(HyperelasticModel &m, const GridFunction &x_)
: model(m), x(x_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual ~ElasticEnergyCoefficient() { }
};
@@ -161,11 +161,11 @@ int main(int argc, char *argv[])
int ref_levels = 2;
int order = 2;
int ode_solver_type = 3;
double t_final = 300.0;
double dt = 3.0;
double visc = 1e-2;
double mu = 0.25;
double K = 5.0;
real_t t_final = 300.0;
real_t dt = 3.0;
real_t visc = 1e-2;
real_t mu = 0.25;
real_t K = 5.0;
bool visualization = true;
int vis_steps = 1;
@@ -205,6 +205,10 @@ int main(int argc, char *argv[])
}
args.PrintOptions(cout);
#ifdef MFEM_USE_SINGLE
MFEM_ABORT("This example is not supported in single precision.");
#endif
// 2. Read the mesh from the given mesh file. We can handle triangular,
// quadrilateral, tetrahedral and hexahedral meshes with the same code.
Mesh *mesh = new Mesh(mesh_file, 1, 1);
@@ -309,13 +313,13 @@ int main(int argc, char *argv[])
<< " Press space (in the GLVis window) to resume it.\n";
}
double ee0 = oper.ElasticEnergy(x.GetTrueVector());
double ke0 = oper.KineticEnergy(v.GetTrueVector());
real_t ee0 = oper.ElasticEnergy(x.GetTrueVector());
real_t ke0 = oper.KineticEnergy(v.GetTrueVector());
cout << "initial elastic energy (EE) = " << ee0 << endl;
cout << "initial kinetic energy (KE) = " << ke0 << endl;
cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
double t = 0.0;
real_t t = 0.0;
oper.SetTime(t);
ode_solver->Init(oper);
@@ -324,7 +328,7 @@ int main(int argc, char *argv[])
bool last_step = false;
for (int ti = 1; !last_step; ti++)
{
double dt_real = min(dt, t_final - t);
real_t dt_real = min(dt, t_final - t);
ode_solver->Step(vx, t, dt_real);
@@ -332,8 +336,8 @@ int main(int argc, char *argv[])
if (last_step || (ti % vis_steps) == 0)
{
double ee = oper.ElasticEnergy(x.GetTrueVector());
double ke = oper.KineticEnergy(v.GetTrueVector());
real_t ee = oper.ElasticEnergy(x.GetTrueVector());
real_t ke = oper.KineticEnergy(v.GetTrueVector());
cout << "step " << ti << ", t = " << t << ", EE = " << ee << ", KE = "
<< ke << ", ΔTE = " << (ee+ke)-(ee0+ke0) << endl;
@@ -419,7 +423,7 @@ ReducedSystemOperator::ReducedSystemOperator(
dt(0.0), v(NULL), x(NULL), w(height), z(height)
{ }
void ReducedSystemOperator::SetParameters(double dt_, const Vector *v_,
void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
const Vector *x_)
{
dt = dt_; v = v_; x = x_;
@@ -453,16 +457,16 @@ ReducedSystemOperator::~ReducedSystemOperator()
HyperelasticOperator::HyperelasticOperator(FiniteElementSpace &f,
Array<int> &ess_bdr, double visc,
double mu, double K)
: TimeDependentOperator(2*f.GetTrueVSize(), 0.0), fespace(f),
Array<int> &ess_bdr, real_t visc,
real_t mu, real_t K)
: TimeDependentOperator(2*f.GetTrueVSize(), (real_t) 0.0), fespace(f),
M(&fespace), S(&fespace), H(&fespace),
viscosity(visc), z(height/2)
{
const double rel_tol = 1e-8;
const real_t rel_tol = 1e-8;
const int skip_zero_entries = 0;
const double ref_density = 1.0; // density in the reference configuration
const real_t ref_density = 1.0; // density in the reference configuration
ConstantCoefficient rho0(ref_density);
M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
M.Assemble(skip_zero_entries);
@@ -533,7 +537,7 @@ void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
dx_dt = v;
}
void HyperelasticOperator::ImplicitSolve(const double dt,
void HyperelasticOperator::ImplicitSolve(const real_t dt,
const Vector &vx, Vector &dvx_dt)
{
int sc = height/2;
@@ -555,12 +559,12 @@ void HyperelasticOperator::ImplicitSolve(const double dt,
add(v, dt, dv_dt, dx_dt);
}
double HyperelasticOperator::ElasticEnergy(const Vector &x) const
real_t HyperelasticOperator::ElasticEnergy(const Vector &x) const
{
return H.GetEnergy(x);
}
double HyperelasticOperator::KineticEnergy(const Vector &v) const
real_t HyperelasticOperator::KineticEnergy(const Vector &v) const
{
return 0.5*M.InnerProduct(v, v);
}
@@ -581,7 +585,7 @@ HyperelasticOperator::~HyperelasticOperator()
}
double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
model.SetTransformation(T);
@@ -601,7 +605,7 @@ void InitialDeformation(const Vector &x, Vector &y)
void InitialVelocity(const Vector &x, Vector &v)
{
const int dim = x.Size();
const double s = 0.1/64.;
const real_t s = 0.1/64.;
v = 0.0;
v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
+38 -34
View File
@@ -63,7 +63,7 @@ protected:
ParBilinearForm M, S;
ParNonlinearForm H;
double viscosity;
real_t viscosity;
HyperelasticModel *model;
HypreParMatrix *Mmat; // Mass matrix from ParallelAssemble()
@@ -86,16 +86,16 @@ protected:
public:
HyperelasticOperator(ParFiniteElementSpace &f, Array<int> &ess_bdr,
double visc, double mu, double K);
real_t visc, real_t mu, real_t K);
/// Compute the right-hand side of the ODE system.
virtual void Mult(const Vector &vx, Vector &dvx_dt) const;
/** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
This is the only requirement for high-order SDIRK implicit integration.*/
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
double ElasticEnergy(const ParGridFunction &x) const;
double KineticEnergy(const ParGridFunction &v) const;
real_t ElasticEnergy(const ParGridFunction &x) const;
real_t KineticEnergy(const ParGridFunction &v) const;
void GetElasticEnergyDensity(const ParGridFunction &x,
ParGridFunction &w) const;
@@ -112,7 +112,7 @@ private:
ParBilinearForm *M, *S;
ParNonlinearForm *H;
mutable HypreParMatrix *Jacobian;
double dt;
real_t dt;
const Vector *v, *x;
mutable Vector w, z;
const Array<int> &ess_tdof_list;
@@ -122,7 +122,7 @@ public:
ParNonlinearForm *H_, const Array<int> &ess_tdof_list);
/// Set current dt, v, x values - needed to compute action and Jacobian.
void SetParameters(double dt_, const Vector *v_, const Vector *x_);
void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
/// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
virtual void Mult(const Vector &k, Vector &y) const;
@@ -146,7 +146,7 @@ private:
public:
ElasticEnergyCoefficient(HyperelasticModel &m, const ParGridFunction &x_)
: model(m), x(x_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual ~ElasticEnergyCoefficient() { }
};
@@ -173,11 +173,11 @@ int main(int argc, char *argv[])
int par_ref_levels = 0;
int order = 2;
int ode_solver_type = 3;
double t_final = 300.0;
double dt = 3.0;
double visc = 1e-2;
double mu = 0.25;
double K = 5.0;
real_t t_final = 300.0;
real_t dt = 3.0;
real_t visc = 1e-2;
real_t mu = 0.25;
real_t K = 5.0;
bool adaptive_lin_rtol = true;
bool visualization = true;
int vis_steps = 1;
@@ -229,6 +229,10 @@ int main(int argc, char *argv[])
args.PrintOptions(cout);
}
#ifdef MFEM_USE_SINGLE
MFEM_ABORT("This example is not supported in single precision.");
#endif
// 3. Read the serial mesh from the given mesh file on all processors. We can
// handle triangular, quadrilateral, tetrahedral and hexahedral meshes
// with the same code.
@@ -358,8 +362,8 @@ int main(int argc, char *argv[])
}
}
double ee0 = oper.ElasticEnergy(x_gf);
double ke0 = oper.KineticEnergy(v_gf);
real_t ee0 = oper.ElasticEnergy(x_gf);
real_t ke0 = oper.KineticEnergy(v_gf);
if (myid == 0)
{
cout << "initial elastic energy (EE) = " << ee0 << endl;
@@ -367,7 +371,7 @@ int main(int argc, char *argv[])
cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
}
double t = 0.0;
real_t t = 0.0;
oper.SetTime(t);
ode_solver->Init(oper);
@@ -376,7 +380,7 @@ int main(int argc, char *argv[])
bool last_step = false;
for (int ti = 1; !last_step; ti++)
{
double dt_real = min(dt, t_final - t);
real_t dt_real = min(dt, t_final - t);
ode_solver->Step(vx, t, dt_real);
@@ -386,8 +390,8 @@ int main(int argc, char *argv[])
{
v_gf.SetFromTrueVector(); x_gf.SetFromTrueVector();
double ee = oper.ElasticEnergy(x_gf);
double ke = oper.KineticEnergy(v_gf);
real_t ee = oper.ElasticEnergy(x_gf);
real_t ke = oper.KineticEnergy(v_gf);
if (myid == 0)
{
@@ -485,7 +489,7 @@ ReducedSystemOperator::ReducedSystemOperator(
ess_tdof_list(ess_tdof_list_)
{ }
void ReducedSystemOperator::SetParameters(double dt_, const Vector *v_,
void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
const Vector *x_)
{
dt = dt_; v = v_; x = x_;
@@ -523,17 +527,17 @@ ReducedSystemOperator::~ReducedSystemOperator()
HyperelasticOperator::HyperelasticOperator(ParFiniteElementSpace &f,
Array<int> &ess_bdr, double visc,
double mu, double K)
: TimeDependentOperator(2*f.TrueVSize(), 0.0), fespace(f),
Array<int> &ess_bdr, real_t visc,
real_t mu, real_t K)
: TimeDependentOperator(2*f.TrueVSize(), (real_t) 0.0), fespace(f),
M(&fespace), S(&fespace), H(&fespace),
viscosity(visc), M_solver(f.GetComm()), newton_solver(f.GetComm()),
z(height/2)
{
const double rel_tol = 1e-8;
const real_t rel_tol = 1e-8;
const int skip_zero_entries = 0;
const double ref_density = 1.0; // density in the reference configuration
const real_t ref_density = 1.0; // density in the reference configuration
ConstantCoefficient rho0(ref_density);
M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
M.Assemble(skip_zero_entries);
@@ -607,7 +611,7 @@ void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
dx_dt = v;
}
void HyperelasticOperator::ImplicitSolve(const double dt,
void HyperelasticOperator::ImplicitSolve(const real_t dt,
const Vector &vx, Vector &dvx_dt)
{
int sc = height/2;
@@ -629,17 +633,17 @@ void HyperelasticOperator::ImplicitSolve(const double dt,
add(v, dt, dv_dt, dx_dt);
}
double HyperelasticOperator::ElasticEnergy(const ParGridFunction &x) const
real_t HyperelasticOperator::ElasticEnergy(const ParGridFunction &x) const
{
return H.GetEnergy(x);
}
double HyperelasticOperator::KineticEnergy(const ParGridFunction &v) const
real_t HyperelasticOperator::KineticEnergy(const ParGridFunction &v) const
{
double loc_energy = 0.5*M.InnerProduct(v, v);
double energy;
MPI_Allreduce(&loc_energy, &energy, 1, MPI_DOUBLE, MPI_SUM,
fespace.GetComm());
real_t loc_energy = 0.5*M.InnerProduct(v, v);
real_t energy;
MPI_Allreduce(&loc_energy, &energy, 1, MPITypeMap<real_t>::mpi_type,
MPI_SUM, fespace.GetComm());
return energy;
}
@@ -660,7 +664,7 @@ HyperelasticOperator::~HyperelasticOperator()
}
double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
model.SetTransformation(T);
@@ -680,7 +684,7 @@ void InitialDeformation(const Vector &x, Vector &y)
void InitialVelocity(const Vector &x, Vector &v)
{
const int dim = x.Size();
const double s = 0.1/64.;
const real_t s = 0.1/64.;
v = 0.0;
v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
+5 -4
View File
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
m->AddDomainIntegrator(new MassIntegrator(one));
m->Assemble();
// shift the eigenvalue corresponding to eliminated dofs to a large value
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
m->Finalize();
HypreParMatrix *A = a->ParallelAssemble();
@@ -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;
@@ -299,7 +300,7 @@ int main(int argc, char *argv[])
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define a
// parallel grid function to represent each of the eigenmodes returned by
// the solver.
Array<double> eigenvalues;
Array<real_t> eigenvalues;
lobpcg->Solve();
lobpcg->GetEigenvalues(eigenvalues);
ParGridFunction x(fespace);
+2 -2
View File
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
m->AddDomainIntegrator(new VectorMassIntegrator());
m->Assemble();
// shift the eigenvalue corresponding to eliminated dofs to a large value
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
m->Finalize();
if (myid == 0)
{
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
// parallel grid function to represent each of the eigenmodes returned by
// the solver.
Array<double> eigenvalues;
Array<real_t> eigenvalues;
lobpcg->Solve();
lobpcg->GetEigenvalues(eigenvalues);
ParGridFunction x(fespace);
+2 -2
View File
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
m->AddDomainIntegrator(new VectorFEMassIntegrator(one));
m->Assemble();
// shift the eigenvalue corresponding to eliminated dofs to a large value
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
m->Finalize();
HypreParMatrix *A = a->ParallelAssemble();
@@ -198,7 +198,7 @@ int main(int argc, char *argv[])
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
// parallel grid function to represent each of the eigenmodes returned by
// the solver.
Array<double> eigenvalues;
Array<real_t> eigenvalues;
ame->Solve();
ame->GetEigenvalues(eigenvalues);
ParGridFunction x(fespace);
+3 -3
View File
@@ -43,9 +43,9 @@ int main(int argc, char *argv[])
const char *mesh_file = "../data/star.mesh";
int ref_levels = -1;
int order = 1;
double sigma = -1.0;
double kappa = -1.0;
double eta = 0.0;
real_t sigma = -1.0;
real_t kappa = -1.0;
real_t eta = 0.0;
bool visualization = 1;
OptionsParser args(argc, argv);
+4 -4
View File
@@ -44,7 +44,7 @@ public:
pmesh(m),
pgf(f) {}
void MonitorSolution(int i, double norm, const Vector &x, bool final)
void MonitorSolution(int i, real_t norm, const Vector &x, bool final)
{
char vishost[] = "localhost";
int visport = 19916;
@@ -81,9 +81,9 @@ int main(int argc, char *argv[])
int ser_ref_levels = -1;
int par_ref_levels = 2;
int order = 1;
double sigma = -1.0;
double kappa = -1.0;
double eta = 0.0;
real_t sigma = -1.0;
real_t kappa = -1.0;
real_t eta = 0.0;
bool visualization = 1;
OptionsParser args(argc, argv);
+30 -30
View File
@@ -63,8 +63,8 @@ int problem;
int nfeatures;
// Prescribed time-dependent boundary and right-hand side functions.
double bdr_func(const Vector &pt, double t);
double rhs_func(const Vector &pt, double t);
real_t bdr_func(const Vector &pt, real_t t);
real_t rhs_func(const Vector &pt, real_t t);
// Update the finite element space, interpolate the solution and perform
// parallel load balancing.
@@ -79,9 +79,9 @@ int main(int argc, char *argv[])
nfeatures = 1;
const char *mesh_file = "../data/star-hilbert.mesh";
int order = 2;
double t_final = 1.0;
double max_elem_error = 5.0e-3;
double hysteresis = 0.15; // derefinement safety coefficient
real_t t_final = 1.0;
real_t max_elem_error = 5.0e-3;
real_t hysteresis = 0.15; // derefinement safety coefficient
int ref_levels = 0;
int nc_limit = 3; // maximum level of hanging nodes
bool visualization = true;
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
// refine the mesh as many times as necessary. Then we derefine any
// elements which have very small errors.
x = 0.0;
for (double time = 0.0; time < t_final + 1e-10; time += 0.01)
for (real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
{
cout << "\nTime " << time << "\n\nRefinement:" << endl;
@@ -366,47 +366,47 @@ void UpdateProblem(Mesh &mesh, FiniteElementSpace &fespace,
}
const double alpha = 0.02;
const real_t alpha = 0.02;
// Spherical front with a Gaussian cross section and radius t
double front(double x, double y, double z, double t, int)
real_t front(real_t x, real_t y, real_t z, real_t t, int)
{
double r = sqrt(x*x + y*y + z*z);
real_t r = sqrt(x*x + y*y + z*z);
return exp(-0.5*pow((r - t)/alpha, 2));
}
double front_laplace(double x, double y, double z, double t, int dim)
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
{
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
double r = sqrt(x2 + y2 + z2);
double a2 = alpha*alpha, a4 = a2*a2;
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
real_t r = sqrt(x2 + y2 + z2);
real_t a2 = alpha*alpha, a4 = a2*a2;
return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
(-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
}
// Smooth spherical step function with radius t
double ball(double x, double y, double z, double t, int)
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
{
double r = sqrt(x*x + y*y + z*z);
real_t r = sqrt(x*x + y*y + z*z);
return -atan(2*(r - t)/alpha);
}
double ball_laplace(double x, double y, double z, double t, int dim)
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
{
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
double r = sqrt(x2 + y2 + z2);
double a2 = alpha*alpha;
double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
real_t r = sqrt(x2 + y2 + z2);
real_t a2 = alpha*alpha;
real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
/* */ : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
}
// Composes several features into one function
template<typename F0, typename F1>
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
{
int dim = pt.Size();
double x = pt(0), y = pt(1), z = 0.0;
real_t x = pt(0), y = pt(1), z = 0.0;
if (dim == 3) { z = pt(2); }
if (problem == 0)
@@ -417,11 +417,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
}
else
{
double sum = 0.0;
real_t sum = 0.0;
for (int i = 0; i < nfeatures; i++)
{
double x0 = 0.5*cos(2*M_PI * i / nfeatures);
double y0 = 0.5*sin(2*M_PI * i / nfeatures);
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures);
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures);
sum += f0(x - x0, y - y0, z, t, dim);
}
return sum;
@@ -429,11 +429,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
}
else
{
double sum = 0.0;
real_t sum = 0.0;
for (int i = 0; i < nfeatures; i++)
{
double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
sum += f1(x - x0, y - y0, z, 0.25, dim);
}
return sum;
@@ -441,13 +441,13 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
}
// Exact solution, used for the Dirichlet BC.
double bdr_func(const Vector &pt, double t)
real_t bdr_func(const Vector &pt, real_t t)
{
return composite_func(pt, t, front, ball);
}
// Laplace of the exact solution, used for the right hand side.
double rhs_func(const Vector &pt, double t)
real_t rhs_func(const Vector &pt, real_t t)
{
return composite_func(pt, t, front_laplace, ball_laplace);
}
+30 -30
View File
@@ -68,8 +68,8 @@ int problem;
int nfeatures;
// Prescribed time-dependent boundary and right-hand side functions.
double bdr_func(const Vector &pt, double t);
double rhs_func(const Vector &pt, double t);
real_t bdr_func(const Vector &pt, real_t t);
real_t rhs_func(const Vector &pt, real_t t);
// Update the finite element space, interpolate the solution and perform
// parallel load balancing.
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
nfeatures = 1;
const char *mesh_file = "../data/star-hilbert.mesh";
int order = 2;
double t_final = 1.0;
double max_elem_error = 1.0e-4;
double hysteresis = 0.25; // derefinement safety coefficient
real_t t_final = 1.0;
real_t max_elem_error = 1.0e-4;
real_t hysteresis = 0.25; // derefinement safety coefficient
int ref_levels = 0;
int nc_limit = 3; // maximum level of hanging nodes
bool visualization = true;
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
// solve the problem on the current mesh, visualize the solution and
// refine the mesh as many times as necessary. Then we derefine any
// elements which have very small errors.
for (double time = 0.0; time < t_final + 1e-10; time += 0.01)
for (real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
{
if (myid == 0)
{
@@ -427,47 +427,47 @@ void UpdateAndRebalance(ParMesh &pmesh, ParFiniteElementSpace &fespace,
}
const double alpha = 0.02;
const real_t alpha = 0.02;
// Spherical front with a Gaussian cross section and radius t
double front(double x, double y, double z, double t, int)
real_t front(real_t x, real_t y, real_t z, real_t t, int)
{
double r = sqrt(x*x + y*y + z*z);
real_t r = sqrt(x*x + y*y + z*z);
return exp(-0.5*pow((r - t)/alpha, 2));
}
double front_laplace(double x, double y, double z, double t, int dim)
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
{
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
double r = sqrt(x2 + y2 + z2);
double a2 = alpha*alpha, a4 = a2*a2;
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
real_t r = sqrt(x2 + y2 + z2);
real_t a2 = alpha*alpha, a4 = a2*a2;
return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
(-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
}
// Smooth spherical step function with radius t
double ball(double x, double y, double z, double t, int)
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
{
double r = sqrt(x*x + y*y + z*z);
real_t r = sqrt(x*x + y*y + z*z);
return -atan(2*(r - t)/alpha);
}
double ball_laplace(double x, double y, double z, double t, int dim)
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
{
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
double r = sqrt(x2 + y2 + z2);
double a2 = alpha*alpha;
double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
real_t r = sqrt(x2 + y2 + z2);
real_t a2 = alpha*alpha;
real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
/* */ : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
}
// Composes several features into one function
template<typename F0, typename F1>
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
{
int dim = pt.Size();
double x = pt(0), y = pt(1), z = 0.0;
real_t x = pt(0), y = pt(1), z = 0.0;
if (dim == 3) { z = pt(2); }
if (problem == 0)
@@ -478,11 +478,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
}
else
{
double sum = 0.0;
real_t sum = 0.0;
for (int i = 0; i < nfeatures; i++)
{
double x0 = 0.5*cos(2*M_PI * i / nfeatures);
double y0 = 0.5*sin(2*M_PI * i / nfeatures);
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures);
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures);
sum += f0(x - x0, y - y0, z, t, dim);
}
return sum;
@@ -490,11 +490,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
}
else
{
double sum = 0.0;
real_t sum = 0.0;
for (int i = 0; i < nfeatures; i++)
{
double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
sum += f1(x - x0, y - y0, z, 0.25, dim);
}
return sum;
@@ -502,13 +502,13 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
}
// Exact solution, used for the Dirichlet BC.
double bdr_func(const Vector &pt, double t)
real_t bdr_func(const Vector &pt, real_t t)
{
return composite_func(pt, t, front, ball);
}
// Laplace of the exact solution, used for the right hand side.
double rhs_func(const Vector &pt, double t)
real_t rhs_func(const Vector &pt, real_t t)
{
return composite_func(pt, t, front_laplace, ball_laplace);
}
+17 -17
View File
@@ -60,7 +60,7 @@ protected:
SparseMatrix Mmat, Kmat;
SparseMatrix *T; // T = M + dt K
double current_dt;
real_t current_dt;
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
DSmoother M_prec; // Preconditioner for the mass matrix M
@@ -68,18 +68,18 @@ protected:
CGSolver T_solver; // Implicit solver for T = M + dt K
DSmoother T_prec; // Preconditioner for the implicit solver
double alpha, kappa;
real_t alpha, kappa;
mutable Vector z; // auxiliary vector
public:
ConductionOperator(FiniteElementSpace &f, double alpha, double kappa,
ConductionOperator(FiniteElementSpace &f, real_t alpha, real_t kappa,
const Vector &u);
virtual void Mult(const Vector &u, Vector &du_dt) const;
/** Solve the Backward-Euler equation: k = f(u + dt*k, t), for the unknown k.
This is the only requirement for high-order SDIRK implicit integration.*/
virtual void ImplicitSolve(const double dt, const Vector &u, Vector &k);
virtual void ImplicitSolve(const real_t dt, const Vector &u, Vector &k);
/// Update the diffusion BilinearForm K using the given true-dof vector `u`.
void SetParameters(const Vector &u);
@@ -87,7 +87,7 @@ public:
virtual ~ConductionOperator();
};
double InitialTemperature(const Vector &x);
real_t InitialTemperature(const Vector &x);
int main(int argc, char *argv[])
{
@@ -96,10 +96,10 @@ int main(int argc, char *argv[])
int ref_levels = 2;
int order = 2;
int ode_solver_type = 3;
double t_final = 0.5;
double dt = 1.0e-2;
double alpha = 1.0e-2;
double kappa = 0.5;
real_t t_final = 0.5;
real_t dt = 1.0e-2;
real_t alpha = 1.0e-2;
real_t kappa = 0.5;
bool visualization = true;
bool visit = false;
int vis_steps = 5;
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
// 8. Perform time-integration (looping over the time iterations, ti, with a
// time-step dt).
ode_solver->Init(oper);
double t = 0.0;
real_t t = 0.0;
bool last_step = false;
for (int ti = 1; !last_step; ti++)
@@ -293,12 +293,12 @@ int main(int argc, char *argv[])
return 0;
}
ConductionOperator::ConductionOperator(FiniteElementSpace &f, double al,
double kap, const Vector &u)
: TimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL), K(NULL),
T(NULL), current_dt(0.0), z(height)
ConductionOperator::ConductionOperator(FiniteElementSpace &f, real_t al,
real_t kap, const Vector &u)
: TimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0), fespace(f),
M(NULL), K(NULL), T(NULL), current_dt(0.0), z(height)
{
const double rel_tol = 1e-8;
const real_t rel_tol = 1e-8;
M = new BilinearForm(&fespace);
M->AddDomainIntegrator(new MassIntegrator());
@@ -336,7 +336,7 @@ void ConductionOperator::Mult(const Vector &u, Vector &du_dt) const
M_solver.Mult(z, du_dt);
}
void ConductionOperator::ImplicitSolve(const double dt,
void ConductionOperator::ImplicitSolve(const real_t dt,
const Vector &u, Vector &du_dt)
{
// Solve the equation:
@@ -382,7 +382,7 @@ ConductionOperator::~ConductionOperator()
delete K;
}
double InitialTemperature(const Vector &x)
real_t InitialTemperature(const Vector &x)
{
if (x.Norml2() < 0.5)
{
+17 -17
View File
@@ -62,7 +62,7 @@ protected:
HypreParMatrix Mmat;
HypreParMatrix Kmat;
HypreParMatrix *T; // T = M + dt K
double current_dt;
real_t current_dt;
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
HypreSmoother M_prec; // Preconditioner for the mass matrix M
@@ -70,18 +70,18 @@ protected:
CGSolver T_solver; // Implicit solver for T = M + dt K
HypreSmoother T_prec; // Preconditioner for the implicit solver
double alpha, kappa;
real_t alpha, kappa;
mutable Vector z; // auxiliary vector
public:
ConductionOperator(ParFiniteElementSpace &f, double alpha, double kappa,
ConductionOperator(ParFiniteElementSpace &f, real_t alpha, real_t kappa,
const Vector &u);
virtual void Mult(const Vector &u, Vector &du_dt) const;
/** Solve the Backward-Euler equation: k = f(u + dt*k, t), for the unknown k.
This is the only requirement for high-order SDIRK implicit integration.*/
virtual void ImplicitSolve(const double dt, const Vector &u, Vector &k);
virtual void ImplicitSolve(const real_t dt, const Vector &u, Vector &k);
/// Update the diffusion BilinearForm K using the given true-dof vector `u`.
void SetParameters(const Vector &u);
@@ -89,7 +89,7 @@ public:
virtual ~ConductionOperator();
};
double InitialTemperature(const Vector &x);
real_t InitialTemperature(const Vector &x);
int main(int argc, char *argv[])
{
@@ -105,10 +105,10 @@ int main(int argc, char *argv[])
int par_ref_levels = 1;
int order = 2;
int ode_solver_type = 3;
double t_final = 0.5;
double dt = 1.0e-2;
double alpha = 1.0e-2;
double kappa = 0.5;
real_t t_final = 0.5;
real_t dt = 1.0e-2;
real_t alpha = 1.0e-2;
real_t kappa = 0.5;
bool visualization = true;
bool visit = false;
int vis_steps = 5;
@@ -313,7 +313,7 @@ int main(int argc, char *argv[])
// 10. Perform time-integration (looping over the time iterations, ti, with a
// time-step dt).
ode_solver->Init(oper);
double t = 0.0;
real_t t = 0.0;
bool last_step = false;
for (int ti = 1; !last_step; ti++)
@@ -382,13 +382,13 @@ int main(int argc, char *argv[])
return 0;
}
ConductionOperator::ConductionOperator(ParFiniteElementSpace &f, double al,
double kap, const Vector &u)
: TimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL), K(NULL),
T(NULL), current_dt(0.0),
ConductionOperator::ConductionOperator(ParFiniteElementSpace &f, real_t al,
real_t kap, const Vector &u)
: TimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0), fespace(f),
M(NULL), K(NULL), T(NULL), current_dt(0.0),
M_solver(f.GetComm()), T_solver(f.GetComm()), z(height)
{
const double rel_tol = 1e-8;
const real_t rel_tol = 1e-8;
M = new ParBilinearForm(&fespace);
M->AddDomainIntegrator(new MassIntegrator());
@@ -427,7 +427,7 @@ void ConductionOperator::Mult(const Vector &u, Vector &du_dt) const
M_solver.Mult(z, du_dt);
}
void ConductionOperator::ImplicitSolve(const double dt,
void ConductionOperator::ImplicitSolve(const real_t dt,
const Vector &u, Vector &du_dt)
{
// Solve the equation:
@@ -473,7 +473,7 @@ ConductionOperator::~ConductionOperator()
delete K;
}
double InitialTemperature(const Vector &x)
real_t InitialTemperature(const Vector &x)
{
if (x.Norml2() < 0.5)
{
+8 -8
View File
@@ -69,7 +69,7 @@ public:
void SetDisplacement(GridFunction &u_) { u = &u_; }
void SetComponent(int i, int j) { si = i; sj = j; }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
};
// Simple GLVis visualization manager.
@@ -104,8 +104,8 @@ int main(int argc, char *argv[])
const char *mesh_file = "../data/beam-tri.mesh";
int ref_levels = -1;
int order = 1;
double alpha = -1.0;
double kappa = -1.0;
real_t alpha = -1.0;
real_t kappa = -1.0;
bool visualization = 1;
OptionsParser args(argc, argv);
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
// solve the system Ax=b with PCG for the symmetric formulation, or GMRES
// for the non-symmetric.
GSSmoother M(A);
const double rtol = 1e-6;
const real_t rtol = 1e-6;
if (alpha == -1.0)
{
PCG(A, M, B, X, 3, 5000, rtol*rtol, 0.0);
@@ -337,17 +337,17 @@ void InitDisplacement(const Vector &x, Vector &u)
}
double StressCoefficient::Eval(ElementTransformation &T,
real_t StressCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
MFEM_ASSERT(u != NULL, "displacement field is not set");
double L = lambda.Eval(T, ip);
double M = mu.Eval(T, ip);
real_t L = lambda.Eval(T, ip);
real_t M = mu.Eval(T, ip);
u->GetVectorGradient(T, grad);
if (si == sj)
{
double div_u = grad.Trace();
real_t div_u = grad.Trace();
return L*div_u + 2*M*grad(si,si);
}
else
+8 -8
View File
@@ -69,7 +69,7 @@ public:
void SetDisplacement(GridFunction &u_) { u = &u_; }
void SetComponent(int i, int j) { si = i; sj = j; }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
};
// Simple GLVis visualization manager.
@@ -108,8 +108,8 @@ int main(int argc, char *argv[])
int ser_ref_levels = -1;
int par_ref_levels = 1;
int order = 1;
double alpha = -1.0;
double kappa = -1.0;
real_t alpha = -1.0;
real_t kappa = -1.0;
bool amg_elast = false;
bool visualization = 1;
@@ -268,7 +268,7 @@ int main(int argc, char *argv[])
// 11. Define a simple symmetric Gauss-Seidel preconditioner and use it to
// solve the system Ax=b with PCG for the symmetric formulation, or GMRES
// for the non-symmetric.
const double rtol = 1e-6;
const real_t rtol = 1e-6;
HypreBoomerAMG amg(A);
if (amg_elast)
{
@@ -376,17 +376,17 @@ void InitDisplacement(const Vector &x, Vector &u)
}
double StressCoefficient::Eval(ElementTransformation &T,
real_t StressCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
MFEM_ASSERT(u != NULL, "displacement field is not set");
double L = lambda.Eval(T, ip);
double M = mu.Eval(T, ip);
real_t L = lambda.Eval(T, ip);
real_t M = mu.Eval(T, ip);
u->GetVectorGradient(T, grad);
if (si == sj)
{
double div_u = grad.Trace();
real_t div_u = grad.Trace();
return L*div_u + 2*M*grad(si,si);
}
else
+10 -10
View File
@@ -52,11 +52,11 @@ int problem;
// Equation constant parameters.
const int num_equation = 4;
const double specific_heat_ratio = 1.4;
const double gas_constant = 1.0;
const real_t specific_heat_ratio = 1.4;
const real_t gas_constant = 1.0;
// Maximum characteristic speed (updated by integrators)
double max_char_speed;
real_t max_char_speed;
int main(int argc, char *argv[])
{
@@ -66,9 +66,9 @@ int main(int argc, char *argv[])
int ref_levels = 1;
int order = 3;
int ode_solver_type = 4;
double t_final = 2.0;
double dt = -0.01;
double cfl = 0.3;
real_t t_final = 2.0;
real_t dt = -0.01;
real_t cfl = 0.3;
bool visualization = true;
int vis_steps = 50;
@@ -228,7 +228,7 @@ int main(int argc, char *argv[])
}
// Determine the minimum element size.
double hmin = 0.0;
real_t hmin = 0.0;
if (cfl > 0)
{
hmin = mesh.GetElementSize(0, 1);
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
tic_toc.Clear();
tic_toc.Start();
double t = 0.0;
real_t t = 0.0;
euler.SetTime(t);
ode_solver->Init(euler);
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
bool done = false;
for (int ti = 0; !done; )
{
double dt_real = min(dt, t_final - t);
real_t dt_real = min(dt, t_final - t);
ode_solver->Step(sol, t, dt_real);
if (cfl > 0)
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
// 10. Compute the L2 solution error summed for all components.
if (t_final == 2.0)
{
const double error = sol.ComputeLpError(2, u0);
const real_t error = sol.ComputeLpError(2, u0);
cout << "Solution error: " << error << endl;
}
+50 -50
View File
@@ -9,11 +9,11 @@ using namespace mfem;
extern int problem;
// Maximum characteristic speed (updated by integrators)
extern double max_char_speed;
extern real_t max_char_speed;
extern const int num_equation;
extern const double specific_heat_ratio;
extern const double gas_constant;
extern const real_t specific_heat_ratio;
extern const real_t gas_constant;
// Time-dependent operator for the right-hand side of the ODE representing the
// DG weak form.
@@ -52,7 +52,7 @@ private:
public:
RiemannSolver();
double Eval(const Vector &state1, const Vector &state2,
real_t Eval(const Vector &state1, const Vector &state2,
const Vector &nor, Vector &flux);
};
@@ -149,13 +149,13 @@ void FE_Evolution::Mult(const Vector &x, Vector &y) const
bool StateIsPhysical(const Vector &state, const int dim);
// Pressure (EOS) computation
inline double ComputePressure(const Vector &state, int dim)
inline real_t ComputePressure(const Vector &state, int dim)
{
const double den = state(0);
const real_t den = state(0);
const Vector den_vel(state.GetData() + 1, dim);
const double den_energy = state(1 + dim);
const real_t den_energy = state(1 + dim);
double den_vel2 = 0;
real_t den_vel2 = 0;
for (int d = 0; d < dim; d++) { den_vel2 += den_vel(d) * den_vel(d); }
den_vel2 /= den;
@@ -165,13 +165,13 @@ inline double ComputePressure(const Vector &state, int dim)
// Compute the vector flux F(u)
void ComputeFlux(const Vector &state, int dim, DenseMatrix &flux)
{
const double den = state(0);
const real_t den = state(0);
const Vector den_vel(state.GetData() + 1, dim);
const double den_energy = state(1 + dim);
const real_t den_energy = state(1 + dim);
MFEM_ASSERT(StateIsPhysical(state, dim), "");
const double pres = ComputePressure(state, dim);
const real_t pres = ComputePressure(state, dim);
for (int d = 0; d < dim; d++)
{
@@ -183,7 +183,7 @@ void ComputeFlux(const Vector &state, int dim, DenseMatrix &flux)
flux(1+d, d) += pres;
}
const double H = (den_energy + pres) / den;
const real_t H = (den_energy + pres) / den;
for (int d = 0; d < dim; d++)
{
flux(1+dim, d) = den_vel(d) * H;
@@ -196,15 +196,15 @@ void ComputeFluxDotN(const Vector &state, const Vector &nor,
{
// NOTE: nor in general is not a unit normal
const int dim = nor.Size();
const double den = state(0);
const real_t den = state(0);
const Vector den_vel(state.GetData() + 1, dim);
const double den_energy = state(1 + dim);
const real_t den_energy = state(1 + dim);
MFEM_ASSERT(StateIsPhysical(state, dim), "");
const double pres = ComputePressure(state, dim);
const real_t pres = ComputePressure(state, dim);
double den_velN = 0;
real_t den_velN = 0;
for (int d = 0; d < dim; d++) { den_velN += den_vel(d) * nor(d); }
fluxN(0) = den_velN;
@@ -213,23 +213,23 @@ void ComputeFluxDotN(const Vector &state, const Vector &nor,
fluxN(1+d) = den_velN * den_vel(d) / den + pres * nor(d);
}
const double H = (den_energy + pres) / den;
const real_t H = (den_energy + pres) / den;
fluxN(1 + dim) = den_velN * H;
}
// Compute the maximum characteristic speed.
inline double ComputeMaxCharSpeed(const Vector &state, const int dim)
inline real_t ComputeMaxCharSpeed(const Vector &state, const int dim)
{
const double den = state(0);
const real_t den = state(0);
const Vector den_vel(state.GetData() + 1, dim);
double den_vel2 = 0;
real_t den_vel2 = 0;
for (int d = 0; d < dim; d++) { den_vel2 += den_vel(d) * den_vel(d); }
den_vel2 /= den;
const double pres = ComputePressure(state, dim);
const double sound = sqrt(specific_heat_ratio * pres / den);
const double vel = sqrt(den_vel2 / den);
const real_t pres = ComputePressure(state, dim);
const real_t sound = sqrt(specific_heat_ratio * pres / den);
const real_t vel = sqrt(den_vel2 / den);
return vel + sound;
}
@@ -254,7 +254,7 @@ void FE_Evolution::GetFlux(const DenseMatrix &x_, DenseTensor &flux_) const
}
// Update max char speed
const double mcs = ComputeMaxCharSpeed(state, flux_dim);
const real_t mcs = ComputeMaxCharSpeed(state, flux_dim);
if (mcs > max_char_speed) { max_char_speed = mcs; }
}
}
@@ -264,7 +264,7 @@ RiemannSolver::RiemannSolver() :
flux1(num_equation),
flux2(num_equation) { }
double RiemannSolver::Eval(const Vector &state1, const Vector &state2,
real_t RiemannSolver::Eval(const Vector &state1, const Vector &state2,
const Vector &nor, Vector &flux)
{
// NOTE: nor in general is not a unit normal
@@ -273,15 +273,15 @@ double RiemannSolver::Eval(const Vector &state1, const Vector &state2,
MFEM_ASSERT(StateIsPhysical(state1, dim), "");
MFEM_ASSERT(StateIsPhysical(state2, dim), "");
const double maxE1 = ComputeMaxCharSpeed(state1, dim);
const double maxE2 = ComputeMaxCharSpeed(state2, dim);
const real_t maxE1 = ComputeMaxCharSpeed(state1, dim);
const real_t maxE2 = ComputeMaxCharSpeed(state2, dim);
const double maxE = max(maxE1, maxE2);
const real_t maxE = max(maxE1, maxE2);
ComputeFluxDotN(state1, nor, flux1);
ComputeFluxDotN(state2, nor, flux2);
double normag = 0;
real_t normag = 0;
for (int i = 0; i < dim; i++)
{
normag += nor(i) * nor(i);
@@ -359,7 +359,7 @@ void FaceIntegrator::AssembleFaceVector(const FiniteElement &el1,
// Get the normal vector and the flux on the face
CalcOrtho(Tr.Jacobian(), nor);
const double mcs = rsolver.Eval(funval1, funval2, nor, fluxN);
const real_t mcs = rsolver.Eval(funval1, funval2, nor, fluxN);
// Update max char speed
if (mcs > max_char_speed) { max_char_speed = mcs; }
@@ -382,9 +382,9 @@ void FaceIntegrator::AssembleFaceVector(const FiniteElement &el1,
// Check that the state is physical - enabled in debug mode
bool StateIsPhysical(const Vector &state, const int dim)
{
const double den = state(0);
const real_t den = state(0);
const Vector den_vel(state.GetData() + 1, dim);
const double den_energy = state(1 + dim);
const real_t den_energy = state(1 + dim);
if (den < 0)
{
@@ -407,11 +407,11 @@ bool StateIsPhysical(const Vector &state, const int dim)
return false;
}
double den_vel2 = 0;
real_t den_vel2 = 0;
for (int i = 0; i < dim; i++) { den_vel2 += den_vel(i) * den_vel(i); }
den_vel2 /= den;
const double pres = (specific_heat_ratio - 1.0) * (den_energy - 0.5 * den_vel2);
const real_t pres = (specific_heat_ratio - 1.0) * (den_energy - 0.5 * den_vel2);
if (pres <= 0)
{
@@ -431,7 +431,7 @@ void InitialCondition(const Vector &x, Vector &y)
{
MFEM_ASSERT(x.Size() == 2, "");
double radius = 0, Minf = 0, beta = 0;
real_t radius = 0, Minf = 0, beta = 0;
if (problem == 1)
{
// "Fast vortex"
@@ -452,36 +452,36 @@ void InitialCondition(const Vector &x, Vector &y)
"Options are: 1 - fast vortex, 2 - slow vortex");
}
const double xc = 0.0, yc = 0.0;
const real_t xc = 0.0, yc = 0.0;
// Nice units
const double vel_inf = 1.;
const double den_inf = 1.;
const real_t vel_inf = 1.;
const real_t den_inf = 1.;
// Derive remainder of background state from this and Minf
const double pres_inf = (den_inf / specific_heat_ratio) * (vel_inf / Minf) *
const real_t pres_inf = (den_inf / specific_heat_ratio) * (vel_inf / Minf) *
(vel_inf / Minf);
const double temp_inf = pres_inf / (den_inf * gas_constant);
const real_t temp_inf = pres_inf / (den_inf * gas_constant);
double r2rad = 0.0;
real_t r2rad = 0.0;
r2rad += (x(0) - xc) * (x(0) - xc);
r2rad += (x(1) - yc) * (x(1) - yc);
r2rad /= (radius * radius);
const double shrinv1 = 1.0 / (specific_heat_ratio - 1.);
const real_t shrinv1 = 1.0 / (specific_heat_ratio - 1.);
const double velX = vel_inf * (1 - beta * (x(1) - yc) / radius * exp(
const real_t velX = vel_inf * (1 - beta * (x(1) - yc) / radius * exp(
-0.5 * r2rad));
const double velY = vel_inf * beta * (x(0) - xc) / radius * exp(-0.5 * r2rad);
const double vel2 = velX * velX + velY * velY;
const real_t velY = vel_inf * beta * (x(0) - xc) / radius * exp(-0.5 * r2rad);
const real_t vel2 = velX * velX + velY * velY;
const double specific_heat = gas_constant * specific_heat_ratio * shrinv1;
const double temp = temp_inf - 0.5 * (vel_inf * beta) *
const real_t specific_heat = gas_constant * specific_heat_ratio * shrinv1;
const real_t temp = temp_inf - 0.5 * (vel_inf * beta) *
(vel_inf * beta) / specific_heat * exp(-r2rad);
const double den = den_inf * pow(temp/temp_inf, shrinv1);
const double pres = den * gas_constant * temp;
const double energy = shrinv1 * pres / den + 0.5 * vel2;
const real_t den = den_inf * pow(temp/temp_inf, shrinv1);
const real_t pres = den * gas_constant * temp;
const real_t energy = shrinv1 * pres / den + 0.5 * vel2;
y(0) = den;
y(1) = den * velX;
+19 -18
View File
@@ -52,11 +52,11 @@ int problem;
// Equation constant parameters.
const int num_equation = 4;
const double specific_heat_ratio = 1.4;
const double gas_constant = 1.0;
const real_t specific_heat_ratio = 1.4;
const real_t gas_constant = 1.0;
// Maximum characteristic speed (updated by integrators)
double max_char_speed;
real_t max_char_speed;
int main(int argc, char *argv[])
{
@@ -71,9 +71,9 @@ int main(int argc, char *argv[])
int par_ref_levels = 1;
int order = 3;
int ode_solver_type = 4;
double t_final = 2.0;
double dt = -0.01;
double cfl = 0.3;
real_t t_final = 2.0;
real_t dt = -0.01;
real_t cfl = 0.3;
bool visualization = true;
int vis_steps = 50;
@@ -270,23 +270,24 @@ int main(int argc, char *argv[])
}
// Determine the minimum element size.
double hmin;
real_t hmin;
if (cfl > 0)
{
double my_hmin = pmesh.GetElementSize(0, 1);
real_t my_hmin = pmesh.GetElementSize(0, 1);
for (int i = 1; i < pmesh.GetNE(); i++)
{
my_hmin = min(pmesh.GetElementSize(i, 1), my_hmin);
}
// Reduce to find the global minimum element size
MPI_Allreduce(&my_hmin, &hmin, 1, MPI_DOUBLE, MPI_MIN, pmesh.GetComm());
MPI_Allreduce(&my_hmin, &hmin, 1, MPITypeMap<real_t>::mpi_type,
MPI_MIN, pmesh.GetComm());
}
// Start the timer.
tic_toc.Clear();
tic_toc.Start();
double t = 0.0;
real_t t = 0.0;
euler.SetTime(t);
ode_solver->Init(euler);
@@ -299,9 +300,9 @@ int main(int argc, char *argv[])
A.Mult(sol, z);
// Reduce to find the global maximum wave speed
{
double all_max_char_speed;
MPI_Allreduce(&max_char_speed, &all_max_char_speed,
1, MPI_DOUBLE, MPI_MAX, pmesh.GetComm());
real_t all_max_char_speed;
MPI_Allreduce(&max_char_speed, &all_max_char_speed, 1,
MPITypeMap<real_t>::mpi_type, MPI_MAX, pmesh.GetComm());
max_char_speed = all_max_char_speed;
}
dt = cfl * hmin / max_char_speed / (2*order+1);
@@ -311,16 +312,16 @@ int main(int argc, char *argv[])
bool done = false;
for (int ti = 0; !done; )
{
double dt_real = min(dt, t_final - t);
real_t dt_real = min(dt, t_final - t);
ode_solver->Step(sol, t, dt_real);
if (cfl > 0)
{
// Reduce to find the global maximum wave speed
{
double all_max_char_speed;
MPI_Allreduce(&max_char_speed, &all_max_char_speed,
1, MPI_DOUBLE, MPI_MAX, pmesh.GetComm());
real_t all_max_char_speed;
MPI_Allreduce(&max_char_speed, &all_max_char_speed, 1,
MPITypeMap<real_t>::mpi_type, MPI_MAX, pmesh.GetComm());
max_char_speed = all_max_char_speed;
}
dt = cfl * hmin / max_char_speed / (2*order+1);
@@ -366,7 +367,7 @@ int main(int argc, char *argv[])
// 12. Compute the L2 solution error summed for all components.
if (t_final == 2.0)
{
const double error = sol.ComputeLpError(2, u0);
const real_t error = sol.ComputeLpError(2, u0);
if (Mpi::Root())
{
cout << "Solution error: " << error << endl;
+10 -10
View File
@@ -48,15 +48,15 @@ public:
print_level = print_lvl;
}
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final);
private:
const std::string prefix;
int print_level;
mutable double norm0;
mutable real_t norm0;
};
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
void GeneralResidualMonitor::MonitorResidual(int it, real_t norm,
const Vector &r, bool final)
{
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
@@ -103,7 +103,7 @@ protected:
BlockOperator *jacobian;
// Scaling factor for the pressure mass matrix in the block preconditioner
double gamma;
real_t gamma;
// Objects for the block preconditioner application
SparseMatrix *pressure_mass;
@@ -157,7 +157,7 @@ protected:
public:
RubberOperator(Array<FiniteElementSpace *> &fes, Array<Array<int> *>&ess_bdr,
Array<int> &block_trueOffsets, double rel_tol, double abs_tol,
Array<int> &block_trueOffsets, real_t rel_tol, real_t abs_tol,
int iter, Coefficient &mu);
// Required to use the native newton solver
@@ -187,10 +187,10 @@ int main(int argc, char *argv[])
int ref_levels = 0;
int order = 2;
bool visualization = true;
double newton_rel_tol = 1e-4;
double newton_abs_tol = 1e-6;
real_t newton_rel_tol = 1e-4;
real_t newton_abs_tol = 1e-6;
int newton_iter = 500;
double mu = 1.0;
real_t mu = 1.0;
OptionsParser args(argc, argv);
args.AddOption(&mesh_file, "-m", "--mesh",
@@ -449,8 +449,8 @@ JacobianPreconditioner::~JacobianPreconditioner()
RubberOperator::RubberOperator(Array<FiniteElementSpace *> &fes,
Array<Array<int> *> &ess_bdr,
Array<int> &offsets,
double rel_tol,
double abs_tol,
real_t rel_tol,
real_t abs_tol,
int iter,
Coefficient &c_mu)
: Operator(fes[0]->GetTrueVSize() + fes[1]->GetTrueVSize()),
+10 -10
View File
@@ -62,15 +62,15 @@ public:
#endif
}
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final);
private:
const std::string prefix;
int print_level;
mutable double norm0;
mutable real_t norm0;
};
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
void GeneralResidualMonitor::MonitorResidual(int it, real_t norm,
const Vector &r, bool final)
{
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
@@ -117,7 +117,7 @@ protected:
BlockOperator *jacobian;
// Scaling factor for the pressure mass matrix in the block preconditioner
double gamma;
real_t gamma;
// Objects for the block preconditioner application
Operator *pressure_mass;
@@ -171,7 +171,7 @@ protected:
public:
RubberOperator(Array<ParFiniteElementSpace *> &fes, Array<Array<int> *>&ess_bdr,
Array<int> &block_trueOffsets, double rel_tol, double abs_tol,
Array<int> &block_trueOffsets, real_t rel_tol, real_t abs_tol,
int iter, Coefficient &mu);
// Required to use the native newton solver
@@ -214,10 +214,10 @@ int main(int argc, char *argv[])
int par_ref_levels = 0;
int order = 2;
bool visualization = true;
double newton_rel_tol = 1e-4;
double newton_abs_tol = 1e-6;
real_t newton_rel_tol = 1e-4;
real_t newton_abs_tol = 1e-6;
int newton_iter = 500;
double mu = 1.0;
real_t mu = 1.0;
OptionsParser args(argc, argv);
args.AddOption(&mesh_file, "-m", "--mesh",
@@ -524,8 +524,8 @@ JacobianPreconditioner::~JacobianPreconditioner()
RubberOperator::RubberOperator(Array<ParFiniteElementSpace *> &fes,
Array<Array<int> *> &ess_bdr,
Array<int> &trueOffsets,
double rel_tol,
double abs_tol,
real_t rel_tol,
real_t abs_tol,
int iter,
Coefficient &c_mu)
: Operator(fes[0]->TrueVSize() + fes[1]->TrueVSize()),
+10 -10
View File
@@ -69,11 +69,11 @@ using namespace mfem;
// Constants used in the Hamiltonian
static int prob_ = 0;
static double m_ = 1.0;
static double k_ = 1.0;
static real_t m_ = 1.0;
static real_t k_ = 1.0;
// Hamiltonian functional, see below for implementation
double hamiltonian(double q, double p, double t);
real_t hamiltonian(real_t q, real_t p, real_t t);
class GradT : public Operator
{
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
// 1. Parse command-line options.
int order = 1;
int nsteps = 100;
double dt = 0.1;
real_t dt = 0.1;
bool visualization = true;
bool gnuplot = false;
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
siaSolver.Init(P,F);
// 3. Set the initial conditions
double t = 0.0;
real_t t = 0.0;
Vector q(1), p(1);
Vector e(nsteps+1);
q(0) = 0.0;
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
Vector x1(3); x1 = 0.0;
// 6. Perform time-stepping
double e_mean = 0.0;
real_t e_mean = 0.0;
for (int i = 0; i < nsteps; i++)
{
@@ -210,13 +210,13 @@ int main(int argc, char *argv[])
// 7. Compute and display mean and standard deviation of the energy
e_mean /= (nsteps + 1);
double e_var = 0.0;
real_t e_var = 0.0;
for (int i=0; i<=nsteps; i++)
{
e_var += pow(e[i] - e_mean, 2);
}
e_var /= (nsteps + 1);
double e_sd = sqrt(e_var);
real_t e_sd = sqrt(e_var);
cout << endl << "Mean and standard deviation of the energy" << endl;
cout << e_mean << "\t" << e_sd << endl;
@@ -256,9 +256,9 @@ int main(int argc, char *argv[])
}
}
double hamiltonian(double q, double p, double t)
real_t hamiltonian(real_t q, real_t p, real_t t)
{
double h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
real_t h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
switch (prob_)
{
case 1:
+16 -15
View File
@@ -74,11 +74,11 @@ using namespace mfem;
// Constants used in the Hamiltonian
static int prob_ = 0;
static double m_ = 1.0;
static double k_ = 1.0;
static real_t m_ = 1.0;
static real_t k_ = 1.0;
// Hamiltonian functional, see below for implementation
double hamiltonian(double q, double p, double t);
real_t hamiltonian(real_t q, real_t p, real_t t);
class GradT : public Operator
{
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
// 2. Parse command-line options.
int order = 1;
int nsteps = 100;
double dt = 0.1;
real_t dt = 0.1;
bool visualization = true;
bool gnuplot = false;
@@ -154,11 +154,11 @@ int main(int argc, char *argv[])
siaSolver.Init(P,F);
// 4. Set the initial conditions
double t = 0.0;
real_t t = 0.0;
Vector q(1), p(1);
Vector e(nsteps+1);
q(0) = sin(2.0*M_PI*(double)myid/num_procs);
p(0) = cos(2.0*M_PI*(double)myid/num_procs);
q(0) = sin(2.0*M_PI*(real_t)myid/num_procs);
p(0) = cos(2.0*M_PI*(real_t)myid/num_procs);
// 5. Prepare GnuPlot output file if needed
ostringstream oss;
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
Vector x1(3); x1 = 0.0;
// 7. Perform time-stepping
double e_mean = 0.0;
real_t e_mean = 0.0;
for (int i = 0; i < nsteps; i++)
{
@@ -238,20 +238,21 @@ int main(int argc, char *argv[])
// 8. Compute and display mean and standard deviation of the energy
e_mean /= (nsteps + 1);
double e_var = 0.0;
real_t e_var = 0.0;
for (int i = 0; i <= nsteps; i++)
{
e_var += pow(e[i] - e_mean, 2);
}
e_var /= (nsteps + 1);
double e_sd = sqrt(e_var);
real_t e_sd = sqrt(e_var);
double e_loc_stats[2];
double *e_stats = (myid == 0) ? new double[2 * num_procs] : (double*)NULL;
real_t e_loc_stats[2];
real_t *e_stats = (myid == 0) ? new real_t[2 * num_procs] : (real_t*)NULL;
e_loc_stats[0] = e_mean;
e_loc_stats[1] = e_sd;
MPI_Gather(e_loc_stats, 2, MPI_DOUBLE, e_stats, 2, MPI_DOUBLE, 0, comm);
MPI_Gather(e_loc_stats, 2, MPITypeMap<real_t>::mpi_type, e_stats, 2,
MPITypeMap<real_t>::mpi_type, 0, comm);
if (myid == 0)
{
@@ -324,9 +325,9 @@ int main(int argc, char *argv[])
}
}
double hamiltonian(double q, double p, double t)
real_t hamiltonian(real_t q, real_t p, real_t t)
{
double h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
real_t h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
switch (prob_)
{
case 1:
+18 -18
View File
@@ -57,13 +57,13 @@
using namespace std;
using namespace mfem;
static double mu_ = 1.0;
static double epsilon_ = 1.0;
static double sigma_ = 20.0;
static double omega_ = 10.0;
static real_t mu_ = 1.0;
static real_t epsilon_ = 1.0;
static real_t sigma_ = 20.0;
static real_t omega_ = 10.0;
double u0_real_exact(const Vector &);
double u0_imag_exact(const Vector &);
real_t u0_real_exact(const Vector &);
real_t u0_imag_exact(const Vector &);
void u1_real_exact(const Vector &, Vector &);
void u1_imag_exact(const Vector &, Vector &);
@@ -80,8 +80,8 @@ int main(int argc, char *argv[])
int ref_levels = 0;
int order = 1;
int prob = 0;
double freq = -1.0;
double a_coef = 0.0;
real_t freq = -1.0;
real_t a_coef = 0.0;
bool visualization = 1;
bool herm_conv = true;
bool exact_sol = true;
@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
break; // This should be unreachable
}
}
double s = (prob != 1) ? 1.0 : -1.0;
real_t s = (prob != 1) ? 1.0 : -1.0;
pc_i = new ScaledOperator(pc_r,
(conv == ComplexOperator::HERMITIAN) ?
s:-s);
@@ -436,8 +436,8 @@ int main(int argc, char *argv[])
if (exact_sol)
{
double err_r = -1.0;
double err_i = -1.0;
real_t err_r = -1.0;
real_t err_i = -1.0;
switch (prob)
{
@@ -524,7 +524,7 @@ int main(int argc, char *argv[])
int i = 0;
while (sol_sock)
{
double t = (double)(i % num_frames) / num_frames;
real_t t = (real_t)(i % num_frames) / num_frames;
ostringstream oss;
oss << "Harmonic Solution (t = " << t << " T)";
@@ -555,21 +555,21 @@ bool check_for_inline_mesh(const char * mesh_file)
return s0 == "inline-";
}
complex<double> u0_exact(const Vector &x)
complex<real_t> u0_exact(const Vector &x)
{
int dim = x.Size();
complex<double> i(0.0, 1.0);
complex<double> alpha = (epsilon_ * omega_ - i * sigma_);
complex<double> kappa = std::sqrt(mu_ * omega_* alpha);
complex<real_t> i(0.0, 1.0);
complex<real_t> alpha = (epsilon_ * omega_ - i * sigma_);
complex<real_t> kappa = std::sqrt(mu_ * omega_* alpha);
return std::exp(-i * kappa * x[dim - 1]);
}
double u0_real_exact(const Vector &x)
real_t u0_real_exact(const Vector &x)
{
return u0_exact(x).real();
}
double u0_imag_exact(const Vector &x)
real_t u0_imag_exact(const Vector &x)
{
return u0_exact(x).imag();
}
+17 -17
View File
@@ -57,13 +57,13 @@
using namespace std;
using namespace mfem;
static double mu_ = 1.0;
static double epsilon_ = 1.0;
static double sigma_ = 20.0;
static double omega_ = 10.0;
static real_t mu_ = 1.0;
static real_t epsilon_ = 1.0;
static real_t sigma_ = 20.0;
static real_t omega_ = 10.0;
double u0_real_exact(const Vector &);
double u0_imag_exact(const Vector &);
real_t u0_real_exact(const Vector &);
real_t u0_imag_exact(const Vector &);
void u1_real_exact(const Vector &, Vector &);
void u1_imag_exact(const Vector &, Vector &);
@@ -87,8 +87,8 @@ int main(int argc, char *argv[])
int par_ref_levels = 1;
int order = 1;
int prob = 0;
double freq = -1.0;
double a_coef = 0.0;
real_t freq = -1.0;
real_t a_coef = 0.0;
bool visualization = 1;
bool herm_conv = true;
bool exact_sol = true;
@@ -475,8 +475,8 @@ int main(int argc, char *argv[])
if (exact_sol)
{
double err_r = -1.0;
double err_i = -1.0;
real_t err_r = -1.0;
real_t err_i = -1.0;
switch (prob)
{
@@ -576,7 +576,7 @@ int main(int argc, char *argv[])
int i = 0;
while (sol_sock)
{
double t = (double)(i % num_frames) / num_frames;
real_t t = (real_t)(i % num_frames) / num_frames;
ostringstream oss;
oss << "Harmonic Solution (t = " << t << " T)";
@@ -608,21 +608,21 @@ bool check_for_inline_mesh(const char * mesh_file)
return s0 == "inline-";
}
complex<double> u0_exact(const Vector &x)
complex<real_t> u0_exact(const Vector &x)
{
int dim = x.Size();
complex<double> i(0.0, 1.0);
complex<double> alpha = (epsilon_ * omega_ - i * sigma_);
complex<double> kappa = std::sqrt(mu_ * omega_* alpha);
complex<real_t> i(0.0, 1.0);
complex<real_t> alpha = (epsilon_ * omega_ - i * sigma_);
complex<real_t> kappa = std::sqrt(mu_ * omega_* alpha);
return std::exp(-i * kappa * x[dim - 1]);
}
double u0_real_exact(const Vector &x)
real_t u0_real_exact(const Vector &x)
{
return u0_exact(x).real();
}
double u0_imag_exact(const Vector &x)
real_t u0_imag_exact(const Vector &x)
{
return u0_exact(x).imag();
}
+19 -21
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.
*/
@@ -47,7 +46,7 @@ protected:
SparseMatrix Mmat, Kmat, Kmat0;
SparseMatrix *T; // T = M + dt K
double current_dt;
real_t current_dt;
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
DSmoother M_prec; // Preconditioner for the mass matrix M
@@ -59,7 +58,7 @@ protected:
mutable Vector z; // auxiliary vector
public:
WaveOperator(FiniteElementSpace &f, Array<int> &ess_bdr,double speed);
WaveOperator(FiniteElementSpace &f, Array<int> &ess_bdr, real_t speed);
using SecondOrderTimeDependentOperator::Mult;
virtual void Mult(const Vector &u, const Vector &du_dt,
@@ -69,7 +68,7 @@ public:
d2udt2 = f(u + fac0*d2udt2,dudt + fac1*d2udt2, t),
for the unknown d2udt2. */
using SecondOrderTimeDependentOperator::ImplicitSolve;
virtual void ImplicitSolve(const double fac0, const double fac1,
virtual void ImplicitSolve(const real_t fac0, const real_t fac1,
const Vector &u, const Vector &dudt, Vector &d2udt2);
///
@@ -80,12 +79,11 @@ public:
WaveOperator::WaveOperator(FiniteElementSpace &f,
Array<int> &ess_bdr, double speed)
: SecondOrderTimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL),
K(NULL),
T(NULL), current_dt(0.0), z(height)
Array<int> &ess_bdr, real_t speed)
: SecondOrderTimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0),
fespace(f), M(NULL), K(NULL), T(NULL), current_dt(0.0), z(height)
{
const double rel_tol = 1e-8;
const real_t rel_tol = 1e-8;
fespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
@@ -133,7 +131,7 @@ void WaveOperator::Mult(const Vector &u, const Vector &du_dt,
M_solver.Mult(z, d2udt2);
}
void WaveOperator::ImplicitSolve(const double fac0, const double fac1,
void WaveOperator::ImplicitSolve(const real_t fac0, const real_t fac1,
const Vector &u, const Vector &dudt, Vector &d2udt2)
{
// Solve the equation:
@@ -168,12 +166,12 @@ WaveOperator::~WaveOperator()
delete c2;
}
double InitialSolution(const Vector &x)
real_t InitialSolution(const Vector &x)
{
return exp(-x.Norml2()*x.Norml2()*30);
}
double InitialRate(const Vector &x)
real_t InitialRate(const Vector &x)
{
return 0.0;
}
@@ -187,9 +185,9 @@ int main(int argc, char *argv[])
int ref_levels = 2;
int order = 2;
int ode_solver_type = 10;
double t_final = 0.5;
double dt = 1.0e-2;
double speed = 1.0;
real_t t_final = 0.5;
real_t dt = 1.0e-2;
real_t speed = 1.0;
bool visualization = true;
bool visit = true;
bool dirichlet = true;
@@ -301,7 +299,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 +354,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."
@@ -367,7 +365,7 @@ int main(int argc, char *argv[])
// 8. Perform time-integration (looping over the time iterations, ti, with a
// time-step dt).
ode_solver->Init(oper);
double t = 0.0;
real_t t = 0.0;
bool last_step = false;
for (int ti = 1; !last_step; ti++)
+14 -14
View File
@@ -44,14 +44,14 @@
using namespace std;
using namespace mfem;
double p_exact(const Vector &x);
real_t p_exact(const Vector &x);
void gradp_exact(const Vector &, Vector &);
double div_gradp_exact(const Vector &x);
real_t div_gradp_exact(const Vector &x);
void v_exact(const Vector &x, Vector &v);
void curlv_exact(const Vector &x, Vector &cv);
int dim;
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int main(int argc, char *argv[])
{
@@ -304,9 +304,9 @@ int main(int argc, char *argv[])
// 12. Compute and print the L_2 norm of the error.
if (prob == 0)
{
double errSol = x.ComputeL2Error(gradp_coef);
double errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
double errProj = exact_proj.ComputeL2Error(gradp_coef);
real_t errSol = x.ComputeL2Error(gradp_coef);
real_t errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
real_t errProj = exact_proj.ComputeL2Error(gradp_coef);
cout << "\n Solution of (E_h,v) = (grad p_h,v) for E_h and v in H(curl): "
"|| E_h - grad p ||_{L_2} = " << errSol << '\n' << endl;
@@ -317,9 +317,9 @@ int main(int argc, char *argv[])
}
else if (prob == 1)
{
double errSol = x.ComputeL2Error(curlv_coef);
double errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
double errProj = exact_proj.ComputeL2Error(curlv_coef);
real_t errSol = x.ComputeL2Error(curlv_coef);
real_t errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
real_t errProj = exact_proj.ComputeL2Error(curlv_coef);
cout << "\n Solution of (E_h,w) = (curl v_h,w) for E_h and w in H(div): "
"|| E_h - curl v ||_{L_2} = " << errSol << '\n' << endl;
@@ -337,9 +337,9 @@ int main(int argc, char *argv[])
irs[i] = &(IntRules.Get(i, order_quad));
}
double errSol = x.ComputeL2Error(divgradp_coef, irs);
double errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
double errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
real_t errSol = x.ComputeL2Error(divgradp_coef, irs);
real_t errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
real_t errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
cout << "\n Solution of (f_h,q) = (div v_h,q) for f_h and q in L_2: "
"|| f_h - div v ||_{L_2} = " << errSol << '\n' << endl;
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
return 0;
}
double p_exact(const Vector &x)
real_t p_exact(const Vector &x)
{
if (dim == 3)
{
@@ -406,7 +406,7 @@ void gradp_exact(const Vector &x, Vector &f)
}
}
double div_gradp_exact(const Vector &x)
real_t div_gradp_exact(const Vector &x)
{
if (dim == 3)
{
+14 -14
View File
@@ -44,14 +44,14 @@
using namespace std;
using namespace mfem;
double p_exact(const Vector &x);
real_t p_exact(const Vector &x);
void gradp_exact(const Vector &, Vector &);
double div_gradp_exact(const Vector &x);
real_t div_gradp_exact(const Vector &x);
void v_exact(const Vector &x, Vector &v);
void curlv_exact(const Vector &x, Vector &cv);
int dim;
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int main(int argc, char *argv[])
{
@@ -352,9 +352,9 @@ int main(int argc, char *argv[])
// 14. Compute and print the L_2 norm of the error.
if (prob == 0)
{
double errSol = x.ComputeL2Error(gradp_coef);
double errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
double errProj = exact_proj.ComputeL2Error(gradp_coef);
real_t errSol = x.ComputeL2Error(gradp_coef);
real_t errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
real_t errProj = exact_proj.ComputeL2Error(gradp_coef);
if (myid == 0)
{
@@ -368,9 +368,9 @@ int main(int argc, char *argv[])
}
else if (prob == 1)
{
double errSol = x.ComputeL2Error(curlv_coef);
double errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
double errProj = exact_proj.ComputeL2Error(curlv_coef);
real_t errSol = x.ComputeL2Error(curlv_coef);
real_t errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
real_t errProj = exact_proj.ComputeL2Error(curlv_coef);
if (myid == 0)
{
@@ -391,9 +391,9 @@ int main(int argc, char *argv[])
irs[i] = &(IntRules.Get(i, order_quad));
}
double errSol = x.ComputeL2Error(divgradp_coef, irs);
double errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
double errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
real_t errSol = x.ComputeL2Error(divgradp_coef, irs);
real_t errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
real_t errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
if (myid == 0)
{
@@ -441,7 +441,7 @@ int main(int argc, char *argv[])
return 0;
}
double p_exact(const Vector &x)
real_t p_exact(const Vector &x)
{
if (dim == 3)
{
@@ -471,7 +471,7 @@ void gradp_exact(const Vector &x, Vector &f)
}
}
double div_gradp_exact(const Vector &x)
real_t div_gradp_exact(const Vector &x)
{
if (dim == 3)
{
+101 -101
View File
@@ -53,13 +53,13 @@ private:
int dim;
// Length of the PML Region in each direction
Array2D<double> length;
Array2D<real_t> length;
// Computational Domain Boundary
Array2D<double> comp_dom_bdr;
Array2D<real_t> comp_dom_bdr;
// Domain Boundary
Array2D<double> dom_bdr;
Array2D<real_t> dom_bdr;
// Integer Array identifying elements in the PML
// 0: in the PML, 1: not in the PML
@@ -70,13 +70,13 @@ private:
public:
// Constructor
PML(Mesh *mesh_,Array2D<double> length_);
PML(Mesh *mesh_,Array2D<real_t> length_);
// Return Computational Domain Boundary
Array2D<double> GetCompDomainBdr() {return comp_dom_bdr;}
Array2D<real_t> GetCompDomainBdr() {return comp_dom_bdr;}
// Return Domain Boundary
Array2D<double> GetDomainBdr() {return dom_bdr;}
Array2D<real_t> GetDomainBdr() {return dom_bdr;}
// Return Markers list for elements
Array<int> * GetMarkedPMLElements() {return &elems;}
@@ -85,7 +85,7 @@ public:
void SetAttributes(Mesh *mesh_);
// PML complex stretching function
void StretchFunction(const Vector &x, vector<complex<double>> &dxs);
void StretchFunction(const Vector &x, vector<complex<real_t>> &dxs);
};
// Class for returning the PML coefficients of the bilinear form
@@ -106,7 +106,7 @@ public:
virtual void Eval(Vector &K, ElementTransformation &T,
const IntegrationPoint &ip)
{
double x[3];
real_t x[3];
Vector transip(x, 3);
T.Transform(ip, transip);
K.SetSize(vdim);
@@ -114,7 +114,7 @@ public:
}
};
void maxwell_solution(const Vector &x, vector<complex<double>> &Eval);
void maxwell_solution(const Vector &x, vector<complex<real_t>> &Eval);
void E_bdr_data_Re(const Vector &x, Vector &E);
void E_bdr_data_Im(const Vector &x, Vector &E);
@@ -134,12 +134,12 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D);
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D);
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D);
Array2D<double> comp_domain_bdr;
Array2D<double> domain_bdr;
Array2D<real_t> comp_domain_bdr;
Array2D<real_t> domain_bdr;
double mu = 1.0;
double epsilon = 1.0;
double omega;
real_t mu = 1.0;
real_t epsilon = 1.0;
real_t omega;
int dim;
bool exact_known = false;
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
int order = 1;
int ref_levels = 3;
int iprob = 4;
double freq = 5.0;
real_t freq = 5.0;
bool herm_conv = true;
bool umf_solver = false;
bool visualization = 1;
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
omega = 2.0 * M_PI * freq;
// Setup PML length
Array2D<double> length(dim, 2); length = 0.0;
Array2D<real_t> length(dim, 2); length = 0.0;
// 4. Setup the Cartesian PML region.
switch (prob)
@@ -470,7 +470,7 @@ int main(int argc, char *argv[])
std::unique_ptr<Operator> pc_r;
std::unique_ptr<Operator> pc_i;
double s = (conv == ComplexOperator::HERMITIAN) ? -1.0 : 1.0;
real_t s = (conv == ComplexOperator::HERMITIAN) ? -1.0 : 1.0;
if (pa)
{
// Jacobi Smoother
@@ -519,14 +519,14 @@ int main(int argc, char *argv[])
irs[i] = &(IntRules.Get(i, order_quad));
}
double L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
real_t L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
pml->GetMarkedPMLElements());
double L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
real_t L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
pml->GetMarkedPMLElements());
ComplexGridFunction x_gf0(fespace);
x_gf0 = 0.0;
double norm_E_Re, norm_E_Im;
real_t norm_E_Re, norm_E_Im;
norm_E_Re = x_gf0.real().ComputeL2Error(E_ex_Re, irs,
pml->GetMarkedPMLElements());
norm_E_Im = x_gf0.imag().ComputeL2Error(E_ex_Im, irs,
@@ -593,7 +593,7 @@ int main(int argc, char *argv[])
int i = 0;
while (sol_sock)
{
double t = (double)(i % num_frames) / num_frames;
real_t t = (real_t)(i % num_frames) / num_frames;
ostringstream oss;
oss << "Harmonic Solution (t = " << t << " T)";
@@ -617,20 +617,20 @@ int main(int argc, char *argv[])
void source(const Vector &x, Vector &f)
{
Vector center(dim);
double r = 0.0;
real_t r = 0.0;
for (int i = 0; i < dim; ++i)
{
center(i) = 0.5 * (comp_domain_bdr(i, 0) + comp_domain_bdr(i, 1));
r += pow(x[i] - center[i], 2.);
}
double n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
double coeff = pow(n, 2) / M_PI;
double alpha = -pow(n, 2) * r;
real_t n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
real_t coeff = pow(n, 2) / M_PI;
real_t alpha = -pow(n, 2) * r;
f = 0.0;
f[0] = coeff * exp(alpha);
}
void maxwell_solution(const Vector &x, vector<complex<double>> &E)
void maxwell_solution(const Vector &x, vector<complex<real_t>> &E)
{
// Initialize
for (int i = 0; i < dim; ++i)
@@ -638,8 +638,8 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
E[i] = 0.0;
}
complex<double> zi = complex<double>(0., 1.);
double k = omega * sqrt(epsilon * mu);
complex<real_t> zi = complex<real_t>(0., 1.);
real_t k = omega * sqrt(epsilon * mu);
switch (prob)
{
case disc:
@@ -654,58 +654,58 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
if (dim == 2)
{
double x0 = x(0) + shift(0);
double x1 = x(1) + shift(1);
double r = sqrt(x0 * x0 + x1 * x1);
double beta = k * r;
real_t x0 = x(0) + shift(0);
real_t x1 = x(1) + shift(1);
real_t r = sqrt(x0 * x0 + x1 * x1);
real_t beta = k * r;
// Bessel functions
complex<double> Ho, Ho_r, Ho_rr;
Ho = jn(0, beta) + zi * yn(0, beta);
Ho_r = -k * (jn(1, beta) + zi * yn(1, beta));
Ho_rr = -k * k * (1.0 / beta *
(jn(1, beta) + zi * yn(1, beta)) -
(jn(2, beta) + zi * yn(2, beta)));
complex<real_t> Ho, Ho_r, Ho_rr;
Ho = jn(0, beta) + (complex<double>) zi * yn(0, beta);
Ho_r = -k * complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta));
Ho_rr = -k * k * (real_t(1) / beta *
complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta)) -
complex<real_t>(jn(2, beta) + (complex<double>) zi * yn(2, beta)));
// First derivatives
double r_x = x0 / r;
double r_y = x1 / r;
double r_xy = -(r_x / r) * r_y;
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
real_t r_x = x0 / r;
real_t r_y = x1 / r;
real_t r_xy = -(r_x / r) * r_y;
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
complex<double> val, val_xx, val_xy;
val = 0.25 * zi * Ho;
val_xx = 0.25 * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
val_xy = 0.25 * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
complex<real_t> val, val_xx, val_xy;
val = real_t(0.25) * zi * Ho;
val_xx = real_t(0.25) * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
val_xy = real_t(0.25) * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
E[0] = zi / k * (k * k * val + val_xx);
E[1] = zi / k * val_xy;
}
else if (dim == 3)
{
double x0 = x(0) + shift(0);
double x1 = x(1) + shift(1);
double x2 = x(2) + shift(2);
double r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
real_t x0 = x(0) + shift(0);
real_t x1 = x(1) + shift(1);
real_t x2 = x(2) + shift(2);
real_t r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
double r_x = x0 / r;
double r_y = x1 / r;
double r_z = x2 / r;
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
double r_yx = -(r_y / r) * r_x;
double r_zx = -(r_z / r) * r_x;
real_t r_x = x0 / r;
real_t r_y = x1 / r;
real_t r_z = x2 / r;
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
real_t r_yx = -(r_y / r) * r_x;
real_t r_zx = -(r_z / r) * r_x;
complex<double> val, val_r, val_rr;
complex<real_t> val, val_r, val_rr;
val = exp(zi * k * r) / r;
val_r = val / r * (zi * k * r - 1.0);
val_r = val / r * (zi * k * r - real_t(1));
val_rr = val / (r * r) * (-k * k * r * r
- 2.0 * zi * k * r + 2.0);
- real_t(2) * zi * k * r + real_t(2));
complex<double> val_xx, val_yx, val_zx;
complex<real_t> val_xx, val_yx, val_zx;
val_xx = val_rr * r_x * r_x + val_r * r_xx;
val_yx = val_rr * r_x * r_y + val_r * r_yx;
val_zx = val_rr * r_x * r_z + val_r * r_zx;
complex<double> alpha = zi * k / 4.0 / M_PI / k / k;
complex<real_t> alpha = zi * k / real_t(4) / (real_t) M_PI / k / k;
E[0] = alpha * (k * k * val + val_xx);
E[1] = alpha * val_yx;
E[2] = alpha * val_zx;
@@ -717,12 +717,12 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
// T_10 mode
if (dim == 3)
{
double k10 = sqrt(k * k - M_PI * M_PI);
E[1] = -zi * k / M_PI * sin(M_PI*x(2))*exp(zi * k10 * x(0));
real_t k10 = sqrt(k * k - M_PI * M_PI);
E[1] = -zi * k / (real_t) M_PI * sin((real_t) M_PI*x(2))*exp(zi * k10 * x(0));
}
else if (dim == 2)
{
E[1] = -zi * k / M_PI * exp(zi * k * x(0));
E[1] = -zi * k / (real_t) M_PI * exp(zi * k * x(0));
}
break;
}
@@ -733,7 +733,7 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
void E_exact_Re(const Vector &x, Vector &E)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -743,7 +743,7 @@ void E_exact_Re(const Vector &x, Vector &E)
void E_exact_Im(const Vector &x, Vector &E)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -768,7 +768,7 @@ void E_bdr_data_Re(const Vector &x, Vector &E)
}
if (!in_pml)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -795,7 +795,7 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
}
if (!in_pml)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -806,8 +806,8 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector &D)
{
vector<complex<double>> dxs(dim);
complex<double> det(1.0, 0.0);
vector<complex<real_t>> dxs(dim);
complex<real_t> det(1.0, 0.0);
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -817,14 +817,14 @@ void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector &D)
for (int i = 0; i < dim; ++i)
{
D(i) = (det / pow(dxs[i], 2)).real();
D(i) = (det / pow(dxs[i], real_t(2))).real();
}
}
void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector &D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -834,14 +834,14 @@ void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector &D)
for (int i = 0; i < dim; ++i)
{
D(i) = (det / pow(dxs[i], 2)).imag();
D(i) = (det / pow(dxs[i], real_t(2))).imag();
}
}
void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector &D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -851,14 +851,14 @@ void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector &D)
for (int i = 0; i < dim; ++i)
{
D(i) = abs(det / pow(dxs[i], 2));
D(i) = abs(det / pow(dxs[i], real_t(2)));
}
}
void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D)
{
vector<complex<double>> dxs(dim);
complex<double> det(1.0, 0.0);
vector<complex<real_t>> dxs(dim);
complex<real_t> det(1.0, 0.0);
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -869,21 +869,21 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D)
// in the 2D case the coefficient is scalar 1/det(J)
if (dim == 2)
{
D = (1.0 / det).real();
D = (real_t(1) / det).real();
}
else
{
for (int i = 0; i < dim; ++i)
{
D(i) = (pow(dxs[i], 2) / det).real();
D(i) = (pow(dxs[i], real_t(2)) / det).real();
}
}
}
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -893,21 +893,21 @@ void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D)
if (dim == 2)
{
D = (1.0 / det).imag();
D = (real_t(1) / det).imag();
}
else
{
for (int i = 0; i < dim; ++i)
{
D(i) = (pow(dxs[i], 2) / det).imag();
D(i) = (pow(dxs[i], real_t(2)) / det).imag();
}
}
}
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -917,18 +917,18 @@ void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D)
if (dim == 2)
{
D = abs(1.0 / det);
D = abs(real_t(1) / det);
}
else
{
for (int i = 0; i < dim; ++i)
{
D(i) = abs(pow(dxs[i], 2) / det);
D(i) = abs(pow(dxs[i], real_t(2)) / det);
}
}
}
PML::PML(Mesh *mesh_, Array2D<double> length_)
PML::PML(Mesh *mesh_, Array2D<real_t> length_)
: mesh(mesh_), length(length_)
{
dim = mesh->Dimension();
@@ -979,7 +979,7 @@ void PML::SetAttributes(Mesh *mesh_)
for (int iv = 0; iv < nrvert; ++iv)
{
int vert_idx = vertices[iv];
double *coords = mesh_->GetVertex(vert_idx);
real_t *coords = mesh_->GetVertex(vert_idx);
for (int comp = 0; comp < dim; ++comp)
{
if (coords[comp] > comp_dom_bdr(comp, 1) ||
@@ -1000,14 +1000,14 @@ void PML::SetAttributes(Mesh *mesh_)
}
void PML::StretchFunction(const Vector &x,
vector<complex<double>> &dxs)
vector<complex<real_t>> &dxs)
{
complex<double> zi = complex<double>(0., 1.);
complex<real_t> zi = complex<real_t>(0., 1.);
double n = 2.0;
double c = 5.0;
double coeff;
double k = omega * sqrt(epsilon * mu);
real_t n = 2.0;
real_t c = 5.0;
real_t coeff;
real_t k = omega * sqrt(epsilon * mu);
// Stretch in each direction independently
for (int i = 0; i < dim; ++i)
@@ -1016,14 +1016,14 @@ void PML::StretchFunction(const Vector &x,
if (x(i) >= comp_domain_bdr(i, 1))
{
coeff = n * c / k / pow(length(i, 1), n);
dxs[i] = 1.0 + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 1), n - 1.0));
dxs[i] = real_t(1) + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 1), n - real_t(1)));
}
if (x(i) <= comp_domain_bdr(i, 0))
{
coeff = n * c / k / pow(length(i, 0), n);
dxs[i] = 1.0 + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 0), n - 1.0));
dxs[i] = real_t(1) + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 0), n - real_t(1)));
}
}
}
+129 -104
View File
@@ -52,13 +52,13 @@ private:
int dim;
// Length of the PML Region in each direction
Array2D<double> length;
Array2D<real_t> length;
// Computational Domain Boundary
Array2D<double> comp_dom_bdr;
Array2D<real_t> comp_dom_bdr;
// Domain Boundary
Array2D<double> dom_bdr;
Array2D<real_t> dom_bdr;
// Integer Array identifying elements in the PML
// 0: in the PML, 1: not in the PML
@@ -69,13 +69,13 @@ private:
public:
// Constructor
PML(Mesh *mesh_,Array2D<double> length_);
PML(Mesh *mesh_,Array2D<real_t> length_);
// Return Computational Domain Boundary
Array2D<double> GetCompDomainBdr() {return comp_dom_bdr;}
Array2D<real_t> GetCompDomainBdr() {return comp_dom_bdr;}
// Return Domain Boundary
Array2D<double> GetDomainBdr() {return dom_bdr;}
Array2D<real_t> GetDomainBdr() {return dom_bdr;}
// Return Markers list for elements
Array<int> * GetMarkedPMLElements() {return &elems;}
@@ -84,7 +84,7 @@ public:
void SetAttributes(ParMesh *pmesh);
// PML complex stretching function
void StretchFunction(const Vector &x, vector<complex<double>> &dxs);
void StretchFunction(const Vector &x, vector<complex<real_t>> &dxs);
};
// Class for returning the PML coefficients of the bilinear form
@@ -105,7 +105,7 @@ public:
virtual void Eval(Vector &K, ElementTransformation &T,
const IntegrationPoint &ip)
{
double x[3];
real_t x[3];
Vector transip(x, 3);
T.Transform(ip, transip);
K.SetSize(vdim);
@@ -113,7 +113,7 @@ public:
}
};
void maxwell_solution(const Vector &x, vector<complex<double>> &Eval);
void maxwell_solution(const Vector &x, vector<complex<real_t>> &Eval);
void E_bdr_data_Re(const Vector &x, Vector &E);
void E_bdr_data_Im(const Vector &x, Vector &E);
@@ -133,12 +133,12 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D);
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D);
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D);
Array2D<double> comp_domain_bdr;
Array2D<double> domain_bdr;
Array2D<real_t> comp_domain_bdr;
Array2D<real_t> domain_bdr;
double mu = 1.0;
double epsilon = 1.0;
double omega;
real_t mu = 1.0;
real_t epsilon = 1.0;
real_t omega;
int dim;
bool exact_known = false;
@@ -166,10 +166,11 @@ int main(int argc, char *argv[])
int ref_levels = 1;
int par_ref_levels = 2;
int iprob = 4;
double freq = 5.0;
real_t freq = 5.0;
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; }
@@ -271,7 +278,7 @@ int main(int argc, char *argv[])
omega = 2.0 * M_PI * freq;
// Setup PML length
Array2D<double> length(dim, 2); length = 0.0;
Array2D<real_t> length(dim, 2); length = 0.0;
// 5. Setup the Cartesian PML region.
switch (prob)
@@ -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);
@@ -574,14 +599,14 @@ int main(int argc, char *argv[])
irs[i] = &(IntRules.Get(i, order_quad));
}
double L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
real_t L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
pml->GetMarkedPMLElements());
double L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
real_t L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
pml->GetMarkedPMLElements());
ParComplexGridFunction x_gf0(fespace);
x_gf0 = 0.0;
double norm_E_Re, norm_E_Im;
real_t norm_E_Re, norm_E_Im;
norm_E_Re = x_gf0.real().ComputeL2Error(E_ex_Re, irs,
pml->GetMarkedPMLElements());
norm_E_Im = x_gf0.imag().ComputeL2Error(E_ex_Im, irs,
@@ -669,7 +694,7 @@ int main(int argc, char *argv[])
int i = 0;
while (sol_sock)
{
double t = (double)(i % num_frames) / num_frames;
real_t t = (real_t)(i % num_frames) / num_frames;
ostringstream oss;
oss << "Harmonic Solution (t = " << t << " T)";
@@ -693,20 +718,20 @@ int main(int argc, char *argv[])
void source(const Vector &x, Vector &f)
{
Vector center(dim);
double r = 0.0;
real_t r = 0.0;
for (int i = 0; i < dim; ++i)
{
center(i) = 0.5 * (comp_domain_bdr(i, 0) + comp_domain_bdr(i, 1));
r += pow(x[i] - center[i], 2.);
}
double n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
double coeff = pow(n, 2) / M_PI;
double alpha = -pow(n, 2) * r;
real_t n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
real_t coeff = pow(n, 2) / M_PI;
real_t alpha = -pow(n, 2) * r;
f = 0.0;
f[0] = coeff * exp(alpha);
}
void maxwell_solution(const Vector &x, vector<complex<double>> &E)
void maxwell_solution(const Vector &x, vector<complex<real_t>> &E)
{
// Initialize
for (int i = 0; i < dim; ++i)
@@ -714,8 +739,8 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
E[i] = 0.0;
}
complex<double> zi = complex<double>(0., 1.);
double k = omega * sqrt(epsilon * mu);
complex<real_t> zi = complex<real_t>(0., 1.);
real_t k = omega * sqrt(epsilon * mu);
switch (prob)
{
case disc:
@@ -730,58 +755,58 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
if (dim == 2)
{
double x0 = x(0) + shift(0);
double x1 = x(1) + shift(1);
double r = sqrt(x0 * x0 + x1 * x1);
double beta = k * r;
real_t x0 = x(0) + shift(0);
real_t x1 = x(1) + shift(1);
real_t r = sqrt(x0 * x0 + x1 * x1);
real_t beta = k * r;
// Bessel functions
complex<double> Ho, Ho_r, Ho_rr;
Ho = jn(0, beta) + zi * yn(0, beta);
Ho_r = -k * (jn(1, beta) + zi * yn(1, beta));
Ho_rr = -k * k * (1.0 / beta *
(jn(1, beta) + zi * yn(1, beta)) -
(jn(2, beta) + zi * yn(2, beta)));
complex<real_t> Ho, Ho_r, Ho_rr;
Ho = jn(0, beta) + (complex<double>) zi * yn(0, beta);
Ho_r = -k * complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta));
Ho_rr = -k * k * complex<real_t>(1.0 / beta *
(jn(1, beta) + (complex<double>) zi * yn(1, beta)) -
(jn(2, beta) + (complex<double>) zi * yn(2, beta)));
// First derivatives
double r_x = x0 / r;
double r_y = x1 / r;
double r_xy = -(r_x / r) * r_y;
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
real_t r_x = x0 / r;
real_t r_y = x1 / r;
real_t r_xy = -(r_x / r) * r_y;
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
complex<double> val, val_xx, val_xy;
val = 0.25 * zi * Ho;
val_xx = 0.25 * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
val_xy = 0.25 * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
complex<real_t> val, val_xx, val_xy;
val = real_t(0.25) * zi * Ho;
val_xx = real_t(0.25) * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
val_xy = real_t(0.25) * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
E[0] = zi / k * (k * k * val + val_xx);
E[1] = zi / k * val_xy;
}
else if (dim == 3)
{
double x0 = x(0) + shift(0);
double x1 = x(1) + shift(1);
double x2 = x(2) + shift(2);
double r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
real_t x0 = x(0) + shift(0);
real_t x1 = x(1) + shift(1);
real_t x2 = x(2) + shift(2);
real_t r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
double r_x = x0 / r;
double r_y = x1 / r;
double r_z = x2 / r;
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
double r_yx = -(r_y / r) * r_x;
double r_zx = -(r_z / r) * r_x;
real_t r_x = x0 / r;
real_t r_y = x1 / r;
real_t r_z = x2 / r;
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
real_t r_yx = -(r_y / r) * r_x;
real_t r_zx = -(r_z / r) * r_x;
complex<double> val, val_r, val_rr;
complex<real_t> val, val_r, val_rr;
val = exp(zi * k * r) / r;
val_r = val / r * (zi * k * r - 1.0);
val_r = val / r * (zi * k * r - real_t(1));
val_rr = val / (r * r) * (-k * k * r * r
- 2.0 * zi * k * r + 2.0);
- real_t(2) * zi * k * r + real_t(2));
complex<double> val_xx, val_yx, val_zx;
complex<real_t> val_xx, val_yx, val_zx;
val_xx = val_rr * r_x * r_x + val_r * r_xx;
val_yx = val_rr * r_x * r_y + val_r * r_yx;
val_zx = val_rr * r_x * r_z + val_r * r_zx;
complex<double> alpha = zi * k / 4.0 / M_PI / k / k;
complex<real_t> alpha = zi * k / real_t(4) / (real_t) M_PI / k / k;
E[0] = alpha * (k * k * val + val_xx);
E[1] = alpha * val_yx;
E[2] = alpha * val_zx;
@@ -793,12 +818,12 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
// T_10 mode
if (dim == 3)
{
double k10 = sqrt(k * k - M_PI * M_PI);
E[1] = -zi * k / M_PI * sin(M_PI*x(2))*exp(zi * k10 * x(0));
real_t k10 = sqrt(k * k - M_PI * M_PI);
E[1] = -zi * k / (real_t) M_PI * sin((real_t) M_PI*x(2))*exp(zi * k10 * x(0));
}
else if (dim == 2)
{
E[1] = -zi * k / M_PI * exp(zi * k * x(0));
E[1] = -zi * k / (real_t) M_PI * exp(zi * k * x(0));
}
break;
}
@@ -809,7 +834,7 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
void E_exact_Re(const Vector &x, Vector &E)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -819,7 +844,7 @@ void E_exact_Re(const Vector &x, Vector &E)
void E_exact_Im(const Vector &x, Vector &E)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -844,7 +869,7 @@ void E_bdr_data_Re(const Vector &x, Vector &E)
}
if (!in_pml)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -871,7 +896,7 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
}
if (!in_pml)
{
vector<complex<double>> Eval(E.Size());
vector<complex<real_t>> Eval(E.Size());
maxwell_solution(x, Eval);
for (int i = 0; i < dim; ++i)
{
@@ -882,8 +907,8 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector & D)
{
vector<complex<double>> dxs(dim);
complex<double> det(1.0, 0.0);
vector<complex<real_t>> dxs(dim);
complex<real_t> det(1.0, 0.0);
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -893,14 +918,14 @@ void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector & D)
for (int i = 0; i < dim; ++i)
{
D(i) = (det / pow(dxs[i], 2)).real();
D(i) = (det / pow(dxs[i], real_t(2))).real();
}
}
void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector & D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -910,14 +935,14 @@ void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector & D)
for (int i = 0; i < dim; ++i)
{
D(i) = (det / pow(dxs[i], 2)).imag();
D(i) = (det / pow(dxs[i], real_t(2))).imag();
}
}
void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector & D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -927,14 +952,14 @@ void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector & D)
for (int i = 0; i < dim; ++i)
{
D(i) = abs(det / pow(dxs[i], 2));
D(i) = abs(det / pow(dxs[i], real_t(2)));
}
}
void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D)
{
vector<complex<double>> dxs(dim);
complex<double> det(1.0, 0.0);
vector<complex<real_t>> dxs(dim);
complex<real_t> det(1.0, 0.0);
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -945,21 +970,21 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D)
// in the 2D case the coefficient is scalar 1/det(J)
if (dim == 2)
{
D = (1.0 / det).real();
D = (real_t(1) / det).real();
}
else
{
for (int i = 0; i < dim; ++i)
{
D(i) = (pow(dxs[i], 2) / det).real();
D(i) = (pow(dxs[i], real_t(2)) / det).real();
}
}
}
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -969,21 +994,21 @@ void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D)
if (dim == 2)
{
D = (1.0 / det).imag();
D = (real_t(1) / det).imag();
}
else
{
for (int i = 0; i < dim; ++i)
{
D(i) = (pow(dxs[i], 2) / det).imag();
D(i) = (pow(dxs[i], real_t(2)) / det).imag();
}
}
}
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D)
{
vector<complex<double>> dxs(dim);
complex<double> det = 1.0;
vector<complex<real_t>> dxs(dim);
complex<real_t> det = 1.0;
pml->StretchFunction(x, dxs);
for (int i = 0; i < dim; ++i)
@@ -993,18 +1018,18 @@ void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D)
if (dim == 2)
{
D = abs(1.0 / det);
D = abs(real_t(1) / det);
}
else
{
for (int i = 0; i < dim; ++i)
{
D(i) = abs(pow(dxs[i], 2) / det);
D(i) = abs(pow(dxs[i], real_t(2)) / det);
}
}
}
PML::PML(Mesh *mesh_, Array2D<double> length_)
PML::PML(Mesh *mesh_, Array2D<real_t> length_)
: mesh(mesh_), length(length_)
{
dim = mesh->Dimension();
@@ -1056,7 +1081,7 @@ void PML::SetAttributes(ParMesh *pmesh)
for (int iv = 0; iv < nrvert; ++iv)
{
int vert_idx = vertices[iv];
double *coords = pmesh->GetVertex(vert_idx);
real_t *coords = pmesh->GetVertex(vert_idx);
for (int comp = 0; comp < dim; ++comp)
{
if (coords[comp] > comp_dom_bdr(comp, 1) ||
@@ -1077,14 +1102,14 @@ void PML::SetAttributes(ParMesh *pmesh)
}
void PML::StretchFunction(const Vector &x,
vector<complex<double>> &dxs)
vector<complex<real_t>> &dxs)
{
complex<double> zi = complex<double>(0., 1.);
complex<real_t> zi = complex<real_t>(0., 1.);
double n = 2.0;
double c = 5.0;
double coeff;
double k = omega * sqrt(epsilon * mu);
real_t n = 2.0;
real_t c = 5.0;
real_t coeff;
real_t k = omega * sqrt(epsilon * mu);
// Stretch in each direction independently
for (int i = 0; i < dim; ++i)
@@ -1093,14 +1118,14 @@ void PML::StretchFunction(const Vector &x,
if (x(i) >= comp_domain_bdr(i, 1))
{
coeff = n * c / k / pow(length(i, 1), n);
dxs[i] = 1.0 + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 1), n - 1.0));
dxs[i] = real_t(1) + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 1), n - real_t(1)));
}
if (x(i) <= comp_domain_bdr(i, 0))
{
coeff = n * c / k / pow(length(i, 0), n);
dxs[i] = 1.0 + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 0), n - 1.0));
dxs[i] = real_t(1) + zi * coeff *
abs(pow(x(i) - comp_domain_bdr(i, 0), n - real_t(1)));
}
}
}
+32 -32
View File
@@ -63,7 +63,7 @@
using namespace std;
using namespace mfem;
static double a_ = 0.2;
static real_t a_ = 0.2;
// Normal to hole with boundary attribute 4
void n4Vec(const Vector &x, Vector &n) { n = x; n[0] -= 0.5; n /= -n.Norml2(); }
@@ -73,25 +73,25 @@ Mesh * GenerateSerialMesh(int ref);
// Compute the average value of alpha*n.Grad(sol) + beta*sol over the boundary
// attributes marked in bdr_marker. Also computes the L2 norm of
// alpha*n.Grad(sol) + beta*sol - gamma over the same boundary.
double IntegrateBC(const GridFunction &sol, const Array<int> &bdr_marker,
double alpha, double beta, double gamma,
double &error);
real_t IntegrateBC(const GridFunction &sol, const Array<int> &bdr_marker,
real_t alpha, real_t beta, real_t gamma,
real_t &error);
int main(int argc, char *argv[])
{
// 1. Parse command-line options.
int ser_ref_levels = 2;
int order = 1;
double sigma = -1.0;
double kappa = -1.0;
real_t sigma = -1.0;
real_t kappa = -1.0;
bool h1 = true;
bool visualization = true;
double mat_val = 1.0;
double dbc_val = 0.0;
double nbc_val = 1.0;
double rbc_a_val = 1.0; // du/dn + a * u = b
double rbc_b_val = 1.0;
real_t mat_val = 1.0;
real_t dbc_val = 0.0;
real_t nbc_val = 1.0;
real_t rbc_a_val = 1.0; // du/dn + a * u = b
real_t rbc_b_val = 1.0;
OptionsParser args(argc, argv);
args.AddOption(&h1, "-h1", "--continuous", "-dg", "--discontinuous",
@@ -302,7 +302,7 @@ int main(int argc, char *argv[])
{
// Integrate the solution on the Dirichlet boundary and compare to the
// expected value.
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
real_t error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
bool hom_dbc = (dbc_val == 0.0);
error /= hom_dbc ? 1.0 : fabs(dbc_val);
@@ -314,7 +314,7 @@ int main(int argc, char *argv[])
{
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
// to the expected value.
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
real_t error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
bool hom_nbc = (nbc_val == 0.0);
error /= hom_nbc ? 1.0 : fabs(nbc_val);
@@ -330,7 +330,7 @@ int main(int argc, char *argv[])
nbc0_bdr = 0;
nbc0_bdr[3] = 1;
double error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
real_t error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
bool hom_nbc = true;
mfem::out << "Average of n.Grad(u) on Gamma_nbc0:\t"
@@ -341,8 +341,8 @@ int main(int argc, char *argv[])
{
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
// expected value.
double error;
double avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
real_t error;
real_t avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
bool hom_rbc = (rbc_b_val == 0.0);
error /= hom_rbc ? 1.0 : fabs(rbc_b_val);
@@ -383,22 +383,22 @@ int main(int argc, char *argv[])
return 0;
}
void quad_trans(double u, double v, double &x, double &y, bool log = false)
void quad_trans(real_t u, real_t v, real_t &x, real_t &y, bool log = false)
{
double a = a_; // Radius of disc
real_t a = a_; // Radius of disc
double d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
real_t d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
double v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
real_t v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
((4.0 - 3 * M_SQRT2) * a +
(8.0 * (M_SQRT2 - 1.0) * a - 2.0) * v) / d;
double r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
real_t r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
2.0 * (1.0 + M_SQRT2 *
(1.0 + 2.0 * (2.0 * a - M_SQRT2 - 1.0) * a)) * v * v
) / d;
double t = asin(v / r) * u / v;
real_t t = asin(v / r) * u / v;
if (log)
{
mfem::out << "u, v, r, v0, t "
@@ -411,7 +411,7 @@ void quad_trans(double u, double v, double &x, double &y, bool log = false)
void trans(const Vector &u, Vector &x)
{
double tol = 1e-4;
real_t tol = 1e-4;
if (u[1] > 0.5 - tol || u[1] < -0.5 + tol)
{
@@ -542,8 +542,8 @@ Mesh * GenerateSerialMesh(int ref)
vi[0] = o + 3; vi[1] = o + 4; mesh->AddBdrSegment(vi, 3 + i);
}
double d[2];
double a = a_ / M_SQRT2;
real_t d[2];
real_t a = a_ / M_SQRT2;
d[0] = -1.0; d[1] = -0.5; mesh->AddVertex(d);
d[0] = -1.0; d[1] = 0.0; mesh->AddVertex(d);
@@ -636,12 +636,12 @@ Mesh * GenerateSerialMesh(int ref)
return mesh;
}
double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
double alpha, double beta, double gamma,
double &error)
real_t IntegrateBC(const GridFunction &x, const Array<int> &bdr,
real_t alpha, real_t beta, real_t gamma,
real_t &error)
{
double nrm = 0.0;
double avg = 0.0;
real_t nrm = 0.0;
real_t avg = 0.0;
error = 0.0;
const bool a_is_zero = alpha == 0.0;
@@ -683,8 +683,8 @@ double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
IntegrationPoint eip;
FTr->Loc1.Transform(ip, eip);
FTr->Face->SetIntPoint(&ip);
double face_weight = FTr->Face->Weight();
double val = 0.0;
real_t face_weight = FTr->Face->Weight();
real_t val = 0.0;
if (!a_is_zero)
{
FTr->Elem1->SetIntPoint(&eip);
+38 -37
View File
@@ -63,7 +63,7 @@
using namespace std;
using namespace mfem;
static double a_ = 0.2;
static real_t a_ = 0.2;
// Normal to hole with boundary attribute 4
void n4Vec(const Vector &x, Vector &n) { n = x; n[0] -= 0.5; n /= -n.Norml2(); }
@@ -73,9 +73,9 @@ Mesh * GenerateSerialMesh(int ref);
// Compute the average value of alpha*n.Grad(sol) + beta*sol over the boundary
// attributes marked in bdr_marker. Also computes the L2 norm of
// alpha*n.Grad(sol) + beta*sol - gamma over the same boundary.
double IntegrateBC(const ParGridFunction &sol, const Array<int> &bdr_marker,
double alpha, double beta, double gamma,
double &error);
real_t IntegrateBC(const ParGridFunction &sol, const Array<int> &bdr_marker,
real_t alpha, real_t beta, real_t gamma,
real_t &error);
int main(int argc, char *argv[])
{
@@ -88,16 +88,16 @@ int main(int argc, char *argv[])
int ser_ref_levels = 2;
int par_ref_levels = 1;
int order = 1;
double sigma = -1.0;
double kappa = -1.0;
real_t sigma = -1.0;
real_t kappa = -1.0;
bool h1 = true;
bool visualization = true;
double mat_val = 1.0;
double dbc_val = 0.0;
double nbc_val = 1.0;
double rbc_a_val = 1.0; // du/dn + a * u = b
double rbc_b_val = 1.0;
real_t mat_val = 1.0;
real_t dbc_val = 0.0;
real_t nbc_val = 1.0;
real_t rbc_a_val = 1.0; // du/dn + a * u = b
real_t rbc_b_val = 1.0;
OptionsParser args(argc, argv);
args.AddOption(&h1, "-h1", "--continuous", "-dg", "--discontinuous",
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
{
// Integrate the solution on the Dirichlet boundary and compare to the
// expected value.
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
real_t error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
bool hom_dbc = (dbc_val == 0.0);
error /= hom_dbc ? 1.0 : fabs(dbc_val);
@@ -334,7 +334,7 @@ int main(int argc, char *argv[])
{
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
// to the expected value.
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
real_t error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
bool hom_nbc = (nbc_val == 0.0);
error /= hom_nbc ? 1.0 : fabs(nbc_val);
@@ -350,7 +350,7 @@ int main(int argc, char *argv[])
nbc0_bdr = 0;
nbc0_bdr[3] = 1;
double error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
real_t error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
bool hom_nbc = true;
mfem::out << "Average of n.Grad(u) on Gamma_nbc0:\t"
@@ -361,7 +361,7 @@ int main(int argc, char *argv[])
{
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
// expected value.
double error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
real_t error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
error);
bool hom_rbc = (rbc_b_val == 0.0);
@@ -409,22 +409,22 @@ int main(int argc, char *argv[])
return 0;
}
void quad_trans(double u, double v, double &x, double &y, bool log = false)
void quad_trans(real_t u, real_t v, real_t &x, real_t &y, bool log = false)
{
double a = a_; // Radius of disc
real_t a = a_; // Radius of disc
double d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
real_t d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
double v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
real_t v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
((4.0 - 3 * M_SQRT2) * a +
(8.0 * (M_SQRT2 - 1.0) * a - 2.0) * v) / d;
double r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
real_t r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
2.0 * (1.0 + M_SQRT2 *
(1.0 + 2.0 * (2.0 * a - M_SQRT2 - 1.0) * a)) * v * v
) / d;
double t = asin(v / r) * u / v;
real_t t = asin(v / r) * u / v;
if (log)
{
mfem::out << "u, v, r, v0, t "
@@ -437,7 +437,7 @@ void quad_trans(double u, double v, double &x, double &y, bool log = false)
void trans(const Vector &u, Vector &x)
{
double tol = 1e-4;
real_t tol = 1e-4;
if (u[1] > 0.5 - tol || u[1] < -0.5 + tol)
{
@@ -568,8 +568,8 @@ Mesh * GenerateSerialMesh(int ref)
vi[0] = o + 3; vi[1] = o + 4; mesh->AddBdrSegment(vi, 3 + i);
}
double d[2];
double a = a_ / M_SQRT2;
real_t d[2];
real_t a = a_ / M_SQRT2;
d[0] = -1.0; d[1] = -0.5; mesh->AddVertex(d);
d[0] = -1.0; d[1] = 0.0; mesh->AddVertex(d);
@@ -662,14 +662,14 @@ Mesh * GenerateSerialMesh(int ref)
return mesh;
}
double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
double alpha, double beta, double gamma,
double &glb_err)
real_t IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
real_t alpha, real_t beta, real_t gamma,
real_t &glb_err)
{
double loc_vals[3];
double &nrm = loc_vals[0];
double &avg = loc_vals[1];
double &error = loc_vals[2];
real_t loc_vals[3];
real_t &nrm = loc_vals[0];
real_t &avg = loc_vals[1];
real_t &error = loc_vals[2];
nrm = 0.0;
avg = 0.0;
@@ -714,8 +714,8 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
IntegrationPoint eip;
FTr->Loc1.Transform(ip, eip);
FTr->Face->SetIntPoint(&ip);
double face_weight = FTr->Face->Weight();
double val = 0.0;
real_t face_weight = FTr->Face->Weight();
real_t val = 0.0;
if (!a_is_zero)
{
FTr->Elem1->SetIntPoint(&eip);
@@ -741,11 +741,12 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
}
}
double glb_vals[3];
MPI_Allreduce(loc_vals, glb_vals, 3, MPI_DOUBLE, MPI_SUM, fes.GetComm());
real_t glb_vals[3];
MPI_Allreduce(loc_vals, glb_vals, 3, MPITypeMap<real_t>::mpi_type,
MPI_SUM, fes.GetComm());
double glb_nrm = glb_vals[0];
double glb_avg = glb_vals[1];
real_t glb_nrm = glb_vals[0];
real_t glb_avg = glb_vals[1];
glb_err = glb_vals[2];
// Normalize by the length of the boundary
+3 -3
View File
@@ -35,7 +35,7 @@ using namespace mfem;
// Return a mesh with a single element with vertices (0, 0), (1, 0), (1, 1),
// (offset, 1) to demonstrate boundary conditions on a surface that is not
// axis-aligned.
Mesh * build_trapezoid_mesh(double offset)
Mesh * build_trapezoid_mesh(real_t offset)
{
MFEM_VERIFY(offset < 0.9, "offset is too large!");
@@ -45,7 +45,7 @@ Mesh * build_trapezoid_mesh(double offset)
Mesh * mesh = new Mesh(dimension, nvt, 1, nbe);
// vertices
double vc[dimension];
real_t vc[dimension];
vc[0] = 0.0; vc[1] = 0.0;
mesh->AddVertex(vc);
vc[0] = 1.0; vc[1] = 0.0;
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
// 1. Parse command-line options.
int order = 1;
bool visualization = 1;
double offset = 0.3;
real_t offset = 0.3;
bool visit = false;
OptionsParser args(argc, argv);
+4 -4
View File
@@ -38,7 +38,7 @@ using namespace mfem;
// Return a mesh with a single element with vertices (0, 0), (1, 0), (1, 1),
// (offset, 1) to demonstrate boundary conditions on a surface that is not
// axis-aligned.
Mesh * build_trapezoid_mesh(double offset)
Mesh * build_trapezoid_mesh(real_t offset)
{
MFEM_VERIFY(offset < 0.9, "offset is too large!");
@@ -48,7 +48,7 @@ Mesh * build_trapezoid_mesh(double offset)
Mesh * mesh = new Mesh(dimension, nvt, 1, nbe);
// vertices
double vc[dimension];
real_t vc[dimension];
vc[0] = 0.0; vc[1] = 0.0;
mesh->AddVertex(vc);
vc[0] = 1.0; vc[1] = 0.0;
@@ -97,9 +97,9 @@ int main(int argc, char *argv[])
int order = 1;
bool visualization = 1;
bool reorder_space = false;
double offset = 0.3;
real_t offset = 0.3;
bool visit = false;
double penalty = 0.0;
real_t penalty = 0.0;
OptionsParser args(argc, argv);
args.AddOption(&order, "-o", "--order",
+6 -6
View File
@@ -34,7 +34,7 @@ void trans(const Vector &x, Vector &r);
void sigmaFunc(const Vector &x, DenseMatrix &s);
double uExact(const Vector &x)
real_t uExact(const Vector &x)
{
return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
}
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
// 13. Compute error in the solution and its flux
FunctionCoefficient uCoef(uExact);
double error = x.ComputeL2Error(uCoef);
real_t error = x.ComputeL2Error(uCoef);
cout << "|u - u_h|_2 = " << error << endl;
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
x.ComputeFlux(*integ, flux); flux *= -1.0;
VectorFunctionCoefficient fluxCoef(3, fluxExact);
double flux_err = flux.ComputeL2Error(fluxCoef);
real_t flux_err = flux.ComputeL2Error(fluxCoef);
cout << "|f - f_h|_2 = " << flux_err << endl;
@@ -304,8 +304,8 @@ void trans(const Vector &x, Vector &r)
{
r.SetSize(3);
double tol = 1e-6;
double theta = 0.0;
real_t tol = 1e-6;
real_t theta = 0.0;
if (fabs(x[1] + 1.0) < tol)
{
theta = 0.25 * M_PI * (x[0] - 2.0);
@@ -337,7 +337,7 @@ void trans(const Vector &x, Vector &r)
void sigmaFunc(const Vector &x, DenseMatrix &s)
{
s.SetSize(3);
double a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
s(0,0) = 0.5 + x[0] * x[0] * (8.0 / a - 0.5);
s(0,1) = x[0] * x[1] * (8.0 / a - 0.5);
s(0,2) = 0.0;
+6 -6
View File
@@ -34,7 +34,7 @@ void trans(const Vector &x, Vector &r);
void sigmaFunc(const Vector &x, DenseMatrix &s);
double uExact(const Vector &x)
real_t uExact(const Vector &x)
{
return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
}
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
// 15. Compute error in the solution and its flux
FunctionCoefficient uCoef(uExact);
double error = x.ComputeL2Error(uCoef);
real_t error = x.ComputeL2Error(uCoef);
if (myid == 0) { cout << "|u - u_h|_2 = " << error << endl; }
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
x.ComputeFlux(*integ, flux); flux *= -1.0;
VectorFunctionCoefficient fluxCoef(3, fluxExact);
double flux_err = flux.ComputeL2Error(fluxCoef);
real_t flux_err = flux.ComputeL2Error(fluxCoef);
if (myid == 0) { cout << "|f - f_h|_2 = " << flux_err << endl; }
@@ -349,8 +349,8 @@ void trans(const Vector &x, Vector &r)
{
r.SetSize(3);
double tol = 1e-6;
double theta = 0.0;
real_t tol = 1e-6;
real_t theta = 0.0;
if (fabs(x[1] + 1.0) < tol)
{
theta = 0.25 * M_PI * (x[0] - 2.0);
@@ -382,7 +382,7 @@ void trans(const Vector &x, Vector &r)
void sigmaFunc(const Vector &x, DenseMatrix &s)
{
s.SetSize(3);
double a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
s(0,0) = 0.5 + x[0] * x[0] * (8.0 / a - 0.5);
s(0,1) = x[0] * x[1] * (8.0 / a - 0.5);
s(0,2) = 0.0;
+1 -1
View File
@@ -53,7 +53,7 @@ using namespace mfem;
// Exact solution, E, and r.h.s., f. See below for implementation.
void E_exact(const Vector &, Vector &);
void f_exact(const Vector &, Vector &);
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int dim;
int main(int argc, char *argv[])
+14 -14
View File
@@ -42,9 +42,9 @@ using namespace std;
using namespace mfem;
// Piecewise-affine function which is sometimes mesh-conforming
double affine_function(const Vector &p)
real_t affine_function(const Vector &p)
{
double x = p(0), y = p(1);
real_t x = p(0), y = p(1);
if (x < 0.0)
{
return 1.0 + x + y;
@@ -56,7 +56,7 @@ double affine_function(const Vector &p)
}
// Piecewise-constant function which is never mesh-conforming
double jump_function(const Vector &p)
real_t jump_function(const Vector &p)
{
if (p.Normlp(2.0) > 0.4 && p.Normlp(2.0) < 0.6)
{
@@ -70,17 +70,17 @@ double jump_function(const Vector &p)
// Singular function derived from the Laplacian of the "steep wavefront" problem
// in [2].
double singular_function(const Vector &p)
real_t singular_function(const Vector &p)
{
double x = p(0), y = p(1);
double alpha = 1000.0;
double xc = 0.75, yc = 0.5;
double r0 = 0.7;
double r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
double num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
double denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
real_t x = p(0), y = p(1);
real_t alpha = 1000.0;
real_t xc = 0.75, yc = 0.5;
real_t r0 = 0.7;
real_t r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
real_t num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
real_t denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
- 2 * pow(alpha,2) * r0 * r + 1.0 ),2);
denom = max(denom,1e-8);
denom = std::max(denom, (real_t) 1.0e-8);
return num / denom;
}
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
int order = 1;
int nc_limit = 1;
int max_elems = 100*1000;
double double_max_elems = double(max_elems);
real_t double_max_elems = real_t(max_elems);
bool visualization = true;
double osc_threshold = 1e-3;
real_t osc_threshold = 1e-3;
int enriched_order = 5;
OptionsParser args(argc, argv);
+15 -15
View File
@@ -42,9 +42,9 @@ using namespace std;
using namespace mfem;
// Piecewise-affine function which is sometimes mesh-conforming
double affine_function(const Vector &p)
real_t affine_function(const Vector &p)
{
double x = p(0), y = p(1);
real_t x = p(0), y = p(1);
if (x < 0.0)
{
return 1.0 + x + y;
@@ -56,7 +56,7 @@ double affine_function(const Vector &p)
}
// Piecewise-constant function which is never mesh-conforming
double jump_function(const Vector &p)
real_t jump_function(const Vector &p)
{
if (p.Normlp(2.0) > 0.4 && p.Normlp(2.0) < 0.6)
{
@@ -70,17 +70,17 @@ double jump_function(const Vector &p)
// Singular function derived from the Laplacian of the "steep wavefront" problem
// in [2].
double singular_function(const Vector &p)
real_t singular_function(const Vector &p)
{
double x = p(0), y = p(1);
double alpha = 1000.0;
double xc = 0.75, yc = 0.5;
double r0 = 0.7;
double r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
double num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
double denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
real_t x = p(0), y = p(1);
real_t alpha = 1000.0;
real_t xc = 0.75, yc = 0.5;
real_t r0 = 0.7;
real_t r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
real_t num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
real_t denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
- 2 * pow(alpha,2) * r0 * r + 1.0 ),2);
denom = max(denom,1e-8);
denom = std::max(denom, (real_t) 1.0e-8);
return num / denom;
}
@@ -97,10 +97,10 @@ int main(int argc, char *argv[])
int order = 1;
int nc_limit = 1;
int max_elems = 1e5;
double double_max_elems = double(max_elems);
real_t double_max_elems = real_t(max_elems);
bool visualization = true;
bool nc_simplices = true;
double osc_threshold = 1e-3;
real_t osc_threshold = 1e-3;
int enriched_order = 5;
OptionsParser args(argc, argv);
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
coeffrefiner.PreprocessMesh(pmesh);
int globalNE = pmesh.GetGlobalNE();
double osc = coeffrefiner.GetOsc();
real_t osc = coeffrefiner.GetOsc();
if (myid == 0)
{
mfem::out << "\n";
+28 -28
View File
@@ -39,7 +39,7 @@ using namespace mfem;
void E_exact(const Vector &, Vector &);
void CurlE_exact(const Vector &, Vector &);
void f_exact(const Vector &, Vector &);
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int dim;
int main(int argc, char *argv[])
@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
// 13. Compute and print the H(Curl) norm of the error.
{
double error = sol.ComputeHCurlError(&E, &CurlE);
real_t error = sol.ComputeHCurlError(&E, &CurlE);
cout << "\n|| E_h - E ||_{H(Curl)} = " << error << '\n' << endl;
}
@@ -376,8 +376,8 @@ void CurlE_exact(const Vector &x, Vector &dE)
{
if (dim == 1)
{
double c4 = cos(kappa * x(0) + 0.4 * M_PI);
double c9 = cos(kappa * x(0) + 0.9 * M_PI);
real_t c4 = cos(kappa * x(0) + 0.4 * M_PI);
real_t c9 = cos(kappa * x(0) + 0.9 * M_PI);
dE(0) = 0.0;
dE(1) = -1.3 * c9;
@@ -386,9 +386,9 @@ void CurlE_exact(const Vector &x, Vector &dE)
}
else if (dim == 2)
{
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
dE(0) = 1.3 * c9;
dE(1) = -1.3 * c9;
@@ -397,13 +397,13 @@ void CurlE_exact(const Vector &x, Vector &dE)
}
else
{
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
double sk = sin(kappa * x(2));
double ck = cos(kappa * x(2));
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t sk = sin(kappa * x(2));
real_t ck = cos(kappa * x(2));
dE(0) = 1.2 * s4 * sk + 1.3 * M_SQRT1_2 * c9 * ck;
dE(1) = -1.1 * s0 * sk - 1.3 * M_SQRT1_2 * c9 * ck;
@@ -416,9 +416,9 @@ void f_exact(const Vector &x, Vector &f)
{
if (dim == 1)
{
double s0 = sin(kappa * x(0) + 0.0 * M_PI);
double s4 = sin(kappa * x(0) + 0.4 * M_PI);
double s9 = sin(kappa * x(0) + 0.9 * M_PI);
real_t s0 = sin(kappa * x(0) + 0.0 * M_PI);
real_t s4 = sin(kappa * x(0) + 0.4 * M_PI);
real_t s9 = sin(kappa * x(0) + 0.9 * M_PI);
f(0) = 2.2 * s0 + 1.2 * M_SQRT1_2 * s4;
f(1) = 1.2 * (2.0 + kappa * kappa) * s4 +
@@ -427,9 +427,9 @@ void f_exact(const Vector &x, Vector &f)
}
else if (dim == 2)
{
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
f(0) = 0.55 * (4.0 + kappa * kappa) * s0 +
0.6 * (M_SQRT2 - kappa * kappa) * s4;
@@ -440,14 +440,14 @@ void f_exact(const Vector &x, Vector &f)
}
else
{
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
double sk = sin(kappa * x(2));
double ck = cos(kappa * x(2));
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t sk = sin(kappa * x(2));
real_t ck = cos(kappa * x(2));
f(0) = 0.55 * (4.0 + 3.0 * kappa * kappa) * s0 * ck +
0.6 * (M_SQRT2 - kappa * kappa) * s4 * ck -
+28 -28
View File
@@ -39,7 +39,7 @@ using namespace mfem;
void E_exact(const Vector &, Vector &);
void CurlE_exact(const Vector &, Vector &);
void f_exact(const Vector &, Vector &);
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int dim;
int main(int argc, char *argv[])
@@ -224,7 +224,7 @@ int main(int argc, char *argv[])
// 14. Compute and print the H(Curl) norm of the error.
{
double error = sol.ComputeHCurlError(&E, &CurlE);
real_t error = sol.ComputeHCurlError(&E, &CurlE);
if (Mpi::Root())
{
cout << "\n|| E_h - E ||_{H(Curl)} = " << error << '\n' << endl;
@@ -442,8 +442,8 @@ void CurlE_exact(const Vector &x, Vector &dE)
{
if (dim == 1)
{
double c4 = cos(kappa * x(0) + 0.4 * M_PI);
double c9 = cos(kappa * x(0) + 0.9 * M_PI);
real_t c4 = cos(kappa * x(0) + 0.4 * M_PI);
real_t c9 = cos(kappa * x(0) + 0.9 * M_PI);
dE(0) = 0.0;
dE(1) = -1.3 * c9;
@@ -452,9 +452,9 @@ void CurlE_exact(const Vector &x, Vector &dE)
}
else if (dim == 2)
{
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
dE(0) = 1.3 * c9;
dE(1) = -1.3 * c9;
@@ -463,13 +463,13 @@ void CurlE_exact(const Vector &x, Vector &dE)
}
else
{
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
double sk = sin(kappa * x(2));
double ck = cos(kappa * x(2));
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t sk = sin(kappa * x(2));
real_t ck = cos(kappa * x(2));
dE(0) = 1.2 * s4 * sk + 1.3 * M_SQRT1_2 * c9 * ck;
dE(1) = -1.1 * s0 * sk - 1.3 * M_SQRT1_2 * c9 * ck;
@@ -482,9 +482,9 @@ void f_exact(const Vector &x, Vector &f)
{
if (dim == 1)
{
double s0 = sin(kappa * x(0) + 0.0 * M_PI);
double s4 = sin(kappa * x(0) + 0.4 * M_PI);
double s9 = sin(kappa * x(0) + 0.9 * M_PI);
real_t s0 = sin(kappa * x(0) + 0.0 * M_PI);
real_t s4 = sin(kappa * x(0) + 0.4 * M_PI);
real_t s9 = sin(kappa * x(0) + 0.9 * M_PI);
f(0) = 2.2 * s0 + 1.2 * M_SQRT1_2 * s4;
f(1) = 1.2 * (2.0 + kappa * kappa) * s4 +
@@ -493,9 +493,9 @@ void f_exact(const Vector &x, Vector &f)
}
else if (dim == 2)
{
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
f(0) = 0.55 * (4.0 + kappa * kappa) * s0 +
0.6 * (M_SQRT2 - kappa * kappa) * s4;
@@ -506,14 +506,14 @@ void f_exact(const Vector &x, Vector &f)
}
else
{
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
double sk = sin(kappa * x(2));
double ck = cos(kappa * x(2));
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
real_t sk = sin(kappa * x(2));
real_t ck = cos(kappa * x(2));
f(0) = 0.55 * (4.0 + 3.0 * kappa * kappa) * s0 * ck +
0.6 * (M_SQRT2 - kappa * kappa) * s4 * ck -
+18 -18
View File
@@ -35,8 +35,8 @@
using namespace std;
using namespace mfem;
double GetVectorMax(int vdim, const ParGridFunction &x);
double GetScalarMax(const ParGridFunction &x);
real_t GetVectorMax(int vdim, const ParGridFunction &x);
real_t GetScalarMax(const ParGridFunction &x);
int main(int argc, char *argv[])
{
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
// extract the corresponding parallel matrices A and M.
HypreParMatrix *A = NULL;
HypreParMatrix *M = NULL;
double shift = 0.0;
real_t shift = 0.0;
{
DenseMatrix epsilonMat(3);
epsilonMat(0,0) = 2.0; epsilonMat(1,1) = 2.0; epsilonMat(2,2) = 2.0;
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
m.AddDomainIntegrator(new VectorFEMassIntegrator(epsilon));
m.Assemble();
// shift the eigenvalue corresponding to eliminated dofs to a large value
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
m.Finalize();
A = a.ParallelAssemble();
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define
// parallel grid functions to represent each of the eigenmodes returned by
// the solver and their derivatives.
Array<double> eigenvalues;
Array<real_t> eigenvalues;
ame->Solve();
ame->GetEigenvalues(eigenvalues);
ParGridFunction x(&fespace_nd);
@@ -308,10 +308,10 @@ int main(int argc, char *argv[])
yComp.ProjectCoefficient(yCoef);
zComp.ProjectCoefficient(zCoef);
double max_x = GetScalarMax(xComp);
double max_y = GetScalarMax(yComp);
double max_z = GetScalarMax(zComp);
double max_r = std::max(max_x, std::max(max_y, max_z));
real_t max_x = GetScalarMax(xComp);
real_t max_y = GetScalarMax(yComp);
real_t max_z = GetScalarMax(zComp);
real_t max_r = std::max(max_x, std::max(max_y, max_z));
ostringstream x_cmd;
x_cmd << " window_title 'Eigenmode " << i+1 << '/' << nev
@@ -368,7 +368,7 @@ int main(int argc, char *argv[])
dyComp.ProjectCoefficient(dyCoef);
dzComp.ProjectCoefficient(dzCoef);
double min_d = max_r / (bbMax[0] - bbMin[0]);
real_t min_d = max_r / (bbMax[0] - bbMin[0]);
max_y = GetScalarMax(dyComp);
max_z = GetScalarMax(dzComp);
@@ -480,9 +480,9 @@ int main(int argc, char *argv[])
xyComp.ProjectCoefficient(xyCoef);
zComp.ProjectCoefficient(zCoef);
double max_v = GetVectorMax(2, xyComp);
double max_s = GetScalarMax(zComp);
double max_r = std::max(max_v, max_s);
real_t max_v = GetVectorMax(2, xyComp);
real_t max_s = GetScalarMax(zComp);
real_t max_r = std::max(max_v, max_s);
ostringstream xy_cmd;
xy_cmd << " window_title 'Eigenmode " << i+1 << '/' << nev
@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
dxyComp.ProjectCoefficient(dxyCoef);
dzComp.ProjectCoefficient(dzCoef);
double min_d = max_r / std::min(bbMax[0] - bbMin[0],
real_t min_d = max_r / std::min(bbMax[0] - bbMin[0],
bbMax[1] - bbMin[1]);
max_v = GetVectorMax(2, dxyComp);
@@ -649,17 +649,17 @@ int main(int argc, char *argv[])
return 0;
}
double GetVectorMax(int vdim, const ParGridFunction &x)
real_t GetVectorMax(int vdim, const ParGridFunction &x)
{
Vector zeroVec(vdim); zeroVec = 0.0;
VectorConstantCoefficient zero(zeroVec);
double nrm = x.ComputeMaxError(zero);
real_t nrm = x.ComputeMaxError(zero);
return nrm;
}
double GetScalarMax(const ParGridFunction &x)
real_t GetScalarMax(const ParGridFunction &x)
{
ConstantCoefficient zero(0.0);
double nrm = x.ComputeMaxError(zero);
real_t nrm = x.ComputeMaxError(zero);
return nrm;
}
+11 -7
View File
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
const char *mesh_file = "../data/star.mesh";
int order = 1;
int num_refs = 3;
double alpha = 0.5;
real_t alpha = 0.5;
bool visualization = true;
bool verification = false;
@@ -118,13 +118,17 @@ int main(int argc, char *argv[])
}
args.PrintOptions(cout);
Array<double> coeffs, poles;
#ifdef MFEM_USE_SINGLE
MFEM_ABORT("This example is not supported in single precision.");
#endif
Array<real_t> coeffs, poles;
int progress_steps = 1;
// 2. Compute the rational expansion coefficients that define the
// integer-order PDEs.
const int power_of_laplace = (int)floor(alpha);
double exponent_to_approximate = alpha - power_of_laplace;
real_t exponent_to_approximate = alpha - power_of_laplace;
bool integer_order = false;
// Check if alpha is an integer or not.
if (abs(exponent_to_approximate) > 1e-12)
@@ -135,7 +139,7 @@ int main(int argc, char *argv[])
ComputePartialFractionApproximation(exponent_to_approximate, coeffs,
poles);
// If the example is build without LAPACK, the exponent_to_approximate
// If the example is built without LAPACK, the exponent_to_approximate
// might be modified by the function call above.
alpha = exponent_to_approximate + power_of_laplace;
}
@@ -173,7 +177,7 @@ int main(int argc, char *argv[])
// 7. Define diffusion coefficient, load, and solution GridFunction.
auto func = [&alpha](const Vector &x)
{
double val = 1.0;
real_t val = 1.0;
for (int i=0; i<x.Size(); i++)
{
val *= sin(M_PI*x(i));
@@ -364,7 +368,7 @@ int main(int argc, char *argv[])
{
auto solution = [] (const Vector &x)
{
double val = 1.0;
real_t val = 1.0;
for (int i=0; i<x.Size(); i++)
{
val *= sin(M_PI*x(i));
@@ -372,7 +376,7 @@ int main(int argc, char *argv[])
return val;
};
FunctionCoefficient sol(solution);
double l2_error = u.ComputeL2Error(sol);
real_t l2_error = u.ComputeL2Error(sol);
string analytic_solution,expected_mesh;
switch (dim)
+28 -28
View File
@@ -50,8 +50,8 @@ using namespace mfem;
See pg. A1501 of Nakatsukasa et al. [1]. */
void RationalApproximation_AAA(const Vector &val, const Vector &pt,
Array<double> &z, Array<double> &f, Vector &w,
double tol, int max_order)
Array<real_t> &z, Array<real_t> &f, Vector &w,
real_t tol, int max_order)
{
// number of sample points
@@ -67,11 +67,11 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
DenseMatrix C, Ctemp, A, Am;
// auxiliary arrays and vectors
Vector f_vec;
Array<double> c_i;
Array<real_t> c_i;
// mean of the value vector
Vector R(val.Size());
double mean_val = val.Sum()/size;
real_t mean_val = val.Sum()/size;
for (int i = 0; i<R.Size(); i++) { R(i) = mean_val; }
@@ -79,10 +79,10 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
{
// select next support point
int idx = 0;
double tmp_max = 0;
real_t tmp_max = 0;
for (int j = 0; j < size; j++)
{
double tmp = abs(val(j)-R(j));
real_t tmp = abs(val(j)-R(j));
if (tmp > tmp_max)
{
tmp_max = tmp;
@@ -98,7 +98,7 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
J.DeleteFirst(idx);
// next column in Cauchy matrix
Array<double> C_tmp(size);
Array<real_t> C_tmp(size);
for (int j = 0; j < size; j++)
{
C_tmp[j] = 1.0/(pt(j)-pt(idx));
@@ -173,7 +173,7 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
See pg. A1501 of Nakatsukasa et al. [1]. */
void ComputePolesAndZeros(const Vector &z, const Vector &f, const Vector &w,
Array<double> & poles, Array<double> & zeros, double &scale)
Array<real_t> & poles, Array<real_t> & zeros, real_t &scale)
{
// Initialization
poles.SetSize(0);
@@ -242,8 +242,8 @@ void ComputePolesAndZeros(const Vector &z, const Vector &f, const Vector &w,
@param[in] zeros Array of zeros
@param[in] scale Scaling constant
@param[out] coeffs Coefficients c_i */
void PartialFractionExpansion(double scale, Array<double> & poles,
Array<double> & zeros, Array<double> & coeffs)
void PartialFractionExpansion(real_t scale, Array<real_t> & poles,
Array<real_t> & zeros, Array<real_t> & coeffs)
{
int psize = poles.Size();
int zsize = zeros.Size();
@@ -259,13 +259,13 @@ void PartialFractionExpansion(double scale, Array<double> & poles,
for (int i=0; i<psize; i++)
{
double tmp_numer=1.0;
real_t tmp_numer=1.0;
for (int j=0; j<zsize; j++)
{
tmp_numer *= poles[i]-zeros[j];
}
double tmp_denom=1.0;
real_t tmp_denom=1.0;
for (int k=0; k<psize; k++)
{
if (k != i) { tmp_denom *= poles[i]-poles[k]; }
@@ -292,10 +292,10 @@ void PartialFractionExpansion(double scale, Array<double> & poles,
@a alpha != 0.99, then @a alpha = 0.5 is used by default.
See pg. A1501 of Nakatsukasa et al. [1]. */
void ComputePartialFractionApproximation(double & alpha,
Array<double> & coeffs, Array<double> & poles,
double lmax = 1000.,
double tol=1e-10, int npoints = 1000,
void ComputePartialFractionApproximation(real_t & alpha,
Array<real_t> & coeffs, Array<real_t> & poles,
real_t lmax = 1000.,
real_t tol=1e-10, int npoints = 1000,
int max_order = 100)
{
MFEM_VERIFY(alpha < 1., "alpha must be less than 1");
@@ -320,26 +320,26 @@ void ComputePartialFractionApproximation(double & alpha,
<< "\nThe default is alpha = 0.5.\n" << string(80, '=') << "\n"
<< endl;
}
const double eps = std::numeric_limits<double>::epsilon();
const real_t eps = std::numeric_limits<real_t>::epsilon();
if (abs(alpha - 0.33) < eps)
{
coeffs = Array<double> ({1.821898e+03, 9.101221e+01, 2.650611e+01,
coeffs = Array<real_t> ({1.821898e+03, 9.101221e+01, 2.650611e+01,
1.174937e+01, 6.140444e+00, 3.441713e+00,
1.985735e+00, 1.162634e+00, 6.891560e-01,
4.111574e-01, 2.298736e-01});
poles = Array<double> ({-4.155583e+04, -2.956285e+03, -8.331715e+02,
poles = Array<real_t> ({-4.155583e+04, -2.956285e+03, -8.331715e+02,
-3.139332e+02, -1.303448e+02, -5.563385e+01,
-2.356255e+01, -9.595516e+00, -3.552160e+00,
-1.032136e+00, -1.241480e-01});
}
else if (abs(alpha - 0.99) < eps)
{
coeffs = Array<double>({2.919591e-02, 1.419750e-02, 1.065798e-02,
coeffs = Array<real_t>({2.919591e-02, 1.419750e-02, 1.065798e-02,
9.395094e-03, 8.915329e-03, 8.822991e-03,
9.058247e-03, 9.814521e-03, 1.180396e-02,
1.834554e-02, 9.840482e-01});
poles = Array<double> ({-1.069683e+04, -1.769370e+03, -5.718374e+02,
poles = Array<real_t> ({-1.069683e+04, -1.769370e+03, -5.718374e+02,
-2.242095e+02, -9.419132e+01, -4.031012e+01,
-1.701525e+01, -6.810088e+00, -2.382810e+00,
-5.700059e-01, -1.384324e-03});
@@ -350,11 +350,11 @@ void ComputePartialFractionApproximation(double & alpha,
{
alpha = 0.5;
}
coeffs = Array<double>({2.290262e+02, 2.641819e+01, 1.005566e+01,
coeffs = Array<real_t>({2.290262e+02, 2.641819e+01, 1.005566e+01,
5.390411e+00, 3.340725e+00, 2.211205e+00,
1.508883e+00, 1.049474e+00, 7.462709e-01,
5.482686e-01, 4.232510e-01, 3.578967e-01});
poles = Array<double>({-3.168211e+04, -3.236077e+03, -9.868287e+02,
poles = Array<real_t>({-3.168211e+04, -3.236077e+03, -9.868287e+02,
-3.945597e+02, -1.738889e+02, -7.925178e+01,
-3.624992e+01, -1.629196e+01, -6.982956e+00,
-2.679984e+00, -7.782607e-01, -7.649166e-02});
@@ -372,15 +372,15 @@ void ComputePartialFractionApproximation(double & alpha,
Vector x(npoints);
Vector val(npoints);
double dx = lmax / (double)(npoints-1);
real_t dx = lmax / (real_t)(npoints-1);
for (int i = 0; i<npoints; i++)
{
x(i) = dx * (double)i;
x(i) = dx * (real_t)i;
val(i) = pow(x(i),1.-alpha);
}
// Apply triple-A algorithm to f(x) = x^{1-a}
Array<double> z, f;
Array<real_t> z, f;
Vector w;
RationalApproximation_AAA(val,x,z,f,w,tol,max_order);
@@ -389,8 +389,8 @@ void ComputePartialFractionApproximation(double & alpha,
vecf.SetDataAndSize(f.GetData(), f.Size());
// Compute poles and zeros for RA of f(x) = x^{1-a}
double scale;
Array<double> zeros;
real_t scale;
Array<real_t> zeros;
ComputePolesAndZeros(vecz, vecf, w, poles, zeros, scale);
// Remove the zero at x=0, thus, delivering a RA for f(x) = x^{-a}
+10 -6
View File
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
const char *mesh_file = "../data/star.mesh";
int order = 1;
int num_refs = 3;
double alpha = 0.5;
real_t alpha = 0.5;
bool visualization = true;
bool verification = false;
@@ -127,13 +127,17 @@ int main(int argc, char *argv[])
args.PrintOptions(cout);
}
Array<double> coeffs, poles;
#ifdef MFEM_USE_SINGLE
MFEM_ABORT("This example is not supported in single precision.");
#endif
Array<real_t> coeffs, poles;
int progress_steps = 1;
// 2. Compute the rational expansion coefficients that define the
// integer-order PDEs.
const int power_of_laplace = floor(alpha);
double exponent_to_approximate = alpha - power_of_laplace;
real_t exponent_to_approximate = alpha - power_of_laplace;
bool integer_order = false;
// Check if alpha is an integer or not.
if (abs(exponent_to_approximate) > 1e-12)
@@ -193,7 +197,7 @@ int main(int argc, char *argv[])
// 7. Define diffusion coefficient, load, and solution GridFunction.
auto func = [&alpha](const Vector &x)
{
double val = 1.0;
real_t val = 1.0;
for (int i=0; i<x.Size(); i++)
{
val *= sin(M_PI*x(i));
@@ -398,7 +402,7 @@ int main(int argc, char *argv[])
{
auto solution = [] (const Vector &x)
{
double val = 1.0;
real_t val = 1.0;
for (int i=0; i<x.Size(); i++)
{
val *= sin(M_PI*x(i));
@@ -406,7 +410,7 @@ int main(int argc, char *argv[])
return val;
};
FunctionCoefficient sol(solution);
double l2_error = u.ComputeL2Error(sol);
real_t l2_error = u.ComputeL2Error(sol);
if (Mpi::Root())
{
+1 -1
View File
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
Array<int> jn_zero_attr;
int ref_levels = 1;
int order = 1;
double delta_const = 1e-6;
real_t delta_const = 1e-6;
bool mixed = true;
bool static_cond = false;
const char *device_config = "cpu";
+1 -1
View File
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
int ser_ref_levels = 1;
int par_ref_levels = 1;
int order = 1;
double delta_const = 1e-6;
real_t delta_const = 1e-6;
bool mixed = true;
bool static_cond = false;
bool pa = false;
+9 -9
View File
@@ -55,9 +55,9 @@
using namespace std;
using namespace mfem;
static double mu_ = 1.0;
static double epsilon_ = 1.0;
static double sigma_ = 2.0;
static real_t mu_ = 1.0;
static real_t epsilon_ = 1.0;
static real_t sigma_ = 2.0;
void SetPortBC(int prob, int dim, int mode, ParGridFunction &port_bc);
@@ -77,9 +77,9 @@ int main(int argc, char *argv[])
Array<int> port_bc_attr;
int prob = 0;
int mode = 1;
double freq = -1.0;
double omega = 2.0 * M_PI;
double a_coef = 0.0;
real_t freq = -1.0;
real_t omega = 2.0 * M_PI;
real_t a_coef = 0.0;
bool herm_conv = true;
bool slu_solver = false;
bool visualization = 1;
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
int i = 0;
while (sol_sock)
{
double t = (double)(i % num_frames) / num_frames;
real_t t = (real_t)(i % num_frames) / num_frames;
ostringstream oss;
oss << "Harmonic Solution (t = " << t << " T)";
@@ -637,7 +637,7 @@ void ScalarWaveGuide(int mode, ParGridFunction &x)
m.AddDomainIntegrator(new MassIntegrator);
m.Assemble();
// shift the eigenvalue corresponding to eliminated dofs to a large value
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
m.Finalize();
HypreParMatrix *A = a.ParallelAssemble();
@@ -694,7 +694,7 @@ void VectorWaveGuide(int mode, ParGridFunction &x)
m.AddDomainIntegrator(new VectorFEMassIntegrator);
m.Assemble();
// shift the eigenvalue corresponding to eliminated dofs to a large value
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
m.Finalize();
HypreParMatrix *A = a.ParallelAssemble();
+45 -45
View File
@@ -37,8 +37,8 @@
using namespace std;
using namespace mfem;
double spherical_obstacle(const Vector &pt);
double exact_solution_obstacle(const Vector &pt);
real_t spherical_obstacle(const Vector &pt);
real_t exact_solution_obstacle(const Vector &pt);
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad);
class LogarithmGridFunctionCoefficient : public Coefficient
@@ -46,14 +46,14 @@ class LogarithmGridFunctionCoefficient : public Coefficient
protected:
GridFunction *u; // grid function
Coefficient *obstacle;
double min_val;
real_t min_val;
public:
LogarithmGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
double min_val_=-36)
real_t min_val_=-36)
: u(&u_), obstacle(&obst_), min_val(min_val_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
};
class ExponentialGridFunctionCoefficient : public Coefficient
@@ -61,15 +61,15 @@ class ExponentialGridFunctionCoefficient : public Coefficient
protected:
GridFunction *u;
Coefficient *obstacle;
double min_val;
double max_val;
real_t min_val;
real_t max_val;
public:
ExponentialGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
double min_val_=0.0, double max_val_=1e6)
real_t min_val_=0.0, real_t max_val_=1e6)
: u(&u_), obstacle(&obst_), min_val(min_val_), max_val(max_val_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
};
int main(int argc, char *argv[])
@@ -78,8 +78,8 @@ int main(int argc, char *argv[])
int order = 1;
int max_it = 10;
int ref_levels = 3;
double alpha = 1.0;
double tol = 1e-5;
real_t alpha = 1.0;
real_t tol = 1e-5;
bool visualization = true;
OptionsParser args(argc, argv);
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
// 3C. Rescale the domain to a unit circle (radius = 1).
GridFunction *nodes = mesh.GetNodes();
double scale = 2*sqrt(2);
real_t scale = 2*sqrt(2);
*nodes /= scale;
// 4. Define the necessary finite element spaces on the mesh.
@@ -159,8 +159,8 @@ int main(int argc, char *argv[])
// 6. Define an initial guess for the solution.
auto IC_func = [](const Vector &x)
{
double r0 = 1.0;
double rr = 0.0;
real_t r0 = 1.0;
real_t rr = 0.0;
for (int i=0; i<x.Size(); i++)
{
rr += x(i)*x(i);
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
// 10. Iterate
int k;
int total_iterations = 0;
double increment_u = 0.1;
real_t increment_u = 0.1;
for (k = 0; k < max_it; k++)
{
GridFunction u_tmp(&H1fes);
@@ -300,10 +300,10 @@ int main(int argc, char *argv[])
delta_psi_gf.MakeRef(&L2fes, x.GetBlock(1), 0);
u_tmp -= u_gf;
double Newton_update_size = u_tmp.ComputeL2Error(zero);
real_t Newton_update_size = u_tmp.ComputeL2Error(zero);
u_tmp = u_gf;
double gamma = 1.0;
real_t gamma = 1.0;
delta_psi_gf *= gamma;
psi_gf += delta_psi_gf;
@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
break;
}
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
mfem::out << "H1-error (|| u - uₕᵏ||) = " << H1_error << endl;
}
@@ -362,13 +362,13 @@ int main(int argc, char *argv[])
}
{
double L2_error = u_gf.ComputeL2Error(exact_coef);
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
real_t L2_error = u_gf.ComputeL2Error(exact_coef);
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
ExponentialGridFunctionCoefficient u_alt_cf(psi_gf,obstacle);
GridFunction u_alt_gf(&L2fes);
u_alt_gf.ProjectCoefficient(u_alt_cf);
double L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
real_t L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
mfem::out << "\n Final L2-error (|| u - uₕ||) = " << L2_error <<
endl;
@@ -380,35 +380,35 @@ int main(int argc, char *argv[])
return 0;
}
double LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
real_t LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
MFEM_ASSERT(u != NULL, "grid function is not set");
double val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
real_t val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
return max(min_val, log(val));
}
double ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
real_t ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
MFEM_ASSERT(u != NULL, "grid function is not set");
double val = u->GetValue(T, ip);
real_t val = u->GetValue(T, ip);
return min(max_val, max(min_val, exp(val) + obstacle->Eval(T, ip)));
}
double spherical_obstacle(const Vector &pt)
real_t spherical_obstacle(const Vector &pt)
{
double x = pt(0), y = pt(1);
double r = sqrt(x*x + y*y);
double r0 = 0.5;
double beta = 0.9;
real_t x = pt(0), y = pt(1);
real_t r = sqrt(x*x + y*y);
real_t r0 = 0.5;
real_t beta = 0.9;
double b = r0*beta;
double tmp = sqrt(r0*r0 - b*b);
double B = tmp + b*b/tmp;
double C = -b/tmp;
real_t b = r0*beta;
real_t tmp = sqrt(r0*r0 - b*b);
real_t B = tmp + b*b/tmp;
real_t C = -b/tmp;
if (r > b)
{
@@ -420,13 +420,13 @@ double spherical_obstacle(const Vector &pt)
}
}
double exact_solution_obstacle(const Vector &pt)
real_t exact_solution_obstacle(const Vector &pt)
{
double x = pt(0), y = pt(1);
double r = sqrt(x*x + y*y);
double r0 = 0.5;
double a = 0.348982574111686;
double A = -0.340129705945858;
real_t x = pt(0), y = pt(1);
real_t r = sqrt(x*x + y*y);
real_t r0 = 0.5;
real_t a = 0.348982574111686;
real_t A = -0.340129705945858;
if (r > a)
{
@@ -440,11 +440,11 @@ double exact_solution_obstacle(const Vector &pt)
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad)
{
double x = pt(0), y = pt(1);
double r = sqrt(x*x + y*y);
double r0 = 0.5;
double a = 0.348982574111686;
double A = -0.340129705945858;
real_t x = pt(0), y = pt(1);
real_t r = sqrt(x*x + y*y);
real_t r0 = 0.5;
real_t a = 0.348982574111686;
real_t A = -0.340129705945858;
if (r > a)
{
+45 -45
View File
@@ -37,8 +37,8 @@
using namespace std;
using namespace mfem;
double spherical_obstacle(const Vector &pt);
double exact_solution_obstacle(const Vector &pt);
real_t spherical_obstacle(const Vector &pt);
real_t exact_solution_obstacle(const Vector &pt);
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad);
class LogarithmGridFunctionCoefficient : public Coefficient
@@ -46,14 +46,14 @@ class LogarithmGridFunctionCoefficient : public Coefficient
protected:
GridFunction *u; // grid function
Coefficient *obstacle;
double min_val;
real_t min_val;
public:
LogarithmGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
double min_val_=-36)
real_t min_val_=-36)
: u(&u_), obstacle(&obst_), min_val(min_val_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
};
class ExponentialGridFunctionCoefficient : public Coefficient
@@ -61,15 +61,15 @@ class ExponentialGridFunctionCoefficient : public Coefficient
protected:
GridFunction *u;
Coefficient *obstacle;
double min_val;
double max_val;
real_t min_val;
real_t max_val;
public:
ExponentialGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
double min_val_=0.0, double max_val_=1e6)
real_t min_val_=0.0, real_t max_val_=1e6)
: u(&u_), obstacle(&obst_), min_val(min_val_), max_val(max_val_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
};
int main(int argc, char *argv[])
@@ -84,8 +84,8 @@ int main(int argc, char *argv[])
int order = 1;
int max_it = 10;
int ref_levels = 3;
double alpha = 1.0;
double tol = 1e-5;
real_t alpha = 1.0;
real_t tol = 1e-5;
bool visualization = true;
OptionsParser args(argc, argv);
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
// 3C. Rescale the domain to a unit circle (radius = 1).
GridFunction *nodes = mesh.GetNodes();
double scale = 2*sqrt(2);
real_t scale = 2*sqrt(2);
*nodes /= scale;
ParMesh pmesh(MPI_COMM_WORLD, mesh);
@@ -192,8 +192,8 @@ int main(int argc, char *argv[])
// 6. Define an initial guess for the solution.
auto IC_func = [](const Vector &x)
{
double r0 = 1.0;
double rr = 0.0;
real_t r0 = 1.0;
real_t rr = 0.0;
for (int i=0; i<x.Size(); i++)
{
rr += x(i)*x(i);
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
// 10. Iterate
int k;
int total_iterations = 0;
double increment_u = 0.1;
real_t increment_u = 0.1;
for (k = 0; k < max_it; k++)
{
ParGridFunction u_tmp(&H1fes);
@@ -346,10 +346,10 @@ int main(int argc, char *argv[])
delta_psi_gf.SetFromTrueDofs(tx.GetBlock(1));
u_tmp -= u_gf;
double Newton_update_size = u_tmp.ComputeL2Error(zero);
real_t Newton_update_size = u_tmp.ComputeL2Error(zero);
u_tmp = u_gf;
double gamma = 1.0;
real_t gamma = 1.0;
delta_psi_gf *= gamma;
psi_gf += delta_psi_gf;
@@ -391,7 +391,7 @@ int main(int argc, char *argv[])
break;
}
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
if (myid == 0)
{
mfem::out << "H1-error (|| u - uₕᵏ||) = " << H1_error << endl;
@@ -423,13 +423,13 @@ int main(int argc, char *argv[])
}
{
double L2_error = u_gf.ComputeL2Error(exact_coef);
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
real_t L2_error = u_gf.ComputeL2Error(exact_coef);
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
ExponentialGridFunctionCoefficient u_alt_cf(psi_gf,obstacle);
ParGridFunction u_alt_gf(&L2fes);
u_alt_gf.ProjectCoefficient(u_alt_cf);
double L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
real_t L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
if (myid == 0)
{
@@ -444,35 +444,35 @@ int main(int argc, char *argv[])
return 0;
}
double LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
real_t LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
MFEM_ASSERT(u != NULL, "grid function is not set");
double val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
real_t val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
return max(min_val, log(val));
}
double ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
real_t ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
MFEM_ASSERT(u != NULL, "grid function is not set");
double val = u->GetValue(T, ip);
real_t val = u->GetValue(T, ip);
return min(max_val, max(min_val, exp(val) + obstacle->Eval(T, ip)));
}
double spherical_obstacle(const Vector &pt)
real_t spherical_obstacle(const Vector &pt)
{
double x = pt(0), y = pt(1);
double r = sqrt(x*x + y*y);
double r0 = 0.5;
double beta = 0.9;
real_t x = pt(0), y = pt(1);
real_t r = sqrt(x*x + y*y);
real_t r0 = 0.5;
real_t beta = 0.9;
double b = r0*beta;
double tmp = sqrt(r0*r0 - b*b);
double B = tmp + b*b/tmp;
double C = -b/tmp;
real_t b = r0*beta;
real_t tmp = sqrt(r0*r0 - b*b);
real_t B = tmp + b*b/tmp;
real_t C = -b/tmp;
if (r > b)
{
@@ -484,13 +484,13 @@ double spherical_obstacle(const Vector &pt)
}
}
double exact_solution_obstacle(const Vector &pt)
real_t exact_solution_obstacle(const Vector &pt)
{
double x = pt(0), y = pt(1);
double r = sqrt(x*x + y*y);
double r0 = 0.5;
double a = 0.348982574111686;
double A = -0.340129705945858;
real_t x = pt(0), y = pt(1);
real_t r = sqrt(x*x + y*y);
real_t r0 = 0.5;
real_t a = 0.348982574111686;
real_t A = -0.340129705945858;
if (r > a)
{
@@ -504,11 +504,11 @@ double exact_solution_obstacle(const Vector &pt)
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad)
{
double x = pt(0), y = pt(1);
double r = sqrt(x*x + y*y);
double r0 = 0.5;
double a = 0.348982574111686;
double A = -0.340129705945858;
real_t x = pt(0), y = pt(1);
real_t r = sqrt(x*x + y*y);
real_t r0 = 0.5;
real_t a = 0.348982574111686;
real_t A = -0.340129705945858;
if (r > a)
{
+24 -24
View File
@@ -67,9 +67,9 @@ using namespace mfem;
* @param target_volume θ vol(Ω)
* @param tol Newton iteration tolerance
* @param max_its Newton maximum iteration number
* @return double Final volume, sigmoid(ψ)
* @return real_t Final volume, sigmoid(ψ)
*/
double proj(GridFunction &psi, double target_volume, double tol=1e-12,
real_t proj(GridFunction &psi, real_t target_volume, real_t tol=1e-12,
int max_its=10)
{
MappedGridFunctionCoefficient sigmoid_psi(&psi, sigmoid);
@@ -84,12 +84,12 @@ double proj(GridFunction &psi, double target_volume, double tol=1e-12,
for (int k=0; k<max_its; k++) // Newton iteration
{
int_sigmoid_psi.Assemble(); // Recompute f(c) with updated ψ
const double f = int_sigmoid_psi.Sum() - target_volume;
const real_t f = int_sigmoid_psi.Sum() - target_volume;
int_der_sigmoid_psi.Assemble(); // Recompute df(c) with updated ψ
const double df = int_der_sigmoid_psi.Sum();
const real_t df = int_der_sigmoid_psi.Sum();
const double dc = -f/df;
const real_t dc = -f/df;
psi += dc;
if (abs(dc) < tol) { done = true; break; }
}
@@ -179,15 +179,15 @@ int main(int argc, char *argv[])
// 1. Parse command-line options.
int ref_levels = 5;
int order = 2;
double alpha = 1.0;
double epsilon = 0.01;
double vol_fraction = 0.5;
real_t alpha = 1.0;
real_t epsilon = 0.01;
real_t vol_fraction = 0.5;
int max_it = 1e3;
double itol = 1e-1;
double ntol = 1e-4;
double rho_min = 1e-6;
double lambda = 1.0;
double mu = 1.0;
real_t itol = 1e-1;
real_t ntol = 1e-4;
real_t rho_min = 1e-6;
real_t lambda = 1.0;
real_t mu = 1.0;
bool glvis_visualization = true;
bool paraview_output = false;
@@ -239,8 +239,8 @@ int main(int argc, char *argv[])
Array<int> vertices;
be->GetVertices(vertices);
double * coords1 = mesh.GetVertex(vertices[0]);
double * coords2 = mesh.GetVertex(vertices[1]);
real_t * coords1 = mesh.GetVertex(vertices[0]);
real_t * coords2 = mesh.GetVertex(vertices[1]);
Vector center(2);
center(0) = 0.5*(coords1[0] + coords2[0]);
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
ElasticitySolver->SetupFEM();
Vector center(2); center(0) = 2.9; center(1) = 0.5;
Vector force(2); force(0) = 0.0; force(1) = -1.0;
double r = 0.05;
real_t r = 0.05;
VolumeForceCoefficient vforce_cf(r,center,force);
ElasticitySolver->SetRHSCoefficient(&vforce_cf);
ElasticitySolver->SetEssentialBoundary(ess_bdr);
@@ -353,8 +353,8 @@ int main(int argc, char *argv[])
LinearForm vol_form(&control_fes);
vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
vol_form.Assemble();
double domain_volume = vol_form(onegf);
const double target_volume = domain_volume * vol_fraction;
real_t domain_volume = vol_form(onegf);
const real_t target_volume = domain_volume * vol_fraction;
// 10. Connect to GLVis. Prepare for VisIt output.
char vishost[] = "localhost";
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
// 11. Iterate:
for (int k = 1; k <= max_it; k++)
{
if (k > 1) { alpha *= ((double) k) / ((double) k-1); }
if (k > 1) { alpha *= ((real_t) k) / ((real_t) k-1); }
mfem::out << "\nStep = " << k << std::endl;
@@ -422,14 +422,14 @@ int main(int argc, char *argv[])
// Step 5 - Update design variable ψ ← proj(ψ - αG)
psi.Add(-alpha, grad);
const double material_volume = proj(psi, target_volume);
const real_t material_volume = proj(psi, target_volume);
// Compute ||ρ - ρ_old|| in control fes.
double norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
double norm_reduced_gradient = norm_increment/alpha;
real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
real_t norm_reduced_gradient = norm_increment/alpha;
psi_old = psi;
double compliance = (*(ElasticitySolver->GetLinearForm()))(u);
real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient <<
std::endl;
mfem::out << "norm of the increment = " << norm_increment << endl;
@@ -449,7 +449,7 @@ int main(int argc, char *argv[])
{
rho_gf.ProjectCoefficient(rho);
paraview_dc.SetCycle(k);
paraview_dc.SetTime((double)k);
paraview_dc.SetTime((real_t)k);
paraview_dc.Save();
}
+40 -40
View File
@@ -9,15 +9,15 @@ namespace mfem
{
/// @brief Inverse sigmoid function
double inv_sigmoid(double x)
real_t inv_sigmoid(real_t x)
{
double tol = 1e-12;
x = std::min(std::max(tol,x),1.0-tol);
real_t tol = 1e-12;
x = std::min(std::max(tol,x), real_t(1.0)-tol);
return std::log(x/(1.0-x));
}
/// @brief Sigmoid function
double sigmoid(double x)
real_t sigmoid(real_t x)
{
if (x >= 0)
{
@@ -30,9 +30,9 @@ double sigmoid(double x)
}
/// @brief Derivative of sigmoid function
double der_sigmoid(double x)
real_t der_sigmoid(real_t x)
{
double tmp = sigmoid(-x);
real_t tmp = sigmoid(-x);
return tmp - std::pow(tmp,2);
}
@@ -40,24 +40,24 @@ double der_sigmoid(double x)
class MappedGridFunctionCoefficient : public GridFunctionCoefficient
{
protected:
std::function<double(const double)> fun; // f:R → R
std::function<real_t(const real_t)> fun; // f:R → R
public:
MappedGridFunctionCoefficient()
:GridFunctionCoefficient(),
fun([](double x) {return x;}) {}
fun([](real_t x) {return x;}) {}
MappedGridFunctionCoefficient(const GridFunction *gf,
std::function<double(const double)> fun_,
std::function<real_t(const real_t)> fun_,
int comp=1)
:GridFunctionCoefficient(gf, comp),
fun(fun_) {}
virtual double Eval(ElementTransformation &T,
virtual real_t Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
return fun(GridFunctionCoefficient::Eval(T, ip));
}
void SetFunction(std::function<double(const double)> fun_) { fun = fun_; }
void SetFunction(std::function<real_t(const real_t)> fun_) { fun = fun_; }
};
@@ -67,30 +67,30 @@ class DiffMappedGridFunctionCoefficient : public GridFunctionCoefficient
protected:
const GridFunction *OtherGridF;
GridFunctionCoefficient OtherGridF_cf;
std::function<double(const double)> fun; // f:R → R
std::function<real_t(const real_t)> fun; // f:R → R
public:
DiffMappedGridFunctionCoefficient()
:GridFunctionCoefficient(),
OtherGridF(nullptr),
OtherGridF_cf(),
fun([](double x) {return x;}) {}
fun([](real_t x) {return x;}) {}
DiffMappedGridFunctionCoefficient(const GridFunction *gf,
const GridFunction *other_gf,
std::function<double(const double)> fun_,
std::function<real_t(const real_t)> fun_,
int comp=1)
:GridFunctionCoefficient(gf, comp),
OtherGridF(other_gf),
OtherGridF_cf(OtherGridF),
fun(fun_) {}
virtual double Eval(ElementTransformation &T,
virtual real_t Eval(ElementTransformation &T,
const IntegrationPoint &ip)
{
const double value1 = fun(GridFunctionCoefficient::Eval(T, ip));
const double value2 = fun(OtherGridF_cf.Eval(T, ip));
const real_t value1 = fun(GridFunctionCoefficient::Eval(T, ip));
const real_t value2 = fun(OtherGridF_cf.Eval(T, ip));
return value1 - value2;
}
void SetFunction(std::function<double(const double)> fun_) { fun = fun_; }
void SetFunction(std::function<real_t(const real_t)> fun_) { fun = fun_; }
};
/// @brief Solid isotropic material penalization (SIMP) coefficient
@@ -98,20 +98,20 @@ class SIMPInterpolationCoefficient : public Coefficient
{
protected:
GridFunction *rho_filter;
double min_val;
double max_val;
double exponent;
real_t min_val;
real_t max_val;
real_t exponent;
public:
SIMPInterpolationCoefficient(GridFunction *rho_filter_, double min_val_= 1e-6,
double max_val_ = 1.0, double exponent_ = 3)
SIMPInterpolationCoefficient(GridFunction *rho_filter_, real_t min_val_= 1e-6,
real_t max_val_ = 1.0, real_t exponent_ = 3)
: rho_filter(rho_filter_), min_val(min_val_), max_val(max_val_),
exponent(exponent_) { }
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
{
double val = rho_filter->GetValue(T, ip);
double coeff = min_val + pow(val,exponent)*(max_val-min_val);
real_t val = rho_filter->GetValue(T, ip);
real_t coeff = min_val + pow(val,exponent)*(max_val-min_val);
return coeff;
}
};
@@ -126,13 +126,13 @@ protected:
GridFunction *u = nullptr; // displacement
GridFunction *rho_filter = nullptr; // filter density
DenseMatrix grad; // auxiliary matrix, used in Eval
double exponent;
double rho_min;
real_t exponent;
real_t rho_min;
public:
StrainEnergyDensityCoefficient(Coefficient *lambda_, Coefficient *mu_,
GridFunction * u_, GridFunction * rho_filter_, double rho_min_=1e-6,
double exponent_ = 3.0)
GridFunction * u_, GridFunction * rho_filter_, real_t rho_min_=1e-6,
real_t exponent_ = 3.0)
: lambda(lambda_), mu(mu_), u(u_), rho_filter(rho_filter_),
exponent(exponent_), rho_min(rho_min_)
{
@@ -142,13 +142,13 @@ public:
MFEM_ASSERT(rho_filter, "density field is not set");
}
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
{
double L = lambda->Eval(T, ip);
double M = mu->Eval(T, ip);
real_t L = lambda->Eval(T, ip);
real_t M = mu->Eval(T, ip);
u->GetVectorGradient(T, grad);
double div_u = grad.Trace();
double density = L*div_u*div_u;
real_t div_u = grad.Trace();
real_t density = L*div_u*div_u;
int dim = T.GetSpaceDim();
for (int i=0; i<dim; i++)
{
@@ -157,7 +157,7 @@ public:
density += M*grad(i,j)*(grad(i,j)+grad(j,i));
}
}
double val = rho_filter->GetValue(T,ip);
real_t val = rho_filter->GetValue(T,ip);
return -exponent * pow(val, exponent-1.0) * (1-rho_min) * density;
}
@@ -167,11 +167,11 @@ public:
class VolumeForceCoefficient : public VectorCoefficient
{
private:
double r;
real_t r;
Vector center;
Vector force;
public:
VolumeForceCoefficient(double r_,Vector & center_, Vector & force_) :
VolumeForceCoefficient(real_t r_,Vector & center_, Vector & force_) :
VectorCoefficient(center_.Size()), r(r_), center(center_), force(force_) { }
using VectorCoefficient::Eval;
@@ -186,7 +186,7 @@ public:
xx[i]=xx[i]-center[i];
}
double cr=xx.Norml2();
real_t cr=xx.Norml2();
V.SetSize(T.GetDimension());
if (cr <= r)
{
@@ -198,7 +198,7 @@ public:
}
}
void Set(double r_,Vector & center_, Vector & force_)
void Set(real_t r_,Vector & center_, Vector & force_)
{
r=r_;
center = center_;
+33 -30
View File
@@ -66,9 +66,9 @@ using namespace mfem;
* @param target_volume θ vol(Ω)
* @param tol Newton iteration tolerance
* @param max_its Newton maximum iteration number
* @return double Final volume, sigmoid(ψ)
* @return real_t Final volume, sigmoid(ψ)
*/
double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
real_t proj(ParGridFunction &psi, real_t target_volume, real_t tol=1e-12,
int max_its=10)
{
MappedGridFunctionCoefficient sigmoid_psi(&psi, sigmoid);
@@ -83,15 +83,17 @@ double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
for (int k=0; k<max_its; k++) // Newton iteration
{
int_sigmoid_psi.Assemble(); // Recompute f(c) with updated ψ
double f = int_sigmoid_psi.Sum();
MPI_Allreduce(MPI_IN_PLACE, &f, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
real_t f = int_sigmoid_psi.Sum();
MPI_Allreduce(MPI_IN_PLACE, &f, 1, MPITypeMap<real_t>::mpi_type,
MPI_SUM, MPI_COMM_WORLD);
f -= target_volume;
int_der_sigmoid_psi.Assemble(); // Recompute df(c) with updated ψ
double df = int_der_sigmoid_psi.Sum();
MPI_Allreduce(MPI_IN_PLACE, &df, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
real_t df = int_der_sigmoid_psi.Sum();
MPI_Allreduce(MPI_IN_PLACE, &df, 1, MPITypeMap<real_t>::mpi_type,
MPI_SUM, MPI_COMM_WORLD);
const double dc = -f/df;
const real_t dc = -f/df;
psi += dc;
if (abs(dc) < tol) { done = true; break; }
}
@@ -101,9 +103,9 @@ double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
"Result may not be accurate.");
}
int_sigmoid_psi.Assemble();
double material_volume = int_sigmoid_psi.Sum();
MPI_Allreduce(MPI_IN_PLACE, &material_volume, 1, MPI_DOUBLE, MPI_SUM,
MPI_COMM_WORLD);
real_t material_volume = int_sigmoid_psi.Sum();
MPI_Allreduce(MPI_IN_PLACE, &material_volume, 1,
MPITypeMap<real_t>::mpi_type, MPI_SUM, MPI_COMM_WORLD);
return material_volume;
}
@@ -190,15 +192,15 @@ int main(int argc, char *argv[])
// 1. Parse command-line options.
int ref_levels = 5;
int order = 2;
double alpha = 1.0;
double epsilon = 0.01;
double vol_fraction = 0.5;
real_t alpha = 1.0;
real_t epsilon = 0.01;
real_t vol_fraction = 0.5;
int max_it = 1e3;
double itol = 1e-1;
double ntol = 1e-4;
double rho_min = 1e-6;
double lambda = 1.0;
double mu = 1.0;
real_t itol = 1e-1;
real_t ntol = 1e-4;
real_t rho_min = 1e-6;
real_t lambda = 1.0;
real_t mu = 1.0;
bool glvis_visualization = true;
bool paraview_output = false;
@@ -258,8 +260,8 @@ int main(int argc, char *argv[])
Array<int> vertices;
be->GetVertices(vertices);
double * coords1 = mesh.GetVertex(vertices[0]);
double * coords2 = mesh.GetVertex(vertices[1]);
real_t * coords1 = mesh.GetVertex(vertices[0]);
real_t * coords2 = mesh.GetVertex(vertices[1]);
Vector center(2);
center(0) = 0.5*(coords1[0] + coords2[0]);
@@ -337,7 +339,7 @@ int main(int argc, char *argv[])
ElasticitySolver->SetupFEM();
Vector center(2); center(0) = 2.9; center(1) = 0.5;
Vector force(2); force(0) = 0.0; force(1) = -1.0;
double r = 0.05;
real_t r = 0.05;
VolumeForceCoefficient vforce_cf(r,center,force);
ElasticitySolver->SetRHSCoefficient(&vforce_cf);
ElasticitySolver->SetEssentialBoundary(ess_bdr);
@@ -378,8 +380,8 @@ int main(int argc, char *argv[])
ParLinearForm vol_form(&control_fes);
vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
vol_form.Assemble();
double domain_volume = vol_form(onegf);
const double target_volume = domain_volume * vol_fraction;
real_t domain_volume = vol_form(onegf);
const real_t target_volume = domain_volume * vol_fraction;
// 10. Connect to GLVis. Prepare for VisIt output.
char vishost[] = "localhost";
@@ -410,7 +412,7 @@ int main(int argc, char *argv[])
// 11. Iterate:
for (int k = 1; k <= max_it; k++)
{
if (k > 1) { alpha *= ((double) k) / ((double) k-1); }
if (k > 1) { alpha *= ((real_t) k) / ((real_t) k-1); }
if (myid == 0)
{
@@ -450,15 +452,16 @@ int main(int argc, char *argv[])
// Step 5 - Update design variable ψ ← proj(ψ - αG)
psi.Add(-alpha, grad);
const double material_volume = proj(psi, target_volume);
const real_t material_volume = proj(psi, target_volume);
// Compute ||ρ - ρ_old|| in control fes.
double norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
double norm_reduced_gradient = norm_increment/alpha;
real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
real_t norm_reduced_gradient = norm_increment/alpha;
psi_old = psi;
double compliance = (*(ElasticitySolver->GetLinearForm()))(u);
MPI_Allreduce(MPI_IN_PLACE,&compliance,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
MPI_Allreduce(MPI_IN_PLACE, &compliance, 1, MPITypeMap<real_t>::mpi_type,
MPI_SUM, MPI_COMM_WORLD);
if (myid == 0)
{
mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient << endl;
@@ -480,7 +483,7 @@ int main(int argc, char *argv[])
{
rho_gf.ProjectCoefficient(rho);
paraview_dc.SetCycle(k);
paraview_dc.SetTime((double)k);
paraview_dc.SetTime((real_t)k);
paraview_dc.Save();
}
+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
real_t 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
real_t 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
real_t 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
real_t 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))));
real_t 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))));
real_t 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 built 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., (real_t)ref_levels) << endl;
}
else
{
cout << .25 / pow(2., (real_t)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 << "Absolute 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 << "Absolute 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
}
+2 -2
View File
@@ -55,7 +55,7 @@ using namespace mfem;
// Exact solution, E, and r.h.s., f. See below for implementation.
void E_exact(const Vector &, Vector &);
void f_exact(const Vector &, Vector &);
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int dim;
int main(int argc, char *argv[])
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
// 15. Compute and print the L^2 norm of the error.
{
double error = x.ComputeL2Error(E);
real_t error = x.ComputeL2Error(E);
if (myid == 0)
{
cout << "\n|| E_h - E ||_{L^2} = " << error << '\n' << endl;
+8 -8
View File
@@ -54,7 +54,7 @@ using namespace mfem;
// Exact solution, F, and r.h.s., f. See below for implementation.
void F_exact(const Vector &, Vector &);
void f_exact(const Vector &, Vector &);
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int main(int argc, char *argv[])
{
@@ -269,9 +269,9 @@ void F_exact(const Vector &p, Vector &F)
{
int dim = p.Size();
double x = p(0);
double y = p(1);
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
real_t x = p(0);
real_t y = p(1);
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
F(0) = cos(kappa*x)*sin(kappa*y);
F(1) = cos(kappa*y)*sin(kappa*x);
@@ -286,11 +286,11 @@ void f_exact(const Vector &p, Vector &f)
{
int dim = p.Size();
double x = p(0);
double y = p(1);
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
real_t x = p(0);
real_t y = p(1);
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
double temp = 1 + 2*kappa*kappa;
real_t temp = 1 + 2*kappa*kappa;
f(0) = temp*cos(kappa*x)*sin(kappa*y);
f(1) = temp*cos(kappa*y)*sin(kappa*x);
+9 -9
View File
@@ -54,7 +54,7 @@ using namespace mfem;
// Exact solution, F, and r.h.s., f. See below for implementation.
void F_exact(const Vector &, Vector &);
void f_exact(const Vector &, Vector &);
double freq = 1.0, kappa;
real_t freq = 1.0, kappa;
int main(int argc, char *argv[])
{
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
// 15. Compute and print the L^2 norm of the error.
{
double error = x.ComputeL2Error(F);
real_t error = x.ComputeL2Error(F);
if (myid == 0)
{
cout << "\n|| F_h - F ||_{L^2} = " << error << '\n' << endl;
@@ -311,9 +311,9 @@ void F_exact(const Vector &p, Vector &F)
{
int dim = p.Size();
double x = p(0);
double y = p(1);
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
real_t x = p(0);
real_t y = p(1);
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
F(0) = cos(kappa*x)*sin(kappa*y);
F(1) = cos(kappa*y)*sin(kappa*x);
@@ -328,11 +328,11 @@ void f_exact(const Vector &p, Vector &f)
{
int dim = p.Size();
double x = p(0);
double y = p(1);
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
real_t x = p(0);
real_t y = p(1);
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
double temp = 1 + 2*kappa*kappa;
real_t temp = 1 + 2*kappa*kappa;
f(0) = temp*cos(kappa*x)*sin(kappa*y);
f(1) = temp*cos(kappa*y)*sin(kappa*x);
+18 -18
View File
@@ -45,10 +45,10 @@ using namespace mfem;
// Define the analytical solution and forcing terms / boundary conditions
void uFun_ex(const Vector & x, Vector & u);
double pFun_ex(const Vector & x);
real_t pFun_ex(const Vector & x);
void fFun(const Vector & x, Vector & f);
double gFun(const Vector & x);
double f_natural(const Vector & x);
real_t gFun(const Vector & x);
real_t f_natural(const Vector & x);
int main(int argc, char *argv[])
{
@@ -270,8 +270,8 @@ int main(int argc, char *argv[])
// 11. Solve the linear system with MINRES.
// Check the norm of the unpreconditioned residual.
int maxIter(1000);
double rtol(1.e-6);
double atol(1.e-10);
real_t rtol(1.e-6);
real_t atol(1.e-10);
chrono.Clear();
chrono.Start();
@@ -313,10 +313,10 @@ int main(int argc, char *argv[])
irs[i] = &(IntRules.Get(i, order_quad));
}
double err_u = u.ComputeL2Error(ucoeff, irs);
double norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
double err_p = p.ComputeL2Error(pcoeff, irs);
double norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
real_t err_u = u.ComputeL2Error(ucoeff, irs);
real_t norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
real_t err_p = p.ComputeL2Error(pcoeff, irs);
real_t norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
std::cout << "|| u_h - u_ex || / || u_ex || = " << err_u / norm_u << "\n";
std::cout << "|| p_h - p_ex || / || p_ex || = " << err_p / norm_p << "\n";
@@ -391,9 +391,9 @@ int main(int argc, char *argv[])
void uFun_ex(const Vector & x, Vector & u)
{
double xi(x(0));
double yi(x(1));
double zi(0.0);
real_t xi(x(0));
real_t yi(x(1));
real_t zi(0.0);
if (x.Size() == 3)
{
zi = x(2);
@@ -409,11 +409,11 @@ void uFun_ex(const Vector & x, Vector & u)
}
// Change if needed
double pFun_ex(const Vector & x)
real_t pFun_ex(const Vector & x)
{
double xi(x(0));
double yi(x(1));
double zi(0.0);
real_t xi(x(0));
real_t yi(x(1));
real_t zi(0.0);
if (x.Size() == 3)
{
@@ -428,7 +428,7 @@ void fFun(const Vector & x, Vector & f)
f = 0.0;
}
double gFun(const Vector & x)
real_t gFun(const Vector & x)
{
if (x.Size() == 3)
{
@@ -440,7 +440,7 @@ double gFun(const Vector & x)
}
}
double f_natural(const Vector & x)
real_t f_natural(const Vector & x)
{
return (-pFun_ex(x));
}
+18 -18
View File
@@ -46,10 +46,10 @@ using namespace mfem;
// Define the analytical solution and forcing terms / boundary conditions
void uFun_ex(const Vector & x, Vector & u);
double pFun_ex(const Vector & x);
real_t pFun_ex(const Vector & x);
void fFun(const Vector & x, Vector & f);
double gFun(const Vector & x);
double f_natural(const Vector & x);
real_t gFun(const Vector & x);
real_t f_natural(const Vector & x);
int main(int argc, char *argv[])
{
@@ -326,8 +326,8 @@ int main(int argc, char *argv[])
// 13. Solve the linear system with MINRES.
// Check the norm of the unpreconditioned residual.
int maxIter(pa ? 1000 : 500);
double rtol(1.e-6);
double atol(1.e-10);
real_t rtol(1.e-6);
real_t atol(1.e-10);
chrono.Clear();
chrono.Start();
@@ -371,10 +371,10 @@ int main(int argc, char *argv[])
irs[i] = &(IntRules.Get(i, order_quad));
}
double err_u = u->ComputeL2Error(ucoeff, irs);
double norm_u = ComputeGlobalLpNorm(2, ucoeff, *pmesh, irs);
double err_p = p->ComputeL2Error(pcoeff, irs);
double norm_p = ComputeGlobalLpNorm(2, pcoeff, *pmesh, irs);
real_t err_u = u->ComputeL2Error(ucoeff, irs);
real_t norm_u = ComputeGlobalLpNorm(2, ucoeff, *pmesh, irs);
real_t err_p = p->ComputeL2Error(pcoeff, irs);
real_t norm_p = ComputeGlobalLpNorm(2, pcoeff, *pmesh, irs);
if (verbose)
{
@@ -493,9 +493,9 @@ int main(int argc, char *argv[])
void uFun_ex(const Vector & x, Vector & u)
{
double xi(x(0));
double yi(x(1));
double zi(0.0);
real_t xi(x(0));
real_t yi(x(1));
real_t zi(0.0);
if (x.Size() == 3)
{
zi = x(2);
@@ -511,11 +511,11 @@ void uFun_ex(const Vector & x, Vector & u)
}
// Change if needed
double pFun_ex(const Vector & x)
real_t pFun_ex(const Vector & x)
{
double xi(x(0));
double yi(x(1));
double zi(0.0);
real_t xi(x(0));
real_t yi(x(1));
real_t zi(0.0);
if (x.Size() == 3)
{
@@ -530,7 +530,7 @@ void fFun(const Vector & x, Vector & f)
f = 0.0;
}
double gFun(const Vector & x)
real_t gFun(const Vector & x)
{
if (x.Size() == 3)
{
@@ -542,7 +542,7 @@ double gFun(const Vector & x)
}
}
double f_natural(const Vector & x)
real_t f_natural(const Vector & x)
{
return (-pFun_ex(x));
}
+8 -8
View File
@@ -28,8 +28,8 @@ using namespace std;
using namespace mfem;
// Exact solution and r.h.s., see below for implementation.
double analytic_solution(const Vector &x);
double analytic_rhs(const Vector &x);
real_t analytic_solution(const Vector &x);
real_t analytic_rhs(const Vector &x);
void SnapNodes(Mesh &mesh);
int main(int argc, char *argv[])
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
if (elem_type == 0) // inscribed octahedron
{
const double tri_v[6][3] =
const real_t tri_v[6][3] =
{
{ 1, 0, 0}, { 0, 1, 0}, {-1, 0, 0},
{ 0, -1, 0}, { 0, 0, 1}, { 0, 0, -1}
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
}
else // inscribed cube
{
const double quad_v[8][3] =
const real_t quad_v[8][3] =
{
{-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}
@@ -249,15 +249,15 @@ int main(int argc, char *argv[])
return 0;
}
double analytic_solution(const Vector &x)
real_t analytic_solution(const Vector &x)
{
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
return x(0)*x(1)/l2;
}
double analytic_rhs(const Vector &x)
real_t analytic_rhs(const Vector &x)
{
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
return 7*x(0)*x(1)/l2;
}
+9 -9
View File
@@ -28,8 +28,8 @@ using namespace std;
using namespace mfem;
// Exact solution and r.h.s., see below for implementation.
double analytic_solution(const Vector &x);
double analytic_rhs(const Vector &x);
real_t analytic_solution(const Vector &x);
real_t analytic_rhs(const Vector &x);
void SnapNodes(Mesh &mesh);
int main(int argc, char *argv[])
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
if (elem_type == 0) // inscribed octahedron
{
const double tri_v[6][3] =
const real_t tri_v[6][3] =
{
{ 1, 0, 0}, { 0, 1, 0}, {-1, 0, 0},
{ 0, -1, 0}, { 0, 0, 1}, { 0, 0, -1}
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
}
else // inscribed cube
{
const double quad_v[8][3] =
const real_t quad_v[8][3] =
{
{-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}
@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
delete b;
// 12. Compute and print the L^2 norm of the error.
double error = x.ComputeL2Error(sol_coef);
real_t error = x.ComputeL2Error(sol_coef);
if (myid == 0)
{
cout << "\nL2 norm of error: " << error << endl;
@@ -323,15 +323,15 @@ int main(int argc, char *argv[])
return 0;
}
double analytic_solution(const Vector &x)
real_t analytic_solution(const Vector &x)
{
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
return x(0)*x(1)/l2;
}
double analytic_rhs(const Vector &x)
real_t analytic_rhs(const Vector &x)
{
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
return 7*x(0)*x(1)/l2;
}
+2 -2
View File
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
SparseMatrix * Shat = RAP(matBhat, matSinv, matBhat);
#ifndef MFEM_USE_SUITESPARSE
const double prec_rtol = 1e-3;
const real_t prec_rtol = 1e-3;
const int prec_maxit = 200;
CGSolver *S0inv = new CGSolver;
S0inv->SetOperator(matS0);
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
Vector LSres(s_test);
B.Mult(x, LSres);
LSres -= F;
double res = sqrt(matSinv.InnerProduct(LSres, LSres));
real_t res = sqrt(matSinv.InnerProduct(LSres, LSres));
cout << "\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
}
+1 -1
View File
@@ -283,7 +283,7 @@ int main(int argc, char *argv[])
B.Mult(x, LSres);
LSres -= *trueF;
matSinv->Mult(LSres, tmp);
double res = sqrt(InnerProduct(LSres, tmp));
real_t res = sqrt(InnerProduct(LSres, tmp));
if (myid == 0)
{
cout << "\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
+25 -25
View File
@@ -58,10 +58,10 @@ int problem;
void velocity_function(const Vector &x, Vector &v);
// Initial condition
double u0_function(const Vector &x);
real_t u0_function(const Vector &x);
// Inflow boundary condition
double inflow_function(const Vector &x);
real_t inflow_function(const Vector &x);
// Mesh bounding box
Vector bb_min, bb_max;
@@ -72,7 +72,7 @@ private:
SparseMatrix &M, &K, A;
GMRESSolver linear_solver;
BlockILU prec;
double dt;
real_t dt;
public:
DG_Solver(SparseMatrix &M_, SparseMatrix &K_, const FiniteElementSpace &fes)
: M(M_),
@@ -89,7 +89,7 @@ public:
linear_solver.SetPreconditioner(prec);
}
void SetTimeStep(double dt_)
void SetTimeStep(real_t dt_)
{
if (dt_ != dt)
{
@@ -135,7 +135,7 @@ public:
FE_Evolution(BilinearForm &M_, BilinearForm &K_, const Vector &b_);
virtual void Mult(const Vector &x, Vector &y) const;
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
virtual ~FE_Evolution();
};
@@ -153,8 +153,8 @@ int main(int argc, char *argv[])
bool fa = false;
const char *device_config = "cpu";
int ode_solver_type = 4;
double t_final = 10.0;
double dt = 0.01;
real_t t_final = 10.0;
real_t dt = 0.01;
bool visualization = true;
bool visit = false;
bool paraview = false;
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
k.SetAssemblyLevel(AssemblyLevel::FULL);
}
m.AddDomainIntegrator(new MassIntegrator);
constexpr double alpha = -1.0;
constexpr real_t alpha = -1.0;
k.AddDomainIntegrator(new ConvectionIntegrator(velocity, alpha));
k.AddInteriorFaceIntegrator(
new NonconservativeDGTraceIntegrator(velocity, alpha));
@@ -393,14 +393,14 @@ int main(int argc, char *argv[])
// iterations, ti, with a time-step dt).
FE_Evolution adv(m, k, b);
double t = 0.0;
real_t t = 0.0;
adv.SetTime(t);
ode_solver->Init(adv);
bool done = false;
for (int ti = 0; !done; )
{
double dt_real = min(dt, t_final - t);
real_t dt_real = min(dt, t_final - t);
ode_solver->Step(u, t, dt_real);
ti++;
@@ -482,7 +482,7 @@ void FE_Evolution::Mult(const Vector &x, Vector &y) const
M_solver.Mult(z, y);
}
void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
void FE_Evolution::ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
{
MFEM_VERIFY(dg_solver != NULL,
"Implicit time integration is not supported with partial assembly");
@@ -507,7 +507,7 @@ void velocity_function(const Vector &x, Vector &v)
Vector X(dim);
for (int i = 0; i < dim; i++)
{
double center = (bb_min[i] + bb_max[i]) * 0.5;
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
}
@@ -529,7 +529,7 @@ void velocity_function(const Vector &x, Vector &v)
case 2:
{
// Clockwise rotation in 2D around the origin
const double w = M_PI/2;
const real_t w = M_PI/2;
switch (dim)
{
case 1: v(0) = 1.0; break;
@@ -541,8 +541,8 @@ void velocity_function(const Vector &x, Vector &v)
case 3:
{
// Clockwise twisting rotation in 2D around the origin
const double w = M_PI/2;
double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
const real_t w = M_PI/2;
real_t d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
d = d*d;
switch (dim)
{
@@ -556,7 +556,7 @@ void velocity_function(const Vector &x, Vector &v)
}
// Initial condition
double u0_function(const Vector &x)
real_t u0_function(const Vector &x)
{
int dim = x.Size();
@@ -564,7 +564,7 @@ double u0_function(const Vector &x)
Vector X(dim);
for (int i = 0; i < dim; i++)
{
double center = (bb_min[i] + bb_max[i]) * 0.5;
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
}
@@ -580,28 +580,28 @@ double u0_function(const Vector &x)
case 2:
case 3:
{
double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
real_t rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
if (dim == 3)
{
const double s = (1. + 0.25*cos(2*M_PI*X(2)));
const real_t s = (1. + 0.25*cos(2*M_PI*X(2)));
rx *= s;
ry *= s;
}
return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
return ( std::erfc(w*(X(0)-cx-rx))*std::erfc(-w*(X(0)-cx+rx)) *
std::erfc(w*(X(1)-cy-ry))*std::erfc(-w*(X(1)-cy+ry)) )/16;
}
}
}
case 2:
{
double x_ = X(0), y_ = X(1), rho, phi;
rho = hypot(x_, y_);
real_t x_ = X(0), y_ = X(1), rho, phi;
rho = std::hypot(x_, y_);
phi = atan2(y_, x_);
return pow(sin(M_PI*rho),2)*sin(3*phi);
}
case 3:
{
const double f = M_PI;
const real_t f = M_PI;
return sin(f*X(0))*sin(f*X(1));
}
}
@@ -609,7 +609,7 @@ double u0_function(const Vector &x)
}
// Inflow boundary condition (zero for the problems considered in this example)
double inflow_function(const Vector &x)
real_t inflow_function(const Vector &x)
{
switch (problem)
{
+25 -25
View File
@@ -59,10 +59,10 @@ int problem;
void velocity_function(const Vector &x, Vector &v);
// Initial condition
double u0_function(const Vector &x);
real_t u0_function(const Vector &x);
// Inflow boundary condition
double inflow_function(const Vector &x);
real_t inflow_function(const Vector &x);
// Mesh bounding box
Vector bb_min, bb_max;
@@ -135,7 +135,7 @@ private:
HypreParMatrix *A;
GMRESSolver linear_solver;
Solver *prec;
double dt;
real_t dt;
public:
DG_Solver(HypreParMatrix &M_, HypreParMatrix &K_, const FiniteElementSpace &fes,
PrecType prec_type)
@@ -169,7 +169,7 @@ public:
M.GetDiag(M_diag);
}
void SetTimeStep(double dt_)
void SetTimeStep(real_t dt_)
{
if (dt_ != dt)
{
@@ -224,7 +224,7 @@ public:
PrecType prec_type);
virtual void Mult(const Vector &x, Vector &y) const;
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
virtual ~FE_Evolution();
};
@@ -249,8 +249,8 @@ int main(int argc, char *argv[])
bool fa = false;
const char *device_config = "cpu";
int ode_solver_type = 4;
double t_final = 10.0;
double dt = 0.01;
real_t t_final = 10.0;
real_t dt = 0.01;
bool visualization = true;
bool visit = false;
bool paraview = false;
@@ -425,7 +425,7 @@ int main(int argc, char *argv[])
}
m->AddDomainIntegrator(new MassIntegrator);
constexpr double alpha = -1.0;
constexpr real_t alpha = -1.0;
k->AddDomainIntegrator(new ConvectionIntegrator(velocity, alpha));
k->AddInteriorFaceIntegrator(
new NonconservativeDGTraceIntegrator(velocity, alpha));
@@ -566,14 +566,14 @@ int main(int argc, char *argv[])
// iterations, ti, with a time-step dt).
FE_Evolution adv(*m, *k, *B, prec_type);
double t = 0.0;
real_t t = 0.0;
adv.SetTime(t);
ode_solver->Init(adv);
bool done = false;
for (int ti = 0; !done; )
{
double dt_real = min(dt, t_final - t);
real_t dt_real = min(dt, t_final - t);
ode_solver->Step(*U, t, dt_real);
ti++;
@@ -704,7 +704,7 @@ FE_Evolution::FE_Evolution(ParBilinearForm &M_, ParBilinearForm &K_,
// u_t = M^{-1}(Ku + b),
// by solving associated linear system
// (M - dt*K) d = K*u + b
void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
void FE_Evolution::ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
{
K->Mult(x, z);
z += b;
@@ -736,7 +736,7 @@ void velocity_function(const Vector &x, Vector &v)
Vector X(dim);
for (int i = 0; i < dim; i++)
{
double center = (bb_min[i] + bb_max[i]) * 0.5;
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
}
@@ -758,7 +758,7 @@ void velocity_function(const Vector &x, Vector &v)
case 2:
{
// Clockwise rotation in 2D around the origin
const double w = M_PI/2;
const real_t w = M_PI/2;
switch (dim)
{
case 1: v(0) = 1.0; break;
@@ -770,8 +770,8 @@ void velocity_function(const Vector &x, Vector &v)
case 3:
{
// Clockwise twisting rotation in 2D around the origin
const double w = M_PI/2;
double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
const real_t w = M_PI/2;
real_t d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
d = d*d;
switch (dim)
{
@@ -785,7 +785,7 @@ void velocity_function(const Vector &x, Vector &v)
}
// Initial condition
double u0_function(const Vector &x)
real_t u0_function(const Vector &x)
{
int dim = x.Size();
@@ -793,7 +793,7 @@ double u0_function(const Vector &x)
Vector X(dim);
for (int i = 0; i < dim; i++)
{
double center = (bb_min[i] + bb_max[i]) * 0.5;
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
}
@@ -809,28 +809,28 @@ double u0_function(const Vector &x)
case 2:
case 3:
{
double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
real_t rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
if (dim == 3)
{
const double s = (1. + 0.25*cos(2*M_PI*X(2)));
const real_t s = (1. + 0.25*cos(2*M_PI*X(2)));
rx *= s;
ry *= s;
}
return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
return ( std::erfc(w*(X(0)-cx-rx))*std::erfc(-w*(X(0)-cx+rx)) *
std::erfc(w*(X(1)-cy-ry))*std::erfc(-w*(X(1)-cy+ry)) )/16;
}
}
}
case 2:
{
double x_ = X(0), y_ = X(1), rho, phi;
rho = hypot(x_, y_);
real_t x_ = X(0), y_ = X(1), rho, phi;
rho = std::hypot(x_, y_);
phi = atan2(y_, x_);
return pow(sin(M_PI*rho),2)*sin(3*phi);
}
case 3:
{
const double f = M_PI;
const real_t f = M_PI;
return sin(f*X(0))*sin(f*X(1));
}
}
@@ -838,7 +838,7 @@ double u0_function(const Vector &x)
}
// Inflow boundary condition (zero for the problems considered in this example)
double inflow_function(const Vector &x)
real_t inflow_function(const Vector &x)
{
switch (problem)
{
+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;
+6 -3
View File
@@ -25,6 +25,8 @@ set(SRCS
integ/bilininteg_diffusion_ea.cpp
integ/bilininteg_diffusion_patch.cpp
integ/bilininteg_divdiv_pa.cpp
integ/bilininteg_elasticity_ea.cpp
integ/bilininteg_elasticity_pa.cpp
integ/bilininteg_gradient_pa.cpp
integ/bilininteg_interp_pa.cpp
integ/bilininteg_mass_mf.cpp
@@ -41,6 +43,7 @@ set(SRCS
integ/bilininteg_vectorfediv_pa.cpp
integ/bilininteg_vectorfemass_pa.cpp
integ/bilininteg_diffusion_kernels.cpp
integ/bilininteg_elasticity_kernels.cpp
integ/bilininteg_hcurl_kernels.cpp
integ/bilininteg_hdiv_kernels.cpp
integ/bilininteg_hcurlhdiv_kernels.cpp
@@ -77,6 +80,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 +100,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
@@ -155,6 +156,7 @@ set(HDRS
bilinearform_ext.hpp
bilininteg.hpp
integ/bilininteg_diffusion_kernels.hpp
integ/bilininteg_elasticity_kernels.hpp
integ/bilininteg_hcurl_kernels.hpp
integ/bilininteg_hdiv_kernels.hpp
integ/bilininteg_hcurlhdiv_kernels.hpp
@@ -186,6 +188,7 @@ set(HDRS
gridfunc.hpp
hybridization.hpp
intrules.hpp
intrules_cut.hpp
ceed/interface/basis.hpp
ceed/interface/integrator.hpp
ceed/interface/interface.hpp
+100 -52
View File
@@ -56,7 +56,7 @@ void BilinearForm::AllocMat()
int *I = dof_dof.GetI();
int *J = dof_dof.GetJ();
double *data = Memory<double>(I[height]);
real_t *data = Memory<real_t>(I[height]);
mat = new SparseMatrix(I, J, data, height, height, true, true, true);
*mat = 0.0;
@@ -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;
@@ -208,12 +209,12 @@ void BilinearForm::UseSparsity(SparseMatrix &A)
UseSparsity(A.GetI(), A.GetJ(), A.ColumnsAreSorted());
}
double& BilinearForm::Elem (int i, int j)
real_t& BilinearForm::Elem (int i, int j)
{
return mat -> Elem(i,j);
}
const double& BilinearForm::Elem (int i, int j) const
const real_t& BilinearForm::Elem (int i, int j) const
{
return mat -> Elem(i,j);
}
@@ -433,6 +434,9 @@ void BilinearForm::Assemble(int skip_zeros)
// Element-wise integration
for (int i = 0; i < fes -> GetNE(); i++)
{
// Set both doftrans (potentially needed to assemble the element
// matrix) and vdofs, which is also needed when the element matrices
// are pre-assembled.
doftrans = fes->GetElementVDofs(i, vdofs);
if (element_matrices)
{
@@ -441,6 +445,8 @@ 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 +454,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;
@@ -996,7 +1001,7 @@ void BilinearForm::EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
}
void BilinearForm::EliminateEssentialBCDiag (const Array<int> &bdr_attr_is_ess,
double value)
real_t value)
{
Array<int> ess_dofs, conf_ess_dofs;
fes->GetEssentialVDofs(bdr_attr_is_ess, ess_dofs);
@@ -1072,7 +1077,8 @@ void BilinearForm::EliminateEssentialBCFromDofs(
void BilinearForm::EliminateEssentialBCFromDofs (const Array<int> &ess_dofs,
DiagonalPolicy dpolicy)
{
MFEM_ASSERT(ess_dofs.Size() == height, "incorrect dof Array size");
MFEM_ASSERT(ess_dofs.Size() == height,
"incorrect dof Array size: " << ess_dofs.Size() << ' ' << height);
for (int i = 0; i < ess_dofs.Size(); i++)
if (ess_dofs[i] < 0)
@@ -1082,9 +1088,10 @@ void BilinearForm::EliminateEssentialBCFromDofs (const Array<int> &ess_dofs,
}
void BilinearForm::EliminateEssentialBCFromDofsDiag (const Array<int> &ess_dofs,
double value)
real_t value)
{
MFEM_ASSERT(ess_dofs.Size() == height, "incorrect dof Array size");
MFEM_ASSERT(ess_dofs.Size() == height,
"incorrect dof Array size: " << ess_dofs.Size() << ' ' << height);
for (int i = 0; i < ess_dofs.Size(); i++)
if (ess_dofs[i] < 0)
@@ -1222,11 +1229,14 @@ MixedBilinearForm::MixedBilinearForm (FiniteElementSpace *tr_fes,
// 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;
@@ -1264,12 +1274,12 @@ void MixedBilinearForm::SetAssemblyLevel(AssemblyLevel assembly_level)
}
}
double & MixedBilinearForm::Elem (int i, int j)
real_t & MixedBilinearForm::Elem (int i, int j)
{
return (*mat)(i, j);
}
const double & MixedBilinearForm::Elem (int i, int j) const
const real_t & MixedBilinearForm::Elem (int i, int j) const
{
return (*mat)(i, j);
}
@@ -1281,7 +1291,7 @@ void MixedBilinearForm::Mult(const Vector & x, Vector & y) const
}
void MixedBilinearForm::AddMult(const Vector & x, Vector & y,
const double a) const
const real_t a) const
{
if (ext)
{
@@ -1300,7 +1310,7 @@ void MixedBilinearForm::MultTranspose(const Vector & x, Vector & y) const
}
void MixedBilinearForm::AddMultTranspose(const Vector & x, Vector & y,
const double a) const
const real_t a) const
{
if (ext)
{
@@ -1349,6 +1359,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 +1401,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)
{
@@ -1405,8 +1423,20 @@ void MixedBilinearForm::Assemble (int skip_zeros)
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++)
{
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);
@@ -1415,10 +1445,14 @@ void MixedBilinearForm::Assemble (int skip_zeros)
elmat = 0.0;
for (int k = 0; k < domain_integs.Size(); k++)
{
domain_integs[k] -> AssembleElementMatrix2 (*trial_fes -> GetFE(i),
*test_fes -> GetFE(i),
*eltrans, elemmat);
elmat += elemmat;
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)
{
@@ -1941,41 +1975,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 +2033,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);
}
}
}
+37 -22
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;
@@ -279,13 +279,13 @@ public:
{ return &boundary_face_integs_marker; }
/// Returns a reference to: \f$ M_{ij} \f$
const double &operator()(int i, int j) { return (*mat)(i,j); }
const real_t &operator()(int i, int j) { return (*mat)(i,j); }
/// Returns a reference to: \f$ M_{ij} \f$
virtual double &Elem(int i, int j);
virtual real_t &Elem(int i, int j);
/// Returns constant reference to: \f$ M_{ij} \f$
virtual const double &Elem(int i, int j) const;
virtual const real_t &Elem(int i, int j) const;
/// Matrix vector multiplication: \f$ y = M x \f$
virtual void Mult(const Vector &x, Vector &y) const;
@@ -297,7 +297,7 @@ public:
{ mat->Mult(x, y); mat_e->AddMult(x, y); }
/// Add the matrix vector multiple to a vector: \f$ y += a M x \f$
virtual void AddMult(const Vector &x, Vector &y, const double a = 1.0) const
virtual void AddMult(const Vector &x, Vector &y, const real_t a = 1.0) const
{ mat -> AddMult (x, y, a); }
/** @brief Add the original uneliminated matrix vector multiple to a vector.
@@ -308,7 +308,7 @@ public:
/// Add the matrix transpose vector multiplication: \f$ y += a M^T x \f$
virtual void AddMultTranspose(const Vector & x, Vector & y,
const double a = 1.0) const
const real_t a = 1.0) const
{ mat->AddMultTranspose(x, y, a); }
/** @brief Add the original uneliminated matrix transpose vector
@@ -321,7 +321,7 @@ public:
virtual void MultTranspose(const Vector & x, Vector & y) const;
/// Compute \f$ y^T M x \f$
double InnerProduct(const Vector &x, const Vector &y) const
real_t InnerProduct(const Vector &x, const Vector &y) const
{ return mat->InnerProduct (x, y); }
/// Returns a pointer to (approximation) of the matrix inverse: \f$ M^{-1} \f$
@@ -423,7 +423,7 @@ public:
Array<int> &bdr_marker);
/// Sets all sparse values of \f$ M \f$ and \f$ M_e \f$ to 'a'.
void operator=(const double a)
void operator=(const real_t a)
{
if (mat != NULL) { *mat = a; }
if (mat_e != NULL) { *mat_e = a; }
@@ -614,7 +614,7 @@ public:
DiagonalPolicy dpolicy = DIAG_ONE);
/// Perform elimination and set the diagonal entry to the given value
void EliminateEssentialBCDiag(const Array<int> &bdr_attr_is_ess,
double value);
real_t value);
/// Eliminate the given @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
/** In this case the eliminations are applied to the internal \f$ M \f$
@@ -643,7 +643,7 @@ public:
DiagonalPolicy dpolicy = DIAG_ONE);
/// Perform elimination and set the diagonal entry to the given value
void EliminateEssentialBCFromDofsDiag(const Array<int> &ess_dofs,
double value);
real_t value);
/** @brief Use the stored eliminated part of the matrix (see
EliminateVDofs(const Array<int> &, DiagonalPolicy)) to modify the r.h.s.
@@ -652,7 +652,7 @@ public:
Vector &b);
/// Compute inner product for full uneliminated matrix \f$ y^T M x + y^T M_e x \f$
double FullInnerProduct(const Vector &x, const Vector &y) const
real_t FullInnerProduct(const Vector &x, const Vector &y) const
{ return mat->InnerProduct(x, y) + mat_e->InnerProduct(x, y); }
/// Update the @a FiniteElementSpace and delete all data associated with the old one.
@@ -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;
@@ -767,20 +770,20 @@ public:
MixedBilinearForm *mbf);
/// Returns a reference to: \f$ M_{ij} \f$
virtual double &Elem(int i, int j);
virtual real_t &Elem(int i, int j);
/// Returns a reference to: \f$ M_{ij} \f$
virtual const double &Elem(int i, int j) const;
virtual const real_t &Elem(int i, int j) const;
/// Matrix multiplication: \f$ y = M x \f$
virtual void Mult(const Vector & x, Vector & y) const;
virtual void AddMult(const Vector & x, Vector & y,
const double a = 1.0) const;
const real_t a = 1.0) const;
virtual void MultTranspose(const Vector & x, Vector & y) const;
virtual void AddMultTranspose(const Vector & x, Vector & y,
const double a = 1.0) const;
const real_t a = 1.0) const;
virtual MatrixInverse *Inverse() const;
@@ -805,12 +808,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 +827,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; }
@@ -849,7 +860,7 @@ public:
{ return &boundary_trace_face_integs_marker; }
/// Sets all sparse values of \f$ M \f$ to @a a.
void operator=(const double a) { *mat = a; }
void operator=(const real_t a) { *mat = a; }
/// Set the desired assembly level. The default is AssemblyLevel::LEGACY.
/** This method must be called before assembly. */
@@ -1065,6 +1076,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 +1086,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. */
+15 -17
View File
@@ -255,9 +255,7 @@ PABilinearFormExtension::PABilinearFormExtension(BilinearForm *form)
void PABilinearFormExtension::SetupRestrictionOperators(const L2FaceValues m)
{
if ( Device::Allows(Backend::CEED_MASK) ) { return; }
ElementDofOrdering ordering = UsesTensorBasis(*a->FESpace())?
ElementDofOrdering::LEXICOGRAPHIC:
ElementDofOrdering::NATIVE;
ElementDofOrdering ordering = GetEVectorOrdering(*a->FESpace());
elem_restrict = trial_fes->GetElementRestriction(ordering);
if (elem_restrict)
{
@@ -303,7 +301,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);
@@ -791,7 +789,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
{
const int e = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A(i, j, e)*X(i, e);
@@ -826,7 +824,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
{
const int f = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A_int(i, j, 0, f)*X(i, 0, f);
@@ -845,7 +843,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
{
const int f = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A_ext(i, j, 0, f)*X(i, 0, f);
@@ -882,7 +880,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
{
const int f = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A(i, j, f)*X(i, f);
@@ -919,7 +917,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
{
const int e = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A(j, i, e)*X(i, e);
@@ -954,7 +952,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
{
const int f = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A_int(j, i, 0, f)*X(i, 0, f);
@@ -973,7 +971,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
{
const int f = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A_ext(j, i, 1, f)*X(i, 0, f);
@@ -1010,7 +1008,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
{
const int f = glob_j/NDOFS;
const int j = glob_j%NDOFS;
double res = 0.0;
real_t res = 0.0;
for (int i = 0; i < NDOFS; i++)
{
res += A(j, i, f)*X(i, f);
@@ -1438,7 +1436,7 @@ void PAMixedBilinearFormExtension::SetupMultInputs(
const Operator *elem_restrict_y,
Vector &y,
Vector &localY,
const double c) const
const real_t c) const
{
// * G operation: localX = c*local(x)
if (elem_restrict_x)
@@ -1478,7 +1476,7 @@ void PAMixedBilinearFormExtension::Mult(const Vector &x, Vector &y) const
}
void PAMixedBilinearFormExtension::AddMult(const Vector &x, Vector &y,
const double c) const
const real_t c) const
{
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
const int iSz = integrators.Size();
@@ -1510,7 +1508,7 @@ void PAMixedBilinearFormExtension::MultTranspose(const Vector &x,
}
void PAMixedBilinearFormExtension::AddMultTranspose(const Vector &x, Vector &y,
const double c) const
const real_t c) const
{
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
const int iSz = integrators.Size();
@@ -1644,7 +1642,7 @@ void PADiscreteLinearOperatorExtension::Assemble()
}
void PADiscreteLinearOperatorExtension::AddMult(
const Vector &x, Vector &y, const double c) const
const Vector &x, Vector &y, const real_t c) const
{
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
const int iSz = integrators.Size();
@@ -1677,7 +1675,7 @@ void PADiscreteLinearOperatorExtension::AddMult(
}
void PADiscreteLinearOperatorExtension::AddMultTranspose(
const Vector &x, Vector &y, const double c) const
const Vector &x, Vector &y, const real_t c) const
{
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
const int iSz = integrators.Size();
+5 -5
View File
@@ -248,7 +248,7 @@ protected:
void SetupMultInputs(const Operator *elem_restrict_x,
const Vector &x, Vector &localX,
const Operator *elem_restrict_y,
Vector &y, Vector &localY, const double c) const;
Vector &y, Vector &localY, const real_t c) const;
public:
PAMixedBilinearFormExtension(MixedBilinearForm *form);
@@ -277,11 +277,11 @@ public:
/// y = A*x
void Mult(const Vector &x, Vector &y) const;
/// y += c*A*x
void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
void AddMult(const Vector &x, Vector &y, const real_t c=1.0) const;
/// y = A^T*x
void MultTranspose(const Vector &x, Vector &y) const;
/// y += c*A^T*x
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
void AddMultTranspose(const Vector &x, Vector &y, const real_t c=1.0) const;
/// Assemble the diagonal of ADA^T for a diagonal vector D.
void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const;
@@ -305,9 +305,9 @@ public:
/// Partial assembly of all internal integrators
void Assemble();
void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
void AddMult(const Vector &x, Vector &y, const real_t c=1.0) const;
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
void AddMultTranspose(const Vector &x, Vector &y, const real_t c=1.0) const;
void FormRectangularSystemOperator(const Array<int>&, const Array<int>&,
OperatorHandle& A);
+105 -97
View File
@@ -14,6 +14,7 @@
#include "fem.hpp"
#include <cmath>
#include <algorithm>
#include <memory>
using namespace std;
@@ -497,7 +498,7 @@ void MixedScalarIntegrator::AssembleElementMatrix2(
this->CalcTestShape(test_fe, Trans, test_shape);
this->CalcTrialShape(trial_fe, Trans, trial_shape);
double w = Trans.Weight() * ip.weight;
real_t w = Trans.Weight() * ip.weight;
if (Q)
{
@@ -591,7 +592,7 @@ void MixedVectorIntegrator::AssembleElementMatrix2(
this->CalcTrialShape(trial_fe, Trans, trial_shape);
}
double w = Trans.Weight() * ip.weight;
real_t w = Trans.Weight() * ip.weight;
if (MQ)
{
@@ -705,7 +706,7 @@ void MixedScalarVectorIntegrator::AssembleElementMatrix2(
int sca_nd = sca_fe->GetDof();
int vec_nd = vec_fe->GetDof();
int vdim = GetVDim(*vec_fe);
double vtmp;
real_t vtmp;
MFEM_VERIFY(VQ->GetVDim() == vdim, "MixedScalarVectorIntegrator: "
"Dimensions of VectorCoefficient and Vector-valued basis "
@@ -744,7 +745,7 @@ void MixedScalarVectorIntegrator::AssembleElementMatrix2(
this->CalcShape(*sca_fe, Trans, shape);
this->CalcVShape(*vec_fe, Trans, vshape);
double w = Trans.Weight() * ip.weight;
real_t w = Trans.Weight() * ip.weight;
VQ->Eval(V, Trans, ip);
V *= w;
@@ -769,7 +770,7 @@ void GradientIntegrator::AssembleElementMatrix2(
dim = test_fe.GetDim();
int trial_dof = trial_fe.GetDof();
int test_dof = test_fe.GetDof();
double c;
real_t c;
Vector d_col;
dshape.SetSize(trial_dof, dim);
@@ -787,13 +788,13 @@ void GradientIntegrator::AssembleElementMatrix2(
for (int i = 0; i < ir->GetNPoints(); i++)
{
const IntegrationPoint &ip = ir->IntPoint(i);
trial_fe.CalcDShape(ip, dshape);
test_fe.CalcShape(ip, shape);
Trans.SetIntPoint(&ip);
CalcAdjugate(Trans.Jacobian(), Jadj);
test_fe.CalcPhysShape(Trans, shape);
trial_fe.CalcDShape(ip, dshape);
Mult(dshape, Jadj, gshape);
c = ip.weight;
@@ -836,7 +837,7 @@ void DiffusionIntegrator::AssembleElementMatrix
dim = el.GetDim();
int spaceDim = Trans.GetSpaceDim();
bool square = (dim == spaceDim);
double w;
real_t w;
if (VQ)
{
@@ -930,7 +931,7 @@ void DiffusionIntegrator::AssembleElementMatrix2(
dim = trial_fe.GetDim();
int spaceDim = Trans.GetSpaceDim();
bool square = (dim == spaceDim);
double w;
real_t w;
if (VQ)
{
@@ -1012,7 +1013,7 @@ void DiffusionIntegrator::AssembleElementVector(
int nd = el.GetDof();
dim = el.GetDim();
int spaceDim = Tr.GetSpaceDim();
double w;
real_t w;
if (VQ)
{
@@ -1186,7 +1187,7 @@ void DiffusionIntegrator::ComputeElementFlux
}
}
double DiffusionIntegrator::ComputeFluxEnergy
real_t DiffusionIntegrator::ComputeFluxEnergy
( const FiniteElement &fluxelem, ElementTransformation &Trans,
Vector &flux, Vector* d_energy)
{
@@ -1209,7 +1210,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
int order = 2 * fluxelem.GetOrder(); // <--
const IntegrationRule *ir = &IntRules.Get(fluxelem.GetGeomType(), order);
double energy = 0.0;
real_t energy = 0.0;
if (d_energy) { *d_energy = 0.0; }
for (int i = 0; i < ir->GetNPoints(); i++)
@@ -1227,7 +1228,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
}
Trans.SetIntPoint(&ip);
double w = Trans.Weight() * ip.weight;
real_t w = Trans.Weight() * ip.weight;
if (MQ)
{
@@ -1242,7 +1243,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
}
else
{
double e = (pointflux * pointflux);
real_t e = (pointflux * pointflux);
if (Q) { e *= Q->Eval(Trans, ip); }
energy += w * e;
}
@@ -1290,7 +1291,7 @@ void MassIntegrator::AssembleElementMatrix
{
int nd = el.GetDof();
// int dim = el.GetDim();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
Vector shape;
@@ -1324,7 +1325,7 @@ void MassIntegrator::AssembleElementMatrix2(
{
int tr_nd = trial_fe.GetDof();
int te_nd = test_fe.GetDof();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
Vector shape, te_shape;
@@ -1340,10 +1341,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)
{
@@ -1378,7 +1380,7 @@ void BoundaryMassIntegrator::AssembleFaceMatrix(
"support for interior faces is not implemented");
int nd1 = el1.GetDof();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
Vector shape;
@@ -1497,15 +1499,15 @@ void GroupConvectionIntegrator::AssembleElementMatrix(
Mult(dshape, adjJ, grad);
double w = alpha * ip.weight;
real_t w = alpha * ip.weight;
// elmat(k,l) += \sum_s w*shape(k)*Q_nodal(s,k)*grad(l,s)
for (int k = 0; k < nd; k++)
{
double wsk = w*shape(k);
real_t wsk = w*shape(k);
for (int l = 0; l < nd; l++)
{
double a = 0.0;
real_t a = 0.0;
for (int s = 0; s < dim; s++)
{
a += Q_nodal(s,k)*grad(l,s);
@@ -1538,7 +1540,7 @@ void VectorMassIntegrator::AssembleElementMatrix
int nd = el.GetDof();
int spaceDim = Trans.GetSpaceDim();
double norm;
real_t norm;
// If vdim is not set, set it to the space dimension
vdim = (vdim == -1) ? spaceDim : vdim;
@@ -1620,7 +1622,7 @@ void VectorMassIntegrator::AssembleElementMatrix2(
int tr_nd = trial_fe.GetDof();
int te_nd = test_fe.GetDof();
double norm;
real_t norm;
// If vdim is not set, set it to the space dimension
vdim = (vdim == -1) ? Trans.GetSpaceDim() : vdim;
@@ -1727,7 +1729,7 @@ void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
trial_fe.CalcDivShape(ip, divshape);
Trans.SetIntPoint(&ip);
test_fe.CalcPhysShape(Trans, shape);
double w = ip.weight;
real_t w = ip.weight;
if (Q)
{
Trans.SetIntPoint(&ip);
@@ -1808,7 +1810,7 @@ void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
trial_fe.CalcVShape(Trans, vshape);
double w = ip.weight;
real_t w = ip.weight;
if (Q)
{
@@ -1898,7 +1900,7 @@ void VectorFECurlIntegrator::AssembleElementMatrix2(
}
}
double w = ip.weight;
real_t w = ip.weight;
if (Q)
{
@@ -1929,7 +1931,7 @@ void DerivativeIntegrator::AssembleElementMatrix2 (
int spaceDim = Trans.GetSpaceDim();
int i, l;
double det;
real_t det;
elmat.SetSize (test_nd,trial_nd);
dshape.SetSize (trial_nd,dim);
@@ -1992,7 +1994,7 @@ void CurlCurlIntegrator::AssembleElementMatrix
int nd = el.GetDof();
dim = el.GetDim();
int dimc = el.GetCurlDim();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
Vector D;
@@ -2065,7 +2067,7 @@ void CurlCurlIntegrator::AssembleElementMatrix2(const FiniteElement &trial_fe,
int te_nd = test_fe.GetDof();
dim = trial_fe.GetDim();
int dimc = trial_fe.GetCurlDim();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
Vector D;
@@ -2152,7 +2154,7 @@ void CurlCurlIntegrator
// TODO: Q, wcoef?
}
double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
real_t CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
ElementTransformation &Trans,
Vector &flux, Vector *d_energy)
{
@@ -2169,7 +2171,7 @@ double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
int order = 2 * fluxelem.GetOrder(); // <--
const IntegrationRule &ir = IntRules.Get(fluxelem.GetGeomType(), order);
double energy = 0.0;
real_t energy = 0.0;
if (d_energy) { *d_energy = 0.0; }
Vector* pfluxes = NULL;
@@ -2187,9 +2189,9 @@ double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
// fluxelem.CalcVShape(ip, vshape);
vshape.MultTranspose(flux, pointflux);
double w = Trans.Weight() * ip.weight;
real_t w = Trans.Weight() * ip.weight;
double e = w * (pointflux * pointflux);
real_t e = w * (pointflux * pointflux);
if (Q)
{
@@ -2291,7 +2293,7 @@ void VectorCurlCurlIntegrator::AssembleElementMatrix(
Trans.SetIntPoint(&ip);
CalcAdjugate(Trans.Jacobian(), Jadj);
double w = ip.weight / Trans.Weight();
real_t w = ip.weight / Trans.Weight();
Mult(dshape_hat, Jadj, dshape);
dshape.GradToCurl(curlshape);
@@ -2305,7 +2307,7 @@ void VectorCurlCurlIntegrator::AssembleElementMatrix(
}
}
double VectorCurlCurlIntegrator::GetElementEnergy(
real_t VectorCurlCurlIntegrator::GetElementEnergy(
const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun)
{
int dim = el.GetDim();
@@ -2330,7 +2332,7 @@ double VectorCurlCurlIntegrator::GetElementEnergy(
ir = &IntRules.Get(el.GetGeomType(), order);
}
double energy = 0.;
real_t energy = 0.;
for (int i = 0; i < ir->GetNPoints(); i++)
{
const IntegrationPoint &ip = ir->IntPoint(i);
@@ -2340,20 +2342,20 @@ double VectorCurlCurlIntegrator::GetElementEnergy(
Tr.SetIntPoint(&ip);
CalcAdjugate(Tr.Jacobian(), Jadj);
double w = ip.weight / Tr.Weight();
real_t w = ip.weight / Tr.Weight();
Mult(grad_hat, Jadj, grad);
if (dim == 2)
{
double curl = grad(0,1) - grad(1,0);
real_t curl = grad(0,1) - grad(1,0);
w *= curl * curl;
}
else
{
double curl_x = grad(2,1) - grad(1,2);
double curl_y = grad(0,2) - grad(2,0);
double curl_z = grad(1,0) - grad(0,1);
real_t curl_x = grad(2,1) - grad(1,2);
real_t curl_y = grad(0,2) - grad(2,0);
real_t curl_z = grad(1,0) - grad(0,1);
w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
}
@@ -2403,7 +2405,7 @@ void MixedCurlIntegrator::AssembleElementMatrix2(
shape.SetSize(test_dof);
elmat = 0.0;
double c;
real_t c;
Vector d_col;
const IntegrationRule *ir = IntRule;
@@ -2436,7 +2438,7 @@ void MixedCurlIntegrator::AssembleElementMatrix2(
for (int d = 0; d < dimc; ++d)
{
double * curldata = &(curlshape.GetData())[d*trial_dof];
real_t * curldata = &(curlshape.GetData())[d*trial_dof];
for (int jj = 0; jj < trial_dof; ++jj)
{
for (int ii = 0; ii < test_dof; ++ii)
@@ -2458,7 +2460,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix(
int spaceDim = Trans.GetSpaceDim();
int vdim = std::max(spaceDim, el.GetRangeDim());
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
Vector D(DQ ? DQ->GetVDim() : 0);
@@ -2527,7 +2529,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
int vdim = std::max(spaceDim, trial_fe.GetRangeDim());
int trial_dof = trial_fe.GetDof();
int test_dof = test_fe.GetDof();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
DenseMatrix trial_vshape(trial_dof, spaceDim);
@@ -2587,7 +2589,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
{
for (int k = 0; k < trial_dof; k++)
{
double Kv = 0.0;
real_t Kv = 0.0;
for (int vd = 0; vd < spaceDim; vd++)
{
Kv += K(d, vd) * trial_vshape(k, vd);
@@ -2626,7 +2628,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
int test_vdim = std::max(spaceDim, test_fe.GetRangeDim());
int trial_dof = trial_fe.GetDof();
int test_dof = test_fe.GetDof();
double w;
real_t w;
#ifdef MFEM_THREAD_SAFE
DenseMatrix trial_vshape(trial_dof,trial_vdim);
@@ -2700,7 +2702,7 @@ void VectorDivergenceIntegrator::AssembleElementMatrix2(
dim = trial_fe.GetDim();
int trial_dof = trial_fe.GetDof();
int test_dof = test_fe.GetDof();
double c;
real_t c;
dshape.SetSize (trial_dof, dim);
gshape.SetSize (trial_dof, dim);
@@ -2757,7 +2759,7 @@ void DivDivIntegrator::AssembleElementMatrix(
DenseMatrix &elmat)
{
int dof = el.GetDof();
double c;
real_t c;
#ifdef MFEM_THREAD_SAFE
Vector divshape(dof);
@@ -2802,7 +2804,7 @@ void DivDivIntegrator::AssembleElementMatrix2(
{
int tr_nd = trial_fe.GetDof();
int te_nd = test_fe.GetDof();
double c;
real_t c;
#ifdef MFEM_THREAD_SAFE
Vector divshape(tr_nd);
@@ -2886,7 +2888,7 @@ void VectorDiffusionIntegrator::AssembleElementMatrix(
el.CalcDShape(ip, dshape);
Trans.SetIntPoint(&ip);
double w = Trans.Weight();
real_t w = Trans.Weight();
w = ip.weight / (square ? w : w*w*w);
// AdjugateJacobian = / adj(J), if J is square
// \ adj(J^t.J).J^t, otherwise
@@ -2971,7 +2973,7 @@ void VectorDiffusionIntegrator::AssembleElementVector(
el.CalcDShape(ip, dshape);
Tr.SetIntPoint(&ip);
double w = Tr.Weight();
real_t w = Tr.Weight();
w = ip.weight / (square ? w : w*w*w);
Mult(dshape, Tr.AdjugateJacobian(), dshapedxt);
MultAAt(dshapedxt, pelmat);
@@ -3015,13 +3017,19 @@ void VectorDiffusionIntegrator::AssembleElementVector(
}
}
ElasticityComponentIntegrator::ElasticityComponentIntegrator(
ElasticityIntegrator &parent_, int i_, int j_)
: parent(parent_),
i_block(i_),
j_block(j_)
{ }
void ElasticityIntegrator::AssembleElementMatrix(
const FiniteElement &el, ElementTransformation &Trans, DenseMatrix &elmat)
{
int dof = el.GetDof();
int dim = el.GetDim();
double w, L, M;
real_t w, L, M;
MFEM_ASSERT(dim == Trans.GetSpaceDim(), "");
@@ -3106,7 +3114,7 @@ void ElasticityIntegrator::ComputeElementFlux(
const int dof = el.GetDof();
const int dim = el.GetDim();
const int tdim = dim*(dim+1)/2; // num. entries in a symmetric tensor
double L, M;
real_t L, M;
MFEM_ASSERT(dim == 2 || dim == 3,
"dimension is not supported: dim = " << dim);
@@ -3120,7 +3128,7 @@ void ElasticityIntegrator::ComputeElementFlux(
dshape.SetSize(dof, dim);
#endif
double gh_data[9], grad_data[9];
real_t gh_data[9], grad_data[9];
DenseMatrix gh(gh_data, dim, dim);
DenseMatrix grad(grad_data, dim, dim);
@@ -3154,7 +3162,7 @@ void ElasticityIntegrator::ComputeElementFlux(
// stress = 2*M*e(u) + L*tr(e(u))*I, where
// e(u) = (1/2)*(grad(u) + grad(u)^T)
const double M2 = 2.0*M;
const real_t M2 = 2.0*M;
if (dim == 2)
{
L *= (grad(0,0) + grad(1,1));
@@ -3177,14 +3185,14 @@ void ElasticityIntegrator::ComputeElementFlux(
}
}
double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
real_t ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
ElementTransformation &Trans,
Vector &flux, Vector *d_energy)
{
const int dof = fluxelem.GetDof();
const int dim = fluxelem.GetDim();
const int tdim = dim*(dim+1)/2; // num. entries in a symmetric tensor
double L, M;
real_t L, M;
// The MFEM_ASSERT constraints in ElasticityIntegrator::ComputeElementFlux
// are assumed here too.
@@ -3196,7 +3204,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
#else
Vector shape(dof);
#endif
double pointstress_data[6];
real_t pointstress_data[6];
Vector pointstress(pointstress_data, tdim);
// View of the 'flux' vector as a (dof x tdim) matrix
@@ -3212,7 +3220,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
ir = &IntRules.Get(fluxelem.GetGeomType(), order);
}
double energy = 0.0;
real_t energy = 0.0;
for (int i = 0; i < ir->GetNPoints(); i++)
{
@@ -3222,7 +3230,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
flux_mat.MultTranspose(shape, pointstress);
Trans.SetIntPoint(&ip);
double w = Trans.Weight() * ip.weight;
real_t w = Trans.Weight() * ip.weight;
M = mu->Eval(Trans, ip);
if (lambda)
@@ -3246,19 +3254,19 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
// Then from the first identity above we can find the strain:
// e = (1/(2*mu))*(s - lambda*tr(e)*I)
double pt_e; // point strain energy density
const double *s = pointstress_data;
real_t pt_e; // point strain energy density
const real_t *s = pointstress_data;
if (dim == 2)
{
// s entries: s_xx, s_yy, s_xy
const double tr_e = (s[0] + s[1])/(2*(M + L));
const real_t tr_e = (s[0] + s[1])/(2*(M + L));
L *= tr_e;
pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + 2*s[2]*s[2]);
}
else // (dim == 3)
{
// s entries: s_xx, s_yy, s_zz, s_xy, s_xz, s_yz
const double tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
const real_t tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
L *= tr_e;
pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + s[2]*(s[2] - L) +
2*(s[3]*s[3] + s[4]*s[4] + s[5]*s[5]));
@@ -3277,7 +3285,7 @@ void DGTraceIntegrator::AssembleFaceMatrix(const FiniteElement &el1,
{
int ndof1, ndof2;
double un, a, b, w;
real_t un, a, b, w;
dim = el1.GetDim();
ndof1 = el1.GetDof();
@@ -3350,7 +3358,7 @@ void DGTraceIntegrator::AssembleFaceMatrix(const FiniteElement &el1,
if (rho)
{
double rho_p;
real_t rho_p;
if (un >= 0.0 && ndof2)
{
rho_p = rho->Eval(*Trans.Elem2, eip2);
@@ -3417,7 +3425,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
{
int dim, ndof1, ndof2, ndofs;
bool kappa_is_nonzero = (kappa != 0.);
double w, wq = 0.0;
real_t w, wq = 0.0;
dim = el1.GetDim();
ndof1 = el1.GetDof();
@@ -3592,7 +3600,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
wq *= kappa;
for (int i = 0; i < ndof1; i++)
{
const double wsi = wq*shape1(i);
const real_t wsi = wq*shape1(i);
for (int j = 0; j <= i; j++)
{
jmat(i, j) += wsi * shape1(j);
@@ -3603,7 +3611,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
for (int i = 0; i < ndof2; i++)
{
const int i2 = ndof1 + i;
const double wsi = wq*shape2(i);
const real_t wsi = wq*shape2(i);
for (int j = 0; j < ndof1; j++)
{
jmat(i2, j) -= wsi * shape1(j);
@@ -3624,7 +3632,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
{
for (int j = 0; j < i; j++)
{
double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
real_t aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
elmat(i,j) = sigma*aji - aij + mij;
elmat(j,i) = sigma*aij - aji + mij;
}
@@ -3637,7 +3645,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
{
for (int j = 0; j < i; j++)
{
double aij = elmat(i,j), aji = elmat(j,i);
real_t aij = elmat(i,j), aji = elmat(j,i);
elmat(i,j) = sigma*aji - aij;
elmat(j,i) = sigma*aij - aji;
}
@@ -3651,7 +3659,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
void DGElasticityIntegrator::AssembleBlock(
const int dim, const int row_ndofs, const int col_ndofs,
const int row_offset, const int col_offset,
const double jmatcoef, const Vector &col_nL, const Vector &col_nM,
const real_t jmatcoef, const Vector &col_nL, const Vector &col_nM,
const Vector &row_shape, const Vector &col_shape,
const Vector &col_dshape_dnM, const DenseMatrix &col_dshape,
DenseMatrix &elmat, DenseMatrix &jmat)
@@ -3660,12 +3668,12 @@ void DGElasticityIntegrator::AssembleBlock(
{
for (int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
{
const double t2 = col_dshape_dnM(jdof);
const real_t t2 = col_dshape_dnM(jdof);
for (int im = 0, i = row_offset; im < dim; ++im)
{
const double t1 = col_dshape(jdof, jm) * col_nL(im);
const double t3 = col_dshape(jdof, im) * col_nM(jm);
const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
const real_t t1 = col_dshape(jdof, jm) * col_nL(im);
const real_t t3 = col_dshape(jdof, im) * col_nM(jm);
const real_t tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
for (int idof = 0; idof < row_ndofs; ++idof, ++i)
{
elmat(i, j) += row_shape(idof) * tt;
@@ -3682,7 +3690,7 @@ void DGElasticityIntegrator::AssembleBlock(
const int io = row_offset + d*row_ndofs;
for (int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
{
const double sj = jmatcoef * col_shape(jdof);
const real_t sj = jmatcoef * col_shape(jdof);
for (int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
{
jmat(i, j) += row_shape(idof) * sj;
@@ -3782,7 +3790,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
CalcOrtho(Trans.Jacobian(), nor);
}
double w, wLM;
real_t w, wLM;
if (ndofs2)
{
el2.CalcShape(eip2, shape2);
@@ -3791,9 +3799,9 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
Mult(dshape2, adjJ, dshape2_ps);
w = ip.weight/2;
const double w2 = w / Trans.Elem2->Weight();
const double wL2 = w2 * lambda->Eval(*Trans.Elem2, eip2);
const double wM2 = w2 * mu->Eval(*Trans.Elem2, eip2);
const real_t w2 = w / Trans.Elem2->Weight();
const real_t wL2 = w2 * lambda->Eval(*Trans.Elem2, eip2);
const real_t wM2 = w2 * mu->Eval(*Trans.Elem2, eip2);
nL2.Set(wL2, nor);
nM2.Set(wM2, nor);
wLM = (wL2 + 2.0*wM2);
@@ -3806,16 +3814,16 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
}
{
const double w1 = w / Trans.Elem1->Weight();
const double wL1 = w1 * lambda->Eval(*Trans.Elem1, eip1);
const double wM1 = w1 * mu->Eval(*Trans.Elem1, eip1);
const real_t w1 = w / Trans.Elem1->Weight();
const real_t wL1 = w1 * lambda->Eval(*Trans.Elem1, eip1);
const real_t wM1 = w1 * mu->Eval(*Trans.Elem1, eip1);
nL1.Set(wL1, nor);
nM1.Set(wM1, nor);
wLM += (wL1 + 2.0*wM1);
dshape1_ps.Mult(nM1, dshape1_dnM);
}
const double jmatcoef = kappa * (nor*nor) * wLM;
const real_t jmatcoef = kappa * (nor*nor) * wLM;
// (1,1) block
AssembleBlock(
@@ -3848,7 +3856,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
{
for (int j = 0; j < i; ++j)
{
double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
real_t aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
elmat(i,j) = alpha*aji - aij + mij;
elmat(j,i) = alpha*aij - aji + mij;
}
@@ -3861,7 +3869,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
{
for (int j = 0; j < i; ++j)
{
double aij = elmat(i,j), aji = elmat(j,i);
real_t aij = elmat(i,j), aji = elmat(j,i);
elmat(i,j) = alpha*aji - aij;
elmat(j,i) = alpha*aij - aji;
}
@@ -3879,7 +3887,7 @@ void TraceJumpIntegrator::AssembleFaceMatrix(
int i, j, face_ndof, ndof1, ndof2;
int order;
double w;
real_t w;
face_ndof = trial_face_fe.GetDof();
ndof1 = test_fe1.GetDof();
@@ -4087,7 +4095,7 @@ void TraceIntegrator::AssembleTraceFaceMatrix(int elem,
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
}
double scale = 1.0;
real_t scale = 1.0;
if (iel != elem) { scale = -1.; }
for (int p = 0; p < ir->GetNPoints(); p++)
{
@@ -4153,7 +4161,7 @@ void NormalTraceIntegrator::AssembleTraceFaceMatrix(int elem,
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
}
double scale = 1.0;
real_t scale = 1.0;
if (iel != elem) { scale = -1.; }
for (int p = 0; p < ir->GetNPoints(); p++)
@@ -4232,7 +4240,7 @@ void TangentTraceIntegrator::AssembleTraceFaceMatrix(int elem,
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
}
double scale = 1.0;
real_t scale = 1.0;
if (iel != elem) { scale = -1.; }
for (int p = 0; p < ir->GetNPoints(); p++)
{
@@ -4256,7 +4264,7 @@ void TangentTraceIntegrator::AssembleTraceFaceMatrix(int elem,
// rotate
cross_product(normal, shape, shape_n);
const double w = scale*ip.weight;
const real_t w = scale*ip.weight;
AddMult_a_ABt(w,shape_n, face_shape, elmat);
}
}
+321 -252
View File
File diff suppressed because it is too large Load Diff
+6 -2
View File
@@ -12,10 +12,14 @@
#ifndef MFEM_LIBCEED_CEED
#define MFEM_LIBCEED_CEED
#include "../../../config/config.hpp"
#ifdef MFEM_USE_CEED
#include <ceed.h>
#if !CEED_VERSION_GE(0,10,0)
#error MFEM requires a libCEED version >= 0.10.0
#if !CEED_VERSION_GE(0,12,0)
#error MFEM requires a libCEED version >= 0.12.0
#endif
namespace mfem
+8 -8
View File
@@ -294,14 +294,14 @@ public:
nelem, nqpts, ncomp, strides,
&quadCoeff->restr);
CeedOperatorSetField(build_oper, "coeff", quadCoeff->restr,
CEED_BASIS_COLLOCATED, quadCoeff->coeffVector);
CEED_BASIS_NONE, quadCoeff->coeffVector);
}
CeedOperatorSetField(build_oper, "dx", mesh_restr,
mesh_basis, CEED_VECTOR_ACTIVE);
CeedOperatorSetField(build_oper, "weights", CEED_ELEMRESTRICTION_NONE,
mesh_basis, CEED_VECTOR_NONE);
CeedOperatorSetField(build_oper, "qdata", restr_i,
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
// Compute the quadrature data for the operator.
CeedOperatorApply(build_oper, node_coords, qdata, CEED_REQUEST_IMMEDIATE);
@@ -355,7 +355,7 @@ public:
{
case EvalMode::None:
CeedOperatorSetField(oper, "u", trial_restr,
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
break;
case EvalMode::Interp:
CeedOperatorSetField(oper, "u", trial_restr, trial_basis, CEED_VECTOR_ACTIVE);
@@ -369,14 +369,14 @@ public:
break;
}
// qdata
CeedOperatorSetField(oper, "qdata", restr_i, CEED_BASIS_COLLOCATED,
CeedOperatorSetField(oper, "qdata", restr_i, CEED_BASIS_NONE,
qdata);
// output
switch (op.test_op)
{
case EvalMode::None:
CeedOperatorSetField(oper, "v", test_restr,
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
break;
case EvalMode::Interp:
CeedOperatorSetField(oper, "v", test_restr, test_basis, CEED_VECTOR_ACTIVE);
@@ -685,14 +685,14 @@ public:
nelem, nqpts, ncomp, strides,
&quadCoeff->restr);
CeedOperatorSetField(oper, "coeff", quadCoeff->restr,
CEED_BASIS_COLLOCATED, quadCoeff->coeffVector);
CEED_BASIS_NONE, quadCoeff->coeffVector);
}
// input
switch (op.trial_op)
{
case EvalMode::None:
CeedOperatorSetField(oper, "u", trial_restr,
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
break;
case EvalMode::Interp:
CeedOperatorSetField(oper, "u", trial_restr, trial_basis,
@@ -718,7 +718,7 @@ public:
{
case EvalMode::None:
CeedOperatorSetField(oper, "v", test_restr,
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
break;
case EvalMode::Interp:
CeedOperatorSetField(oper, "v", test_restr, test_basis,
+1 -1
View File
@@ -70,7 +70,7 @@ void Operator::Mult(const mfem::Vector &x, mfem::Vector &y) const
}
void Operator::AddMult(const mfem::Vector &x, mfem::Vector &y,
const double a) const
const real_t a) const
{
#ifdef MFEM_USE_CEED
MFEM_VERIFY(a == 1.0, "General coefficient case is not yet supported!");
+1 -1
View File
@@ -39,7 +39,7 @@ public:
#endif
void Mult(const mfem::Vector &x, mfem::Vector &y) const override;
void AddMult(const mfem::Vector &x, mfem::Vector &y,
const double a = 1.0) const override;
const real_t a = 1.0) const override;
void GetDiagonal(mfem::Vector &diag) const;
using mfem::Operator::SetupRAP;
virtual ~Operator()

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